Skip to content

Commit

Permalink
feat: adds initial support for Minecraft 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
timbru31 committed Jun 24, 2024
1 parent ec91c23 commit 14c8e5f
Show file tree
Hide file tree
Showing 8 changed files with 625 additions and 10 deletions.
1 change: 1 addition & 0 deletions .github/workflows/maven-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
run: |
cd BuildTools
[ -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
[ -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
- name: Build with Maven
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
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ This Bukkit (compatible with CraftBukkit, Spigot, Paper) plugin adds a way to ob
- Economy addon [SilkSpawnersEcoAddon](https://dev.bukkit.org/projects/silkspawnersecoaddon)
- Shop addon [SilkSpawnersShopAddon](https://spigotmc.org/resources/12028/) (login required, Premium Plugin)
- BossBarAPI support for >= 1.9, otherwise BarAPI can be used
- Support for multiple Minecraft versions, from 1.8.8 to 1.20.6 (with exlusion of 1.9 and 1.10)
- Support for multiple Minecraft versions, from 1.8.8 to 1.21 (with exlusion of 1.9 and 1.10)

_Third party features, all of them can be disabled_

Expand Down Expand Up @@ -315,6 +315,7 @@ Unfortunately, I can't give access to https://repo.dustplanet.de/artifactory/pri
mkdir -p BuildTools
cd BuildTools
wget -q https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
java -jar BuildTools.jar --rev 1.21 --remapped
java -jar BuildTools.jar --rev 1.20.6 --remapped
java -jar BuildTools.jar --rev 1.20.4 --remapped
java -jar BuildTools.jar --rev 1.20.2 --remapped
Expand Down
2 changes: 1 addition & 1 deletion modules/API/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
7 changes: 6 additions & 1 deletion modules/SilkSpawners/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.20.6-R0.1-SNAPSHOT</version>
<version>1.21-R0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sk89q</groupId>
Expand Down Expand Up @@ -203,6 +203,11 @@
<artifactId>silkspawners-v1_20_R4</artifactId>
<version>8.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.dustplanet</groupId>
<artifactId>silkspawners-v1_21_R1</artifactId>
<version>8.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.dustplanet</groupId>
<artifactId>silkspawners-API</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.util.Map;
import java.util.logging.Level;

import org.apache.commons.lang.StringUtils;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.Material;
Expand Down Expand Up @@ -62,11 +61,12 @@ public class SilkSpawners extends JavaPlugin {
private static final int BSTATS_PLUGIN_ID = 273;
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",
"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",
"v1_20_R2", "v1_20_R3", "v1_20_R4" };
"v1_20_R2", "v1_20_R3", "v1_20_R4", "v1_21_R1" };
public static final Map<Integer, String> PROTOCOL_VERSION_PACKAGE_MAP = new HashMap<Integer, String>() {
private static final long serialVersionUID = -5188779509588704507L;
{
put(766, "v1_20_R4");
put(767, "v1_21_R1");
}
};
public CommentedConfiguration config;
Expand Down Expand Up @@ -94,11 +94,12 @@ public void onEnable() {
String _nmsVersion = packageName.substring(packageName.lastIndexOf('.') + 1);
if (_nmsVersion.equals("craftbukkit")) {
try {
String minecraftVersion = (String) Server.class.getDeclaredMethod("getMinecraftVersion").invoke(Bukkit.getServer());
Semver semver = new Semver(minecraftVersion);
final String minecraftVersion = (String) Server.class.getDeclaredMethod("getMinecraftVersion").invoke(Bukkit.getServer());
final Semver semver = new Semver(minecraftVersion);
if (semver.isGreaterThanOrEqualTo("1.20.5")) {
@SuppressWarnings("deprecation")
int protocolVersion = (Integer) UnsafeValues.class.getDeclaredMethod("getProtocolVersion").invoke(Bukkit.getUnsafe());
final int protocolVersion = (Integer) UnsafeValues.class.getDeclaredMethod("getProtocolVersion")
.invoke(Bukkit.getUnsafe());
_nmsVersion = PROTOCOL_VERSION_PACKAGE_MAP.get(protocolVersion);
}
} catch (IllegalAccessException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
Expand Down Expand Up @@ -556,18 +557,31 @@ private boolean shapeContainsIngredient(final List<String> shape, final char c)
/**
* Sends a message to the player if the 'silkspawners.info' permission is granted. Empty messages are ignored and not are not sent.
*
* @param player the player to message
* @param player the player to message
* @param message the message to send
*/
public void informPlayer(final Player player, final String message) {
if (StringUtils.isBlank(message)) {
if (isBlank(message)) {
return;
}
if (player.hasPermission("silkspawners.info")) {
su.sendMessage(player, message);
}
}

public boolean isBlank(final CharSequence cs) {
final int strLen = cs == null ? 0 : cs.length();
if (strLen == 0) {
return true;
}
for (int i = 0; i < strLen; i++) {
if (!Character.isWhitespace(cs.charAt(i))) {
return false;
}
}
return true;
}

public void reloadConfigs() {
config.load();
config.save();
Expand Down
72 changes: 72 additions & 0 deletions modules/v1_21_R1/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<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">
<modelVersion>4.0.0</modelVersion>
<artifactId>silkspawners-v1_21_R1</artifactId>
<packaging>jar</packaging>
<name>SilkSpawners for v1_21_R1</name>

<parent>
<groupId>de.dustplanet</groupId>
<artifactId>silkspawners-parent</artifactId>
<version>8.0.1-SNAPSHOT</version>
<relativePath>../../</relativePath>
</parent>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.21-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<classifier>remapped-mojang</classifier>
<exclusions>
<exclusion>
<groupId>org.spigotmc</groupId>
<artifactId>minecraft-server</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.dustplanet</groupId>
<artifactId>silkspawners-API</artifactId>
<version>8.0.1-SNAPSHOT</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>net.md-5</groupId>
<artifactId>specialsource-maven-plugin</artifactId>
<version>2.0.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>remap</goal>
</goals>
<id>remap-mojang</id>
<configuration>
<srgIn>org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:txt:maps-mojang</srgIn>
<reverse>true</reverse>
<remappedDependencies>org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
<remappedArtifactAttached>true</remappedArtifactAttached>
<remappedClassifierName>remapped-mojang</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-mojang.jar</inputFile>
<srgIn>org.spigotmc:minecraft-server:1.21-R0.1-SNAPSHOT:csrg:maps-spigot</srgIn>
<remappedDependencies>org.spigotmc:spigot:1.21-R0.1-SNAPSHOT:jar:remapped-mojang</remappedDependencies>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit 14c8e5f

Please sign in to comment.