8000 Hotfix CommandAPI throwing errors because of Paper's Brigadier command API by DerEchtePilz · Pull Request #555 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

Hotfix CommandAPI throwing errors because of Paper's Brigadier command API #555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Initial commit for a hotfix
Regards Paper 1.20.6, build 65+, they've merged the Brigadier command API and removed the vanillaCommandDispatcher field.
  • Loading branch information
DerEchtePilz committed May 12, 2024
commit 7db2e9e3676d72894b896740ade7e2cb5d2c60bf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.mojang.brigadier.tree.CommandNode;
import dev.jorel.commandapi.CommandAPIBukkit;
import dev.jorel.commandapi.CommandAPIHandler;
import dev.jorel.commandapi.SafeVarHandle;
import dev.jorel.commandapi.arguments.ArgumentSubType;
import dev.jorel.commandapi.arguments.SuggestionProviders;
import dev.jorel.commandapi.commandsenders.AbstractCommandSender;
Expand Down Expand Up @@ -92,6 +93,12 @@
*/
public abstract class NMS_Common extends CommandAPIBukkit<CommandSourceStack> {

private static final SafeVarHandle<MinecraftServer, CommandDispatcher> commandDispatcher;

static {
commandDispatcher = SafeVarHandle.ofOrNull(MinecraftServer.class, "vanillaCommandDispatcher", "vanillaCommandDispatcher", CommandDispatcher.class);
}

private static NamespacedKey fromResourceLocation(ResourceLocation key) {
return NamespacedKey.fromString(key.getNamespace() + ":" + key.getPath());
}
Expand Down Expand Up @@ -350,7 +357,12 @@ public abstract Predicate<Block> getBlockPredicate(CommandContext<CommandSourceS

@Override
public final CommandDispatcher<CommandSourceStack> getBrigadierDispatcher() {
return this.<MinecraftServer>getMinecraftServer().vanillaCommandDispatcher.getDispatcher();
if (commandDispatcher != null) {
return this.<MinecraftServer>getMinecraftServer().vanillaCommandDispatcher.getDispatcher();
} else {
// Hoping this actually acts as a hotfix and commands at least register with Paper 1.20.6 build 65
return getResourcesDispatcher();
}
}

@Override
Expand Down
0