10000 Registering commands during server runtime (Bukkit) by willkroboth · Pull Request #417 · CommandAPI/CommandAPI · GitHub
[go: up one dir, main page]

Skip to content

Registering commands during server runtime (Bukkit) #417

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 20 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
2c65c44
Implement registering commands during server runtime
willkroboth Mar 31, 2023
ffd5de2
Don't wrap command nodes in CommandAPIBukkit#registerCommandNode
willkroboth Mar 31, 2023
33188cb
Add CommandAPIBukkit#getKnownCommandsMap and use SafeVarHandle instea…
willkroboth Apr 3, 2023
8000
0b10ce1
Clean up logic for unregistering and fix when server is running
willkroboth Apr 4, 2023
6d01d57
Add 1.20 support for registering commands during server runtime
willkroboth Jun 13, 2023
0d0cce9
Use Player#updateCommands instead of `resendPackets`
willkroboth Jul 24, 2023
661ae89
Finish some tasks for Bukkit runtime register PR (https://github.com…
willkroboth Jul 26, 2023
8fedf11
Finish tests for registering/unregistering while server is enabled
willkroboth Jul 27, 2023
428b6bb
Fix formatting error in commandregistration.md
willkroboth Jul 27, 2023
365bf00
Inline `CommandAPIBukkit#getKnownCommands` since it is only being use…
willkroboth Aug 3, 2023
46ea5ac
Rename unregister parameter `force` to `unregisterNamespaces` and add…
willkroboth Aug 6, 2023
7020df1
Fix bug where the namespaced version of a command registered while Bu…
willkroboth Aug 6, 2023
c78c686
Make `CommandAPIBukkit#unregister` static, Tweak `unregister` javadocs
willkroboth Aug 7, 2023
acc0505
Respect `unregisterBukkit` when removing commands from resources disp…
willkroboth Aug 7, 2023
f063702
Add tests for `CommandAPIBukkit#unregister` while server is not enabled
willkroboth Aug 8, 2023
8e49c4a
Document new `CommandAPI#unregister` behavior
willkroboth Aug 11, 2023
cb28042
Add `log` language to unlabeled code block in commandunregistration.md
willkroboth Aug 11, 2023
bb43e1b
Fix `unreigster` typo in commandunregistration.md
willkroboth Aug 11, 2023
073334a
Rename anchors from `commandUnregistration(Purpose)` to `commandUnreg…
willkroboth Aug 11, 2023
c83a880
Add entry for runtime registering/unregistering to Changelog
willkroboth Aug 11, 2023
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
Prev Previous commit
Next Next commit
Make CommandAPIBukkit#unregister static, Tweak unregister javadocs
  • Loading branch information
willkroboth committed Aug 11, 2023
commit c78c6868fd11301fe7491fe15e2df286c5e16097
Original file line number Diff line number Diff line change
Expand Up @@ -259,12 +259,13 @@ public static void unregister(String command) {
}

/**
* Unregisters a command, by force (removes all instances of that command)
* Unregisters a command
*
* @param command the name of the command to unregister
* @param unregisterNamespaces whether the unregistration system should attempt to remove versions of the
* command that start with a namespace. Eg. `minecraft:command`, `bukkit:command`,
* or `plugin:command`
* command that start with a namespace. E.g. `minecraft:command`, `bukkit:command`,
* or `plugin:command`. If true, these namespaced versions of a command are also
* unregistered.
*/
public static void unregister(String command, boolean unregisterNamespaces) {
CommandAPIHandler.getInstance().getPlatform().unregister(command, unregisterNamespaces);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -494,20 +494,28 @@ public LiteralCommandNode<Source> registerCommandNode(LiteralArgumentBuilder<Sou

@Override
public void unregister(String commandName, boolean unregisterNamespaces) {
unregister(commandName, unregisterNamespaces, false);
unregisterInternal(commandName, unregisterNamespaces, false);
}

// TODO: Should there be a static version of this method so developers don't have to call CommandAPIBukkit.get()?
/**
* Unregisters a command from the CommandGraph so it can't be run anymore.
* Unregisters a command from the CommandGraph, so it can't be run anymore. This Bukkit-specific unregister has an
* additional parameter, {@code unregisterBukkit}, compared to {@link CommandAPI#unregister(String, boolean)}.
*
* @param commandName the name of the command to unregister
* @param unregisterNamespaces whether the unregistration system should attempt to remove versions of the
* command that start with a namespace. Eg. `minecraft:command`, `bukkit:command`,
* or `plugin:command`
* @param unregisterBukkit whether the unregistration system should unregister
* command that start with a namespace. E.g. `minecraft:command`, `bukkit:command`,
* or `plugin:command`. If true, these namespaced versions of a command are also
* unregistered.
* @param unregisterBukkit whether the unregistration system should unregister Vanilla or Bukkit commands. If true,
* only Bukkit commands are unregistered, otherwise only Vanilla commands are unregistered.
* For the purposes of this parameter, commands registered using the CommandAPI are Vanilla
* commands, and commands registered by other plugin using Bukkit API are Bukkit commands.
*/
public void unregister(String commandName, boolean unregisterNamespaces, boolean unregisterBukkit) {
public static void unregister(String commandName, boolean unregisterNamespaces, boolean unregisterBukkit) {
CommandAPIBukkit.get().unregisterInternal(commandName, unregisterNamespaces, unregisterBukkit);
}

private void unregisterInternal(String commandName, boolean unregisterNamespaces, boolean unregisterBukkit) {
CommandAPI.logInfo("Unregistering command /" + commandName);

if(!unregisterBukkit) {
Expand Down
0