Skip to content

Commit 6369d3d

Browse files
committed
fix: use runtime command keys
1 parent cbba4eb commit 6369d3d

2 files changed

Lines changed: 6 additions & 9 deletions

File tree

src/main/java/me/croabeast/command/BukkitCommand.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import me.croabeast.common.Registrable;
88
import org.apache.commons.lang.StringUtils;
99
import org.bukkit.Bukkit;
10-
import org.bukkit.NamespacedKey;
1110
import org.bukkit.Server;
1211
import org.bukkit.command.CommandSender;
1312
import org.bukkit.command.PluginIdentifiableCommand;
@@ -31,7 +30,7 @@
3130
* <p>
3231
* Key features include:
3332
* <ul>
34-
* <li>Generating a unique {@link NamespacedKey} for each command.</li>
33+
* <li>Generating a unique runtime key for each command instance.</li>
3534
* <li>Managing sub-commands through an internal set.</li>
3635
* <li>Customizable error handling via {@code executingError} and {@code completingError} predicates.</li>
3736
* <li>Dynamic addition and removal of aliases.</li>
@@ -50,7 +49,7 @@ public abstract class BukkitCommand extends org.bukkit.command.defaults.BukkitCo
5049
/**
5150
* The unique key associated with this command.
5251
*/
53-
private final NamespacedKey key;
52+
private final String key;
5453

5554
/**
5655
* The plugin that owns this command.
@@ -252,7 +251,7 @@ public BukkitCommand(Plugin plugin, String name, String permission) {
252251
super(name);
253252
this.plugin = Objects.requireNonNull(plugin);
254253

255-
key = new NamespacedKey(plugin, UUID.randomUUID().toString());
254+
key = Entry.pluginName(plugin) + ':' + UUID.randomUUID();
256255
setPermission(permission);
257256

258257
subCommandMap = SubCommandMap.create();

src/main/java/me/croabeast/command/Command.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package me.croabeast.command;
22

33
import me.croabeast.common.Registrable;
4-
import org.bukkit.Keyed;
54
import org.bukkit.command.PluginIdentifiableCommand;
65
import org.jetbrains.annotations.NotNull;
76

@@ -13,7 +12,7 @@
1312
* <ul>
1413
* <li>{@link BaseCommand} for basic command properties (name, aliases, and executable predicate).</li>
1514
* <li>{@link Completable} for generating tab-completion suggestions.</li>
16-
* <li>{@link PluginIdentifiableCommand} and {@link Keyed} for associating the command with a plugin.</li>
15+
* <li>{@link PluginIdentifiableCommand} for associating the command with a plugin.</li>
1716
* <li>{@link Registrable} for handling command registration.</li>
1817
* </ul>
1918
* </p>
@@ -73,17 +72,16 @@
7372
* }
7473
* }
7574
*
76-
* // Other methods from Completable, PluginIdentifiableCommand, Keyed, and Registrable...
75+
* // Other methods from Completable, PluginIdentifiableCommand, and Registrable...
7776
* }
7877
* }</pre></p>
7978
*
8079
* @see BaseCommand
8180
* @see Completable
8281
* @see PluginIdentifiableCommand
83-
* @see Keyed
8482
* @see Registrable
8583
*/
86-
public interface Command extends BaseCommand, Completable, PluginIdentifiableCommand, Keyed, Registrable {
84+
public interface Command extends BaseCommand, Completable, PluginIdentifiableCommand, Registrable {
8785

8886
/**
8987
* Checks if the command is currently enabled.

0 commit comments

Comments
 (0)