From 8e5fe8df7bb3556a380668fbf5b1858abb56ae61 Mon Sep 17 00:00:00 2001 From: ASangarin Date: Wed, 28 Aug 2019 13:45:46 +0100 Subject: [PATCH] Added Type argument to '/mi browse' --- .../Indyuce/mmoitems/command/MMOItemsCommand.java | 15 ++++++++++++--- .../command/completion/MMOItemsCompletion.java | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/Indyuce/mmoitems/command/MMOItemsCommand.java b/src/main/java/net/Indyuce/mmoitems/command/MMOItemsCommand.java index 88dcf64d..714b9099 100644 --- a/src/main/java/net/Indyuce/mmoitems/command/MMOItemsCommand.java +++ b/src/main/java/net/Indyuce/mmoitems/command/MMOItemsCommand.java @@ -85,7 +85,16 @@ public class MMOItemsCommand implements CommandExecutor { return true; } - new ItemBrowser((Player) sender).open(); + if (args.length < 2) { + new ItemBrowser((Player) sender).open(); + } + + if (!Type.isValid(args[1])) { + sender.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + "Please specify a valid item type."); + return true; + } + + new ItemBrowser((Player) sender, Type.get(args[1])).open(); } // ================================================================================================================================== else if (args[0].equalsIgnoreCase("update")) { @@ -583,11 +592,11 @@ public class MMOItemsCommand implements CommandExecutor { if (MMOItems.plugin.getVersion().getDurabilityHandler().isDamaged(item, item.getItemMeta())) config.getConfig().set(name + ".durability", MMOItems.plugin.getVersion().getDurabilityHandler().getDurability(item, item.getItemMeta())); if (item.getItemMeta().hasDisplayName()) - config.getConfig().set(name + ".name", item.getItemMeta().getDisplayName().replace("§", "&")); + config.getConfig().set(name + ".name", item.getItemMeta().getDisplayName().replace("�", "&")); if (item.getItemMeta().hasLore()) { List lore = new ArrayList<>(); for (String line : item.getItemMeta().getLore()) - lore.add(line.replace("§", "&")); + lore.add(line.replace("�", "&")); config.getConfig().set(name + ".lore", lore); } if (item.getItemMeta().hasItemFlag(ItemFlag.HIDE_ENCHANTS)) diff --git a/src/main/java/net/Indyuce/mmoitems/command/completion/MMOItemsCompletion.java b/src/main/java/net/Indyuce/mmoitems/command/completion/MMOItemsCompletion.java index 7a1ed62d..28f6e388 100644 --- a/src/main/java/net/Indyuce/mmoitems/command/completion/MMOItemsCompletion.java +++ b/src/main/java/net/Indyuce/mmoitems/command/completion/MMOItemsCompletion.java @@ -72,7 +72,7 @@ public class MMOItemsCompletion implements TabCompleter { list.add("spirit"); } - else if (args[0].equalsIgnoreCase("itemlist") || args[0].equalsIgnoreCase("drop") || args[0].equalsIgnoreCase("create") || args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("edit") || args[0].equalsIgnoreCase("copy") || args[0].equalsIgnoreCase("load")) + else if (args[0].equalsIgnoreCase("browse") || args[0].equalsIgnoreCase("itemlist") || args[0].equalsIgnoreCase("drop") || args[0].equalsIgnoreCase("create") || args[0].equalsIgnoreCase("delete") || args[0].equalsIgnoreCase("remove") || args[0].equalsIgnoreCase("edit") || args[0].equalsIgnoreCase("copy") || args[0].equalsIgnoreCase("load")) for (Type type : MMOItems.plugin.getTypes().getAll()) list.add(type.getId());