Cleaned up commands.

This commit is contained in:
Brianna 2020-09-09 10:08:29 -05:00
parent 0c80dfd901
commit 1a346e8d1c
4 changed files with 34 additions and 34 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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;
}

View File

@ -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;
}