Cleaned up commands.

This commit is contained in:
Brianna 2020-09-05 10:08:23 -05:00
parent ca5387ec2a
commit 01dc7c13d2
4 changed files with 31 additions and 31 deletions

View File

@ -14,21 +14,21 @@ import java.util.List;
public class CommandBoost extends AbstractCommand {
final EpicHoppers instance;
private final EpicHoppers plugin;
public CommandBoost(EpicHoppers instance) {
super(false, "boost");
this.instance = instance;
public CommandBoost(EpicHoppers 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 &7hopper transfer rates by &6" + args[1] + "x" + (duration == 0L ? "" : (" for " + Methods.makeReadable(duration))) + "&7.").sendPrefixedMessage(sender);
return ReturnType.SUCCESS;
}

View File

@ -13,11 +13,11 @@ import java.util.List;
public class CommandGive extends AbstractCommand {
final EpicHoppers instance;
private final EpicHoppers plugin;
public CommandGive(EpicHoppers instance) {
super(false, "give");
this.instance = instance;
public CommandGive(EpicHoppers plugin) {
super(CommandType.CONSOLE_OK, "give");
this.plugin = plugin;
}
@Override
@ -26,29 +26,29 @@ public class CommandGive extends AbstractCommand {
return ReturnType.SYNTAX_ERROR;
}
if (Bukkit.getPlayerExact(args[0]) == null) {
instance.getLocale().newMessage("&cThat username does not exist, or the user is not online!").sendPrefixedMessage(sender);
plugin.getLocale().newMessage("&cThat username does not exist, or the user is not online!").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
Level level = instance.getLevelManager().getLowestLevel();
Level level = plugin.getLevelManager().getLowestLevel();
Player player;
if (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 {
player = Bukkit.getPlayer(args[0]);
}
if (!instance.getLevelManager().isLevel(Integer.parseInt(args[1]))) {
instance.getLocale().newMessage("&cNot a valid level... The current valid levels are: &4" + level.getLevel() + "-" + instance.getLevelManager().getHighestLevel().getLevel() + "&c.")
if (!plugin.getLevelManager().isLevel(Integer.parseInt(args[1]))) {
plugin.getLocale().newMessage("&cNot a valid level... The current valid levels are: &4" + level.getLevel() + "-" + plugin.getLevelManager().getHighestLevel().getLevel() + "&c.")
.sendPrefixedMessage(sender);
return ReturnType.FAILURE;
} else {
level = instance.getLevelManager().getLevel(Integer.parseInt(args[1]));
level = plugin.getLevelManager().getLevel(Integer.parseInt(args[1]));
}
player.getInventory().addItem(instance.newHopperItem(level));
instance.getLocale().getMessage("command.give.success").processPlaceholder("level", level.getLevel()).sendPrefixedMessage(player);
player.getInventory().addItem(plugin.newHopperItem(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 EpicHoppers instance;
private final EpicHoppers plugin;
public CommandReload(EpicHoppers instance) {
public CommandReload(EpicHoppers plugin) {
super(false, "reload");
this.instance = instance;
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;
}

View File

@ -10,16 +10,16 @@ import java.util.List;
public class CommandSettings extends AbstractCommand {
final EpicHoppers instance;
private final EpicHoppers plugin;
public CommandSettings(EpicHoppers instance) {
super(true, "settings");
this.instance = instance;
public CommandSettings(EpicHoppers 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;
}