Fix bukkit command unloading
This commit is contained in:
parent
d9a9372af5
commit
2d1a92c584
1 changed files with 16 additions and 3 deletions
|
|
@ -251,15 +251,28 @@ public class BukkitPluginManager extends AbstractPluginManager<Plugin, BukkitPlu
|
||||||
unregisterCommands(getPluginCommands(plugin));
|
unregisterCommands(getPluginCommands(plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void unregisterCommands(Map<String, ? extends Command> pluginCommands) {
|
private static void unregisterCommands(Map<String, ? extends Command> commands) {
|
||||||
pluginCommands.values().forEach(c -> c.unregister(RCraftServer.getCommandMap()));
|
commands.values().forEach(c -> {
|
||||||
RCommandDispatcher.removeCommands(pluginCommands.keySet());
|
if (c instanceof PluginCommand) {
|
||||||
|
PluginCommand pluginCommand = (PluginCommand) c;
|
||||||
|
pluginCommand.setExecutor(null);
|
||||||
|
pluginCommand.setTabCompleter(null);
|
||||||
|
}
|
||||||
|
c.unregister(RCraftServer.getCommandMap());
|
||||||
|
});
|
||||||
|
RCommandDispatcher.removeCommands(commands.keySet());
|
||||||
|
|
||||||
|
Map<String, Command> knownCommands = getKnownCommands();
|
||||||
|
if (knownCommands == null) return;
|
||||||
|
knownCommands.values().removeIf(c -> c.equals(commands.get(c.getName().toLowerCase())));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters all the specified PluginCommand's.
|
* Unregisters all the specified PluginCommand's.
|
||||||
|
* @deprecated Use {@link BukkitPluginManager#unregisterCommands(Map)} instead.
|
||||||
* @param pluginCommands The commands to unregister.
|
* @param pluginCommands The commands to unregister.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public static void unregisterCommands(Collection<? extends PluginCommand> pluginCommands) {
|
public static void unregisterCommands(Collection<? extends PluginCommand> pluginCommands) {
|
||||||
Map<String, Command> knownCommands = getKnownCommands();
|
Map<String, Command> knownCommands = getKnownCommands();
|
||||||
if (knownCommands == null) return;
|
if (knownCommands == null) return;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue