From 1a346e8d1cf388bcb475fb2a9c78a7558043c1d7 Mon Sep 17 00:00:00 2001 From: Brianna Date: Wed, 9 Sep 2020 10:08:29 -0500 Subject: [PATCH] Cleaned up commands. --- .../epicfarming/commands/CommandBoost.java | 18 ++++++------ .../commands/CommandGiveFarmItem.java | 28 +++++++++---------- .../epicfarming/commands/CommandReload.java | 12 ++++---- .../epicfarming/commands/CommandSettings.java | 10 +++---- 4 files changed, 34 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/songoda/epicfarming/commands/CommandBoost.java b/src/main/java/com/songoda/epicfarming/commands/CommandBoost.java index 0f446b6..ef9ee70 100644 --- a/src/main/java/com/songoda/epicfarming/commands/CommandBoost.java +++ b/src/main/java/com/songoda/epicfarming/commands/CommandBoost.java @@ -14,21 +14,21 @@ import java.util.List; public class CommandBoost extends AbstractCommand { - final EpicFarming instance; + private final EpicFarming plugin; - public CommandBoost(EpicFarming instance) { - super(false, "boost"); - this.instance = instance; + public CommandBoost(EpicFarming plugin) { + super(CommandType.CONSOLE_OK, "boost"); + this.plugin = plugin; } @Override protected ReturnType runCommand(CommandSender sender, String... args) { if (args.length < 2) { - instance.getLocale().newMessage("&7Syntax error...").sendPrefixedMessage(sender); + plugin.getLocale().newMessage("&7Syntax error...").sendPrefixedMessage(sender); return ReturnType.SYNTAX_ERROR; } if (!Methods.isInt(args[1])) { - instance.getLocale().newMessage("&6" + args[1] + " &7is not a number...").sendPrefixedMessage(sender); + plugin.getLocale().newMessage("&6" + args[1] + " &7is not a number...").sendPrefixedMessage(sender); return ReturnType.SYNTAX_ERROR; } @@ -45,13 +45,13 @@ public class CommandBoost extends AbstractCommand { Player player = Bukkit.getPlayer(args[0]); if (player == null) { - instance.getLocale().newMessage("&cThat player does not exist or is not online...").sendPrefixedMessage(sender); + plugin.getLocale().newMessage("&cThat player does not exist or is not online...").sendPrefixedMessage(sender); return ReturnType.FAILURE; } BoostData boostData = new BoostData(Integer.parseInt(args[1]), duration == 0L ? Long.MAX_VALUE : System.currentTimeMillis() + duration, player.getUniqueId()); - instance.getBoostManager().addBoostToPlayer(boostData); - instance.getLocale().newMessage("&7Successfully boosted &6" + Bukkit.getPlayer(args[0]).getName() + plugin.getBoostManager().addBoostToPlayer(boostData); + plugin.getLocale().newMessage("&7Successfully boosted &6" + Bukkit.getPlayer(args[0]).getName() + "'s &7farms by &6" + args[1] + "x" + (duration == 0L ? "" : (" for " + Methods.makeReadable(duration))) + "&7.").sendPrefixedMessage(sender); return ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/epicfarming/commands/CommandGiveFarmItem.java b/src/main/java/com/songoda/epicfarming/commands/CommandGiveFarmItem.java index d0ac957..503f6fe 100644 --- a/src/main/java/com/songoda/epicfarming/commands/CommandGiveFarmItem.java +++ b/src/main/java/com/songoda/epicfarming/commands/CommandGiveFarmItem.java @@ -13,25 +13,25 @@ import java.util.List; public class CommandGiveFarmItem extends AbstractCommand { - final EpicFarming instance; + private final EpicFarming plugin; - public CommandGiveFarmItem(EpicFarming instance) { - super(false, "givefarmitem"); - this.instance = instance; + public CommandGiveFarmItem(EpicFarming plugin) { + super(CommandType.CONSOLE_OK, "givefarmitem"); + this.plugin = plugin; } @Override protected ReturnType runCommand(CommandSender sender, String... args) { if (args.length == 1) return ReturnType.SYNTAX_ERROR; - Level level = instance.getLevelManager().getLowestLevel(); + Level level = plugin.getLevelManager().getLowestLevel(); Player player; if (args.length != 0 && Bukkit.getPlayer(args[0]) == null) { - instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender); + plugin.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } else if (args.length == 0) { if (!(sender instanceof Player)) { - instance.getLocale().newMessage("&cYou need to be a player to give a farm item to yourself.").sendPrefixedMessage(sender); + plugin.getLocale().newMessage("&cYou need to be a player to give a farm item to yourself.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } player = (Player) sender; @@ -40,17 +40,17 @@ public class CommandGiveFarmItem extends AbstractCommand { } - if (args.length >= 2 && !instance.getLevelManager().isLevel(Integer.parseInt(args[1]))) { - instance.getLocale().newMessage("&cNot a valid level... The current valid levels are: &4" - + instance.getLevelManager().getLowestLevel().getLevel() + "-" - + instance.getLevelManager().getHighestLevel().getLevel() + "&c.").sendPrefixedMessage(sender); + if (args.length >= 2 && !plugin.getLevelManager().isLevel(Integer.parseInt(args[1]))) { + plugin.getLocale().newMessage("&cNot a valid level... The current valid levels are: &4" + + plugin.getLevelManager().getLowestLevel().getLevel() + "-" + + plugin.getLevelManager().getHighestLevel().getLevel() + "&c.").sendPrefixedMessage(sender); return ReturnType.FAILURE; } else if (args.length != 0) { - level = instance.getLevelManager().getLevel(Integer.parseInt(args[1])); + level = plugin.getLevelManager().getLevel(Integer.parseInt(args[1])); } - player.getInventory().addItem(instance.makeFarmItem(level)); - instance.getLocale().getMessage("command.give.success") + player.getInventory().addItem(plugin.makeFarmItem(level)); + plugin.getLocale().getMessage("command.give.success") .processPlaceholder("level", level.getLevel()).sendPrefixedMessage(player); return ReturnType.SUCCESS; diff --git a/src/main/java/com/songoda/epicfarming/commands/CommandReload.java b/src/main/java/com/songoda/epicfarming/commands/CommandReload.java index 8186860..51b2a60 100644 --- a/src/main/java/com/songoda/epicfarming/commands/CommandReload.java +++ b/src/main/java/com/songoda/epicfarming/commands/CommandReload.java @@ -8,17 +8,17 @@ import java.util.List; public class CommandReload extends AbstractCommand { - final EpicFarming instance; + private final EpicFarming plugin; - public CommandReload(EpicFarming instance) { - super(false, "reload"); - this.instance = instance; + public CommandReload(EpicFarming 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 AbstractCommand.ReturnType.SUCCESS; } diff --git a/src/main/java/com/songoda/epicfarming/commands/CommandSettings.java b/src/main/java/com/songoda/epicfarming/commands/CommandSettings.java index 1b52b2c..08bcaca 100644 --- a/src/main/java/com/songoda/epicfarming/commands/CommandSettings.java +++ b/src/main/java/com/songoda/epicfarming/commands/CommandSettings.java @@ -10,16 +10,16 @@ import java.util.List; public class CommandSettings extends AbstractCommand { - final EpicFarming instance; + private final EpicFarming plugin; - public CommandSettings(EpicFarming instance) { - super(true, "settings"); - this.instance = instance; + public CommandSettings(EpicFarming plugin) { + super(CommandType.PLAYER_ONLY, "settings"); + this.plugin = plugin; } @Override protected ReturnType runCommand(CommandSender sender, String... args) { - instance.getGuiManager().showGUI((Player) sender, new PluginConfigGui(instance)); + plugin.getGuiManager().showGUI((Player) sender, new PluginConfigGui(plugin)); return ReturnType.SUCCESS; }