Reimplement /searchender

This commit is contained in:
Jikoo 2016-11-25 16:59:41 -05:00
parent 4335b8dc2c
commit 5c4886c66b
3 changed files with 36 additions and 31 deletions

View file

@ -144,7 +144,9 @@ public class OpenInv extends JavaPlugin {
pm.registerEvents(new OpenInvInventoryListener(this), this); pm.registerEvents(new OpenInvInventoryListener(this), this);
getCommand("openinv").setExecutor(new OpenInvPluginCommand(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("silentchest").setExecutor(new SilentChestPluginCommand(this));
getCommand("anychest").setExecutor(new AnyChestPluginCommand(this)); getCommand("anychest").setExecutor(new AnyChestPluginCommand(this));
getCommand("openender").setExecutor(new OpenEnderPluginCommand(this)); getCommand("openender").setExecutor(new OpenEnderPluginCommand(this));
@ -566,7 +568,7 @@ public class OpenInv extends JavaPlugin {
} }
// Send usage // Send usage
player.sendMessage(command.getUsage()); player.sendMessage(command.getUsage().replace("<command>", commandName));
List<String> aliases = command.getAliases(); List<String> aliases = command.getAliases();
if (aliases.isEmpty()) { if (aliases.isEmpty()) {

View file

@ -23,9 +23,11 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
public class SearchInvPluginCommand implements CommandExecutor { public class SearchInvPluginCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Material material = null; Material material = null;
@ -53,7 +55,8 @@ public class SearchInvPluginCommand implements CommandExecutor {
StringBuilder players = new StringBuilder(); StringBuilder players = new StringBuilder();
for (Player player : Bukkit.getServer().getOnlinePlayers()) { 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(", "); players.append(player.getName()).append(", ");
} }
} }

View file

@ -2,44 +2,44 @@ name: OpenInv
main: com.lishid.openinv.OpenInv main: com.lishid.openinv.OpenInv
version: ${openinv.version} version: ${openinv.version}
author: lishid author: lishid
authors: [ShadowRanger] authors: [Jikoo, ShadowRanger]
description: > description: >
This plugin allows you to open a player's inventory as a chest and interact with it in real time. This plugin allows you to open a player's inventory as a chest and interact with it in real time.
commands: commands:
openinv: openinv:
aliases: [oi, inv, open] aliases: [oi, inv, open]
description: Opens a player's inventory. description: Open a player's inventory
usage: | permission: OpenInv.*;OpenInv.openinv
/<command> - Opens last person's inventory. usage: |-
/<command> <player> - Opens a player's inventory. /<command> [Player] - Open a player's inventory
openender: openender:
aliases: [oe] aliases: [oe]
description: Opens a player's ender chest. description: Opens the enderchest of a player
usage: | permission: OpenInv.*;OpenInv.openender
/<command> - Opens last person's ender chest. usage: |-
/<command> <player> - Opens a player's ender chest. /<command> [Player] - Open a player's enderchest
searchinv: searchinv:
aliases: [si] aliases: [si]
description: Searches and lists players that have a specific item in their inventory. description: Search and list players having a specific item
usage: | permission: OpenInv.*;OpenInv.search
/<command> <item> [minAmount] - Item can be the Item ID or the CraftBukkit Item Name, minAmount is the minimum amount to be considered. usage: |-
/<command> <Item> [MinAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required
searchender: searchender:
aliases: [se] aliases: [se]
description: Searches and lists players that have a specific item in their ender chest. permission: OpenInv.*;OpenInv.search
usage: | description: Searches and lists players having a specific item in their ender chest
/<command> <item> [minAmount] - Item can be the Item ID or the CraftBukkit Item Name, minAmount is the minimum amount to be considered. usage: |-
toggleopeninv: /<command> <item> [minAmount] - Item is the ID or the Bukkit Material, MinAmount is the minimum amount required
aliases: [toi, toggleoi, toggleinv]
description: Toggles the item openinv function.
usage: |
/<command> [check] - Checks whether item openinv is enabled.
anychest:
aliases: [ac]
description: Toggles the any chest function, which allows opening of blocked chests.
usage: |
/<command> [check] - Checks whether any chest is enabled.
silentchest: silentchest:
aliases: [sc, silent] aliases: [sc, silent]
description: Toggles the silent chest function, which hides the animation of a chest when opened or closed, and suppresses the sound. description: Toggle silent chest function, which stops sounds and animations when using containers.
usage: | permission: OpenInv.*;OpenInv.silent
/<command> [check] - Checks whether silent chest is enabled. usage: |-
/<command> [Check] - Check or toggle silent chest
anychest:
aliases: [ac]
description: Toggle anychest function, which allows opening of blocked chests.
permission: OpenInv.*;OpenInv.anychest
usage: |-
/<command> [Check] - Checks or toggle anychest