From 050d5c183044c61cc6cdccd7f8ff5237204e6d8c Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 24 Sep 2020 14:08:29 -0500 Subject: [PATCH] Cleaned up commands. --- .../epicheads/commands/CommandAdd.java | 16 ++++++------ .../epicheads/commands/CommandBase64.java | 10 +++---- .../epicheads/commands/CommandEpicHeads.java | 4 +-- .../epicheads/commands/CommandGive.java | 26 +++++++++---------- .../epicheads/commands/CommandGiveToken.java | 14 +++++----- .../epicheads/commands/CommandHelp.java | 12 ++++----- .../epicheads/commands/CommandReload.java | 12 ++++----- .../epicheads/commands/CommandSearch.java | 4 +-- .../epicheads/commands/CommandSettings.java | 4 +-- .../epicheads/commands/CommandUrl.java | 10 +++---- 10 files changed, 56 insertions(+), 56 deletions(-) diff --git a/src/main/java/com/songoda/epicheads/commands/CommandAdd.java b/src/main/java/com/songoda/epicheads/commands/CommandAdd.java index eee4226..afd8d12 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandAdd.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandAdd.java @@ -12,11 +12,11 @@ import java.util.stream.Collectors; public class CommandAdd extends AbstractCommand { - final EpicHeads instance; + private final EpicHeads plugin; - public CommandAdd(EpicHeads instance) { - super(false, "add"); - this.instance = instance; + public CommandAdd(EpicHeads plugin) { + super(CommandType.CONSOLE_OK, "add"); + this.plugin = plugin; } @Override @@ -27,10 +27,10 @@ public class CommandAdd extends AbstractCommand { String name = args[1].replace("_", " "); String categoryStr = args[2].replace("_", " "); - HeadManager headManager = instance.getHeadManager(); + HeadManager headManager = plugin.getHeadManager(); if (headManager.getLocalHeads().stream().anyMatch(head -> head.getURL().equals(url))) { - instance.getLocale().getMessage("command.add.exists").sendPrefixedMessage(sender); + plugin.getLocale().getMessage("command.add.exists").sendPrefixedMessage(sender); return ReturnType.FAILURE; } @@ -40,10 +40,10 @@ public class CommandAdd extends AbstractCommand { headManager.addLocalHead(new Head(headManager.getNextLocalId(), name, url, category, true, null, (byte) 0)); - instance.getLocale().getMessage("command.add.success") + plugin.getLocale().getMessage("command.add.success") .processPlaceholder("name", name).sendPrefixedMessage(sender); if (categories.isEmpty()) { - instance.reloadConfig(); + plugin.reloadConfig(); } return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandBase64.java b/src/main/java/com/songoda/epicheads/commands/CommandBase64.java index b3f2a5c..873be64 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandBase64.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandBase64.java @@ -12,11 +12,11 @@ import java.util.List; public class CommandBase64 extends AbstractCommand { - final EpicHeads instance; + private final EpicHeads plugin; - public CommandBase64(EpicHeads instance) { - super(true, "base64"); - this.instance = instance; + public CommandBase64(EpicHeads plugin) { + super(CommandType.PLAYER_ONLY, "base64"); + this.plugin = plugin; } @Override @@ -32,7 +32,7 @@ public class CommandBase64 extends AbstractCommand { if (encodededStr == null) return ReturnType.FAILURE; - instance.getLocale().newMessage(encodededStr).sendPrefixedMessage(player); + plugin.getLocale().newMessage(encodededStr).sendPrefixedMessage(player); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandEpicHeads.java b/src/main/java/com/songoda/epicheads/commands/CommandEpicHeads.java index cf4ab0c..0c01bc5 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandEpicHeads.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandEpicHeads.java @@ -10,10 +10,10 @@ import java.util.List; public class CommandEpicHeads extends AbstractCommand { - final GuiManager guiManager; + private final GuiManager guiManager; public CommandEpicHeads(GuiManager guiManager) { - super(false, "EpicHeads"); + super(CommandType.PLAYER_ONLY, "EpicHeads"); this.guiManager = guiManager; } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandGive.java b/src/main/java/com/songoda/epicheads/commands/CommandGive.java index 53cee0c..20926a6 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandGive.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandGive.java @@ -15,11 +15,11 @@ import java.util.Optional; public class CommandGive extends AbstractCommand { - final EpicHeads instance; + private final EpicHeads plugin; - public CommandGive(EpicHeads instance) { - super(false, "give"); - this.instance = instance; + public CommandGive(EpicHeads plugin) { + super(CommandType.CONSOLE_OK, "give"); + this.plugin = plugin; } @Override @@ -32,7 +32,7 @@ public class CommandGive extends AbstractCommand { int headId = Integer.parseInt(args[2]); if (player == null && !playerStr.equals("all")) { - instance.getLocale().getMessage("command.give.notonline") + plugin.getLocale().getMessage("command.give.notonline") .processPlaceholder("name", args[1]).sendPrefixedMessage(sender); return ReturnType.FAILURE; } @@ -40,9 +40,9 @@ public class CommandGive extends AbstractCommand { List heads; if (archive.equalsIgnoreCase("global")) - heads = instance.getHeadManager().getGlobalHeads(); + heads = plugin.getHeadManager().getGlobalHeads(); else if (archive.equalsIgnoreCase("local")) - heads = instance.getHeadManager().getLocalHeads(); + heads = plugin.getHeadManager().getLocalHeads(); else { return ReturnType.SYNTAX_ERROR; } @@ -61,18 +61,18 @@ public class CommandGive extends AbstractCommand { if (pl == sender) continue; pl.getInventory().addItem(item); - instance.getLocale().getMessage("command.give.receive") + plugin.getLocale().getMessage("command.give.receive") .processPlaceholder("name", head.get().getName()).sendPrefixedMessage(pl); } - instance.getLocale().getMessage("command.give.success") - .processPlaceholder("player", instance.getLocale().getMessage("general.word.everyone").getMessage()) + plugin.getLocale().getMessage("command.give.success") + .processPlaceholder("player", plugin.getLocale().getMessage("general.word.everyone").getMessage()) .processPlaceholder("name", head.get().getName()) .sendPrefixedMessage(sender); } else { player.getInventory().addItem(item); - instance.getLocale().getMessage("command.give.receive") + plugin.getLocale().getMessage("command.give.receive") .processPlaceholder("name", head.get().getName()).sendPrefixedMessage(player); - instance.getLocale().getMessage("command.give.success") + plugin.getLocale().getMessage("command.give.success") .processPlaceholder("player", player.getName()) .processPlaceholder("name", head.get().getName()) .sendPrefixedMessage(sender); @@ -80,7 +80,7 @@ public class CommandGive extends AbstractCommand { return ReturnType.SUCCESS; } else { - instance.getLocale().getMessage("command.give.notfound") + plugin.getLocale().getMessage("command.give.notfound") .processPlaceholder("name", head.get().getName()).sendPrefixedMessage(sender); return ReturnType.FAILURE; } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandGiveToken.java b/src/main/java/com/songoda/epicheads/commands/CommandGiveToken.java index a33034e..e49c355 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandGiveToken.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandGiveToken.java @@ -11,11 +11,11 @@ import java.util.List; public class CommandGiveToken extends AbstractCommand { - final EpicHeads instance; + private final EpicHeads plugin; - public CommandGiveToken(EpicHeads instance) { - super(false, "givetoken"); - this.instance = instance; + public CommandGiveToken(EpicHeads plugin) { + super(CommandType.CONSOLE_OK, "givetoken"); + this.plugin = plugin; } @Override @@ -26,18 +26,18 @@ public class CommandGiveToken extends AbstractCommand { int amount = Integer.parseInt(args[1]); if (player == null) { - instance.getLocale().getMessage("command.give.notonline") + plugin.getLocale().getMessage("command.give.notonline") .processPlaceholder("name", args[1]).sendPrefixedMessage(sender); return ReturnType.FAILURE; } player.getInventory().addItem(Methods.createToken(amount)); - instance.getLocale().getMessage("command.givetoken.receive") + plugin.getLocale().getMessage("command.givetoken.receive") .processPlaceholder("amount", amount).sendPrefixedMessage(player); if (player != sender) - instance.getLocale().getMessage("command.givetoken.success") + plugin.getLocale().getMessage("command.givetoken.success") .processPlaceholder("player", player.getName()) .processPlaceholder("amount", amount).sendPrefixedMessage(sender); diff --git a/src/main/java/com/songoda/epicheads/commands/CommandHelp.java b/src/main/java/com/songoda/epicheads/commands/CommandHelp.java index 615f5eb..6485740 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandHelp.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandHelp.java @@ -11,24 +11,24 @@ import java.util.List; public class CommandHelp extends AbstractCommand { - final EpicHeads instance; + private final EpicHeads plugin; - public CommandHelp(EpicHeads instance) { - super(false, "help"); - this.instance = instance; + public CommandHelp(EpicHeads plugin) { + super(CommandType.CONSOLE_OK, "help"); + this.plugin = plugin; } @Override protected ReturnType runCommand(CommandSender sender, String... args) { sender.sendMessage(""); new ChatMessage().fromText(String.format("#ff8080&l%s &8ยป &7Version %s Created with <3 by #ec4e74&l&oS#fa5b65&l&oo#ff6c55&l&on#ff7f44&l&og#ff9432&l&oo#ffaa1e&l&od#f4c009&l&oa", - instance.getDescription().getName(), instance.getDescription().getVersion())) + plugin.getDescription().getName(), plugin.getDescription().getVersion())) .sendTo(sender); sender.sendMessage(""); sender.sendMessage(Methods.formatText("&7Welcome to EpicHeads! To get started try using the command /heads to access the heads panel.")); sender.sendMessage(""); sender.sendMessage(Methods.formatText("&6Commands:")); - for (AbstractCommand command : instance.getCommandManager().getAllCommands()) { + for (AbstractCommand command : plugin.getCommandManager().getAllCommands()) { if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) { sender.sendMessage(ChatColor.DARK_GRAY + "- " + ChatColor.YELLOW + command.getSyntax() + ChatColor.GRAY + " - " + command.getDescription()); } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandReload.java b/src/main/java/com/songoda/epicheads/commands/CommandReload.java index 989e79f..49034d7 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandReload.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandReload.java @@ -8,17 +8,17 @@ import java.util.List; public class CommandReload extends AbstractCommand { - final EpicHeads instance; + private final EpicHeads plugin; - public CommandReload(EpicHeads instance) { - super(false, "reload"); - this.instance = instance; + public CommandReload(EpicHeads plugin) { + super(CommandType.CONSOLE_OK, "reload"); + this.plugin = plugin; } @Override protected ReturnType runCommand(CommandSender sender, String... args) { - instance.reloadConfig(); - instance.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender); + plugin.reloadConfig(); + plugin.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandSearch.java b/src/main/java/com/songoda/epicheads/commands/CommandSearch.java index d0071ca..f9684f4 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandSearch.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandSearch.java @@ -11,10 +11,10 @@ import java.util.List; public class CommandSearch extends AbstractCommand { - final GuiManager guiManager; + private final GuiManager guiManager; public CommandSearch(GuiManager guiManager) { - super(true, "search"); + super(CommandType.PLAYER_ONLY, "search"); this.guiManager = guiManager; } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandSettings.java b/src/main/java/com/songoda/epicheads/commands/CommandSettings.java index e7863a0..e8312f9 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandSettings.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandSettings.java @@ -11,10 +11,10 @@ import java.util.List; public class CommandSettings extends AbstractCommand { - final GuiManager guiManager; + private final GuiManager guiManager; public CommandSettings(GuiManager guiManager) { - super(true, "settings"); + super(CommandType.PLAYER_ONLY, "settings"); this.guiManager = guiManager; } diff --git a/src/main/java/com/songoda/epicheads/commands/CommandUrl.java b/src/main/java/com/songoda/epicheads/commands/CommandUrl.java index dd7f5c0..7926337 100644 --- a/src/main/java/com/songoda/epicheads/commands/CommandUrl.java +++ b/src/main/java/com/songoda/epicheads/commands/CommandUrl.java @@ -12,11 +12,11 @@ import java.util.List; public class CommandUrl extends AbstractCommand { - final EpicHeads instance; + private final EpicHeads plugin; - public CommandUrl(EpicHeads instance) { - super(true, "url"); - this.instance = instance; + public CommandUrl(EpicHeads plugin) { + super(CommandType.PLAYER_ONLY, "url"); + this.plugin = plugin; } @Override @@ -33,7 +33,7 @@ public class CommandUrl extends AbstractCommand { String url = ItemUtils.getDecodedTexture(encodededStr); - instance.getLocale().newMessage("http://textures.minecraft.net/texture/" + url).sendPrefixedMessage(player); + plugin.getLocale().newMessage("http://textures.minecraft.net/texture/" + url).sendPrefixedMessage(player); return ReturnType.SUCCESS; }