From 5c4886c66b4a242521ba8729859d4e8e92a97043 Mon Sep 17 00:00:00 2001 From: Jikoo Date: Fri, 25 Nov 2016 16:59:41 -0500 Subject: [PATCH] Reimplement /searchender --- .../main/java/com/lishid/openinv/OpenInv.java | 6 +- .../commands/SearchInvPluginCommand.java | 5 +- plugin/src/main/resources/plugin.yml | 56 +++++++++---------- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/plugin/src/main/java/com/lishid/openinv/OpenInv.java b/plugin/src/main/java/com/lishid/openinv/OpenInv.java index 7bc80e5..48b7637 100644 --- a/plugin/src/main/java/com/lishid/openinv/OpenInv.java +++ b/plugin/src/main/java/com/lishid/openinv/OpenInv.java @@ -144,7 +144,9 @@ public class OpenInv extends JavaPlugin { pm.registerEvents(new OpenInvInventoryListener(this), this); getCommand("openinv").setExecutor(new OpenInvPluginCommand(this)); - getCommand("searchinv").setExecutor(new SearchInvPluginCommand()); + SearchInvPluginCommand searchInv = new SearchInvPluginCommand(); + getCommand("searchinv").setExecutor(searchInv); + getCommand("searchender").setExecutor(searchInv); getCommand("silentchest").setExecutor(new SilentChestPluginCommand(this)); getCommand("anychest").setExecutor(new AnyChestPluginCommand(this)); getCommand("openender").setExecutor(new OpenEnderPluginCommand(this)); @@ -566,7 +568,7 @@ public class OpenInv extends JavaPlugin { } // Send usage - player.sendMessage(command.getUsage()); + player.sendMessage(command.getUsage().replace("", commandName)); List aliases = command.getAliases(); if (aliases.isEmpty()) { diff --git a/plugin/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java b/plugin/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java index 917d883..04ee588 100644 --- a/plugin/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java +++ b/plugin/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java @@ -23,9 +23,11 @@ import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.inventory.Inventory; public class SearchInvPluginCommand implements CommandExecutor { + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { Material material = null; @@ -53,7 +55,8 @@ public class SearchInvPluginCommand implements CommandExecutor { StringBuilder players = new StringBuilder(); for (Player player : Bukkit.getServer().getOnlinePlayers()) { - if (player.getInventory().contains(material, count)) { + Inventory inventory = command.getName().equals("searchinv") ? player.getInventory() : player.getEnderChest(); + if (inventory.contains(material, count)) { players.append(player.getName()).append(", "); } } diff --git a/plugin/src/main/resources/plugin.yml b/plugin/src/main/resources/plugin.yml index 32c0457..f1fed56 100644 --- a/plugin/src/main/resources/plugin.yml +++ b/plugin/src/main/resources/plugin.yml @@ -2,44 +2,44 @@ name: OpenInv main: com.lishid.openinv.OpenInv version: ${openinv.version} author: lishid -authors: [ShadowRanger] +authors: [Jikoo, ShadowRanger] description: > This plugin allows you to open a player's inventory as a chest and interact with it in real time. commands: openinv: aliases: [oi, inv, open] - description: Opens a player's inventory. - usage: | - / - Opens last person's inventory. - / - Opens a player's inventory. + description: Open a player's inventory + permission: OpenInv.*;OpenInv.openinv + usage: |- + / [Player] - Open a player's inventory openender: aliases: [oe] - description: Opens a player's ender chest. - usage: | - / - Opens last person's ender chest. - / - Opens a player's ender chest. + description: Opens the enderchest of a player + permission: OpenInv.*;OpenInv.openender + usage: |- + / [Player] - Open a player's enderchest searchinv: aliases: [si] - description: Searches and lists players that have a specific item in their inventory. - usage: | - / [minAmount] - Item can be the Item ID or the CraftBukkit Item Name, minAmount is the minimum amount to be considered. + description: Search and list players having a specific item + permission: OpenInv.*;OpenInv.search + usage: |- + / [MinAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required searchender: aliases: [se] - description: Searches and lists players that have a specific item in their ender chest. - usage: | - / [minAmount] - Item can be the Item ID or the CraftBukkit Item Name, minAmount is the minimum amount to be considered. - toggleopeninv: - aliases: [toi, toggleoi, toggleinv] - description: Toggles the item openinv function. - usage: | - / [check] - Checks whether item openinv is enabled. - anychest: - aliases: [ac] - description: Toggles the any chest function, which allows opening of blocked chests. - usage: | - / [check] - Checks whether any chest is enabled. + permission: OpenInv.*;OpenInv.search + description: Searches and lists players having a specific item in their ender chest + usage: |- + / [minAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required silentchest: aliases: [sc, silent] - description: Toggles the silent chest function, which hides the animation of a chest when opened or closed, and suppresses the sound. - usage: | - / [check] - Checks whether silent chest is enabled. + description: Toggle silent chest function, which stops sounds and animations when using containers. + permission: OpenInv.*;OpenInv.silent + usage: |- + / [Check] - Check or toggle silent chest + anychest: + aliases: [ac] + description: Toggle anychest function, which allows opening of blocked chests. + permission: OpenInv.*;OpenInv.anychest + usage: |- + / [Check] - Checks or toggle anychest +