mirror of
https://github.com/plexusorg/Plex.git
synced 2026-06-04 05:26:55 +00:00
API
This commit is contained in:
@@ -55,22 +55,39 @@ public abstract class PlexModule
|
|||||||
public void registerListener(Listener listener)
|
public void registerListener(Listener listener)
|
||||||
{
|
{
|
||||||
listeners.add(listener);
|
listeners.add(listener);
|
||||||
|
if (api != null)
|
||||||
|
{
|
||||||
|
api.listeners().register(listener);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterListener(Listener listener)
|
public void unregisterListener(Listener listener)
|
||||||
{
|
{
|
||||||
listeners.remove(listener);
|
listeners.remove(listener);
|
||||||
|
if (api != null)
|
||||||
|
{
|
||||||
|
api.listeners().unregister(listener);
|
||||||
|
return;
|
||||||
|
}
|
||||||
HandlerList.unregisterAll(listener);
|
HandlerList.unregisterAll(listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerCommand(Command command)
|
public void registerCommand(Command command)
|
||||||
{
|
{
|
||||||
commands.add(command);
|
commands.add(command);
|
||||||
|
if (api != null)
|
||||||
|
{
|
||||||
|
api.commands().register(command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterCommand(Command command)
|
public void unregisterCommand(Command command)
|
||||||
{
|
{
|
||||||
commands.remove(command);
|
commands.remove(command);
|
||||||
|
if (api != null)
|
||||||
|
{
|
||||||
|
api.commands().unregister(command);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ final class DefaultCommandApi implements CommandApi
|
|||||||
@Override
|
@Override
|
||||||
public void unregister(Command command)
|
public void unregister(Command command)
|
||||||
{
|
{
|
||||||
plugin.getServer().getCommandMap().getKnownCommands().remove(command.getName());
|
plugin.getServer().getCommandMap().getKnownCommands().remove(command.getName().toLowerCase());
|
||||||
command.getAliases().forEach(alias -> plugin.getServer().getCommandMap().getKnownCommands().remove(alias));
|
command.getAliases().forEach(alias -> plugin.getServer().getCommandMap().getKnownCommands().remove(alias.toLowerCase()));
|
||||||
command.unregister(plugin.getServer().getCommandMap());
|
command.unregister(plugin.getServer().getCommandMap());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user