Skip to content

Commit 14c8e5f

Browse files
committed
feat: adds initial support for Minecraft 1.21
1 parent ec91c23 commit 14c8e5f

File tree

8 files changed

+625
-10
lines changed

8 files changed

+625
-10
lines changed

.github/workflows/maven-pr.yml

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ jobs:
8787
run: |
8888
cd BuildTools
8989
[ -f ~/.m2/repository/org/spigotmc/spigot/1.20.6-R0.1-SNAPSHOT/spigot-1.20.6-R0.1-SNAPSHOT-remapped-mojang.jar ] || java -jar BuildTools.jar --rev 1.20.6 --remapped
90+
[ -f ~/.m2/repository/org/spigotmc/spigot/1.21-R0.1-SNAPSHOT/spigot-1.21-R0.1-SNAPSHOT-remapped-mojang.jar ] || java -jar BuildTools.jar --rev 1.21 --remapped
9091
9192
- name: Build with Maven
9293
run: mvn -D"http.keepAlive=false" -D"maven.wagon.http.pool=false" -D"maven.wagon.httpconnectionManager.ttlSeconds=120" "-Dhttps.protocols=TLSv1.2" -DskipTests=true "-Dmaven.javadoc.skip=true" -B clean package

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ This Bukkit (compatible with CraftBukkit, Spigot, Paper) plugin adds a way to ob
2727
- Economy addon [SilkSpawnersEcoAddon](https://dev.bukkit.org/projects/silkspawnersecoaddon)
2828
- Shop addon [SilkSpawnersShopAddon](https://spigotmc.org/resources/12028/) (login required, Premium Plugin)
2929
- BossBarAPI support for >= 1.9, otherwise BarAPI can be used
30-
- Support for multiple Minecraft versions, from 1.8.8 to 1.20.6 (with exlusion of 1.9 and 1.10)
30+
- Support for multiple Minecraft versions, from 1.8.8 to 1.21 (with exlusion of 1.9 and 1.10)
3131

3232
_Third party features, all of them can be disabled_
3333

@@ -315,6 +315,7 @@ Unfortunately, I can't give access to https://repo.dustplanet.de/artifactory/pri
315315
mkdir -p BuildTools
316316
cd BuildTools
317317
wget -q https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
318+
java -jar BuildTools.jar --rev 1.21 --remapped
318319
java -jar BuildTools.jar --rev 1.20.6 --remapped
319320
java -jar BuildTools.jar --rev 1.20.4 --remapped
320321
java -jar BuildTools.jar --rev 1.20.2 --remapped

modules/API/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<dependency>
2424
<groupId>org.spigotmc</groupId>
2525
<artifactId>spigot-api</artifactId>
26-
<version>1.20.6-R0.1-SNAPSHOT</version>
26+
<version>1.21-R0.1-SNAPSHOT</version>
2727
</dependency>
2828
</dependencies>
2929

modules/SilkSpawners/pom.xml

+6-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>org.spigotmc</groupId>
4444
<artifactId>spigot-api</artifactId>
45-
<version>1.20.6-R0.1-SNAPSHOT</version>
45+
<version>1.21-R0.1-SNAPSHOT</version>
4646
</dependency>
4747
<dependency>
4848
<groupId>com.sk89q</groupId>
@@ -203,6 +203,11 @@
203203
<artifactId>silkspawners-v1_20_R4</artifactId>
204204
<version>8.0.1-SNAPSHOT</version>
205205
</dependency>
206+
<dependency>
207+
<groupId>de.dustplanet</groupId>
208+
<artifactId>silkspawners-v1_21_R1</artifactId>
209+
<version>8.0.1-SNAPSHOT</version>
210+
</dependency>
206211
<dependency>
207212
<groupId>de.dustplanet</groupId>
208213
<artifactId>silkspawners-API</artifactId>

modules/SilkSpawners/src/main/java/de/dustplanet/silkspawners/SilkSpawners.java

+21-7
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
import java.util.Map;
1414
import java.util.logging.Level;
1515

16-
import org.apache.commons.lang.StringUtils;
1716
import org.bstats.bukkit.Metrics;
1817
import org.bukkit.Bukkit;
1918
import org.bukkit.Material;
@@ -62,11 +61,12 @@ public class SilkSpawners extends JavaPlugin {
6261
private static final int BSTATS_PLUGIN_ID = 273;
6362
private static final String[] COMPATIBLE_MINECRAFT_VERSIONS = { "v1_8_R3", "v1_11_R1", "v1_12_R1", "v1_13_R2", "v1_14_R1", "v1_15_R1",
6463
"v1_16_R1", "v1_16_R2", "v1_16_R3", "v1_17_R1", "v1_18_R1", "v1_18_R2", "v1_19_R1", "v1_19_R2", "v1_19_R3", "v1_20_R1",
65-
"v1_20_R2", "v1_20_R3", "v1_20_R4" };
64+
"v1_20_R2", "v1_20_R3", "v1_20_R4", "v1_21_R1" };
6665
public static final Map<Integer, String> PROTOCOL_VERSION_PACKAGE_MAP = new HashMap<Integer, String>() {
6766
private static final long serialVersionUID = -5188779509588704507L;
6867
{
6968
put(766, "v1_20_R4");
69+
put(767, "v1_21_R1");
7070
}
7171
};
7272
public CommentedConfiguration config;
@@ -94,11 +94,12 @@ public void onEnable() {
9494
String _nmsVersion = packageName.substring(packageName.lastIndexOf('.') + 1);
9595
if (_nmsVersion.equals("craftbukkit")) {
9696
try {
97-
String minecraftVersion = (String) Server.class.getDeclaredMethod("getMinecraftVersion").invoke(Bukkit.getServer());
98-
Semver semver = new Semver(minecraftVersion);
97+
final String minecraftVersion = (String) Server.class.getDeclaredMethod("getMinecraftVersion").invoke(Bukkit.getServer());
98+
final Semver semver = new Semver(minecraftVersion);
9999
if (semver.isGreaterThanOrEqualTo("1.20.5")) {
100100
@SuppressWarnings("deprecation")
101-
int protocolVersion = (Integer) UnsafeValues.class.getDeclaredMethod("getProtocolVersion").invoke(Bukkit.getUnsafe());
101+
final int protocolVersion = (Integer) UnsafeValues.class.getDeclaredMethod("getProtocolVersion")
102+
.invoke(Bukkit.getUnsafe());
102103
_nmsVersion = PROTOCOL_VERSION_PACKAGE_MAP.get(protocolVersion);
103104
}
104105
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
@@ -556,18 +557,31 @@ private boolean shapeContainsIngredient(final List<String> shape, final char c)
556557
/**
557558
* Sends a message to the player if the 'silkspawners.info' permission is granted. Empty messages are ignored and not are not sent.
558559
*
559-
* @param player the player to message
560+
* @param player the player to message
560561
* @param message the message to send
561562
*/
562563
public void informPlayer(final Player player, final String message) {
563-
if (StringUtils.isBlank(message)) {
564+
if (isBlank(message)) {
564565
return;
565566
}
566567
if (player.hasPermission("silkspawners.info")) {
567568
su.sendMessage(player, message);
568569
}
569570
}
570571

572+
public boolean isBlank(final CharSequence cs) {
573+
final int strLen = cs == null ? 0 : cs.length();
574+
if (strLen == 0) {
575+
return true;
576+
}
577+
for (int i = 0; i < strLen; i++) {
578+
if (!Character.isWhitespace(cs.charAt(i))) {
579+
return false;
580+
}
581+
}
582+
return true;
583+
}
584+
571585
public void reloadConfigs() {
572586
config.load();
573587
config.save();

modules/v1_21_R1/pom.xml

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<modelVersion>4.0.0</modelVersion>
3+
<artifactId>silkspawners-v1_21_R1</artifactId>
4+
<packaging>jar</packaging>
5+
<name>SilkSpawners for v1_21_R1</name>
6+
7+
<parent>
8+
<groupId>de.dustplanet</groupId>
9+
<artifactId>silkspawners-parent</artifactId>
10+
<version>8.0.1-SNAPSHOT</version>
11+
<relativePath>../../</relativePath>
12+
</parent>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>org.spigotmc</groupId>
17+
<artifactId>spigot</artifactId>
18+
<version>1.21-R0.1-SNAPSHOT</version>
19+
<scope>provided</scope>
20+
<classifier>remapped-mojang</classifier>
21+
<exclusions>
22+
<exclusion>
23+
<groupId>org.spigotmc</groupId>
24+
<artifactId>minecraft-server</artifactId>
25+
</exclusion>
26+
</exclusions>
27+
</dependency>
28+
<dependency>
29+
<groupId>de.dustplanet</groupId>
30+
<artifactId>silkspawners-API</artifactId>
31+
<version>8.0.1-SNAPSHOT</version>
32+
</dependency>
33+
</dependencies>
34+
35+
<build>
36+
<plugins>
37+
<plugin>
38+
<groupId>net.md-5</groupId>
39+
<artifactId>specialsource-maven-plugin</artifactId>
40+
<version>2.0.2</version>
41+
<executions>
42+
<execution>
43+
<phase>package</phase>
44+
<goals>
45+
<goal>remap</goal>
46+
</goals>
47+
<id>remap-mojang</id>
48+
<configuration>
49+
<srgIn>org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
50+
<reverse>true</reverse>
51+
<remappedDependencies>org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
52+
<remappedArtifactAttached>true</remappedArtifactAttached>
53+
<remappedClassifierName>remapped-mojang</remappedClassifierName>
54+
</configuration>
55+
</execution>
56+
<execution>
57+
<phase>package</phase>
58+
<goals>
59+
<goal>remap</goal>
60+
</goals>
61+
<id>remap-spigot</id>
62+
<configuration>
63+
<inputFile>${project.build.directory}/${project.artifactId}-${project.version}-remapped-mojang.jar</inputFile>
64+
<srgIn>org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
65+
<remappedDependencies>org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
66+
</configuration>
67+
</execution>
68+
</executions>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
</project>

0 commit comments

Comments
 (0)