diff --git a/.gitignore b/.gitignore index 02e7ddd..3c10ff7 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,3 @@ /bin /lib /out -*.iml diff --git a/pom.xml b/pom.xml index c5084d4..ef32711 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.lishid openinv jar - 2.2.9 + 2.3.0 OpenInv http://dev.bukkit.org/bukkit-plugins/openinv/ diff --git a/src/main/java/com/lishid/openinv/OpenInv.java b/src/main/java/com/lishid/openinv/OpenInv.java index fbae1bc..10e56a2 100644 --- a/src/main/java/com/lishid/openinv/OpenInv.java +++ b/src/main/java/com/lishid/openinv/OpenInv.java @@ -67,13 +67,13 @@ public class OpenInv extends JavaPlugin { mainPlugin = this; FileConfiguration config = getConfig(); config.set("CheckForUpdates", config.getBoolean("CheckForUpdates", true)); - config.set("NotifySilentChest", config.getBoolean("NotifySilentChest", true)); - config.set("NotifyAnyChest", config.getBoolean("NotifyAnyChest", true)); + config.set("notifySilentChest", config.getBoolean("notifySilentChest", true)); + config.set("notifyAnyChest", config.getBoolean("notifyAnyChest", true)); config.set("ItemOpenInvItemID", config.getInt("ItemOpenInvItemID", 280)); config.addDefault("ItemOpenInvItemID", 280); config.addDefault("CheckForUpdates", true); - config.addDefault("NotifySilentChest", true); - config.addDefault("NotifyAnyChest", true); + config.addDefault("notifySilentChest", true); + config.addDefault("notifyAnyChest", true); config.options().copyDefaults(true); saveConfig(); @@ -89,49 +89,49 @@ public class OpenInv extends JavaPlugin { getCommand("openender").setExecutor(new OpenEnderPluginCommand(this)); } - public static boolean NotifySilentChest() { - return mainPlugin.getConfig().getBoolean("NotifySilentChest", true); + public static boolean notifySilentChest() { + return mainPlugin.getConfig().getBoolean("notifySilentChest", true); } - public static boolean NotifyAnyChest() { - return mainPlugin.getConfig().getBoolean("NotifyAnyChest", true); + public static boolean notifyAnyChest() { + return mainPlugin.getConfig().getBoolean("notifyAnyChest", true); } - public static boolean GetPlayerItemOpenInvStatus(String name) { + public static boolean getPlayerItemOpenInvStatus(String name) { return mainPlugin.getConfig().getBoolean("ItemOpenInv." + name.toLowerCase() + ".toggle", false); } - public static void SetPlayerItemOpenInvStatus(String name, boolean status) { + public static void setPlayerItemOpenInvStatus(String name, boolean status) { mainPlugin.getConfig().set("ItemOpenInv." + name.toLowerCase() + ".toggle", status); mainPlugin.saveConfig(); } - public static boolean GetPlayerSilentChestStatus(String name) { + public static boolean getPlayerSilentChestStatus(String name) { return mainPlugin.getConfig().getBoolean("SilentChest." + name.toLowerCase() + ".toggle", false); } - public static void SetPlayerSilentChestStatus(String name, boolean status) { + public static void setPlayerSilentChestStatus(String name, boolean status) { mainPlugin.getConfig().set("SilentChest." + name.toLowerCase() + ".toggle", status); mainPlugin.saveConfig(); } - public static boolean GetPlayerAnyChestStatus(String name) { + public static boolean getPlayerAnyChestStatus(String name) { return mainPlugin.getConfig().getBoolean("AnyChest." + name.toLowerCase() + ".toggle", true); } - public static void SetPlayerAnyChestStatus(String name, boolean status) { + public static void setPlayerAnyChestStatus(String name, boolean status) { mainPlugin.getConfig().set("AnyChest." + name.toLowerCase() + ".toggle", status); mainPlugin.saveConfig(); } - public static int GetItemOpenInvItem() { + public static int getItemOpenInvItem() { if (mainPlugin.getConfig().get("ItemOpenInvItemID") == null) { - SaveToConfig("ItemOpenInvItemID", 280); + saveToConfig("ItemOpenInvItemID", 280); } return mainPlugin.getConfig().getInt("ItemOpenInvItemID", 280); } - public static Object GetFromConfig(String data, Object defaultValue) { + public static Object getFromConfig(String data, Object defaultValue) { Object val = mainPlugin.getConfig().get(data); if (val == null) { mainPlugin.getConfig().set(data, defaultValue); @@ -142,7 +142,7 @@ public class OpenInv extends JavaPlugin { } } - public static void SaveToConfig(String data, Object value) { + public static void saveToConfig(String data, Object value) { mainPlugin.getConfig().set(data, value); mainPlugin.saveConfig(); } @@ -162,7 +162,7 @@ public class OpenInv extends JavaPlugin { e.printStackTrace(); } - public static void ShowHelp(Player player) { + public static void showHelp(Player player) { player.sendMessage(ChatColor.GREEN + "/openinv - Open a player's inventory"); player.sendMessage(ChatColor.GREEN + " (aliases: oi, inv, open)"); player.sendMessage(ChatColor.GREEN + "/openender - Open a player's enderchest"); diff --git a/src/main/java/com/lishid/openinv/commands/AnyChestPluginCommand.java b/src/main/java/com/lishid/openinv/commands/AnyChestPluginCommand.java index 8de71ae..21423fe 100644 --- a/src/main/java/com/lishid/openinv/commands/AnyChestPluginCommand.java +++ b/src/main/java/com/lishid/openinv/commands/AnyChestPluginCommand.java @@ -40,15 +40,15 @@ public class AnyChestPluginCommand implements CommandExecutor { if (args.length > 0) { if (args[0].equalsIgnoreCase("check")) { - if (OpenInv.GetPlayerAnyChestStatus(sender.getName())) + if (OpenInv.getPlayerAnyChestStatus(sender.getName())) sender.sendMessage("AnyChest is ON."); else sender.sendMessage("AnyChest is OFF."); } } - OpenInv.SetPlayerAnyChestStatus(sender.getName(), !OpenInv.GetPlayerAnyChestStatus(sender.getName())); - sender.sendMessage("AnyChest is now " + (OpenInv.GetPlayerAnyChestStatus(sender.getName()) ? "On" : "Off") + "."); + OpenInv.setPlayerAnyChestStatus(sender.getName(), !OpenInv.getPlayerAnyChestStatus(sender.getName())); + sender.sendMessage("AnyChest is now " + (OpenInv.getPlayerAnyChestStatus(sender.getName()) ? "On" : "Off") + "."); return true; } diff --git a/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java b/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java index bb383c5..e190286 100644 --- a/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java +++ b/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java @@ -54,7 +54,7 @@ public class OpenEnderPluginCommand implements CommandExecutor { } if (args.length > 0 && args[0].equalsIgnoreCase("?")) { - OpenInv.ShowHelp((Player) sender); + OpenInv.showHelp((Player) sender); return true; } diff --git a/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java b/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java index 7d01e73..a3e8629 100644 --- a/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java +++ b/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java @@ -53,7 +53,7 @@ public class OpenInvPluginCommand implements CommandExecutor { } if (args.length > 0 && args[0].equalsIgnoreCase("?")) { - OpenInv.ShowHelp((Player) sender); + OpenInv.showHelp((Player) sender); return true; } diff --git a/src/main/java/com/lishid/openinv/commands/SilentChestPluginCommand.java b/src/main/java/com/lishid/openinv/commands/SilentChestPluginCommand.java index f698431..90bd3fc 100644 --- a/src/main/java/com/lishid/openinv/commands/SilentChestPluginCommand.java +++ b/src/main/java/com/lishid/openinv/commands/SilentChestPluginCommand.java @@ -40,15 +40,15 @@ public class SilentChestPluginCommand implements CommandExecutor { if (args.length > 0) { if (args[0].equalsIgnoreCase("check")) { - if (OpenInv.GetPlayerSilentChestStatus(sender.getName())) + if (OpenInv.getPlayerSilentChestStatus(sender.getName())) sender.sendMessage("SilentChest is ON."); else sender.sendMessage("SilentChest is OFF."); } } - OpenInv.SetPlayerSilentChestStatus(sender.getName(), !OpenInv.GetPlayerSilentChestStatus(sender.getName())); - sender.sendMessage("SilentChest is now " + (OpenInv.GetPlayerSilentChestStatus(sender.getName()) ? "On" : "Off") + "."); + OpenInv.setPlayerSilentChestStatus(sender.getName(), !OpenInv.getPlayerSilentChestStatus(sender.getName())); + sender.sendMessage("SilentChest is now " + (OpenInv.getPlayerSilentChestStatus(sender.getName()) ? "On" : "Off") + "."); return true; } diff --git a/src/main/java/com/lishid/openinv/commands/ToggleOpenInvPluginCommand.java b/src/main/java/com/lishid/openinv/commands/ToggleOpenInvPluginCommand.java index 0ba0fb7..b59f841 100644 --- a/src/main/java/com/lishid/openinv/commands/ToggleOpenInvPluginCommand.java +++ b/src/main/java/com/lishid/openinv/commands/ToggleOpenInvPluginCommand.java @@ -43,19 +43,19 @@ public class ToggleOpenInvPluginCommand implements CommandExecutor { Player player = (Player) sender; if (args.length > 0) { if (args[0].equalsIgnoreCase("check")) { - if (OpenInv.GetPlayerItemOpenInvStatus(player.getName())) - player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is ON."); + if (OpenInv.getPlayerItemOpenInvStatus(player.getName())) + player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.getItemOpenInvItem()).toString() + " is ON."); else - player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is OFF."); + player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.getItemOpenInvItem()).toString() + " is OFF."); } } - if (OpenInv.GetPlayerItemOpenInvStatus(player.getName())) { - OpenInv.SetPlayerItemOpenInvStatus(player.getName(), false); - player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is OFF."); + if (OpenInv.getPlayerItemOpenInvStatus(player.getName())) { + OpenInv.setPlayerItemOpenInvStatus(player.getName(), false); + player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.getItemOpenInvItem()).toString() + " is OFF."); } else { - OpenInv.SetPlayerItemOpenInvStatus(player.getName(), true); - player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is ON."); + OpenInv.setPlayerItemOpenInvStatus(player.getName(), true); + player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.getItemOpenInvItem()).toString() + " is ON."); } return true; } diff --git a/src/main/java/com/lishid/openinv/internal/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/AnySilentChest.java index 47b6421..d668c82 100644 --- a/src/main/java/com/lishid/openinv/internal/AnySilentChest.java +++ b/src/main/java/com/lishid/openinv/internal/AnySilentChest.java @@ -124,7 +124,7 @@ public class AnySilentChest { boolean returnValue = true; if (silentchest) { tileInventory = new SilentInventory(tileInventory); - if (OpenInv.NotifySilentChest()) { + if (OpenInv.notifySilentChest()) { p.sendMessage("You are opening a chest silently."); } returnValue = false; @@ -132,7 +132,7 @@ public class AnySilentChest { player.openContainer(tileInventory); - if (anychest && OpenInv.NotifyAnyChest()) { + if (anychest && OpenInv.notifyAnyChest()) { p.sendMessage("You are opening a blocked chest."); } diff --git a/src/main/java/com/lishid/openinv/internal/EnumDirectionList.java b/src/main/java/com/lishid/openinv/internal/EnumDirectionList.java index 7ee4c7f..56c5b48 100644 --- a/src/main/java/com/lishid/openinv/internal/EnumDirectionList.java +++ b/src/main/java/com/lishid/openinv/internal/EnumDirectionList.java @@ -11,7 +11,7 @@ public enum EnumDirectionList implements Iterable { HORIZONTAL(EnumDirectionLimit.HORIZONTAL), VERTICAL(EnumDirectionLimit.VERTICAL); - private EnumDirectionLimit list; + private final EnumDirectionLimit list; private EnumDirectionList(EnumDirectionLimit list) { this.list = list; diff --git a/src/main/java/com/lishid/openinv/internal/SilentInventory.java b/src/main/java/com/lishid/openinv/internal/SilentInventory.java index 3061142..dcea079 100644 --- a/src/main/java/com/lishid/openinv/internal/SilentInventory.java +++ b/src/main/java/com/lishid/openinv/internal/SilentInventory.java @@ -111,10 +111,12 @@ public class SilentInventory implements ITileInventory { return inv.getContents(); } + @Override public void onOpen(CraftHumanEntity craftHumanEntity) { inv.onOpen(craftHumanEntity); } + @Override public void onClose(CraftHumanEntity craftHumanEntity) { inv.onClose(craftHumanEntity); } diff --git a/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java index 75f4d95..ed43765 100644 --- a/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java +++ b/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java @@ -28,9 +28,9 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.*; import org.bukkit.craftbukkit.v1_8_R3.inventory.*; public class SpecialEnderChest extends InventorySubcontainer { - private CraftInventory inventory = new CraftInventory(this); - private InventoryEnderChest enderChest; - private CraftPlayer owner; + private final CraftInventory inventory = new CraftInventory(this); + private final InventoryEnderChest enderChest; + private final CraftPlayer owner; private boolean playerOnline = false; public SpecialEnderChest(Player p, Boolean online) { diff --git a/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java index c34f3be..f167e28 100644 --- a/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java +++ b/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java @@ -27,9 +27,9 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.*; import org.bukkit.craftbukkit.v1_8_R3.inventory.*; public class SpecialPlayerInventory extends PlayerInventory { - private CraftInventory inventory = new CraftInventory(this); - private ItemStack[] extra = new ItemStack[5]; - private CraftPlayer owner; + private final CraftInventory inventory = new CraftInventory(this); + private final ItemStack[] extra = new ItemStack[5]; + private final CraftPlayer owner; private boolean playerOnline = false; public SpecialPlayerInventory(Player p, boolean online) { diff --git a/src/main/java/com/lishid/openinv/listeners/OpenInvEntityListener.java b/src/main/java/com/lishid/openinv/listeners/OpenInvEntityListener.java index 4e1ba92..5697cfb 100644 --- a/src/main/java/com/lishid/openinv/listeners/OpenInvEntityListener.java +++ b/src/main/java/com/lishid/openinv/listeners/OpenInvEntityListener.java @@ -41,7 +41,7 @@ public class OpenInvEntityListener implements Listener { Player player = (Player) attacker; - if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem()) || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName())) || !OpenInv.hasPermission(player, "OpenInv.openinv")) { + if (!(player.getItemInHand().getType().getId() == OpenInv.getItemOpenInvItem()) || (!OpenInv.getPlayerItemOpenInvStatus(player.getName())) || !OpenInv.hasPermission(player, "OpenInv.openinv")) { return; } diff --git a/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java b/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java index 97a00e9..b78e606 100644 --- a/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java +++ b/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java @@ -79,7 +79,7 @@ public class OpenInvPlayerListener implements Listener { } if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == org.bukkit.Material.ENDER_CHEST) { - if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.GetPlayerSilentChestStatus(player.getName())) { + if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.getPlayerSilentChestStatus(player.getName())) { event.setCancelled(true); player.openInventory(player.getEnderChest()); } @@ -92,11 +92,11 @@ public class OpenInvPlayerListener implements Listener { int y = event.getClickedBlock().getY(); int z = event.getClickedBlock().getZ(); - if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.GetPlayerSilentChestStatus(player.getName())) { + if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.getPlayerSilentChestStatus(player.getName())) { silentchest = true; } - if (OpenInv.hasPermission(player, Permissions.PERM_ANYCHEST) && OpenInv.GetPlayerAnyChestStatus(player.getName())) { + if (OpenInv.hasPermission(player, Permissions.PERM_ANYCHEST) && OpenInv.getPlayerAnyChestStatus(player.getName())) { try { anychest = OpenInv.anySilentChest.IsAnyChestNeeded(player, x, y, z); } @@ -129,7 +129,7 @@ public class OpenInvPlayerListener implements Listener { } if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) { - if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem()) || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName())) || !OpenInv.hasPermission(player, Permissions.PERM_OPENINV)) { + if (!(player.getItemInHand().getType().getId() == OpenInv.getItemOpenInvItem()) || (!OpenInv.getPlayerItemOpenInvStatus(player.getName())) || !OpenInv.hasPermission(player, Permissions.PERM_OPENINV)) { return; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 067a298..4cd5127 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: OpenInv main: com.lishid.openinv.OpenInv -version: 2.2.9 +version: 2.3.0 author: lishid description: > This plugin allows you to open a player's inventory as a chest and interact with it in real time.