Closed willkroboth closed 1 month ago
What's our standpoint on those
*
imports? Do we want them?
We don't care. They don't change the output of the compiled code, the only downside to them is it's harder for humans to statically analyse code by staring at it in something other than an IDE, but it's 2024 and that's basically irrelevant.
This PR moves a lot of the current logic for registering commands on Bukkit into the class
SpigotCommandRegistration
. This allows an alternate implementation of the newCommandRegistrationStrategy
interface to be loaded when internal changes from https://github.com/PaperMC/Paper/pull/8235 (Paper-1.20.6-65 and later) are present. TheCommandRegistrationStrategy
is created by the methodNMS#createCommandRegistrationStrategy
.This is a more permanent fix than https://github.com/JorelAli/CommandAPI/pull/555 and resolves these issues when running on Paper-1.20.65 and later:
/minecraft:reload
deletes CommandAPI commands (Thanks FireML on Discord)unregisterBukkit
parameter ofCommandAPIBukkit#unregister
isn't fully taken into accountThe implementation can still probably be refined by https://github.com/JorelAli/CommandAPI/pull/517 (e.g. CommandAPI-Spigot should never need
PaperCommandRegistration
, and later Paper versions should never needSpigotCommandReigistration
)The NMS methods
getResourcesDispatcher
,isVanillaCommandWrapper
,wrapToVanillaCommandWrapper
, andisBukkitCommandWrapper
were moved toSpigotCommandRegistration
because they only make sense if Paper changes are not present. These methods are only used in the CommandAPI bySpigotCommandRegistration
anyway, but developers can still access them usingCommandAPIBukkit#getCommandRegistrationStrategy
.PaperCommandRegistration
provides a similar method:isBukkitCommand
.TODO:
Before merging I want to double check that the following works
unregisterBukkit
parameter is repsectedminecraft:reload
On the following versions:
[x] Latest Paper (Paper-1.20.6-131)
[x] Paper-1.20.6-65
[x] Paper-1.20.6-64
[x] Paper-1.20.5
[x] Paper-1.20.4
[x] Spigot 1.20.6
[x] Spigot 1.20.4
And of course~ code review is greatly appreciated!