8000 Fix CommandAPI loading on old versions (tested 1.19) · CommandAPI/CommandAPI@7479cb8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7479cb8

Browse files
committed
Fix CommandAPI loading on old versions (tested 1.19)
This was a similar issue to what was brought up here: #594 (comment). It seems that having `NMS_1_21_R1::new` as a method reference still loads the `NMS_1_21_R1` class enough that Java gets mad. On 1.19, trying to load the CommandAPI gives `java.lang.VerifyError: Bad type on operand stack - Type 'net/minecraft/commands/CommandBuildContext' (current frame, stack[1]) is not assignable to 'net/minecraft/core/HolderLookup$a'` with the stacktrace going through that line. Moving all references to the `NMS_1_21_R1` class into the if statements allowed loading on 1.19 as expected. That does mean the slight inconvenience of having to specify and update the latest NMS object in two place.
1 parent 4edb542 commit 7479cb8

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-vh/src/main/java/dev/jorel/commandapi/CommandAPIVersionHandler.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import dev.jorel.commandapi.nms.*;
2525
import org.bukkit.Bukkit;
2626

27-
import java.util.function.Supplier;
28-
2927
/**
3028
* This file handles the NMS version to be loaded. The CommandAPIVersionHandler
3129
* file within the commandapi-core module is NOT used at compile time. Instead,
@@ -52,9 +50,8 @@ public interface CommandAPIVersionHandler {
5250
*/
5351
static LoadContext getPlatform() {
5452
String latestMajorVersion = "21"; // Change this for Minecraft's major update
55-
Supplier<CommandAPIPlatform<?, ?, ?>> latestNMS = NMS_1_21_R1::new;
5653
if (CommandAPI.getConfiguration().shouldUseLatestNMSVersion()) {
57-
return new LoadContext(latestNMS.get(), () -> {
54+
return new LoadContext(new NMS_1_21_R1(), () -> {
5855
CommandAPI.logWarning("Loading the CommandAPI with the latest and potentially incompatible NMS implementation.");
5956
CommandAPI.logWarning("While you may find success with this, further updates might be necessary to fully support the version you are using.");
6057
});
@@ -83,7 +80,7 @@ static LoadContext getPlatform() {
8380
if (CommandAPI.getConfiguration().shouldBeLenientForMinorVersions()) {
8481
String currentMajorVersion = version.split("\\.")[1];
8582
if (latestMajorVersion.equals(currentMajorVersion)) {
86-
return new LoadContext(latestNMS.get(), () -> {
83+
return new LoadContext(new NMS_1_21_R1(), () -> {
8784
CommandAPI.logWarning("Loading the CommandAPI with a potentially incompatible NMS implementation.");
8885
CommandAPI.logWarning("While you may find success with this, further updates might be necessary to fully support the version you are using.");
8986
});

0 commit comments

Comments
 (0)
0