Skip to content

Commit 9f4a4fd

Browse files
committed
Initial Bukkit 1.12.0
1 parent d057627 commit 9f4a4fd

File tree

5 files changed

+228
-4
lines changed

5 files changed

+228
-4
lines changed

platform/quickshop-platform-interface/src/main/java/com/ghostchu/quickshop/platform/GameVersion.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ public enum GameVersion {
4141
v1_16_R4(true, false, true, false, false, false),
4242
v1_17_R1(true, false, true, true, true, true),
4343
v1_18_R1(true, false, true, true, true, true),
44+
v1_18_R2(true, false, true, true, true, true),
45+
v1_19_R1(true, false, true, true, true, true),
46+
v1_19_R2(true, false, true, true, true, true),
47+
v1_20_R1(true, false, true, true, true, true),
4448
UNKNOWN(true, false, true, true, true, true);
4549
/**
4650
* CoreSupports - Check does QuickShop most features supports this server version
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns="http://maven.apache.org/POM/4.0.0"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<parent>
9+
<groupId>com.ghostchu</groupId>
10+
<artifactId>quickshop-hikari</artifactId>
11+
<version>4.2.2.1</version>
12+
<relativePath>../../pom.xml</relativePath>
13+
</parent>
14+
15+
<artifactId>quickshop-platform-spigot-v1_20_R1</artifactId>
16+
<packaging>jar</packaging>
17+
18+
<name>quickshop-platform-spigot-v1_20_R1</name>
19+
20+
<build>
21+
<plugins>
22+
<plugin>
23+
<groupId>org.apache.maven.plugins</groupId>
24+
<artifactId>maven-compiler-plugin</artifactId>
25+
</plugin>
26+
27+
<plugin>
28+
<groupId>net.md-5</groupId>
29+
<artifactId>specialsource-maven-plugin</artifactId>
30+
<version>1.2.5</version>
31+
<executions>
32+
<execution>
33+
<phase>package</phase>
34+
<goals>
35+
<goal>remap</goal>
36+
</goals>
37+
<id>remap-obf</id>
38+
<configuration>
39+
<srgIn>org.spigotmc:minecraft-server:1.20-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
40+
<reverse>true</reverse>
41+
<remappedDependencies>org.spigotmc:spigot:1.20-R0.1-SNAPSHOT:jar:remapped-mojang
42+
</remappedDependencies>
43+
<remappedArtifactAttached>true</remappedArtifactAttached>
44+
<remappedClassifierName>remapped-obf</remappedClassifierName>
45+
</configuration>
46+
</execution>
47+
<execution>
48+
<phase>package</phase>
49+
<goals>
50+
<goal>remap</goal>
51+
</goals>
52+
<id>remap-spigot</id>
53+
<configuration>
54+
<inputFile>
55+
${project.build.directory}/${project.artifactId}-${project.version}-remapped-obf.jar
56+
</inputFile>
57+
<srgIn>org.spigotmc:minecraft-server:1.20-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
58+
<remappedDependencies>org.spigotmc:spigot:1.20-R0.1-SNAPSHOT:jar:remapped-obf
59+
</remappedDependencies>
60+
</configuration>
61+
</execution>
62+
</executions>
63+
</plugin>
64+
</plugins>
65+
<resources>
66+
<resource>
67+
<directory>src/main/resources</directory>
68+
<filtering>true</filtering>
69+
</resource>
70+
</resources>
71+
</build>
72+
73+
<repositories>
74+
<repository>
75+
<id>nms-repo</id>
76+
<url>https://repo.codemc.io/repository/nms/</url>
77+
</repository>
78+
<repository>
79+
<id>spigot-repo</id>
80+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
81+
</repository>
82+
</repositories>
83+
84+
<dependencies>
85+
<dependency>
86+
<groupId>com.ghostchu</groupId>
87+
<artifactId>quickshop-platform-interface</artifactId>
88+
<version>${parent.version}</version>
89+
<scope>compile</scope>
90+
</dependency>
91+
<dependency>
92+
<groupId>com.ghostchu</groupId>
93+
<artifactId>quickshop-platform-spigot-abstract</artifactId>
94+
<version>${parent.version}</version>
95+
<scope>compile</scope>
96+
</dependency>
97+
<dependency>
98+
<groupId>org.spigotmc</groupId>
99+
<artifactId>spigot</artifactId>
100+
<version>1.20-R0.1-SNAPSHOT</version>
101+
<classifier>remapped-mojang</classifier>
102+
<scope>provided</scope>
103+
</dependency>
104+
<dependency>
105+
<groupId>de.tr7zw</groupId>
106+
<artifactId>item-nbt-api-plugin</artifactId>
107+
<version>2.11.2</version>
108+
<scope>provided</scope>
109+
<exclusions>
110+
<exclusion>
111+
<artifactId>*</artifactId>
112+
<groupId>*</groupId>
113+
</exclusion>
114+
</exclusions>
115+
</dependency>
116+
</dependencies>
117+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
package com.ghostchu.quickshop.platform.spigot.v1_20_1;
2+
3+
import com.ghostchu.quickshop.platform.Platform;
4+
import com.ghostchu.quickshop.platform.Util;
5+
import com.ghostchu.quickshop.platform.spigot.AbstractSpigotPlatform;
6+
import net.kyori.adventure.key.Key;
7+
import net.kyori.adventure.nbt.api.BinaryTagHolder;
8+
import net.kyori.adventure.text.event.HoverEvent;
9+
import net.minecraft.nbt.CompoundTag;
10+
import org.bukkit.Bukkit;
11+
import org.bukkit.Material;
12+
import org.bukkit.NamespacedKey;
13+
import org.bukkit.command.Command;
14+
import org.bukkit.craftbukkit.v1_20_R1.CraftServer;
15+
import org.bukkit.craftbukkit.v1_20_R1.inventory.CraftItemStack;
16+
import org.bukkit.craftbukkit.v1_20_R1.potion.CraftPotionEffectType;
17+
import org.bukkit.craftbukkit.v1_20_R1.util.CraftMagicNumbers;
18+
import org.bukkit.enchantments.Enchantment;
19+
import org.bukkit.entity.EntityType;
20+
import org.bukkit.inventory.ItemStack;
21+
import org.bukkit.plugin.Plugin;
22+
import org.bukkit.potion.PotionEffectType;
23+
import org.bukkit.potion.PotionEffectTypeWrapper;
24+
import org.jetbrains.annotations.NotNull;
25+
26+
import java.util.Map;
27+
import java.util.Optional;
28+
29+
public class Spigot1201Platform extends AbstractSpigotPlatform implements Platform {
30+
31+
public Spigot1201Platform(@NotNull Plugin plugin) {
32+
super(plugin);
33+
}
34+
35+
@Override
36+
public @NotNull HoverEvent<HoverEvent.ShowItem> getItemStackHoverEvent(@NotNull ItemStack stack) {
37+
NamespacedKey namespacedKey = stack.getType().getKey();
38+
Key key = Key.key(namespacedKey.toString());
39+
BinaryTagHolder holder;
40+
if (Util.methodExists(BinaryTagHolder.class, "binaryTagHolder")) {
41+
holder = BinaryTagHolder.binaryTagHolder(CraftItemStack.asNMSCopy(stack).save(new CompoundTag()).toString());
42+
} else {
43+
//noinspection UnstableApiUsage
44+
holder = BinaryTagHolder.of(CraftItemStack.asNMSCopy(stack).save(new CompoundTag()).toString());
45+
}
46+
return HoverEvent.showItem(key, stack.getAmount(), holder);
47+
}
48+
49+
@Override
50+
public @NotNull String getMinecraftVersion() {
51+
return ((CraftServer) Bukkit.getServer()).getServer().getServerVersion();
52+
}
53+
54+
@Override
55+
public void registerCommand(@NotNull String prefix, @NotNull Command command) {
56+
((CraftServer) Bukkit.getServer()).getCommandMap().register(prefix, command);
57+
command.register(((CraftServer) Bukkit.getServer()).getCommandMap());
58+
((CraftServer) Bukkit.getServer()).syncCommands();
59+
}
60+
61+
@Override
62+
public @NotNull String getTranslationKey(@NotNull Material material) {
63+
if (material.isBlock()) {
64+
return CraftMagicNumbers.getBlock(material).getDescriptionId();
65+
} else {
66+
return postProcessingTranslationKey(CraftMagicNumbers.getItem(material).getDescriptionId());
67+
}
68+
}
69+
70+
private String postProcessingTranslationKey(String key) {
71+
return this.translationMapping.getOrDefault(key, key);
72+
}
73+
74+
@Override
75+
public @NotNull String getTranslationKey(@NotNull EntityType type) {
76+
Optional<net.minecraft.world.entity.EntityType<?>> op = net.minecraft.world.entity.EntityType.byString(type.getKey().toString());
77+
if (op.isPresent()) {
78+
return postProcessingTranslationKey(op.get().getDescriptionId());
79+
} else {
80+
return postProcessingTranslationKey("entity." + type.getKey());
81+
}
82+
}
83+
84+
@Override
85+
public @NotNull String getTranslationKey(@NotNull PotionEffectType potionEffectType) {
86+
if (potionEffectType instanceof PotionEffectTypeWrapper wrapper) {
87+
potionEffectType = wrapper.getType();
88+
}
89+
CraftPotionEffectType craftPotionEffectType = (CraftPotionEffectType) potionEffectType;
90+
return postProcessingTranslationKey(craftPotionEffectType.getHandle().getDescriptionId());
91+
}
92+
93+
@Override
94+
public @NotNull String getTranslationKey(@NotNull Enchantment enchantment) {
95+
return postProcessingTranslationKey(localeManager.queryEnchantments(Map.of(enchantment, 1)).getOrDefault(enchantment, "Unknown"));
96+
}
97+
98+
@Override
99+
public @NotNull String getTranslationKey(@NotNull ItemStack stack) {
100+
return postProcessingTranslationKey(stack.getTranslationKey());
101+
}
102+
}

pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@
450450
<module>platform/quickshop-platform-spigot-v1_19_R1</module>
451451
<module>platform/quickshop-platform-spigot-v1_19_R2</module>
452452
<module>platform/quickshop-platform-spigot-v1_19_R3</module>
453+
<module>platform/quickshop-platform-spigot-v1_20_R1</module>
453454
<module>platform/quickshop-platform-paper</module>
454455
<module>quickshop-bukkit</module>
455456
<module>compatibility/common</module>

quickshop-bukkit/src/main/resources/plugin.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ libraries:
3333
- com.ghostchu.crowdin:crowdinota:1.0.3
3434
- com.google.code.gson:gson:2.10.1
3535
- net.kyori:adventure-platform-bukkit:4.3.0
36-
- net.kyori:adventure-text-minimessage:4.13.0
37-
- net.kyori:adventure-text-serializer-gson:4.13.0
38-
- net.kyori:adventure-text-serializer-plain:4.13.0
39-
- net.kyori:adventure-text-serializer-legacy:4.13.0
36+
- net.kyori:adventure-text-minimessage:4.13.1
37+
- net.kyori:adventure-text-serializer-gson:4.13.1
38+
- net.kyori:adventure-text-serializer-plain:4.13.1
39+
- net.kyori:adventure-text-serializer-legacy:4.13.1
4040
# - org.slf4j:slf4j-nop:1.7.35
4141
authors:
4242
- Ghost_chu

0 commit comments

Comments
 (0)