-
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ed0557f
commit 485098e
Showing
6 changed files
with
294 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# User-specific stuff | ||
.idea/ | ||
|
||
.paper-nms | ||
|
||
*.iml | ||
*.ipr | ||
*.iws | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
143 changes: 143 additions & 0 deletions
143
...1_R4/src/main/java/com/ghostchu/quickshop/platform/spigot/v1_21_4/Spigot1214Platform.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters