More fixes and improvements - continued

This commit is contained in:
ShadowRanger 2015-06-24 19:19:45 +10:00
parent 2f1fd87435
commit 471b631838
15 changed files with 156 additions and 146 deletions

View file

@ -61,9 +61,11 @@ public class ConfigUpdater {
configFile.delete(); configFile.delete();
} }
plugin.getLogger().info("[Config] Backup of old config.yml file created.");
// Get the old config settings // Get the old config settings
int itemOpenInvItemId = config.getInt("ItemOpenInvItemID", 280); int itemOpenInvItemId = config.getInt("ItemOpenInvItemID", 280);
boolean checkForUpdates = config.getBoolean("CheckForUpdates", true); // boolean checkForUpdates = config.getBoolean("CheckForUpdates", true);
boolean notifySilentChest = config.getBoolean("NotifySilentChest", true); boolean notifySilentChest = config.getBoolean("NotifySilentChest", true);
boolean notifyAnyChest = config.getBoolean("NotifyAnyChest", true); boolean notifyAnyChest = config.getBoolean("NotifyAnyChest", true);
@ -92,10 +94,10 @@ public class ConfigUpdater {
plugin.saveDefaultConfig(); plugin.saveDefaultConfig();
plugin.reloadConfig(); plugin.reloadConfig();
config = plugin.getConfig(); // Refresh the referenced config config = plugin.getConfig(); // Refresh the referenced plugin config
config.set("config-version", "2"); config.set("config-version", 2);
config.set("check-for-updates", checkForUpdates); // config.set("check-for-updates", checkForUpdates);
config.set("items.open-inv", getMaterialById(itemOpenInvItemId).toString()); config.set("items.open-inv", getMaterialById(itemOpenInvItemId).toString());
config.set("notify.any-chest", notifyAnyChest); config.set("notify.any-chest", notifyAnyChest);
config.set("notify.silent-chest", notifySilentChest); config.set("notify.silent-chest", notifySilentChest);
@ -132,17 +134,20 @@ public class ConfigUpdater {
return null; return null;
} }
int total = keys.size();
int converted = 0;
for (String playerName : keys) { for (String playerName : keys) {
UUID uuid = UUIDUtil.getUUIDOf(playerName); UUID uuid = UUIDUtil.getUUIDOf(playerName);
if (uuid != null) { if (uuid != null) {
boolean toggled = section.getBoolean(playerName + ".toggle", false); boolean toggled = section.getBoolean(playerName + ".toggle", false);
toggles.put(uuid, toggled); toggles.put(uuid, toggled);
} converted++;
else {
plugin.getLogger().warning("Failed to retrieve UUID of player: " + playerName);
} }
} }
plugin.getLogger().info("[Config] Converted (" + converted + "/" + total + ") " + sectionName + " toggle player usernames to UUIDs.");
return toggles; return toggles;
} }

View file

@ -31,6 +31,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.lishid.openinv.commands.AnyChestCommand; import com.lishid.openinv.commands.AnyChestCommand;
import com.lishid.openinv.commands.OpenEnderCommand; import com.lishid.openinv.commands.OpenEnderCommand;
import com.lishid.openinv.commands.OpenInvCommand; import com.lishid.openinv.commands.OpenInvCommand;
import com.lishid.openinv.commands.SearchEnderCommand;
import com.lishid.openinv.commands.SearchInvCommand; import com.lishid.openinv.commands.SearchInvCommand;
import com.lishid.openinv.commands.SilentChestCommand; import com.lishid.openinv.commands.SilentChestCommand;
import com.lishid.openinv.commands.ToggleOpenInvCommand; import com.lishid.openinv.commands.ToggleOpenInvCommand;
@ -63,7 +64,7 @@ public class OpenInv extends JavaPlugin {
// Plugin // Plugin
mainPlugin = this; mainPlugin = this;
// Config // Config Updater
ConfigUpdater configUpdater = new ConfigUpdater(this); ConfigUpdater configUpdater = new ConfigUpdater(this);
configUpdater.checkForUpdates(); configUpdater.checkForUpdates();
@ -90,11 +91,12 @@ public class OpenInv extends JavaPlugin {
private void registerCommands() { private void registerCommands() {
getCommand("openinv").setExecutor(new OpenInvCommand(this)); getCommand("openinv").setExecutor(new OpenInvCommand(this));
getCommand("searchinv").setExecutor(new SearchInvCommand());
getCommand("toggleopeninv").setExecutor(new ToggleOpenInvCommand());
getCommand("silentchest").setExecutor(new SilentChestCommand());
getCommand("anychest").setExecutor(new AnyChestCommand());
getCommand("openender").setExecutor(new OpenEnderCommand(this)); getCommand("openender").setExecutor(new OpenEnderCommand(this));
getCommand("searchinv").setExecutor(new SearchInvCommand());
getCommand("searchender").setExecutor(new SearchEnderCommand());
getCommand("toggleopeninv").setExecutor(new ToggleOpenInvCommand());
getCommand("anychest").setExecutor(new AnyChestCommand());
getCommand("silentchest").setExecutor(new SilentChestCommand());
} }
public static PlayerDataManager getPlayerLoader() { public static PlayerDataManager getPlayerLoader() {
@ -109,21 +111,19 @@ public class OpenInv extends JavaPlugin {
return anySilentChest; return anySilentChest;
} }
/* public static Object getFromConfig(String path, Object defaultValue) {
public static Object getFromConfig(String data, Object defaultValue) { Object val = mainPlugin.getConfig().get(path);
Object val = mainPlugin.getConfig().get(data);
if (val == null) { if (val == null) {
mainPlugin.getConfig().set(data, defaultValue); mainPlugin.getConfig().set(path, defaultValue);
return defaultValue; return defaultValue;
} }
else { else {
return val; return val;
} }
} }
*/
public static void saveToConfig(String data, Object value) { public static void saveToConfig(String path, Object value) {
mainPlugin.getConfig().set(data, value); mainPlugin.getConfig().set(path, value);
mainPlugin.saveConfig(); mainPlugin.saveConfig();
} }
@ -174,48 +174,41 @@ public class OpenInv extends JavaPlugin {
saveToConfig("toggles.silent-chest." + player.getUniqueId(), status); saveToConfig("toggles.silent-chest." + player.getUniqueId(), status);
} }
/**
* Logs a given message to console.
*
* @param text the text to log
*/
public static void log(String text) { public static void log(String text) {
mainPlugin.getLogger().info("[OpenInv] " + text); mainPlugin.getLogger().info("[OpenInv] " + text);
} }
/**
* Logs an error to console.
*
* @param e the throwable error to log
*/
public static void log(Throwable e) { public static void log(Throwable e) {
mainPlugin.getLogger().severe("[OpenInv] " + e.toString()); mainPlugin.getLogger().severe("[OpenInv] " + e.toString());
e.printStackTrace(); e.printStackTrace();
} }
/**
* Sends a specified message to a given CommandSender with the OpenInv prefix.
*
* @param sender the CommandSender to message
* @param message the message to send to the player
*/
public static void sendMessage(CommandSender sender, String message) { public static void sendMessage(CommandSender sender, String message) {
sender.sendMessage(ChatColor.AQUA + "[OpenInv] " + ChatColor.WHITE + message); sender.sendMessage(ChatColor.AQUA + "[OpenInv] " + ChatColor.WHITE + message);
} }
public static void showHelp(Player player) { public static void showHelp(Player player) {
player.sendMessage(ChatColor.GREEN + "/openinv <player> - Open a player's inventory"); player.sendMessage(ChatColor.GREEN + "/openinv <player> - Open a player's inventory.");
player.sendMessage(ChatColor.GREEN + " (aliases: oi, inv, open)"); player.sendMessage(ChatColor.GREEN + " (aliases: oi, inv, open)");
player.sendMessage(ChatColor.GREEN + "/openender <player> - Open a player's ender chest");
player.sendMessage(ChatColor.GREEN + " (aliases: oe, enderchest)"); player.sendMessage(ChatColor.GREEN + "/openender <player> - Open a player's ender chest.");
player.sendMessage(ChatColor.GREEN + "/toggleopeninv - Toggle item openinv function"); player.sendMessage(ChatColor.GREEN + " (aliases: oe)");
player.sendMessage(ChatColor.GREEN + " (aliases: toi, toggleoi, toggleinv)");
player.sendMessage(ChatColor.GREEN + "/searchinv <item> [minAmount] - "); player.sendMessage(ChatColor.GREEN + "/searchinv <item> [minAmount] -");
player.sendMessage(ChatColor.GREEN + " Search and list players having a specific item."); player.sendMessage(ChatColor.GREEN + " Search and list players having a specific item.");
player.sendMessage(ChatColor.GREEN + " (aliases: si, search)"); player.sendMessage(ChatColor.GREEN + " (aliases: si)");
player.sendMessage(ChatColor.GREEN + "/anychest - Toggle anychest function");
player.sendMessage(ChatColor.GREEN + "/searchender <item> [minAmount] -");
player.sendMessage(ChatColor.GREEN + " Search and list players having a specific item.");
player.sendMessage(ChatColor.GREEN + " (aliases: se)");
player.sendMessage(ChatColor.GREEN + "/toggleopeninv - Toggle the item openinv function.");
player.sendMessage(ChatColor.GREEN + " (aliases: toi, toggleoi, toggleinv)");
player.sendMessage(ChatColor.GREEN + "/anychest - Toggle the any chest function.");
player.sendMessage(ChatColor.GREEN + " (aliases: ac)"); player.sendMessage(ChatColor.GREEN + " (aliases: ac)");
player.sendMessage(ChatColor.GREEN + "/silentchest - Toggle silent chest function");
player.sendMessage(ChatColor.GREEN + "/silentchest - Toggle the silent chest function.");
player.sendMessage(ChatColor.GREEN + " (aliases: sc, silent)"); player.sendMessage(ChatColor.GREEN + " (aliases: sc, silent)");
} }

View file

@ -62,7 +62,6 @@ public class OpenEnderCommand implements CommandExecutor {
// History management // History management
UUID history = openEnderHistory.get(player.getUniqueId()); UUID history = openEnderHistory.get(player.getUniqueId());
if (history == null) { if (history == null) {
history = player.getUniqueId(); history = player.getUniqueId();
openEnderHistory.put(player.getUniqueId(), history); openEnderHistory.put(player.getUniqueId(), history);

View file

@ -61,7 +61,6 @@ public class OpenInvCommand implements CommandExecutor {
// History management // History management
UUID history = openInvHistory.get(player.getUniqueId()); UUID history = openInvHistory.get(player.getUniqueId());
if (history == null) { if (history == null) {
history = player.getUniqueId(); history = player.getUniqueId();
openInvHistory.put(player.getUniqueId(), history); openInvHistory.put(player.getUniqueId(), history);

View file

@ -16,7 +16,7 @@ public class SearchEnderCommand implements CommandExecutor {
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("searchinv")) { if (command.getName().equalsIgnoreCase("searchender")) {
if (sender instanceof Player) { if (sender instanceof Player) {
if (!OpenInv.hasPermission(sender, Permissions.PERM_SEARCH)) { if (!OpenInv.hasPermission(sender, Permissions.PERM_SEARCH)) {
sender.sendMessage(ChatColor.RED + "You do not have permission to search player ender chests."); sender.sendMessage(ChatColor.RED + "You do not have permission to search player ender chests.");
@ -28,7 +28,7 @@ public class SearchEnderCommand implements CommandExecutor {
int count = 1; int count = 1;
if (args.length >= 1) { if (args.length >= 1) {
String[] gData = null; String[] gData;
gData = args[0].split(":"); gData = args[0].split(":");
material = Material.matchMaterial(gData[0]); material = Material.matchMaterial(gData[0]);
} }
@ -50,14 +50,14 @@ public class SearchEnderCommand implements CommandExecutor {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (Player onlinePlayer : Bukkit.getServer().getOnlinePlayers()) { for (Player onlinePlayer : Bukkit.getServer().getOnlinePlayers()) {
if (onlinePlayer.getInventory().contains(material, count)) { if (onlinePlayer.getEnderChest().contains(material, count)) {
sb.append(onlinePlayer.getName()); sb.append(onlinePlayer.getName());
sb.append(" "); sb.append(" ");
} }
} }
String playerList = sb.toString(); String playerList = sb.toString();
sender.sendMessage("Players with the item " + material.toString() + ": " + playerList); sender.sendMessage("Players with the item " + ChatColor.GRAY + material.toString() + ChatColor.RESET + " in their ender chest: " + playerList);
return true; return true;
} }

View file

@ -42,7 +42,7 @@ public class SearchInvCommand implements CommandExecutor {
int count = 1; int count = 1;
if (args.length >= 1) { if (args.length >= 1) {
String[] gData = null; String[] gData;
gData = args[0].split(":"); gData = args[0].split(":");
material = Material.matchMaterial(gData[0]); material = Material.matchMaterial(gData[0]);
} }
@ -71,7 +71,7 @@ public class SearchInvCommand implements CommandExecutor {
} }
String playerList = sb.toString(); String playerList = sb.toString();
sender.sendMessage("Players with the item " + material.toString() + ": " + playerList); sender.sendMessage("Players with the item " + ChatColor.GRAY + material.toString() + ChatColor.RESET + " in their inventory: " + playerList);
return true; return true;
} }

View file

@ -22,7 +22,7 @@ import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv; import com.lishid.openinv.OpenInv;
//Volatile // Volatile
import net.minecraft.server.v1_8_R3.*; import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.*; import org.bukkit.craftbukkit.v1_8_R3.entity.*;
@ -125,7 +125,7 @@ public class AnySilentChest {
if (silentChest) { if (silentChest) {
tileInventory = new SilentInventory(tileInventory); tileInventory = new SilentInventory(tileInventory);
if (OpenInv.notifySilentChest()) { if (OpenInv.notifySilentChest()) {
p.sendMessage("You are opening a chest silently."); OpenInv.sendMessage(p, "You are opening a chest silently.");
} }
returnValue = false; returnValue = false;
} }
@ -133,7 +133,7 @@ public class AnySilentChest {
player.openContainer(tileInventory); player.openContainer(tileInventory);
if (anyChest && OpenInv.notifyAnyChest()) { if (anyChest && OpenInv.notifyAnyChest()) {
p.sendMessage("You are opening a blocked chest."); OpenInv.sendMessage(p, "You are opening a blocked chest.");
} }
return returnValue; return returnValue;

View file

@ -24,7 +24,7 @@ import org.bukkit.inventory.Inventory;
import com.lishid.openinv.OpenInv; import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions; import com.lishid.openinv.Permissions;
//Volatile // Volatile
import net.minecraft.server.v1_8_R3.*; import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.inventory.*; import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
@ -53,7 +53,7 @@ public class InventoryAccess {
return ((CraftInventory) inventory).getInventory(); return ((CraftInventory) inventory).getInventory();
} }
//Use reflection to find the inventory // Use reflection to find the inventory
Class<? extends Inventory> clazz = inventory.getClass(); Class<? extends Inventory> clazz = inventory.getClass();
IInventory result = null; IInventory result = null;
for(Field f : clazz.getDeclaredFields()) { for(Field f : clazz.getDeclaredFields()) {

View file

@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv; import com.lishid.openinv.OpenInv;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
//Volatile // Volatile
import net.minecraft.server.v1_8_R3.*; import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.*; import org.bukkit.craftbukkit.v1_8_R3.*;

View file

@ -16,7 +16,7 @@
package com.lishid.openinv.internal; package com.lishid.openinv.internal;
//Volatile // Volatile
import net.minecraft.server.v1_8_R3.*; import net.minecraft.server.v1_8_R3.*;
public class SilentContainerChest extends ContainerChest { public class SilentContainerChest extends ContainerChest {
@ -25,7 +25,7 @@ public class SilentContainerChest extends ContainerChest {
public SilentContainerChest(IInventory i1, IInventory i2, EntityHuman human) { public SilentContainerChest(IInventory i1, IInventory i2, EntityHuman human) {
super(i1, i2, human); super(i1, i2, human);
inv = i2; inv = i2;
// close signal // Close signal
inv.closeContainer(human); inv.closeContainer(human);
} }

View file

@ -6,7 +6,7 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity; import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
//Volatile // Volatile
import net.minecraft.server.v1_8_R3.*; import net.minecraft.server.v1_8_R3.*;
public class SilentInventory implements ITileInventory { public class SilentInventory implements ITileInventory {
@ -73,12 +73,12 @@ public class SilentInventory implements ITileInventory {
@Override @Override
public void startOpen(EntityHuman entityHuman) { public void startOpen(EntityHuman entityHuman) {
//Don't do anything // Don't do anything
} }
@Override @Override
public void closeContainer(EntityHuman entityHuman) { public void closeContainer(EntityHuman entityHuman) {
//Don't do anything // Don't do anything
} }
@Override @Override
@ -153,7 +153,7 @@ public class SilentInventory implements ITileInventory {
@Override @Override
public Container createContainer(PlayerInventory playerInventory, EntityHuman entityHuman) { public Container createContainer(PlayerInventory playerInventory, EntityHuman entityHuman) {
//Don't let the chest itself create the container. // Don't let the chest itself create the container.
return new ContainerChest(playerInventory, this, entityHuman); return new ContainerChest(playerInventory, this, entityHuman);
} }

View file

@ -22,8 +22,9 @@ import org.bukkit.inventory.InventoryHolder;
import com.lishid.openinv.OpenInv; import com.lishid.openinv.OpenInv;
//Volatile // Volatile
import net.minecraft.server.v1_8_R3.*; import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.*; import org.bukkit.craftbukkit.v1_8_R3.entity.*;
import org.bukkit.craftbukkit.v1_8_R3.inventory.*; import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
@ -31,17 +32,17 @@ public class SpecialEnderChest extends InventorySubcontainer {
private final CraftInventory inventory = new CraftInventory(this); private final CraftInventory inventory = new CraftInventory(this);
private final InventoryEnderChest enderChest; private final InventoryEnderChest enderChest;
private final CraftPlayer owner; private final CraftPlayer owner;
private boolean playerOnline = false; private boolean playerOnline;
public SpecialEnderChest(Player p, Boolean online) { public SpecialEnderChest(Player p, boolean online) {
this(p, ((CraftPlayer) p).getHandle().getEnderChest(), online); this(p, ((CraftPlayer) p).getHandle().getEnderChest(), online);
} }
public SpecialEnderChest(Player p, InventoryEnderChest enderchest, boolean online) { public SpecialEnderChest(Player p, InventoryEnderChest enderChest, boolean online) {
super(enderchest.getName(), enderchest.hasCustomName(), enderchest.getSize()); super(enderChest.getName(), enderChest.hasCustomName(), enderChest.getSize());
this.owner = (CraftPlayer) p; this.owner = (CraftPlayer) p;
this.enderChest = enderchest; this.enderChest = enderChest;
this.items = enderChest.getContents(); this.items = this.enderChest.getContents();
this.playerOnline = online; this.playerOnline = online;
OpenInv.enderChests.put(owner.getUniqueId(), this); OpenInv.enderChests.put(owner.getUniqueId(), this);
} }

View file

@ -21,8 +21,9 @@ import org.bukkit.inventory.Inventory;
import com.lishid.openinv.OpenInv; import com.lishid.openinv.OpenInv;
//Volatile // Volatile
import net.minecraft.server.v1_8_R3.*; import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.*; import org.bukkit.craftbukkit.v1_8_R3.entity.*;
import org.bukkit.craftbukkit.v1_8_R3.inventory.*; import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
@ -30,7 +31,7 @@ public class SpecialPlayerInventory extends PlayerInventory {
private final CraftInventory inventory = new CraftInventory(this); private final CraftInventory inventory = new CraftInventory(this);
private final ItemStack[] extra = new ItemStack[5]; private final ItemStack[] extra = new ItemStack[5];
private final CraftPlayer owner; private final CraftPlayer owner;
private boolean playerOnline = false; private boolean playerOnline;
public SpecialPlayerInventory(Player p, boolean online) { public SpecialPlayerInventory(Player p, boolean online) {
super(((CraftPlayer) p).getHandle()); super(((CraftPlayer) p).getHandle());

View file

@ -67,7 +67,7 @@ public class OpenInvPlayerListener implements Listener {
} }
} }
@EventHandler(priority = EventPriority.MONITOR) @EventHandler
public void onPlayerInteract(PlayerInteractEvent event) { public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
@ -76,24 +76,27 @@ public class OpenInvPlayerListener implements Listener {
} }
Action action = event.getAction(); Action action = event.getAction();
Block block = event.getClickedBlock();
if (action == Action.RIGHT_CLICK_BLOCK && event.useInteractedBlock() == Result.DENY) { switch (action) {
case RIGHT_CLICK_BLOCK:
if (event.useInteractedBlock() == Result.DENY) {
return; return;
} }
Block block = event.getClickedBlock(); // Ender Chests
if (block.getType() == Material.ENDER_CHEST) {
if (action == Action.RIGHT_CLICK_BLOCK && block.getType() == Material.ENDER_CHEST) {
if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.getPlayerSilentChestStatus(player)) { if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.getPlayerSilentChestStatus(player)) {
event.setCancelled(true); event.setCancelled(true);
player.openInventory(player.getEnderChest()); player.openInventory(player.getEnderChest());
return;
} }
} }
if (action == Action.RIGHT_CLICK_BLOCK && block.getState() instanceof Chest) { // Chests
if (block.getState() instanceof Chest) {
boolean silentChest = false; boolean silentChest = false;
boolean anyChest = false; boolean anyChest = false;
int x = block.getX(); int x = block.getX();
int y = block.getY(); int y = block.getY();
int z = block.getZ(); int z = block.getZ();
@ -112,15 +115,18 @@ public class OpenInvPlayerListener implements Listener {
} }
} }
// If the anychest or silentchest is active // If the anyChest or silentChest is active
if (anyChest || silentChest) { if (anyChest || silentChest) {
if (!OpenInv.getAnySilentChest().activateChest(player, anyChest, silentChest, x, y, z)) { if (!OpenInv.getAnySilentChest().activateChest(player, anyChest, silentChest, x, y, z)) {
event.setCancelled(true); event.setCancelled(true);
} }
} }
return;
} }
if (action == Action.RIGHT_CLICK_BLOCK && block.getState() instanceof Sign) { // Signs
if (block.getState() instanceof Sign) {
try { try {
Sign sign = ((Sign) block.getState()); Sign sign = ((Sign) block.getState());
if (OpenInv.hasPermission(player, Permissions.PERM_OPENINV) && sign.getLine(0).equalsIgnoreCase("[openinv]")) { if (OpenInv.hasPermission(player, Permissions.PERM_OPENINV) && sign.getLine(0).equalsIgnoreCase("[openinv]")) {
@ -128,18 +134,18 @@ public class OpenInvPlayerListener implements Listener {
player.performCommand("openinv " + text); player.performCommand("openinv " + text);
} }
} }
catch (Exception ex) { catch (Exception e) {
player.sendMessage("Internal Error."); player.sendMessage("Internal Error.");
ex.printStackTrace(); e.printStackTrace();
}
} }
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
if (!(player.getItemInHand().getType() == OpenInv.getOpenInvItem()) || (!OpenInv.getPlayerItemOpenInvStatus(player)) || !OpenInv.hasPermission(player, Permissions.PERM_OPENINV)) {
return; return;
} }
case RIGHT_CLICK_AIR:
// OpenInv item
if (player.getItemInHand().getType() == OpenInv.getOpenInvItem() && OpenInv.getPlayerItemOpenInvStatus(player) && OpenInv.hasPermission(player, Permissions.PERM_OPENINV)) {
player.performCommand("openinv"); player.performCommand("openinv");
} }
} }
}
} }

View file

@ -7,32 +7,38 @@ description: >
commands: commands:
openinv: openinv:
aliases: [oi, inv, open] aliases: [oi, inv, open]
description: Open a player's inventory description: Open a player's inventory.
usage: | usage: |
/<command> - Open last person's inventory /<command> - Opens last person's inventory.
/<command> <Player> - Open a player's inventory /<command> <player> - Opens a player's inventory.
openender: openender:
aliases: [oe] aliases: [oe]
description: Opens the enderchest of a player description: Opens a player's ender chest.
usage: | usage: |
/<command> <Player> - Opens a player's enderchest /<command> - Opens last person's ender chest.
/<command> <player> - Opens a player's ender chest.
searchinv: searchinv:
aliases: [si] aliases: [si]
description: Search and list players having a specific item description: Searches and lists players that have a specific item in their inventory.
usage: | usage: |
/<command> <Item> [MinAmount] - Item can be the Item ID or the CraftBukkit Item Name, MinAmount is the minimum amount to be considered. /<command> <item> [minAmount] - Item can be the Item ID or the CraftBukkit Item Name, minAmount is the minimum amount to be considered.
searchender:
aliases: [se]
description: Searches and lists players that have a specific item in their ender chest.
usage: |
/<command> <item> [minAmount] - Item can be the Item ID or the CraftBukkit Item Name, minAmount is the minimum amount to be considered.
toggleopeninv: toggleopeninv:
aliases: [toi, toggleoi, toggleinv] aliases: [toi, toggleoi, toggleinv]
description: Toggle item openinv function description: Toggles the item openinv function.
usage: | usage: |
/<command> [Check] - Checks whether item openinv is enabled /<command> [check] - Checks whether item openinv is enabled.
silentchest:
aliases: [sc, silent]
description: Toggle silent chest function, which hides the animation of a chest when opened or closed, and suppresses the sound.
usage: |
/<command> [Check] - Checks whether silent chest is enabled
anychest: anychest:
aliases: [ac] aliases: [ac]
description: Toggle anychest function, which allows opening of blocked chests. description: Toggles the any chest function, which allows opening of blocked chests.
usage: | usage: |
/<command> [Check] - Checks whether anychest is enabled /<command> [check] - Checks whether any chest is enabled.
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: |
/<command> [check] - Checks whether silent chest is enabled.