mirror of
https://github.com/plexusorg/Module-LibsDisguises.git
synced 2026-06-04 01:06:55 +00:00
More refactoring
This commit is contained in:
@@ -8,7 +8,7 @@ import org.bukkit.Bukkit;
|
|||||||
|
|
||||||
public class LibsDisguises extends PlexModule
|
public class LibsDisguises extends PlexModule
|
||||||
{
|
{
|
||||||
public static boolean enabled = true;
|
private boolean enabled = true;
|
||||||
DisguiseListener disguiseListener;
|
DisguiseListener disguiseListener;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -25,7 +25,7 @@ public class LibsDisguises extends PlexModule
|
|||||||
api().logging().error("The Plex-LibsDisguises module requires the LibsDisguises plugin to work.");
|
api().logging().error("The Plex-LibsDisguises module requires the LibsDisguises plugin to work.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
registerCommand(new DisguiseToggleCMD());
|
registerCommand(new DisguiseToggleCMD(this));
|
||||||
registerCommand(new UndisguiseAllCMD());
|
registerCommand(new UndisguiseAllCMD());
|
||||||
disguiseListener = new DisguiseListener(this);
|
disguiseListener = new DisguiseListener(this);
|
||||||
disguiseListener.getCommands();
|
disguiseListener.getCommands();
|
||||||
@@ -37,4 +37,14 @@ public class LibsDisguises extends PlexModule
|
|||||||
{
|
{
|
||||||
// Unregistering listeners / commands is handled by Plex
|
// Unregistering listeners / commands is handled by Plex
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled)
|
||||||
|
{
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,23 +13,27 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
|
|
||||||
public class DisguiseToggleCMD extends SimplePlexCommand
|
public class DisguiseToggleCMD extends SimplePlexCommand
|
||||||
{
|
{
|
||||||
public DisguiseToggleCMD()
|
private final LibsDisguises module;
|
||||||
|
|
||||||
|
public DisguiseToggleCMD(LibsDisguises module)
|
||||||
{
|
{
|
||||||
super(command("disguisetoggle")
|
super(command("disguisetoggle")
|
||||||
.description("Toggle LibsDisguises")
|
.description("Toggle LibsDisguises")
|
||||||
.aliases("dtoggle")
|
.aliases("dtoggle")
|
||||||
.permission("plex.libsdisguises.disguisetoggle")
|
.permission("plex.libsdisguises.disguisetoggle")
|
||||||
.build());
|
.build());
|
||||||
|
this.module = module;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] strings)
|
protected Component execute(@NotNull CommandSender commandSender, @Nullable Player player, @NotNull String[] strings)
|
||||||
{
|
{
|
||||||
LibsDisguises.enabled = !LibsDisguises.enabled;
|
module.setEnabled(!module.isEnabled());
|
||||||
if (!LibsDisguises.enabled)
|
if (!module.isEnabled())
|
||||||
{
|
{
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new UndisguiseEvent(true));
|
Bukkit.getServer().getPluginManager().callEvent(new UndisguiseEvent(true));
|
||||||
}
|
}
|
||||||
broadcast(messageComponent(LibsDisguises.enabled ? "disguisesEnabled" : "disguisesDisabled", commandSender.getName()));
|
broadcast(messageComponent(module.isEnabled() ? "disguisesEnabled" : "disguisesDisabled", commandSender.getName()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ public class DisguiseListener extends PlexListener
|
|||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
// Don't check the arguments
|
// Don't check the arguments
|
||||||
message = message.replaceAll("\\s.*", "").replaceFirst("/", "");
|
message = message.replaceAll("\\s.*", "").replaceFirst("/", "");
|
||||||
if (!LibsDisguises.enabled)
|
if (!module.isEnabled())
|
||||||
{
|
{
|
||||||
for (Command command : commands)
|
for (Command command : commands)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user