mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-22 16:05:03 +00:00
Merge pull request #26 from ShadowRanger/master
General refactoring + minor changes
This commit is contained in:
commit
f260ed1175
16 changed files with 50 additions and 49 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,4 +7,3 @@
|
|||
/bin
|
||||
/lib
|
||||
/out
|
||||
*.iml
|
||||
|
|
2
pom.xml
2
pom.xml
|
@ -4,7 +4,7 @@
|
|||
<groupId>com.lishid</groupId>
|
||||
<artifactId>openinv</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>2.2.9</version>
|
||||
<version>2.3.0</version>
|
||||
<name>OpenInv</name>
|
||||
<url>http://dev.bukkit.org/bukkit-plugins/openinv/</url>
|
||||
|
||||
|
|
|
@ -89,49 +89,49 @@ public class OpenInv extends JavaPlugin {
|
|||
getCommand("openender").setExecutor(new OpenEnderPluginCommand(this));
|
||||
}
|
||||
|
||||
public static boolean NotifySilentChest() {
|
||||
public static boolean notifySilentChest() {
|
||||
return mainPlugin.getConfig().getBoolean("NotifySilentChest", true);
|
||||
}
|
||||
|
||||
public static boolean NotifyAnyChest() {
|
||||
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 <Player> - Open a player's inventory");
|
||||
player.sendMessage(ChatColor.GREEN + " (aliases: oi, inv, open)");
|
||||
player.sendMessage(ChatColor.GREEN + "/openender <Player> - Open a player's enderchest");
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -49,12 +49,12 @@ public class OpenEnderPluginCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
if (!OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST)) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to access player enderchests.");
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission to access player ender chests.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
|
||||
OpenInv.ShowHelp((Player) sender);
|
||||
OpenInv.showHelp((Player) sender);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -129,13 +129,13 @@ public class OpenEnderPluginCommand implements CommandExecutor {
|
|||
}
|
||||
|
||||
if (target != player && !OpenInv.hasPermission(player, Permissions.PERM_ENDERCHEST_ALL)) {
|
||||
player.sendMessage(ChatColor.RED + "You do not have permission to access other player's enderchest");
|
||||
player.sendMessage(ChatColor.RED + "You do not have permission to access other player's ender chests");
|
||||
return;
|
||||
}
|
||||
|
||||
// Permissions checks
|
||||
if (!OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE) && OpenInv.hasPermission(target, Permissions.PERM_EXEMPT)) {
|
||||
player.sendMessage(ChatColor.RED + target.getDisplayName() + "'s enderchest is protected!");
|
||||
player.sendMessage(ChatColor.RED + target.getDisplayName() + "'s ender chest is protected!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ public enum EnumDirectionList implements Iterable<EnumDirection> {
|
|||
HORIZONTAL(EnumDirectionLimit.HORIZONTAL),
|
||||
VERTICAL(EnumDirectionLimit.VERTICAL);
|
||||
|
||||
private EnumDirectionLimit list;
|
||||
private final EnumDirectionLimit list;
|
||||
|
||||
private EnumDirectionList(EnumDirectionLimit list) {
|
||||
this.list = list;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue