Skip to content

Commit

Permalink
Initial 1.21.4 code.
Browse files Browse the repository at this point in the history
  • Loading branch information
creatorfromhell committed Dec 6, 2024
1 parent ed0557f commit 485098e
Show file tree
Hide file tree
Showing 6 changed files with 294 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# User-specific stuff
.idea/

.paper-nms

*.iml
*.ipr
*.iws
Expand Down
138 changes: 138 additions & 0 deletions platform/quickshop-platform-spigot-v1_21_R4/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-hikari</artifactId>
<version>6.2.0.7</version>
<relativePath>../../pom.xml</relativePath>
</parent>

<artifactId>quickshop-platform-spigot-v1_21_R4</artifactId>
<packaging>takari-jar</packaging>

<name>quickshop-platform-spigot-v1_21_R4</name>

<pluginRepositories>

<pluginRepository>
<id>bytecode.space</id>
<url>https://repo.bytecode.space/repository/maven-public/</url>
</pluginRepository>
</pluginRepositories>

<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-obf</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.21.4-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.21.4-R0.1-SNAPSHOT:jar:remapped-mojang
</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-obf</remappedClassifierName>
</configuration>
</execution>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-spigot</id>
<configuration>
<inputFile>
${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.21.4-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.21.4-R0.1-SNAPSHOT:jar:remapped-obf
</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
<!-- Modern Minecraft is Java 21... -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.13.0</version>
<configuration>
<skip>true</skip>
<skipMain>true</skipMain>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<plugin>
<groupId>io.takari.maven.plugins</groupId>
<artifactId>takari-lifecycle-plugin</artifactId>
<version>2.1.6</version>
<extensions>true</extensions>
<configuration>
<proc>proc</proc>
<source>21</source>
<target>21</target>
<sourceJar>true</sourceJar>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<repositories>
<repository>
<id>nms-repo</id>
<url>https://repo.codemc.io/repository/nms/</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-platform-spigot-abstract</artifactId>
<version>${project.parent.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.21.4-R0.1-SNAPSHOT</version>
<classifier>remapped-mojang</classifier>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api-plugin</artifactId>
<version>2.13.2</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>*</artifactId>
<groupId>*</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
package com.ghostchu.quickshop.platform.spigot.v1_21_4;

import com.ghostchu.quickshop.platform.Platform;
import com.ghostchu.quickshop.platform.spigot.AbstractSpigotPlatform;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.HoverEvent;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
import net.minecraft.core.component.DataComponents;
import net.minecraft.world.item.component.ItemLore;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.craftbukkit.v1_21_R3.CraftServer;
import org.bukkit.craftbukkit.v1_21_R3.inventory.CraftItemStack;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Collection;
import java.util.List;

public class Spigot1214Platform extends AbstractSpigotPlatform implements Platform {

public Spigot1214Platform(@NotNull final Plugin plugin) {

super(plugin);
}

@Override
public @NotNull Component setItemStackHoverEvent(@NotNull final Component oldComponent, @NotNull final ItemStack stack) {

return oldComponent.hoverEvent(HoverEvent.showText(Component.text("Click to preview the item")
.appendNewline()
.append(Component.text("× Item hover preview are not available at this time (Spigot 1.20.5+) due major item nbt related changes.").color(NamedTextColor.RED))
.appendNewline()
.append(Component.text("💡 Consider switch to Paper to use PaperAPI instead.").color(NamedTextColor.GRAY))));

}

@Override
public @NotNull String getMinecraftVersion() {

try {
return ((CraftServer)Bukkit.getServer()).getServer().getServerVersion();
} catch(final Exception e) {
return super.getMinecraftVersion();
}
}

@Override
public void registerCommand(@NotNull final String prefix, @NotNull final Command command) {

((CraftServer)Bukkit.getServer()).getCommandMap().register(prefix, command);
command.register(((CraftServer)Bukkit.getServer()).getCommandMap());
((CraftServer)Bukkit.getServer()).syncCommands();
}

@Override
public @NotNull String getTranslationKey(@NotNull final Material material) {

return postProcessingTranslationKey(material.getTranslationKey());
}

@Override
public void setDisplayName(@NotNull final ItemStack stack, @Nullable final Component component) {

final net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(stack);
if(component == null) {
nmsItemStack.remove(DataComponents.CUSTOM_NAME);
return;
}
final String json = GsonComponentSerializer.gson().serialize(component);
nmsItemStack.set(DataComponents.CUSTOM_NAME,
net.minecraft.network.chat.Component.Serializer
.fromJson(json,
((CraftServer)Bukkit.getServer())
.getServer()
.registryAccess()));
stack.setItemMeta(CraftItemStack.asBukkitCopy(nmsItemStack).getItemMeta());
}


@Override
public void setLore(@NotNull final ItemStack stack, @NotNull final Collection<Component> components) {

final net.minecraft.world.item.ItemStack nmsItemStack = CraftItemStack.asNMSCopy(stack);
if(components.isEmpty()) {
nmsItemStack.remove(DataComponents.LORE);
} else {
final List<net.minecraft.network.chat.Component> componentsList = components.stream()
.map(c->GsonComponentSerializer.gson().serialize(c))
.map(json->(net.minecraft.network.chat.Component)
net.minecraft.network.chat.Component.Serializer
.fromJson(json,
((CraftServer)Bukkit.getServer())
.getServer()
.registryAccess()))
.toList();
nmsItemStack.set(DataComponents.LORE, new ItemLore(componentsList));
}
stack.setItemMeta(CraftItemStack.asBukkitCopy(nmsItemStack).getItemMeta());
}

private String postProcessingTranslationKey(final String key) {

return this.translationMapping.getOrDefault(key, key);
}

@Override
public @NotNull String getTranslationKey(@NotNull final EntityType type) {
//noinspection deprecation
return postProcessingTranslationKey(type.getTranslationKey());
// Optional<net.minecraft.world.entity.EntityType<?>> op = net.minecraft.world.entity.EntityType.byString(type.getKey().toString());
// if (op.isPresent()) {
// return postProcessingTranslationKey(op.get().getDescriptionId());
// } else {
// return postProcessingTranslationKey("entity." + type.getKey());
// }
}

@Override
public @NotNull String getTranslationKey(@NotNull final PotionEffectType potionEffectType) {

return postProcessingTranslationKey(potionEffectType.getTranslationKey());
}

@Override
public @NotNull String getTranslationKey(@NotNull final Enchantment enchantment) {

return postProcessingTranslationKey(enchantment.getTranslationKey());
}

@Override
public @NotNull String getTranslationKey(@NotNull final ItemStack stack) {

return postProcessingTranslationKey(stack.getTranslationKey());
}
}
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,12 @@
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
</dependency>
<dependency>
<groupId>com.ghostchu</groupId>
<artifactId>quickshop-platform-spigot-abstract</artifactId>
<version>6.2.0.7</version>
<scope>compile</scope>
</dependency>
</dependencies>

<modules>
Expand All @@ -409,6 +415,7 @@
<module>platform/quickshop-platform-spigot-v1_21_R1</module>
<module>platform/quickshop-platform-spigot-v1_21_R2</module>
<module>platform/quickshop-platform-spigot-v1_21_R3</module>
<module>platform/quickshop-platform-spigot-v1_21_R4</module>
<module>platform/quickshop-platform-paper</module>
<module>quickshop-bukkit</module>
<module>compatibility/common</module>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum GameVersion {
v1_20_R3(new String[]{ "1.20.4", "1.20.5" }, true, false, true, true, true),
v1_20_R4(new String[]{ "1.20.6" }, true, false, true, true, true),
v1_21_R1(new String[]{ "1.21", "1.21.1" }, true, false, true, true, true),
v1_21_R2(new String[]{ "1.21.2", "1.21.3", "1.21.4" }, true, false, true, true, true),
v1_21_R2(new String[]{ "1.21.2", "1.21.3" }, true, false, true, true, true),
v1_21_R3(new String[]{ "1.21.4" }, true, false, true, true, true),
UNKNOWN(new String[0], true, false, false, true, true);
private final String[] mcVersion;
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.ghostchu.quickshop.platform.spigot.v1_20_4.Spigot1205Platform;
import com.ghostchu.quickshop.platform.spigot.v1_21_1.Spigot1210Platform;
import com.ghostchu.quickshop.platform.spigot.v1_21_3.Spigot1231Platform;
import com.ghostchu.quickshop.platform.spigot.v1_21_4.Spigot1214Platform;
import com.ghostchu.quickshop.util.PackageUtil;
import com.vdurmont.semver4j.Semver;
import io.papermc.lib.PaperLib;
Expand Down Expand Up @@ -264,6 +265,7 @@ private void loadPlatform() throws Exception {
case "v1_21_R1" -> new Spigot1210Platform(this);
//case "v1_21_R2" -> new Spigot1211Platform(this);
case "v1_21_R2" -> new Spigot1231Platform(this);
case "v1_21_R3" -> new Spigot1214Platform(this);
default -> {
bootstrapLogger.warning("This server running " + internalNMSVersion + " not supported by Hikari. (Try update? or Use Paper's fork to get cross-platform compatibility.)");
Bukkit.getPluginManager().disablePlugin(this);
Expand Down

0 comments on commit 485098e

Please sign in to comment.