Cleaned up commands.
This commit is contained in:
parent
0064cc6e16
commit
050d5c1830
|
@ -12,11 +12,11 @@ import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class CommandAdd extends AbstractCommand {
|
public class CommandAdd extends AbstractCommand {
|
||||||
|
|
||||||
final EpicHeads instance;
|
private final EpicHeads plugin;
|
||||||
|
|
||||||
public CommandAdd(EpicHeads instance) {
|
public CommandAdd(EpicHeads plugin) {
|
||||||
super(false, "add");
|
super(CommandType.CONSOLE_OK, "add");
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -27,10 +27,10 @@ public class CommandAdd extends AbstractCommand {
|
||||||
String name = args[1].replace("_", " ");
|
String name = args[1].replace("_", " ");
|
||||||
String categoryStr = args[2].replace("_", " ");
|
String categoryStr = args[2].replace("_", " ");
|
||||||
|
|
||||||
HeadManager headManager = instance.getHeadManager();
|
HeadManager headManager = plugin.getHeadManager();
|
||||||
|
|
||||||
if (headManager.getLocalHeads().stream().anyMatch(head -> head.getURL().equals(url))) {
|
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;
|
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));
|
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);
|
.processPlaceholder("name", name).sendPrefixedMessage(sender);
|
||||||
if (categories.isEmpty()) {
|
if (categories.isEmpty()) {
|
||||||
instance.reloadConfig();
|
plugin.reloadConfig();
|
||||||
}
|
}
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,11 +12,11 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandBase64 extends AbstractCommand {
|
public class CommandBase64 extends AbstractCommand {
|
||||||
|
|
||||||
final EpicHeads instance;
|
private final EpicHeads plugin;
|
||||||
|
|
||||||
public CommandBase64(EpicHeads instance) {
|
public CommandBase64(EpicHeads plugin) {
|
||||||
super(true, "base64");
|
super(CommandType.PLAYER_ONLY, "base64");
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,7 +32,7 @@ public class CommandBase64 extends AbstractCommand {
|
||||||
|
|
||||||
if (encodededStr == null) return ReturnType.FAILURE;
|
if (encodededStr == null) return ReturnType.FAILURE;
|
||||||
|
|
||||||
instance.getLocale().newMessage(encodededStr).sendPrefixedMessage(player);
|
plugin.getLocale().newMessage(encodededStr).sendPrefixedMessage(player);
|
||||||
|
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,10 +10,10 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandEpicHeads extends AbstractCommand {
|
public class CommandEpicHeads extends AbstractCommand {
|
||||||
|
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandEpicHeads(GuiManager guiManager) {
|
public CommandEpicHeads(GuiManager guiManager) {
|
||||||
super(false, "EpicHeads");
|
super(CommandType.PLAYER_ONLY, "EpicHeads");
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ import java.util.Optional;
|
||||||
|
|
||||||
public class CommandGive extends AbstractCommand {
|
public class CommandGive extends AbstractCommand {
|
||||||
|
|
||||||
final EpicHeads instance;
|
private final EpicHeads plugin;
|
||||||
|
|
||||||
public CommandGive(EpicHeads instance) {
|
public CommandGive(EpicHeads plugin) {
|
||||||
super(false, "give");
|
super(CommandType.CONSOLE_OK, "give");
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -32,7 +32,7 @@ public class CommandGive extends AbstractCommand {
|
||||||
int headId = Integer.parseInt(args[2]);
|
int headId = Integer.parseInt(args[2]);
|
||||||
|
|
||||||
if (player == null && !playerStr.equals("all")) {
|
if (player == null && !playerStr.equals("all")) {
|
||||||
instance.getLocale().getMessage("command.give.notonline")
|
plugin.getLocale().getMessage("command.give.notonline")
|
||||||
.processPlaceholder("name", args[1]).sendPrefixedMessage(sender);
|
.processPlaceholder("name", args[1]).sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
@ -40,9 +40,9 @@ public class CommandGive extends AbstractCommand {
|
||||||
List<Head> heads;
|
List<Head> heads;
|
||||||
|
|
||||||
if (archive.equalsIgnoreCase("global"))
|
if (archive.equalsIgnoreCase("global"))
|
||||||
heads = instance.getHeadManager().getGlobalHeads();
|
heads = plugin.getHeadManager().getGlobalHeads();
|
||||||
else if (archive.equalsIgnoreCase("local"))
|
else if (archive.equalsIgnoreCase("local"))
|
||||||
heads = instance.getHeadManager().getLocalHeads();
|
heads = plugin.getHeadManager().getLocalHeads();
|
||||||
else {
|
else {
|
||||||
return ReturnType.SYNTAX_ERROR;
|
return ReturnType.SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -61,18 +61,18 @@ public class CommandGive extends AbstractCommand {
|
||||||
if (pl == sender) continue;
|
if (pl == sender) continue;
|
||||||
pl.getInventory().addItem(item);
|
pl.getInventory().addItem(item);
|
||||||
|
|
||||||
instance.getLocale().getMessage("command.give.receive")
|
plugin.getLocale().getMessage("command.give.receive")
|
||||||
.processPlaceholder("name", head.get().getName()).sendPrefixedMessage(pl);
|
.processPlaceholder("name", head.get().getName()).sendPrefixedMessage(pl);
|
||||||
}
|
}
|
||||||
instance.getLocale().getMessage("command.give.success")
|
plugin.getLocale().getMessage("command.give.success")
|
||||||
.processPlaceholder("player", instance.getLocale().getMessage("general.word.everyone").getMessage())
|
.processPlaceholder("player", plugin.getLocale().getMessage("general.word.everyone").getMessage())
|
||||||
.processPlaceholder("name", head.get().getName())
|
.processPlaceholder("name", head.get().getName())
|
||||||
.sendPrefixedMessage(sender);
|
.sendPrefixedMessage(sender);
|
||||||
} else {
|
} else {
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
instance.getLocale().getMessage("command.give.receive")
|
plugin.getLocale().getMessage("command.give.receive")
|
||||||
.processPlaceholder("name", head.get().getName()).sendPrefixedMessage(player);
|
.processPlaceholder("name", head.get().getName()).sendPrefixedMessage(player);
|
||||||
instance.getLocale().getMessage("command.give.success")
|
plugin.getLocale().getMessage("command.give.success")
|
||||||
.processPlaceholder("player", player.getName())
|
.processPlaceholder("player", player.getName())
|
||||||
.processPlaceholder("name", head.get().getName())
|
.processPlaceholder("name", head.get().getName())
|
||||||
.sendPrefixedMessage(sender);
|
.sendPrefixedMessage(sender);
|
||||||
|
@ -80,7 +80,7 @@ public class CommandGive extends AbstractCommand {
|
||||||
|
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
instance.getLocale().getMessage("command.give.notfound")
|
plugin.getLocale().getMessage("command.give.notfound")
|
||||||
.processPlaceholder("name", head.get().getName()).sendPrefixedMessage(sender);
|
.processPlaceholder("name", head.get().getName()).sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,11 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandGiveToken extends AbstractCommand {
|
public class CommandGiveToken extends AbstractCommand {
|
||||||
|
|
||||||
final EpicHeads instance;
|
private final EpicHeads plugin;
|
||||||
|
|
||||||
public CommandGiveToken(EpicHeads instance) {
|
public CommandGiveToken(EpicHeads plugin) {
|
||||||
super(false, "givetoken");
|
super(CommandType.CONSOLE_OK, "givetoken");
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -26,18 +26,18 @@ public class CommandGiveToken extends AbstractCommand {
|
||||||
int amount = Integer.parseInt(args[1]);
|
int amount = Integer.parseInt(args[1]);
|
||||||
|
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
instance.getLocale().getMessage("command.give.notonline")
|
plugin.getLocale().getMessage("command.give.notonline")
|
||||||
.processPlaceholder("name", args[1]).sendPrefixedMessage(sender);
|
.processPlaceholder("name", args[1]).sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
player.getInventory().addItem(Methods.createToken(amount));
|
player.getInventory().addItem(Methods.createToken(amount));
|
||||||
|
|
||||||
instance.getLocale().getMessage("command.givetoken.receive")
|
plugin.getLocale().getMessage("command.givetoken.receive")
|
||||||
.processPlaceholder("amount", amount).sendPrefixedMessage(player);
|
.processPlaceholder("amount", amount).sendPrefixedMessage(player);
|
||||||
|
|
||||||
if (player != sender)
|
if (player != sender)
|
||||||
instance.getLocale().getMessage("command.givetoken.success")
|
plugin.getLocale().getMessage("command.givetoken.success")
|
||||||
.processPlaceholder("player", player.getName())
|
.processPlaceholder("player", player.getName())
|
||||||
.processPlaceholder("amount", amount).sendPrefixedMessage(sender);
|
.processPlaceholder("amount", amount).sendPrefixedMessage(sender);
|
||||||
|
|
||||||
|
|
|
@ -11,24 +11,24 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandHelp extends AbstractCommand {
|
public class CommandHelp extends AbstractCommand {
|
||||||
|
|
||||||
final EpicHeads instance;
|
private final EpicHeads plugin;
|
||||||
|
|
||||||
public CommandHelp(EpicHeads instance) {
|
public CommandHelp(EpicHeads plugin) {
|
||||||
super(false, "help");
|
super(CommandType.CONSOLE_OK, "help");
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
sender.sendMessage("");
|
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",
|
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);
|
.sendTo(sender);
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(Methods.formatText("&7Welcome to EpicHeads! To get started try using the command /heads to access the heads panel."));
|
sender.sendMessage(Methods.formatText("&7Welcome to EpicHeads! To get started try using the command /heads to access the heads panel."));
|
||||||
sender.sendMessage("");
|
sender.sendMessage("");
|
||||||
sender.sendMessage(Methods.formatText("&6Commands:"));
|
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())) {
|
if (command.getPermissionNode() == null || sender.hasPermission(command.getPermissionNode())) {
|
||||||
sender.sendMessage(ChatColor.DARK_GRAY + "- " + ChatColor.YELLOW + command.getSyntax() + ChatColor.GRAY + " - " + command.getDescription());
|
sender.sendMessage(ChatColor.DARK_GRAY + "- " + ChatColor.YELLOW + command.getSyntax() + ChatColor.GRAY + " - " + command.getDescription());
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,17 +8,17 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandReload extends AbstractCommand {
|
public class CommandReload extends AbstractCommand {
|
||||||
|
|
||||||
final EpicHeads instance;
|
private final EpicHeads plugin;
|
||||||
|
|
||||||
public CommandReload(EpicHeads instance) {
|
public CommandReload(EpicHeads plugin) {
|
||||||
super(false, "reload");
|
super(CommandType.CONSOLE_OK, "reload");
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
instance.reloadConfig();
|
plugin.reloadConfig();
|
||||||
instance.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
plugin.getLocale().getMessage("&7Configuration and Language files reloaded.").sendPrefixedMessage(sender);
|
||||||
return ReturnType.SUCCESS;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandSearch extends AbstractCommand {
|
public class CommandSearch extends AbstractCommand {
|
||||||
|
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandSearch(GuiManager guiManager) {
|
public CommandSearch(GuiManager guiManager) {
|
||||||
super(true, "search");
|
super(CommandType.PLAYER_ONLY, "search");
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,10 +11,10 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandSettings extends AbstractCommand {
|
public class CommandSettings extends AbstractCommand {
|
||||||
|
|
||||||
final GuiManager guiManager;
|
private final GuiManager guiManager;
|
||||||
|
|
||||||
public CommandSettings(GuiManager guiManager) {
|
public CommandSettings(GuiManager guiManager) {
|
||||||
super(true, "settings");
|
super(CommandType.PLAYER_ONLY, "settings");
|
||||||
this.guiManager = guiManager;
|
this.guiManager = guiManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,11 @@ import java.util.List;
|
||||||
|
|
||||||
public class CommandUrl extends AbstractCommand {
|
public class CommandUrl extends AbstractCommand {
|
||||||
|
|
||||||
final EpicHeads instance;
|
private final EpicHeads plugin;
|
||||||
|
|
||||||
public CommandUrl(EpicHeads instance) {
|
public CommandUrl(EpicHeads plugin) {
|
||||||
super(true, "url");
|
super(CommandType.PLAYER_ONLY, "url");
|
||||||
this.instance = instance;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -33,7 +33,7 @@ public class CommandUrl extends AbstractCommand {
|
||||||
|
|
||||||
String url = ItemUtils.getDecodedTexture(encodededStr);
|
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;
|
return ReturnType.SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue