Cleaned up commands.

This commit is contained in:
Brianna 2020-09-24 14:08:29 -05:00
parent 0064cc6e16
commit 050d5c1830
10 changed files with 56 additions and 56 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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