Skip to content

Commit d118033

Browse files
committed
Update for Minecraft 1.21
1 parent af73f8f commit d118033

File tree

11 files changed

+89
-60
lines changed

11 files changed

+89
-60
lines changed

build.gradle

+11-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id 'com.github.johnrengelman.shadow' version '7.0.0'
2+
id "io.github.goooler.shadow" version "8.1.8"
33
id "com.jfrog.artifactory" version "4.21.0"
44
}
55

@@ -39,11 +39,12 @@ ext.internalVersion = pluginVersion + ";" + gitCommitHash
3939

4040
java {
4141
toolchain {
42-
languageVersion = JavaLanguageVersion.of(16)
42+
languageVersion = JavaLanguageVersion.of(21)
4343
}
4444
}
4545

4646
repositories {
47+
mavenLocal()
4748
mavenCentral()
4849
maven {
4950
name = 'EngineHub Repo'
@@ -60,9 +61,9 @@ repositories {
6061
}
6162

6263
dependencies {
63-
compileOnly 'com.destroystokyo.paper:paper-api:1.15.2-R0.1-SNAPSHOT'
64-
compileOnly 'com.sk89q.worldedit:worldedit-core:7.2.0-SNAPSHOT'
65-
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT'
64+
compileOnly 'io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT'
65+
compileOnly 'com.sk89q.worldedit:worldedit-core:7.3.4'
66+
compileOnly 'com.sk89q.worldedit:worldedit-bukkit:7.3.4'
6667
compileOnly 'org.enginehub.jinglenote:jinglenote-core:1.0.0-SNAPSHOT'
6768
implementation('org.enginehub.jinglenote:jinglenote-bukkit:1.0.0-SNAPSHOT') {
6869
exclude group: 'org.spigotmc', module: 'spigot-api'
@@ -71,8 +72,8 @@ dependencies {
7172
implementation 'com.zachsthings.libcomponents:libcomponents-bukkit:1.3.1'
7273
implementation 'net.sf.opencsv:opencsv:2.0'
7374

74-
compileOnly 'com.sk89q.worldedit.worldedit-libs:ap:7.2.0-SNAPSHOT'
75-
annotationProcessor 'com.sk89q.worldedit.worldedit-libs:ap:7.2.0-SNAPSHOT'
75+
compileOnly 'com.sk89q.worldedit.worldedit-libs:ap:7.3.4'
76+
annotationProcessor 'com.sk89q.worldedit.worldedit-libs:ap:7.3.4'
7677
annotationProcessor "com.google.guava:guava:21.0"
7778

7879
testImplementation group: 'junit', name: 'junit', version: '4.12'
@@ -83,12 +84,12 @@ tasks.withType(JavaCompile).configureEach {
8384
}
8485

8586
task sourcesJar(type: Jar, dependsOn: classes) {
86-
classifier = 'sources'
87+
archiveClassifier = 'sources'
8788
from sourceSets.main.allSource
8889
}
8990

9091
task javadocJar(type: Jar, dependsOn: javadoc) {
91-
classifier = 'javadoc'
92+
archiveClassifier = 'javadoc'
9293
from javadoc.destinationDir
9394
}
9495

@@ -121,7 +122,7 @@ jar {
121122
}
122123

123124
shadowJar {
124-
classifier 'dist'
125+
archiveClassifier.set('dist')
125126

126127
dependencies {
127128
include(dependency('com.zachsthings.libcomponents:libcomponents-core'))

gradle/wrapper/gradle-wrapper.jar

-15.7 KB
Binary file not shown.
+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
4+
networkTimeout=10000
5+
validateDistributionUrl=true
46
zipStoreBase=GRADLE_USER_HOME
57
zipStorePath=wrapper/dists

gradlew

+28-13
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
# Darwin, MinGW, and NonStop.
5656
#
5757
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
58+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5959
# within the Gradle project.
6060
#
6161
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -80,13 +80,11 @@ do
8080
esac
8181
done
8282

83-
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84-
85-
APP_NAME="Gradle"
83+
# This is normally unused
84+
# shellcheck disable=SC2034
8685
APP_BASE_NAME=${0##*/}
87-
88-
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89-
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
86+
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87+
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
9088

9189
# Use the maximum available, or set MAX_FD != -1 to use that value.
9290
MAX_FD=maximum
@@ -133,22 +131,29 @@ location of your Java installation."
133131
fi
134132
else
135133
JAVACMD=java
136-
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
134+
if ! command -v java >/dev/null 2>&1
135+
then
136+
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137137
138138
Please set the JAVA_HOME variable in your environment to match the
139139
location of your Java installation."
140+
fi
140141
fi
141142

142143
# Increase the maximum file descriptors if we can.
143144
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144145
case $MAX_FD in #(
145146
max*)
147+
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
148+
# shellcheck disable=SC2039,SC3045
146149
MAX_FD=$( ulimit -H -n ) ||
147150
warn "Could not query maximum file descriptor limit"
148151
esac
149152
case $MAX_FD in #(
150153
'' | soft) :;; #(
151154
*)
155+
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
156+
# shellcheck disable=SC2039,SC3045
152157
ulimit -n "$MAX_FD" ||
153158
warn "Could not set maximum file descriptor limit to $MAX_FD"
154159
esac
@@ -193,18 +198,28 @@ if "$cygwin" || "$msys" ; then
193198
done
194199
fi
195200

196-
# Collect all arguments for the java command;
197-
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198-
# shell script including quotes and variable substitutions, so put them in
199-
# double quotes to make sure that they get re-expanded; and
200-
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
203+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204+
205+
# Collect all arguments for the java command:
206+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207+
# and any embedded shellness will be escaped.
208+
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209+
# treated as '${Hostname}' itself on the command line.
201210

202211
set -- \
203212
"-Dorg.gradle.appname=$APP_BASE_NAME" \
204213
-classpath "$CLASSPATH" \
205214
org.gradle.wrapper.GradleWrapperMain \
206215
"$@"
207216

217+
# Stop when "xargs" is not available.
218+
if ! command -v xargs >/dev/null 2>&1
219+
then
220+
die "xargs is not available"
221+
fi
222+
208223
# Use "xargs" to parse quoted args.
209224
#
210225
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.

gradlew.bat

+19-16
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
@rem limitations under the License.
1515
@rem
1616

17-
@if "%DEBUG%" == "" @echo off
17+
@if "%DEBUG%"=="" @echo off
1818
@rem ##########################################################################
1919
@rem
2020
@rem Gradle startup script for Windows
@@ -25,7 +25,8 @@
2525
if "%OS%"=="Windows_NT" setlocal
2626

2727
set DIRNAME=%~dp0
28-
if "%DIRNAME%" == "" set DIRNAME=.
28+
if "%DIRNAME%"=="" set DIRNAME=.
29+
@rem This is normally unused
2930
set APP_BASE_NAME=%~n0
3031
set APP_HOME=%DIRNAME%
3132

@@ -40,13 +41,13 @@ if defined JAVA_HOME goto findJavaFromJavaHome
4041

4142
set JAVA_EXE=java.exe
4243
%JAVA_EXE% -version >NUL 2>&1
43-
if "%ERRORLEVEL%" == "0" goto execute
44+
if %ERRORLEVEL% equ 0 goto execute
4445

45-
echo.
46-
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47-
echo.
48-
echo Please set the JAVA_HOME variable in your environment to match the
49-
echo location of your Java installation.
46+
echo. 1>&2
47+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
48+
echo. 1>&2
49+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
50+
echo location of your Java installation. 1>&2
5051

5152
goto fail
5253

@@ -56,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe
5657

5758
if exist "%JAVA_EXE%" goto execute
5859

59-
echo.
60-
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61-
echo.
62-
echo Please set the JAVA_HOME variable in your environment to match the
63-
echo location of your Java installation.
60+
echo. 1>&2
61+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
62+
echo. 1>&2
63+
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
64+
echo location of your Java installation. 1>&2
6465

6566
goto fail
6667

@@ -75,13 +76,15 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
7576

7677
:end
7778
@rem End local scope for the variables with windows NT shell
78-
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
if %ERRORLEVEL% equ 0 goto mainEnd
7980

8081
:fail
8182
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
8283
rem the _cmd.exe /c_ return code!
83-
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84-
exit /b 1
84+
set EXIT_CODE=%ERRORLEVEL%
85+
if %EXIT_CODE% equ 0 set EXIT_CODE=1
86+
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
87+
exit /b %EXIT_CODE%
8588

8689
:mainEnd
8790
if "%OS%"=="Windows_NT" endlocal

src/main/java/com/sk89q/commandbook/PlatformCommandManager.java

+8-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
import com.sk89q.commandbook.command.argument.OfflineSinglePlayerTargetConverter;
1010
import com.sk89q.commandbook.command.argument.SinglePlayerTargetConverter;
1111
import com.sk89q.commandbook.util.WorldEditAdapter;
12-
import com.sk89q.worldedit.WorldEdit;
1312
import com.sk89q.worldedit.command.argument.Arguments;
1413
import com.sk89q.worldedit.command.util.PermissionCondition;
1514
import com.sk89q.worldedit.extension.platform.Actor;
@@ -30,6 +29,7 @@
3029
import org.enginehub.piston.inject.*;
3130
import org.enginehub.piston.suggestion.Suggestion;
3231
import org.enginehub.piston.util.HelpGenerator;
32+
import org.enginehub.piston.util.TextHelper;
3333
import org.enginehub.piston.util.ValueProvider;
3434
import org.slf4j.Logger;
3535
import org.slf4j.LoggerFactory;
@@ -40,8 +40,6 @@
4040
import java.util.stream.Collectors;
4141
import java.util.stream.Stream;
4242

43-
import static com.sk89q.worldedit.util.formatting.WorldEditText.reduceToText;
44-
4543
public class PlatformCommandManager {
4644
public static final Pattern COMMAND_CLEAN_PATTERN = Pattern.compile("^[/]+");
4745
private static final Logger log = LoggerFactory.getLogger(PlatformCommandManager.class);
@@ -108,9 +106,13 @@ private void registerCommandsWithBukkit(CommandManager commandManager, CommandBo
108106
command.getAliases().stream()
109107
).toArray(String[]::new);
110108
// TODO Handle localisation correctly
111-
return new CommandInfo(reduceToText(command.getUsage(), WorldEdit.getInstance().getConfiguration().defaultLocale),
112-
reduceToText(command.getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale), aliases,
113-
inspector, permissionsArray);
109+
return new CommandInfo(
110+
TextHelper.reduceToText(command.getUsage()),
111+
TextHelper.reduceToText(command.getDescription()),
112+
aliases,
113+
inspector,
114+
permissionsArray
115+
);
114116
}).collect(Collectors.toList()));
115117
}
116118

src/main/java/com/sk89q/commandbook/component/bans/CSVBanDatabase.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.sk89q.commandbook.util.ChatUtil;
66
import com.sk89q.commandbook.util.ServerUtil;
77
import com.sk89q.commandbook.util.entity.player.UUIDUtil;
8-
import org.apache.commons.lang.Validate;
8+
import org.apache.commons.lang3.Validate;
99
import org.bukkit.command.CommandSender;
1010
import org.bukkit.entity.Player;
1111

src/main/java/com/sk89q/commandbook/component/entityspawn/EntitySpawnComponent.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ public LivingEntity spawn(Location loc, EntityType type, String specialTypes,
162162
((Skeleton) creature).setSkeletonType(Skeleton.SkeletonType.WITHER);
163163
}
164164
break outerloop;
165-
case PIG_ZOMBIE:
165+
case ZOMBIFIED_PIGLIN:
166166
if (specialType.matches("(?i)angry")) {
167167
((PigZombie) creature).setAngry(true);
168168
return creature;

src/main/java/com/sk89q/commandbook/component/locations/FlatFileLocationsManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import au.com.bytecode.opencsv.CSVWriter;
2323
import com.sk89q.commandbook.CommandBook;
2424
import com.sk89q.commandbook.util.entity.player.UUIDUtil;
25-
import org.apache.commons.lang.Validate;
25+
import org.apache.commons.lang3.Validate;
2626
import org.bukkit.Location;
2727
import org.bukkit.World;
2828
import org.bukkit.entity.Player;

src/main/java/com/sk89q/commandbook/component/thor/ThorComponent.java

+15-9
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
import com.sk89q.minecraft.util.commands.CommandContext;
3030
import com.sk89q.minecraft.util.commands.CommandException;
3131
import com.sk89q.minecraft.util.commands.CommandPermissions;
32-
import com.sk89q.worldedit.bukkit.BukkitAdapter;
33-
import com.sk89q.worldedit.world.item.ItemTypes;
3432
import com.zachsthings.libcomponents.ComponentInformation;
3533
import com.zachsthings.libcomponents.Depend;
3634
import com.zachsthings.libcomponents.InjectComponent;
@@ -48,10 +46,10 @@
4846
import org.bukkit.event.block.Action;
4947
import org.bukkit.event.player.PlayerInteractEvent;
5048

51-
import java.util.Arrays;
52-
import java.util.HashSet;
49+
import java.util.List;
5350
import java.util.Random;
5451
import java.util.Set;
52+
import java.util.stream.Collectors;
5553

5654
@ComponentInformation(friendlyName = "Thor", desc = "Thor's hammer and other lightning effects.")
5755
@Depend(components = SessionComponent.class)
@@ -76,19 +74,27 @@ public void reload() {
7674
configure(config);
7775
}
7876

77+
private static final List<Material> DEFAULT_THOR_ITEMS = List.of(
78+
Material.WOODEN_PICKAXE,
79+
Material.STONE_PICKAXE,
80+
Material.IRON_PICKAXE,
81+
Material.GOLDEN_PICKAXE,
82+
Material.DIAMOND_PICKAXE,
83+
Material.NETHERITE_PICKAXE
84+
);
85+
7986
private static class LocalConfiguration extends ConfigurationBase {
80-
@Setting("hammer-items") public Set<String> thorItems = new HashSet<>(Arrays.asList(
81-
ItemTypes.WOODEN_PICKAXE.getId(), ItemTypes.STONE_PICKAXE.getId(), ItemTypes.IRON_PICKAXE.getId(),
82-
ItemTypes.GOLDEN_PICKAXE.getId(), ItemTypes.DIAMOND_PICKAXE.getId()
83-
));
87+
@Setting("hammer-items") public Set<String> thorItems = DEFAULT_THOR_ITEMS.stream().map(
88+
s -> s.key().asString()
89+
).collect(Collectors.toSet());
8490
}
8591

8692
@EventHandler
8793
public void onInteract(PlayerInteractEvent event) {
8894
Player player = event.getPlayer();
8995

9096
if (sessions.getSession(UserSession.class, player).hasThor()) {
91-
if (!config.thorItems.contains(BukkitAdapter.adapt(player.getItemInHand()).getType().getId())) {
97+
if (!config.thorItems.contains(player.getItemInHand().getType().key().asString())) {
9298
return;
9399
}
94100

src/main/resources/plugin.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: CommandBook
22
main: com.sk89q.commandbook.CommandBook
33
version: "${internalVersion}"
4-
softdepend: [WorldEdit]
5-
api-version: 1.13
4+
depend: [WorldEdit]
5+
api-version: 1.21

0 commit comments

Comments
 (0)