diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..c5084d4
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,62 @@
+
+ 4.0.0
+ com.lishid
+ openinv
+ jar
+ 2.2.9
+ OpenInv
+ http://dev.bukkit.org/bukkit-plugins/openinv/
+
+
+ UTF-8
+
+
+
+
+ bukkit-repo
+ https://hub.spigotmc.org/nexus/content/groups/public/
+
+
+
+
+
+ org.bukkit
+ bukkit
+ 1.8.7-R0.1-SNAPSHOT
+ provided
+
+
+
+ org.bukkit
+ craftbukkit
+ 1.8.7-R0.1-SNAPSHOT
+ provided
+
+
+
+
+ clean install
+ src/main/java
+
+
+ src/main/resources
+ true
+
+ **/*.java
+
+
+
+
+
+
+ maven-compiler-plugin
+ 2.3.2
+
+ 1.6
+ 1.6
+
+
+
+
+
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/OpenInv.java b/src/main/java/com/lishid/openinv/OpenInv.java
index 3c76149..fbae1bc 100644
--- a/src/main/java/com/lishid/openinv/OpenInv.java
+++ b/src/main/java/com/lishid/openinv/OpenInv.java
@@ -18,6 +18,7 @@ package com.lishid.openinv;
import java.util.HashMap;
import java.util.Map;
+import java.util.UUID;
import java.util.logging.Logger;
import org.bukkit.ChatColor;
@@ -28,12 +29,14 @@ import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import com.lishid.openinv.commands.*;
-import com.lishid.openinv.internal.IAnySilentChest;
-import com.lishid.openinv.internal.IInventoryAccess;
-import com.lishid.openinv.internal.IPlayerDataManager;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-import com.lishid.openinv.internal.InternalAccessor;
+import com.lishid.openinv.internal.AnySilentChest;
+import com.lishid.openinv.internal.InventoryAccess;
+import com.lishid.openinv.internal.PlayerDataManager;
+import com.lishid.openinv.internal.SpecialEnderChest;
+import com.lishid.openinv.internal.SpecialPlayerInventory;
+import com.lishid.openinv.listeners.OpenInvEntityListener;
+import com.lishid.openinv.listeners.OpenInvInventoryListener;
+import com.lishid.openinv.listeners.OpenInvPlayerListener;
/**
* Open other player's inventory
@@ -43,32 +46,23 @@ import com.lishid.openinv.internal.InternalAccessor;
public class OpenInv extends JavaPlugin {
public static final Logger logger = Logger.getLogger("Minecraft.OpenInv");
- public static Map inventories = new HashMap();
- public static Map enderChests = new HashMap();
+ public static final Map inventories = new HashMap();
+ public static final Map enderChests = new HashMap();
public static OpenInv mainPlugin;
- public static IPlayerDataManager playerLoader;
- public static IInventoryAccess inventoryAccess;
- public static IAnySilentChest anySilentChest;
+ public static PlayerDataManager playerLoader;
+ public static InventoryAccess inventoryAccess;
+ public static AnySilentChest anySilentChest;
+ @Override
public void onEnable() {
// Get plugin manager
PluginManager pm = getServer().getPluginManager();
- // Version check
- boolean success = InternalAccessor.Initialize(this.getServer());
-
- if (!success) {
- OpenInv.log("Your version of CraftBukkit is not supported.");
- OpenInv.log("Please look for an updated version of OpenInv.");
- pm.disablePlugin(this);
- return;
- }
-
- playerLoader = InternalAccessor.Instance.newPlayerDataManager();
- inventoryAccess = InternalAccessor.Instance.newInventoryAccess();
- anySilentChest = InternalAccessor.Instance.newAnySilentChest();
+ playerLoader = new PlayerDataManager();
+ inventoryAccess = new InventoryAccess();
+ anySilentChest = new AnySilentChest();
mainPlugin = this;
FileConfiguration config = getConfig();
@@ -90,8 +84,8 @@ public class OpenInv extends JavaPlugin {
getCommand("openinv").setExecutor(new OpenInvPluginCommand(this));
getCommand("searchinv").setExecutor(new SearchInvPluginCommand());
getCommand("toggleopeninv").setExecutor(new ToggleOpenInvPluginCommand());
- getCommand("silentchest").setExecutor(new SilentChestPluginCommand(this));
- getCommand("anychest").setExecutor(new AnyChestPluginCommand(this));
+ getCommand("silentchest").setExecutor(new SilentChestPluginCommand());
+ getCommand("anychest").setExecutor(new AnyChestPluginCommand());
getCommand("openender").setExecutor(new OpenEnderPluginCommand(this));
}
@@ -195,4 +189,4 @@ public class OpenInv extends JavaPlugin {
}
return player.hasPermission(permission);
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/lishid/openinv/commands/AnyChestPluginCommand.java b/src/main/java/com/lishid/openinv/commands/AnyChestPluginCommand.java
index 03c80cb..8de71ae 100644
--- a/src/main/java/com/lishid/openinv/commands/AnyChestPluginCommand.java
+++ b/src/main/java/com/lishid/openinv/commands/AnyChestPluginCommand.java
@@ -26,32 +26,33 @@ import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
public class AnyChestPluginCommand implements CommandExecutor {
- public AnyChestPluginCommand(OpenInv plugin) {
-
- }
-
+ @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
- return true;
- }
- if (!OpenInv.hasPermission(sender, Permissions.PERM_ANYCHEST)) {
- sender.sendMessage(ChatColor.RED + "You do not have permission to use anychest.");
- return true;
- }
-
- if (args.length > 0) {
- if (args[0].equalsIgnoreCase("check")) {
- if (OpenInv.GetPlayerAnyChestStatus(sender.getName()))
- sender.sendMessage("AnyChest is ON.");
- else
- sender.sendMessage("AnyChest is OFF.");
+ if (command.getName().equalsIgnoreCase("anychest")) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
+ return true;
}
+ if (!OpenInv.hasPermission(sender, Permissions.PERM_ANYCHEST)) {
+ sender.sendMessage(ChatColor.RED + "You do not have permission to use anychest.");
+ return true;
+ }
+
+ if (args.length > 0) {
+ if (args[0].equalsIgnoreCase("check")) {
+ 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") + ".");
+
+ return true;
}
- OpenInv.SetPlayerAnyChestStatus(sender.getName(), !OpenInv.GetPlayerAnyChestStatus(sender.getName()));
- sender.sendMessage("AnyChest is now " + (OpenInv.GetPlayerAnyChestStatus(sender.getName()) ? "On" : "Off") + ".");
-
- return true;
+ return false;
}
}
diff --git a/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java b/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java
index 82c492a..5a05087 100644
--- a/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java
+++ b/src/main/java/com/lishid/openinv/commands/OpenEnderPluginCommand.java
@@ -17,6 +17,7 @@
package com.lishid.openinv.commands;
import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
@@ -28,88 +29,93 @@ import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-import com.lishid.openinv.internal.InternalAccessor;
+import com.lishid.openinv.internal.SpecialEnderChest;
+import com.lishid.openinv.utils.UUIDUtil;
public class OpenEnderPluginCommand implements CommandExecutor {
private final OpenInv plugin;
- public static Map openEnderHistory = new ConcurrentHashMap();
+ public static final Map openEnderHistory = new ConcurrentHashMap();
public OpenEnderPluginCommand(OpenInv plugin) {
this.plugin = plugin;
}
+ @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
- return true;
- }
-
- if (!OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST)) {
- sender.sendMessage(ChatColor.RED + "You do not have permission to access player enderchest");
- return true;
- }
-
- if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
- OpenInv.ShowHelp((Player) sender);
- return true;
- }
-
- Player player = (Player) sender;
-
- // History management
- String history = openEnderHistory.get(player);
-
- if (history == null || history == "") {
- history = player.getName();
- openEnderHistory.put(player, history);
- }
-
- final String name;
-
- // Read from history if target is not named
- if (args.length < 1) {
- if (history != null && history != "") {
- name = history;
- }
- else {
- sender.sendMessage(ChatColor.RED + "OpenEnder history is empty!");
+ if (command.getName().equalsIgnoreCase("openender")) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
return true;
}
- }
- else {
- name = args[0];
- }
- final String playername = player.getName();
- Player target = plugin.getServer().getPlayer(name);
- // Targeted player was not found online, start asynchron lookup in files
- if (target == null) {
- sender.sendMessage(ChatColor.GREEN + "Starting inventory lookup.");
- plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
- @Override
- public void run() {
- // Try loading the player's data asynchronly
- final Player target = OpenInv.playerLoader.loadPlayer(name);
- // Back to synchron to send messages and display inventory
- Bukkit.getScheduler().runTask(plugin, new Runnable() {
- @Override
- public void run() {
- Player player = Bukkit.getPlayer(playername);
- // If sender is no longer online after loading the target. Abort!
- if (player == null) {
- return;
- }
- openInventory(player, target);
- }
- });
+ if (!OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST)) {
+ sender.sendMessage(ChatColor.RED + "You do not have permission to access player enderchest");
+ return true;
+ }
+
+ if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
+ OpenInv.ShowHelp((Player) sender);
+ return true;
+ }
+
+ Player player = (Player) sender;
+
+ // History management
+ UUID history = openEnderHistory.get(player.getUniqueId());
+
+ if (history == null) {
+ history = player.getUniqueId();
+ openEnderHistory.put(player.getUniqueId(), history);
+ }
+
+ final UUID uuid;
+
+ // Read from history if target is not named
+ if (args.length < 1) {
+ if (history != null) {
+ uuid = history;
}
- });
- } else {
- openInventory(player, target);
+ else {
+ sender.sendMessage(ChatColor.RED + "OpenEnder history is empty!");
+ return true;
+ }
+ }
+ else {
+ uuid = UUIDUtil.getUUIDOf(args[0]);
+ }
+
+ final UUID playerUUID = player.getUniqueId();
+ Player target = Bukkit.getPlayer(uuid);
+ // Targeted player was not found online, start asynchron lookup in files
+ if (target == null) {
+ sender.sendMessage(ChatColor.GREEN + "Starting inventory lookup.");
+ plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
+ @Override
+ public void run() {
+ // Try loading the player's data asynchronly
+ final Player target = OpenInv.playerLoader.loadPlayer(uuid);
+ // Back to synchron to send messages and display inventory
+ Bukkit.getScheduler().runTask(plugin, new Runnable() {
+ @Override
+ public void run() {
+ Player player = Bukkit.getPlayer(playerUUID);
+ // If sender is no longer online after loading the target. Abort!
+ if (player == null) {
+ return;
+ }
+ openInventory(player, target);
+ }
+ });
+ }
+ });
+ } else {
+ openInventory(player, target);
+ }
+
+ return true;
}
- return true;
+ return false;
}
private void openInventory(Player player, Player target) {
@@ -136,17 +142,15 @@ public class OpenEnderPluginCommand implements CommandExecutor {
}
// Record the target
- openEnderHistory.put(player, target.getName());
+ openEnderHistory.put(player.getUniqueId(), target.getUniqueId());
// Create the inventory
- ISpecialEnderChest chest = OpenInv.enderChests.get(target.getName().toLowerCase());
+ SpecialEnderChest chest = OpenInv.enderChests.get(target.getUniqueId());
if (chest == null) {
- chest = InternalAccessor.Instance.newSpecialEnderChest(target, target.isOnline());
+ chest = new SpecialEnderChest(target, target.isOnline());
}
// Open the inventory
player.openInventory(chest.getBukkitInventory());
-
- return;
}
}
diff --git a/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java b/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java
index b2bcd88..4ae1f19 100644
--- a/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java
+++ b/src/main/java/com/lishid/openinv/commands/OpenInvPluginCommand.java
@@ -17,6 +17,7 @@
package com.lishid.openinv.commands;
import java.util.Map;
+import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
@@ -28,79 +29,86 @@ import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-import com.lishid.openinv.internal.InternalAccessor;
+import com.lishid.openinv.internal.SpecialPlayerInventory;
+import com.lishid.openinv.utils.UUIDUtil;
public class OpenInvPluginCommand implements CommandExecutor {
private final OpenInv plugin;
- public static Map openInvHistory = new ConcurrentHashMap();
+ public static final Map openInvHistory = new ConcurrentHashMap();
public OpenInvPluginCommand(OpenInv plugin) {
this.plugin = plugin;
}
+ @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
- return true;
- }
- if (!OpenInv.hasPermission(sender, Permissions.PERM_OPENINV)) {
- sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
- return true;
- }
+ if (command.getName().equalsIgnoreCase("openinv")) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
+ return true;
+ }
+ if (!OpenInv.hasPermission(sender, Permissions.PERM_OPENINV)) {
+ sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
+ return true;
+ }
- if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
- OpenInv.ShowHelp((Player) sender);
- return true;
- }
+ if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
+ OpenInv.ShowHelp((Player) sender);
+ return true;
+ }
- Player player = (Player) sender;
+ Player player = (Player) sender;
- // History management
- String history = openInvHistory.get(player);
+ // History management
+ UUID history = openInvHistory.get(player.getUniqueId());
- if (history == null || history == "") {
- history = player.getName();
- openInvHistory.put(player, history);
- }
+ if (history == null) {
+ history = player.getUniqueId();
+ openInvHistory.put(player.getUniqueId(), history);
+ }
- final String name;
+ final UUID uuid;
- // Read from history if target is not named
- if (args.length < 1) {
- name = history;
- } else {
- name = args[0];
- }
+ // Read from history if target is not named
+ if (args.length < 1) {
+ uuid = history;
+ }
+ else {
+ uuid = UUIDUtil.getUUIDOf(args[0]);
+ }
- final String playername = player.getName();
- Player target = plugin.getServer().getPlayer(name);
- // Targeted player was not found online, start asynchron lookup in files
- if (target == null) {
- sender.sendMessage(ChatColor.GREEN + "Starting inventory lookup.");
- plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
- @Override
- public void run() {
- // Try loading the player's data asynchronly
- final Player target = OpenInv.playerLoader.loadPlayer(name);
- // Back to synchron to send messages and display inventory
- Bukkit.getScheduler().runTask(plugin, new Runnable() {
- @Override
- public void run() {
- Player player = Bukkit.getPlayer(playername);
- // If sender is no longer online after loading the target. Abort!
- if (player == null) {
- return;
+ final UUID playerUUID = player.getUniqueId();
+ Player target = Bukkit.getPlayer(uuid);
+ // Targeted player was not found online, start asynchron lookup in files
+ if (target == null) {
+ sender.sendMessage(ChatColor.GREEN + "Starting inventory lookup.");
+ plugin.getServer().getScheduler().runTaskAsynchronously(plugin, new Runnable() {
+ @Override
+ public void run() {
+ // Try loading the player's data asynchronly
+ final Player target = OpenInv.playerLoader.loadPlayer(uuid);
+ // Back to synchron to send messages and display inventory
+ Bukkit.getScheduler().runTask(plugin, new Runnable() {
+ @Override
+ public void run() {
+ Player player = Bukkit.getPlayer(playerUUID);
+ // If sender is no longer online after loading the target. Abort!
+ if (player == null) {
+ return;
+ }
+ openInventory(player, target);
}
- openInventory(player, target);
- }
- });
- }
- });
- } else {
- openInventory(player, target);
+ });
+ }
+ });
+ } else {
+ openInventory(player, target);
+ }
+
+ return true;
}
- return true;
+
+ return false;
}
private void openInventory(Player player, Player target) {
@@ -128,17 +136,15 @@ public class OpenInvPluginCommand implements CommandExecutor {
}
// Record the target
- openInvHistory.put(player, target.getName());
+ openInvHistory.put(player.getUniqueId(), target.getUniqueId());
// Create the inventory
- ISpecialPlayerInventory inv = OpenInv.inventories.get(target.getName().toLowerCase());
+ SpecialPlayerInventory inv = OpenInv.inventories.get(target.getUniqueId());
if (inv == null) {
- inv = InternalAccessor.Instance.newSpecialPlayerInventory(target, target.isOnline());
+ inv = new SpecialPlayerInventory(target, target.isOnline());
}
// Open the inventory
player.openInventory(inv.getBukkitInventory());
-
- return;
}
}
diff --git a/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java b/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java
index 0e75a08..968e1ab 100644
--- a/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java
+++ b/src/main/java/com/lishid/openinv/commands/SearchInvPluginCommand.java
@@ -28,50 +28,52 @@ import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
public class SearchInvPluginCommand implements CommandExecutor {
- public SearchInvPluginCommand() {
-
- }
-
+ @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (sender instanceof Player) {
- if (!OpenInv.hasPermission(sender, Permissions.PERM_SEARCH)) {
- sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
- return true;
+ if (command.getName().equalsIgnoreCase("searchinv")) {
+ if (sender instanceof Player) {
+ if (!OpenInv.hasPermission(sender, Permissions.PERM_SEARCH)) {
+ sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
+ return true;
+ }
}
- }
- String PlayerList = "";
+ String playerList = "";
- Material material = null;
- int count = 1;
+ Material material = null;
+ int count = 1;
- if (args.length >= 1) {
- String[] gData = null;
- gData = args[0].split(":");
- material = Material.matchMaterial(gData[0]);
- }
- if (args.length >= 2) {
- try {
- count = Integer.parseInt(args[1]);
+ if (args.length >= 1) {
+ String[] gData = null;
+ gData = args[0].split(":");
+ material = Material.matchMaterial(gData[0]);
}
- catch (NumberFormatException ex) {
- sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number!");
+ if (args.length >= 2) {
+ try {
+ count = Integer.parseInt(args[1]);
+ }
+ catch (NumberFormatException ex) {
+ sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number!");
+ return false;
+ }
+ }
+
+ if (material == null) {
+ sender.sendMessage(ChatColor.RED + "Unknown item");
return false;
}
- }
- if (material == null) {
- sender.sendMessage(ChatColor.RED + "Unknown item");
- return false;
- }
-
- for (Player templayer : Bukkit.getServer().getOnlinePlayers()) {
- if (templayer.getInventory().contains(material, count)) {
- PlayerList += templayer.getName() + " ";
+ for (Player templayer : Bukkit.getServer().getOnlinePlayers()) {
+ if (templayer.getInventory().contains(material, count)) {
+ playerList += templayer.getName() + " ";
+ }
}
+
+ sender.sendMessage("Players with the item " + material.toString() + ": " + playerList);
+
+ return true;
}
- sender.sendMessage("Players with the item " + material.toString() + ": " + PlayerList);
- return true;
+ return false;
}
}
diff --git a/src/main/java/com/lishid/openinv/commands/SilentChestPluginCommand.java b/src/main/java/com/lishid/openinv/commands/SilentChestPluginCommand.java
index 4dfbb7f..f698431 100644
--- a/src/main/java/com/lishid/openinv/commands/SilentChestPluginCommand.java
+++ b/src/main/java/com/lishid/openinv/commands/SilentChestPluginCommand.java
@@ -26,32 +26,33 @@ import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
public class SilentChestPluginCommand implements CommandExecutor {
- public SilentChestPluginCommand(OpenInv plugin) {
-
- }
-
+ @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
- return true;
- }
- if (!OpenInv.hasPermission(sender, Permissions.PERM_SILENT)) {
- sender.sendMessage(ChatColor.RED + "You do not have permission to use silent chest.");
- return true;
- }
-
- if (args.length > 0) {
- if (args[0].equalsIgnoreCase("check")) {
- if (OpenInv.GetPlayerSilentChestStatus(sender.getName()))
- sender.sendMessage("SilentChest is ON.");
- else
- sender.sendMessage("SilentChest is OFF.");
+ if (command.getName().equalsIgnoreCase("silentchest")) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
+ return true;
}
+ if (!OpenInv.hasPermission(sender, Permissions.PERM_SILENT)) {
+ sender.sendMessage(ChatColor.RED + "You do not have permission to use silent chest.");
+ return true;
+ }
+
+ if (args.length > 0) {
+ if (args[0].equalsIgnoreCase("check")) {
+ 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") + ".");
+
+ return true;
}
- OpenInv.SetPlayerSilentChestStatus(sender.getName(), !OpenInv.GetPlayerSilentChestStatus(sender.getName()));
- sender.sendMessage("SilentChest is now " + (OpenInv.GetPlayerSilentChestStatus(sender.getName()) ? "On" : "Off") + ".");
-
- return true;
+ return false;
}
}
diff --git a/src/main/java/com/lishid/openinv/commands/ToggleOpenInvPluginCommand.java b/src/main/java/com/lishid/openinv/commands/ToggleOpenInvPluginCommand.java
index 005239f..0ba0fb7 100644
--- a/src/main/java/com/lishid/openinv/commands/ToggleOpenInvPluginCommand.java
+++ b/src/main/java/com/lishid/openinv/commands/ToggleOpenInvPluginCommand.java
@@ -26,35 +26,40 @@ import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
+@SuppressWarnings("deprecation")
public class ToggleOpenInvPluginCommand implements CommandExecutor {
-
+ @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
- if (!(sender instanceof Player)) {
- sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
- return true;
- }
- if (!OpenInv.hasPermission(sender, Permissions.PERM_OPENINV)) {
- sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
+ if (command.getName().equalsIgnoreCase("toggleopeninv")) {
+ if (!(sender instanceof Player)) {
+ sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
+ return true;
+ }
+ if (!OpenInv.hasPermission(sender, Permissions.PERM_OPENINV)) {
+ sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
+ return true;
+ }
+
+ 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.");
+ else
+ 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.");
+ }
return true;
}
- 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.");
- else
- 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.");
- }
- return true;
+ return false;
}
}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/AnySilentChest.java
similarity index 97%
rename from src/main/java/com/lishid/openinv/internal/v1_8_R3/AnySilentChest.java
rename to src/main/java/com/lishid/openinv/internal/AnySilentChest.java
index 56a2f33..47b6421 100644
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/AnySilentChest.java
+++ b/src/main/java/com/lishid/openinv/internal/AnySilentChest.java
@@ -14,22 +14,20 @@
* along with this program. If not, see .
*/
-package com.lishid.openinv.internal.v1_8_R3;
+package com.lishid.openinv.internal;
import java.util.Iterator;
import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
//Volatile
import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.*;
-public class AnySilentChest implements IAnySilentChest {
+public class AnySilentChest {
public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
// FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
BlockPosition position = new BlockPosition(x, y, z);
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/EnumDirectionList.java b/src/main/java/com/lishid/openinv/internal/EnumDirectionList.java
similarity index 92%
rename from src/main/java/com/lishid/openinv/internal/v1_8_R3/EnumDirectionList.java
rename to src/main/java/com/lishid/openinv/internal/EnumDirectionList.java
index 3c18e98..7ee4c7f 100644
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/EnumDirectionList.java
+++ b/src/main/java/com/lishid/openinv/internal/EnumDirectionList.java
@@ -1,11 +1,12 @@
-package com.lishid.openinv.internal.v1_8_R3;
-
-import com.google.common.collect.Iterators;
-import net.minecraft.server.v1_8_R3.EnumDirection;
-import net.minecraft.server.v1_8_R3.EnumDirection.EnumDirectionLimit;
+package com.lishid.openinv.internal;
import java.util.Iterator;
+import com.google.common.collect.Iterators;
+
+import net.minecraft.server.v1_8_R3.EnumDirection;
+import net.minecraft.server.v1_8_R3.EnumDirection.EnumDirectionLimit;
+
public enum EnumDirectionList implements Iterable {
HORIZONTAL(EnumDirectionLimit.HORIZONTAL),
VERTICAL(EnumDirectionLimit.VERTICAL);
@@ -20,5 +21,4 @@ public enum EnumDirectionList implements Iterable {
public Iterator iterator() {
return Iterators.forArray(list.a());
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/lishid/openinv/internal/IAnySilentChest.java b/src/main/java/com/lishid/openinv/internal/IAnySilentChest.java
deleted file mode 100644
index 7177763..0000000
--- a/src/main/java/com/lishid/openinv/internal/IAnySilentChest.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal;
-
-import org.bukkit.entity.Player;
-
-public interface IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z);
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z);
-}
diff --git a/src/main/java/com/lishid/openinv/internal/IInventoryAccess.java b/src/main/java/com/lishid/openinv/internal/IInventoryAccess.java
deleted file mode 100644
index f49c168..0000000
--- a/src/main/java/com/lishid/openinv/internal/IInventoryAccess.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-public interface IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player);
-}
diff --git a/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java
deleted file mode 100644
index ce0ed2f..0000000
--- a/src/main/java/com/lishid/openinv/internal/IPlayerDataManager.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal;
-
-import org.bukkit.entity.Player;
-
-public interface IPlayerDataManager {
- public Player loadPlayer(String name);
-}
diff --git a/src/main/java/com/lishid/openinv/internal/ISpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/ISpecialEnderChest.java
deleted file mode 100644
index 5c2d03c..0000000
--- a/src/main/java/com/lishid/openinv/internal/ISpecialEnderChest.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-public interface ISpecialEnderChest {
- public Inventory getBukkitInventory();
-
- public void playerOnline(Player p);
-
- public void playerOffline();
-
-}
diff --git a/src/main/java/com/lishid/openinv/internal/ISpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/ISpecialPlayerInventory.java
deleted file mode 100644
index a613721..0000000
--- a/src/main/java/com/lishid/openinv/internal/ISpecialPlayerInventory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-public interface ISpecialPlayerInventory {
- public Inventory getBukkitInventory();
-
- public void playerOnline(Player p);
-
- public void playerOffline();
-}
diff --git a/src/main/java/com/lishid/openinv/internal/InternalAccessor.java b/src/main/java/com/lishid/openinv/internal/InternalAccessor.java
deleted file mode 100644
index b8b406c..0000000
--- a/src/main/java/com/lishid/openinv/internal/InternalAccessor.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal;
-
-import org.bukkit.Server;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-
-public class InternalAccessor {
- public static InternalAccessor Instance;
- private String version;
-
- /*
- * Returns false if version not supported
- */
- public static boolean Initialize(Server server) {
- Instance = new InternalAccessor();
- String packageName = server.getClass().getPackage().getName();
- Instance.version = packageName.substring(packageName.lastIndexOf('.') + 1);
-
- try {
- Class.forName("com.lishid.openinv.internal." + Instance.version + ".AnySilentChest");
- return true;
- }
- catch (Exception e) {
- return false;
- }
- }
-
- public void PrintError() {
- OpenInv.log("OpenInv encountered an error with the CraftBukkit version \"" + Instance.version + "\". Please look for an updated version of OpenInv.");
- }
-
- public IPlayerDataManager newPlayerDataManager() {
- return (IPlayerDataManager) createObject(IPlayerDataManager.class, "PlayerDataManager");
- }
-
- public IInventoryAccess newInventoryAccess() {
- return (IInventoryAccess) createObject(IInventoryAccess.class, "InventoryAccess");
- }
-
- public IAnySilentChest newAnySilentChest() {
- return (IAnySilentChest) createObject(IAnySilentChest.class, "AnySilentChest");
- }
-
- public ISpecialPlayerInventory newSpecialPlayerInventory(Player player, boolean offline) {
- try {
- Class> internalClass = Class.forName("com.lishid.openinv.internal." + version + ".SpecialPlayerInventory");
- if (ISpecialPlayerInventory.class.isAssignableFrom(internalClass)) {
- return (ISpecialPlayerInventory) internalClass.getConstructor(Player.class, Boolean.class).newInstance(player, offline);
- }
- }
- catch (Exception e) {
- PrintError();
- OpenInv.log(e);
- }
-
- return null;
- }
-
- public ISpecialEnderChest newSpecialEnderChest(Player player, boolean offline) {
- try {
- Class> internalClass = Class.forName("com.lishid.openinv.internal." + version + ".SpecialEnderChest");
- if (ISpecialEnderChest.class.isAssignableFrom(internalClass)) {
- return (ISpecialEnderChest) internalClass.getConstructor(Player.class, Boolean.class).newInstance(player, offline);
- }
- }
- catch (Exception e) {
- PrintError();
- OpenInv.log(e);
- }
-
- return null;
- }
-
- private Object createObject(Class extends Object> assignableClass, String className) {
- try {
- Class> internalClass = Class.forName("com.lishid.openinv.internal." + version + "." + className);
- if (assignableClass.isAssignableFrom(internalClass)) {
- return internalClass.getConstructor().newInstance();
- }
- }
- catch (Exception e) {
- PrintError();
- OpenInv.log(e);
- }
-
- return null;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/InventoryAccess.java
similarity index 93%
rename from src/main/java/com/lishid/openinv/internal/v1_8_R3/InventoryAccess.java
rename to src/main/java/com/lishid/openinv/internal/InventoryAccess.java
index 86a85d3..97931f4 100644
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/InventoryAccess.java
+++ b/src/main/java/com/lishid/openinv/internal/InventoryAccess.java
@@ -14,23 +14,22 @@
* along with this program. If not, see .
*/
-package com.lishid.openinv.internal.v1_8_R3;
+package com.lishid.openinv.internal;
import java.lang.reflect.Field;
-
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.Inventory;
import com.lishid.openinv.OpenInv;
import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
//Volatile
import net.minecraft.server.v1_8_R3.*;
+
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
-public class InventoryAccess implements IInventoryAccess {
+public class InventoryAccess {
public boolean check(Inventory inventory, HumanEntity player) {
IInventory inv = grabInventory(inventory);
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/PlayerDataManager.java
similarity index 55%
rename from src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java
rename to src/main/java/com/lishid/openinv/internal/PlayerDataManager.java
index 2a0b2b2..d0ee87e 100644
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/PlayerDataManager.java
+++ b/src/main/java/com/lishid/openinv/internal/PlayerDataManager.java
@@ -14,7 +14,7 @@
* along with this program. If not, see .
*/
-package com.lishid.openinv.internal.v1_8_R3;
+package com.lishid.openinv.internal;
import java.util.UUID;
@@ -23,7 +23,6 @@ import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
import com.mojang.authlib.GameProfile;
//Volatile
@@ -31,14 +30,9 @@ import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.*;
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
+public class PlayerDataManager {
+ public Player loadPlayer(UUID uuid) {
try {
- UUID uuid = matchUser(name);
- if (uuid == null) {
- return null;
- }
-
OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
if (player == null) {
return null;
@@ -63,39 +57,4 @@ public class PlayerDataManager implements IPlayerDataManager {
return null;
}
-
- private static UUID matchUser(String search) {
- OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(search);
- if (offlinePlayer != null && offlinePlayer.hasPlayedBefore()) {
- return offlinePlayer.getUniqueId();
- }
- UUID found = null;
-
- String lowerSearch = search.toLowerCase();
- int delta = 2147483647;
-
- OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
- for (OfflinePlayer player : offlinePlayers) {
- String name = player.getName();
-
- if (name == null){
- continue;
- }
- if (name.equalsIgnoreCase(search)){
- return player.getUniqueId();
- }
- if (name.toLowerCase().startsWith(lowerSearch)) {
- int curDelta = name.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = player.getUniqueId();
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
- }
- }
-
- return found;
- }
}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/SilentContainerChest.java
similarity index 95%
rename from src/main/java/com/lishid/openinv/internal/v1_8_R3/SilentContainerChest.java
rename to src/main/java/com/lishid/openinv/internal/SilentContainerChest.java
index 4352ef1..bc923e0 100644
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SilentContainerChest.java
+++ b/src/main/java/com/lishid/openinv/internal/SilentContainerChest.java
@@ -14,12 +14,11 @@
* along with this program. If not, see .
*/
-package com.lishid.openinv.internal.v1_8_R3;
+package com.lishid.openinv.internal;
//Volatile
import net.minecraft.server.v1_8_R3.*;
-
public class SilentContainerChest extends ContainerChest {
public IInventory inv;
@@ -34,4 +33,4 @@ public class SilentContainerChest extends ContainerChest {
public void b(EntityHuman paramEntityHuman) {
// Don't send close signal twice, might screw up
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SilentInventory.java b/src/main/java/com/lishid/openinv/internal/SilentInventory.java
similarity index 97%
rename from src/main/java/com/lishid/openinv/internal/v1_8_R3/SilentInventory.java
rename to src/main/java/com/lishid/openinv/internal/SilentInventory.java
index 65f93fa..3061142 100644
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SilentInventory.java
+++ b/src/main/java/com/lishid/openinv/internal/SilentInventory.java
@@ -1,11 +1,13 @@
-package com.lishid.openinv.internal.v1_8_R3;
+package com.lishid.openinv.internal;
+
+import java.util.List;
-import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftHumanEntity;
import org.bukkit.entity.HumanEntity;
import org.bukkit.inventory.InventoryHolder;
-import java.util.List;
+//Volatile
+import net.minecraft.server.v1_8_R3.*;
public class SilentInventory implements ITileInventory {
public ITileInventory inv;
@@ -109,12 +111,10 @@ 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);
}
@@ -159,4 +159,4 @@ public class SilentInventory implements ITileInventory {
public String getContainerName() {
return inv.getContainerName();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java
similarity index 88%
rename from src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialEnderChest.java
rename to src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java
index e5c9137..75f4d95 100644
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialEnderChest.java
+++ b/src/main/java/com/lishid/openinv/internal/SpecialEnderChest.java
@@ -14,21 +14,20 @@
* along with this program. If not, see .
*/
-package com.lishid.openinv.internal.v1_8_R3;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
+package com.lishid.openinv.internal;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
+import com.lishid.openinv.OpenInv;
+
//Volatile
import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.*;
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
-public class SpecialEnderChest extends InventorySubcontainer implements ISpecialEnderChest {
+public class SpecialEnderChest extends InventorySubcontainer {
private CraftInventory inventory = new CraftInventory(this);
private InventoryEnderChest enderChest;
private CraftPlayer owner;
@@ -44,13 +43,13 @@ public class SpecialEnderChest extends InventorySubcontainer implements ISpecial
this.enderChest = enderchest;
this.items = enderChest.getContents();
this.playerOnline = online;
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
+ OpenInv.enderChests.put(owner.getUniqueId(), this);
}
private void saveOnExit() {
if (transaction.isEmpty() && !playerOnline) {
owner.saveData();
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
+ OpenInv.enderChests.remove(owner.getUniqueId());
}
}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java
similarity index 94%
rename from src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java
rename to src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java
index 09f4cba..48cdcdd 100644
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R3/SpecialPlayerInventory.java
+++ b/src/main/java/com/lishid/openinv/internal/SpecialPlayerInventory.java
@@ -14,21 +14,19 @@
* along with this program. If not, see .
*/
-package com.lishid.openinv.internal.v1_8_R3;
+package com.lishid.openinv.internal;
import org.bukkit.entity.Player;
-
import org.bukkit.inventory.Inventory;
import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
//Volatile
import net.minecraft.server.v1_8_R3.*;
import org.bukkit.craftbukkit.v1_8_R3.entity.*;
import org.bukkit.craftbukkit.v1_8_R3.inventory.*;
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
+public class SpecialPlayerInventory extends PlayerInventory {
private CraftInventory inventory = new CraftInventory(this);
private ItemStack[] extra = new ItemStack[5];
private CraftPlayer owner;
@@ -40,7 +38,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
this.items = player.inventory.items;
this.armor = player.inventory.armor;
this.playerOnline = online;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
+ OpenInv.inventories.put(owner.getUniqueId(), this);
}
public Inventory getBukkitInventory() {
@@ -50,7 +48,7 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
private void saveOnExit() {
if (transaction.isEmpty() && !playerOnline) {
owner.saveData();
- OpenInv.inventories.remove(owner.getName().toLowerCase());
+ OpenInv.inventories.remove(owner.getUniqueId());
}
}
@@ -250,4 +248,4 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
super.update();
player.inventory.update();
}
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/lishid/openinv/internal/craftbukkit/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/craftbukkit/AnySilentChest.java
deleted file mode 100644
index df0b089..0000000
--- a/src/main/java/com/lishid/openinv/internal/craftbukkit/AnySilentChest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.craftbukkit;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.*;
-
-import org.bukkit.craftbukkit.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.s(x, y + 1, z))
- return true;
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.s(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.s(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.s(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.s(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- if (!anychest) {
- if (world.s(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.s(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.s(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.s(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.s(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int id = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- id = windowID.getInt(player);
- id = id % 100 + 1;
- windowID.setInt(player, id);
- }
- catch (NoSuchFieldException e) {}
-
- player.netServerHandler.sendPacket(new Packet100OpenWindow(id, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize()));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = id;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/craftbukkit/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/craftbukkit/InventoryAccess.java
deleted file mode 100644
index 3ac3352..0000000
--- a/src/main/java/com/lishid/openinv/internal/craftbukkit/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.craftbukkit;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.*;
-import org.bukkit.craftbukkit.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/craftbukkit/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/craftbukkit/PlayerDataManager.java
deleted file mode 100644
index 6a67c37..0000000
--- a/src/main/java/com/lishid/openinv/internal/craftbukkit/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.craftbukkit;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.*;
-import org.bukkit.craftbukkit.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new ItemInWorldManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/craftbukkit/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/craftbukkit/SilentContainerChest.java
deleted file mode 100644
index a5128f0..0000000
--- a/src/main/java/com/lishid/openinv/internal/craftbukkit/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.craftbukkit;
-
-//Volatile
-import net.minecraft.server.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.f();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/craftbukkit/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/craftbukkit/SpecialEnderChest.java
deleted file mode 100644
index 2d45c2e..0000000
--- a/src/main/java/com/lishid/openinv/internal/craftbukkit/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.craftbukkit;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.*;
-import org.bukkit.craftbukkit.entity.*;
-import org.bukkit.craftbukkit.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/craftbukkit/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/craftbukkit/SpecialPlayerInventory.java
deleted file mode 100644
index 680c695..0000000
--- a/src/main/java/com/lishid/openinv/internal/craftbukkit/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.craftbukkit;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.*;
-import org.bukkit.craftbukkit.entity.*;
-import org.bukkit.craftbukkit.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.name.length() > 16) {
- return player.name.substring(0, 16);
- }
- return player.name;
- }
-
- @Override
- public boolean a_(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/AnySilentChest.java
deleted file mode 100644
index 50d6921..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_5/AnySilentChest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_5;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_4_5.*;
-
-import org.bukkit.craftbukkit.v1_4_5.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.s(x, y + 1, z))
- return true;
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.s(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.s(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.s(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.s(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- if (!anychest) {
- if (world.s(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.s(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.s(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.s(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.s(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int id = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- id = windowID.getInt(player);
- id = id % 100 + 1;
- windowID.setInt(player, id);
- }
- catch (NoSuchFieldException e) {}
-
- player.netServerHandler.sendPacket(new Packet100OpenWindow(id, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize()));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = id;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/InventoryAccess.java
deleted file mode 100644
index b4f6d7e..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_5/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_5;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_4_5.*;
-import org.bukkit.craftbukkit.v1_4_5.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java
deleted file mode 100644
index 9138717..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_5/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_5;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.v1_4_5.*;
-import org.bukkit.craftbukkit.v1_4_5.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new ItemInWorldManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/SilentContainerChest.java
deleted file mode 100644
index 9663096..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_5/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_5;
-
-//Volatile
-import net.minecraft.server.v1_4_5.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.f();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialEnderChest.java
deleted file mode 100644
index 74a51f9..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_5;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_4_5.*;
-import org.bukkit.craftbukkit.v1_4_5.entity.*;
-import org.bukkit.craftbukkit.v1_4_5.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java
deleted file mode 100644
index e1029fa..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_5/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_5;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_4_5.*;
-import org.bukkit.craftbukkit.v1_4_5.entity.*;
-import org.bukkit.craftbukkit.v1_4_5.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.name.length() > 16) {
- return player.name.substring(0, 16);
- }
- return player.name;
- }
-
- @Override
- public boolean a_(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/AnySilentChest.java
deleted file mode 100644
index ea08779..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_6/AnySilentChest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_6;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_4_6.*;
-
-import org.bukkit.craftbukkit.v1_4_6.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.s(x, y + 1, z))
- return true;
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.s(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.s(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.s(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.s(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- if (!anychest) {
- if (world.s(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.s(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.s(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.s(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.s(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int id = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- id = windowID.getInt(player);
- id = id % 100 + 1;
- windowID.setInt(player, id);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new Packet100OpenWindow(id, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize()));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = id;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/InventoryAccess.java
deleted file mode 100644
index b71024c..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_6/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_6;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_4_6.*;
-import org.bukkit.craftbukkit.v1_4_6.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java
deleted file mode 100644
index 84b37ad..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_6/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_6;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.v1_4_6.*;
-import org.bukkit.craftbukkit.v1_4_6.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/SilentContainerChest.java
deleted file mode 100644
index e245206..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_6/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_6;
-
-//Volatile
-import net.minecraft.server.v1_4_6.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.f();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialEnderChest.java
deleted file mode 100644
index fbbb96f..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_6;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_4_6.*;
-import org.bukkit.craftbukkit.v1_4_6.entity.*;
-import org.bukkit.craftbukkit.v1_4_6.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java
deleted file mode 100644
index 631e732..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_6/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_6;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_4_6.*;
-import org.bukkit.craftbukkit.v1_4_6.entity.*;
-import org.bukkit.craftbukkit.v1_4_6.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.name.length() > 16) {
- return player.name.substring(0, 16);
- }
- return player.name;
- }
-
- @Override
- public boolean a_(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/AnySilentChest.java
deleted file mode 100644
index aa21018..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/AnySilentChest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_R1;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_4_R1.*;
-
-import org.bukkit.craftbukkit.v1_4_R1.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.s(x, y + 1, z))
- return true;
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.s(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.s(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.s(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.s(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- if (!anychest) {
- if (world.s(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == Block.CHEST.id) && (world.s(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == Block.CHEST.id) && (world.s(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == Block.CHEST.id) && (world.s(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == Block.CHEST.id) && (world.s(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int id = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- id = windowID.getInt(player);
- id = id % 100 + 1;
- windowID.setInt(player, id);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new Packet100OpenWindow(id, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize()));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = id;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/InventoryAccess.java
deleted file mode 100644
index 6ac96fe..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_R1;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_4_R1.*;
-import org.bukkit.craftbukkit.v1_4_R1.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java
deleted file mode 100644
index 0f69936..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_R1;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.v1_4_R1.*;
-import org.bukkit.craftbukkit.v1_4_R1.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SilentContainerChest.java
deleted file mode 100644
index 7364a38..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_R1;
-
-//Volatile
-import net.minecraft.server.v1_4_R1.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.f();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialEnderChest.java
deleted file mode 100644
index 00a0c5e..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_R1;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_4_R1.*;
-import org.bukkit.craftbukkit.v1_4_R1.entity.*;
-import org.bukkit.craftbukkit.v1_4_R1.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java
deleted file mode 100644
index d39c6a7..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_4_R1/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_4_R1;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_4_R1.*;
-import org.bukkit.craftbukkit.v1_4_R1.entity.*;
-import org.bukkit.craftbukkit.v1_4_R1.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.name.length() > 16) {
- return player.name.substring(0, 16);
- }
- return player.name;
- }
-
- @Override
- public boolean a_(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/AnySilentChest.java
deleted file mode 100644
index f91b90e..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/AnySilentChest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R2;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_5_R2.*;
-
-import org.bukkit.craftbukkit.v1_5_R2.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.t(x, y + 1, z))
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- if (!anychest) {
- if (world.t(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new Packet100OpenWindow(windowId, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/InventoryAccess.java
deleted file mode 100644
index 56bc450..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R2;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_5_R2.*;
-import org.bukkit.craftbukkit.v1_5_R2.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java
deleted file mode 100644
index 6768a97..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R2;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.v1_5_R2.*;
-import org.bukkit.craftbukkit.v1_5_R2.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager((World) server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SilentContainerChest.java
deleted file mode 100644
index 4eb0ecb..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R2;
-
-//Volatile
-import net.minecraft.server.v1_5_R2.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.g();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialEnderChest.java
deleted file mode 100644
index 0ee7079..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R2;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_5_R2.*;
-import org.bukkit.craftbukkit.v1_5_R2.entity.*;
-import org.bukkit.craftbukkit.v1_5_R2.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java
deleted file mode 100644
index da08414..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R2/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R2;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_5_R2.*;
-import org.bukkit.craftbukkit.v1_5_R2.entity.*;
-import org.bukkit.craftbukkit.v1_5_R2.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.name.length() > 16) {
- return player.name.substring(0, 16);
- }
- return player.name;
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/AnySilentChest.java
deleted file mode 100644
index 0f3805c..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/AnySilentChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R3;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-import com.lishid.openinv.internal.v1_5_R3.SilentContainerChest;
-
-//Volatile
-import net.minecraft.server.v1_5_R3.*;
-
-import org.bukkit.craftbukkit.v1_5_R3.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.t(x, y + 1, z))
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- if (!anychest) {
- if (world.t(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new Packet100OpenWindow(windowId, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/InventoryAccess.java
deleted file mode 100644
index 192619c..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R3;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_5_R3.*;
-import org.bukkit.craftbukkit.v1_5_R3.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java
deleted file mode 100644
index 82e03fc..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R3;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.v1_5_R3.*;
-import org.bukkit.craftbukkit.v1_5_R3.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager((World) server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SilentContainerChest.java
deleted file mode 100644
index 66615b1..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R3;
-
-//Volatile
-import net.minecraft.server.v1_5_R3.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.g();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialEnderChest.java
deleted file mode 100644
index cf98df4..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R3;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_5_R3.*;
-import org.bukkit.craftbukkit.v1_5_R3.entity.*;
-import org.bukkit.craftbukkit.v1_5_R3.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java
deleted file mode 100644
index 5f5aacd..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_5_R3/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_5_R3;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_5_R3.*;
-import org.bukkit.craftbukkit.v1_5_R3.entity.*;
-import org.bukkit.craftbukkit.v1_5_R3.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.name.length() > 16) {
- return player.name.substring(0, 16);
- }
- return player.name;
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/AnySilentChest.java
deleted file mode 100644
index b081942..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/AnySilentChest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R1;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_6_R1.*;
-
-import org.bukkit.craftbukkit.v1_6_R1.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.t(x, y + 1, z))
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- if (!anychest) {
- if (world.t(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new Packet100OpenWindow(windowId, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/InventoryAccess.java
deleted file mode 100644
index 15acaa7..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R1;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_6_R1.*;
-import org.bukkit.craftbukkit.v1_6_R1.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java
deleted file mode 100644
index 393eedf..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R1;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.v1_6_R1.*;
-import org.bukkit.craftbukkit.v1_6_R1.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager((World) server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SilentContainerChest.java
deleted file mode 100644
index 1e63378..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R1;
-
-//Volatile
-import net.minecraft.server.v1_6_R1.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.g();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialEnderChest.java
deleted file mode 100644
index 0513edc..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R1;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_6_R1.*;
-import org.bukkit.craftbukkit.v1_6_R1.entity.*;
-import org.bukkit.craftbukkit.v1_6_R1.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java
deleted file mode 100644
index 8abfcfb..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R1/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R1;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_6_R1.*;
-import org.bukkit.craftbukkit.v1_6_R1.entity.*;
-import org.bukkit.craftbukkit.v1_6_R1.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.getName().length() > 16) {
- return player.getName().substring(0, 16);
- }
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/AnySilentChest.java
deleted file mode 100644
index e516a71..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/AnySilentChest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R2;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_6_R2.*;
-
-import org.bukkit.craftbukkit.v1_6_R2.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.t(x, y + 1, z))
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- if (!anychest) {
- if (world.t(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new Packet100OpenWindow(windowId, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/InventoryAccess.java
deleted file mode 100644
index 6325e80..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R2;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_6_R2.*;
-import org.bukkit.craftbukkit.v1_6_R2.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java
deleted file mode 100644
index 3143ab3..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R2;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.v1_6_R2.*;
-import org.bukkit.craftbukkit.v1_6_R2.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager((World) server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SilentContainerChest.java
deleted file mode 100644
index d014f35..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R2;
-
-//Volatile
-import net.minecraft.server.v1_6_R2.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.g();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java
deleted file mode 100644
index 624d07a..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R2;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_6_R2.*;
-import org.bukkit.craftbukkit.v1_6_R2.entity.*;
-import org.bukkit.craftbukkit.v1_6_R2.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java
deleted file mode 100644
index 6a3ee41..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R2/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R2;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_6_R2.*;
-import org.bukkit.craftbukkit.v1_6_R2.entity.*;
-import org.bukkit.craftbukkit.v1_6_R2.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.getName().length() > 16) {
- return player.getName().substring(0, 16);
- }
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/AnySilentChest.java
deleted file mode 100644
index e2a93e7..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/AnySilentChest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R3;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_6_R3.*;
-
-import org.bukkit.craftbukkit.v1_6_R3.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.t(x, y + 1, z))
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- // If block next to chest is chest and has a block on top
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = world.getTypeId(x, y, z);
-
- if (!anychest) {
- if (world.t(x, y + 1, z))
- return true;
- if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
- return true;
- if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
- return true;
- if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
- return true;
- }
-
- if (world.getTypeId(x - 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (world.getTypeId(x + 1, y, z) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (world.getTypeId(x, y, z - 1) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (world.getTypeId(x, y, z + 1) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new Packet100OpenWindow(windowId, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/InventoryAccess.java
deleted file mode 100644
index ecf5740..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R3;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_6_R3.*;
-import org.bukkit.craftbukkit.v1_6_R3.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java
deleted file mode 100644
index e87eb7a..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R3;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-
-//Volatile
-import net.minecraft.server.v1_6_R3.*;
-import org.bukkit.craftbukkit.v1_6_R3.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager((World) server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SilentContainerChest.java
deleted file mode 100644
index 3a37b25..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R3;
-
-//Volatile
-import net.minecraft.server.v1_6_R3.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.g();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java
deleted file mode 100644
index 4fc3e5e..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R3;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_6_R3.*;
-import org.bukkit.craftbukkit.v1_6_R3.entity.*;
-import org.bukkit.craftbukkit.v1_6_R3.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java
deleted file mode 100644
index 4d10281..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_6_R3/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_6_R3;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_6_R3.*;
-import org.bukkit.craftbukkit.v1_6_R3.entity.*;
-import org.bukkit.craftbukkit.v1_6_R3.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getName() {
- if (player.getName().length() > 16) {
- return player.getName().substring(0, 16);
- }
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/AnySilentChest.java
deleted file mode 100644
index 92aa7ec..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/AnySilentChest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R1;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_7_R1.*;
-
-import org.bukkit.craftbukkit.v1_7_R1.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.getType(x, y + 1, z).c())
- return true;
-
- int id = Block.b(world.getType(x, y, z));
-
- // If block next to chest is chest and has a block on top
- if ((Block.b(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
- return true;
- if ((Block.b(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = Block.b(world.getType(x, y, z));
-
- if (!anychest) {
- if (world.getType(x, y + 1, z).c())
- return true;
- if ((Block.b(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
- return true;
- if ((Block.b(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
- return true;
- }
-
- if (Block.b(world.getType(x - 1, y, z)) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (Block.b(world.getType(x + 1, y, z)) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (Block.b(world.getType(x, y, z - 1)) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (Block.b(world.getType(x, y, z + 1)) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, 0, ((IInventory) chest).getInventoryName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/InventoryAccess.java
deleted file mode 100644
index 6121bcb..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R1;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_7_R1.*;
-import org.bukkit.craftbukkit.v1_7_R1.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java
deleted file mode 100644
index 96423ce..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/PlayerDataManager.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R1;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-import net.minecraft.util.com.mojang.authlib.GameProfile;
-
-//Volatile
-import net.minecraft.server.v1_7_R1.*;
-import org.bukkit.craftbukkit.v1_7_R1.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- GameProfile profile = new GameProfile(null, playername);
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SilentContainerChest.java
deleted file mode 100644
index eaf44e3..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R1;
-
-//Volatile
-import net.minecraft.server.v1_7_R1.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.l_();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java
deleted file mode 100644
index c203684..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R1;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_7_R1.*;
-import org.bukkit.craftbukkit.v1_7_R1.entity.*;
-import org.bukkit.craftbukkit.v1_7_R1.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java
deleted file mode 100644
index efaaa90..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R1/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R1;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_7_R1.*;
-import org.bukkit.craftbukkit.v1_7_R1.entity.*;
-import org.bukkit.craftbukkit.v1_7_R1.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack, true);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getInventoryName() {
- if (player.getName().length() > 16) {
- return player.getName().substring(0, 16);
- }
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/AnySilentChest.java
deleted file mode 100644
index ef4e932..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/AnySilentChest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R2;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_7_R2.*;
-
-import org.bukkit.craftbukkit.v1_7_R2.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.getType(x, y + 1, z).c())
- return true;
-
- int id = Block.b(world.getType(x, y, z));
-
- // If block next to chest is chest and has a block on top
- if ((Block.b(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
- return true;
- if ((Block.b(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = Block.b(world.getType(x, y, z));
-
- if (!anychest) {
- if (world.getType(x, y + 1, z).c())
- return true;
- if ((Block.b(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
- return true;
- if ((Block.b(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
- return true;
- }
-
- if (Block.b(world.getType(x - 1, y, z)) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (Block.b(world.getType(x + 1, y, z)) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (Block.b(world.getType(x, y, z - 1)) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (Block.b(world.getType(x, y, z + 1)) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, 0, ((IInventory) chest).getInventoryName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/InventoryAccess.java
deleted file mode 100644
index 5d04cd3..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R2;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_7_R2.*;
-import org.bukkit.craftbukkit.v1_7_R2.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java
deleted file mode 100644
index 35ce584..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/PlayerDataManager.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R2;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-import net.minecraft.util.com.mojang.authlib.GameProfile;
-
-//Volatile
-import net.minecraft.server.v1_7_R2.*;
-import org.bukkit.craftbukkit.v1_7_R2.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
- if (!playerfolder.exists()) {
- return null;
- }
-
- String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
-
- if (playername == null) {
- return null;
- }
-
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
-
- GameProfile profile = new GameProfile(null, playername);
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- /**
- * @author Balor (aka Antoine Aflalo)
- */
- private static String matchUser(final Collection container, final String search) {
- String found = null;
- if (search == null) {
- return found;
- }
- final String lowerSearch = search.toLowerCase();
- int delta = Integer.MAX_VALUE;
- for (final File file : container) {
- final String filename = file.getName();
- final String str = filename.substring(0, filename.length() - 4);
- if (!str.toLowerCase().startsWith(lowerSearch)) {
- continue;
- }
- final int curDelta = str.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = str;
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
-
- }
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SilentContainerChest.java
deleted file mode 100644
index ef092cb..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R2;
-
-//Volatile
-import net.minecraft.server.v1_7_R2.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.l_();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialEnderChest.java
deleted file mode 100644
index fc1f6bb..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R2;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_7_R2.*;
-import org.bukkit.craftbukkit.v1_7_R2.entity.*;
-import org.bukkit.craftbukkit.v1_7_R2.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java
deleted file mode 100644
index 436299a..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R2/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R2;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_7_R2.*;
-import org.bukkit.craftbukkit.v1_7_R2.entity.*;
-import org.bukkit.craftbukkit.v1_7_R2.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack, true);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getInventoryName() {
- if (player.getName().length() > 16) {
- return player.getName().substring(0, 16);
- }
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/AnySilentChest.java
deleted file mode 100644
index 7eb95a5..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/AnySilentChest.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R3;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_7_R3.*;
-
-import org.bukkit.craftbukkit.v1_7_R3.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- // If block on top
- if (world.getType(x, y + 1, z).c())
- return true;
-
- int id = Block.b(world.getType(x, y, z));
-
- // If block next to chest is chest and has a block on top
- if ((Block.b(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
- return true;
- if ((Block.b(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = Block.b(world.getType(x, y, z));
-
- if (!anychest) {
- if (world.getType(x, y + 1, z).c())
- return true;
- if ((Block.b(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
- return true;
- if ((Block.b(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
- return true;
- if ((Block.b(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
- return true;
- }
-
- if (Block.b(world.getType(x - 1, y, z)) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (Block.b(world.getType(x + 1, y, z)) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (Block.b(world.getType(x, y, z - 1)) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (Block.b(world.getType(x, y, z + 1)) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, 0, ((IInventory) chest).getInventoryName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/InventoryAccess.java
deleted file mode 100644
index 234fd2b..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/InventoryAccess.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R3;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_7_R3.*;
-import org.bukkit.craftbukkit.v1_7_R3.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = ((CraftInventory) inventory).getInventory();
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java
deleted file mode 100644
index 6326403..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/PlayerDataManager.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R3;
-
-import java.io.File;
-import java.util.UUID;
-
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-import net.minecraft.util.com.mojang.authlib.GameProfile;
-
-//Volatile
-import net.minecraft.server.v1_7_R3.*;
-
-import org.bukkit.craftbukkit.v1_7_R3.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- UUID uuid = matchUser(name);
- if (uuid == null) {
- return null;
- }
-
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata");
- if (!playerfolder.exists()) {
- return null;
- }
-
- OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
- if (player == null) {
- return null;
- }
- GameProfile profile = new GameProfile(uuid, player.getName());
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- private static UUID matchUser(String search) {
- OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(search);
- if (offlinePlayer != null && offlinePlayer.hasPlayedBefore()) {
- return offlinePlayer.getUniqueId();
- }
- UUID found = null;
-
- String lowerSearch = search.toLowerCase();
- int delta = 2147483647;
-
- OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
- for (OfflinePlayer player : offlinePlayers) {
- String name = player.getName();
-
- if (name.equalsIgnoreCase(search))
- return player.getUniqueId();
-
- if (name.toLowerCase().startsWith(lowerSearch)) {
- int curDelta = name.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = player.getUniqueId();
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
- }
- }
-
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SilentContainerChest.java
deleted file mode 100644
index 867e714..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R3;
-
-//Volatile
-import net.minecraft.server.v1_7_R3.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.l_();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialEnderChest.java
deleted file mode 100644
index 4e9f663..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R3;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_7_R3.*;
-import org.bukkit.craftbukkit.v1_7_R3.entity.*;
-import org.bukkit.craftbukkit.v1_7_R3.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java
deleted file mode 100644
index 348f8c7..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R3/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R3;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_7_R3.*;
-import org.bukkit.craftbukkit.v1_7_R3.entity.*;
-import org.bukkit.craftbukkit.v1_7_R3.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack, true);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getInventoryName() {
- if (player.getName().length() > 16) {
- return player.getName().substring(0, 16);
- }
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/AnySilentChest.java
deleted file mode 100644
index f51f819..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/AnySilentChest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R4;
-
-import java.lang.reflect.Field;
-
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-//Volatile
-import net.minecraft.server.v1_7_R4.*;
-
-import org.bukkit.craftbukkit.v1_7_R4.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
-
- // If block on top
- if (world.getType(x, y + 1, z).c())
- return true;
-
- int id = Block.getId(world.getType(x, y, z));
-
- // If block next to chest is chest and has a block on top
- if ((Block.getId(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
- return true;
- if ((Block.getId(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
- return true;
- if ((Block.getId(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
- return true;
- if ((Block.getId(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
- return true;
-
- return false;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
- if (chest == null)
- return true;
-
- int id = Block.getId(world.getType(x, y, z));
-
- if (!anychest) {
- if (world.getType(x, y + 1, z).c())
- return true;
- if ((Block.getId(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
- return true;
- if ((Block.getId(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
- return true;
- if ((Block.getId(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
- return true;
- if ((Block.getId(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
- return true;
- }
-
- if (Block.getId(world.getType(x - 1, y, z)) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
- if (Block.getId(world.getType(x + 1, y, z)) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
- if (Block.getId(world.getType(x, y, z - 1)) == id)
- chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
- if (Block.getId(world.getType(x, y, z + 1)) == id)
- chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
-
- boolean returnValue = true;
- if (!silentchest) {
- player.openContainer((IInventory) chest);
- }
- else {
- try {
- int windowId = 0;
- try {
- Field windowID = player.getClass().getDeclaredField("containerCounter");
- windowID.setAccessible(true);
- windowId = windowID.getInt(player);
- windowId = windowId % 100 + 1;
- windowID.setInt(player, windowId);
- }
- catch (NoSuchFieldException e) {}
-
- player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, 0, ((IInventory) chest).getInventoryName(), ((IInventory) chest).getSize(), true));
- player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
- player.activeContainer.windowId = windowId;
- player.activeContainer.addSlotListener(player);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
- catch (Exception e) {
- e.printStackTrace();
- p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
- }
- }
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/InventoryAccess.java
deleted file mode 100644
index 3aae59c..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/InventoryAccess.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R4;
-
-import java.lang.reflect.Field;
-
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_7_R4.*;
-import org.bukkit.craftbukkit.v1_7_R4.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = grabInventory(inventory);
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-
- private IInventory grabInventory(Inventory inventory) {
- if(inventory instanceof CraftInventory) {
- return ((CraftInventory) inventory).getInventory();
- }
-
- //Use reflection to find the iiventory
- Class extends Inventory> clazz = inventory.getClass();
- IInventory result = null;
- for(Field f : clazz.getDeclaredFields()) {
- f.setAccessible(true);
- if(IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
- try {
- result = (IInventory) f.get(inventory);
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
- }
- }
- return result;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java
deleted file mode 100644
index 9273d63..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/PlayerDataManager.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R4;
-
-import java.io.File;
-import java.util.UUID;
-
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-import net.minecraft.util.com.mojang.authlib.GameProfile;
-
-//Volatile
-import net.minecraft.server.v1_7_R4.*;
-
-import org.bukkit.craftbukkit.v1_7_R4.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- UUID uuid = matchUser(name);
- if (uuid == null) {
- return null;
- }
-
- // Default player folder
- File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "playerdata");
- if (!playerfolder.exists()) {
- return null;
- }
-
- OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
- if (player == null) {
- return null;
- }
- GameProfile profile = new GameProfile(uuid, player.getName());
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = (entity == null) ? null : entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- private static UUID matchUser(String search) {
- OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(search);
- if (offlinePlayer != null && offlinePlayer.hasPlayedBefore()) {
- return offlinePlayer.getUniqueId();
- }
- UUID found = null;
-
- String lowerSearch = search.toLowerCase();
- int delta = 2147483647;
-
- OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
- for (OfflinePlayer player : offlinePlayers) {
- String name = player.getName();
-
- if (name == null){
- continue;
- }
- if (name.equalsIgnoreCase(search)){
- return player.getUniqueId();
- }
- if (name.toLowerCase().startsWith(lowerSearch)) {
- int curDelta = name.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = player.getUniqueId();
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
- }
- }
-
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SilentContainerChest.java
deleted file mode 100644
index 0cbf298..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SilentContainerChest.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R4;
-
-//Volatile
-import net.minecraft.server.v1_7_R4.*;
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2) {
- super(i1, i2);
- inv = i2;
- // close signal
- inv.closeContainer();
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialEnderChest.java
deleted file mode 100644
index 776d1cf..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialEnderChest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R4;
-
-import java.lang.reflect.Field;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_7_R4.*;
-import org.bukkit.craftbukkit.v1_7_R4.entity.*;
-import org.bukkit.craftbukkit.v1_7_R4.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
- public List transaction = new ArrayList();
- public boolean playerOnline = false;
- private CraftPlayer owner;
- private InventoryEnderChest enderChest;
- private int maxStack = MAX_STACK;
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialEnderChest(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
- CraftPlayer player = (CraftPlayer) p;
- this.enderChest = player.getHandle().getEnderChest();
- this.owner = player;
- this.items = enderChest.getContents();
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- try {
- InventoryEnderChest playerEnderChest = ((CraftPlayer) p).getHandle().getEnderChest();
- Field field = playerEnderChest.getClass().getField("items");
- field.setAccessible(true);
- field.set(playerEnderChest, this.items);
- }
- catch (Exception e) {}
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- }
-
- public ItemStack[] getContents() {
- return this.items;
- }
-
- public void onOpen(CraftHumanEntity who) {
- transaction.add(who);
- }
-
- public void onClose(CraftHumanEntity who) {
- transaction.remove(who);
- this.InventoryRemovalCheck();
- }
-
- public List getViewers() {
- return transaction;
- }
-
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- public void setMaxStackSize(int size) {
- maxStack = size;
- }
-
- public int getMaxStackSize() {
- return maxStack;
- }
-
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- public void startOpen() {
-
- }
-
- public void f() {
-
- }
-
- public void update() {
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java
deleted file mode 100644
index d480b59..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_7_R4/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_7_R4;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_7_R4.*;
-import org.bukkit.craftbukkit.v1_7_R4.entity.*;
-import org.bukkit.craftbukkit.v1_7_R4.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- CraftPlayer owner;
- public boolean playerOnline = false;
- private ItemStack[] extra = new ItemStack[5];
- private CraftInventory inventory = new CraftInventory(this);
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = ((CraftPlayer) p);
- this.playerOnline = online;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- @Override
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void InventoryRemovalCheck() {
- owner.saveData();
- if (transaction.isEmpty() && !playerOnline) {
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- @Override
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- p.getHandle().inventory.items = this.items;
- p.getHandle().inventory.armor = this.armor;
- p.saveData();
- playerOnline = true;
- }
- }
-
- @Override
- public void playerOffline() {
- playerOnline = false;
- this.InventoryRemovalCheck();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.InventoryRemovalCheck();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- }
- else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- }
- else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- }
- else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- }
- else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- }
- else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack, true);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public String getInventoryName() {
- if (player.getName().length() > 16) {
- return player.getName().substring(0, 16);
- }
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/AnySilentChest.java
deleted file mode 100644
index 30756a7..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/AnySilentChest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R1;
-
-import java.util.Iterator;
-
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-
-//Volatile
-import net.minecraft.server.v1_8_R1.*;
-
-import org.bukkit.craftbukkit.v1_8_R1.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- BlockPosition position = new BlockPosition(x, y, z);
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).b == 1 ?
- Block.getByName("trapped_chest") : Block.getByName("chest"));
-
- // If block on top
- if (topBlocking(world, position)) {
- return true;
- }
-
- // If block next to chest is chest and has a block on top
- for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
- BlockPosition sidePosition = position.shift(direction);
- Block var8 = world.getType(sidePosition).getBlock();
- if (var8 == chest) {
- if (this.topBlocking(world, sidePosition)) {
- return true;
- }
- }
- }
-
- return false;
- }
- private boolean topBlocking(World world, BlockPosition position) {
- return this.blockOnTop(world, position) || this.ocelotOnTop(world, position);
- }
-
- private boolean blockOnTop(World world, BlockPosition position) {
- return world.getType(position.up()).getBlock().isOccluding();
- }
-
- private boolean ocelotOnTop(World world, BlockPosition position) {
- Iterator var3 = world.a(EntityOcelot.class,
- new AxisAlignedBB((double) position.getX(), (double) (position.getY() + 1),
- (double) position.getZ(), (double) (position.getX() + 1),
- (double) (position.getY() + 2), (double) (position.getZ() + 1))).iterator();
-
- EntityOcelot var5;
- do {
- if (!var3.hasNext()) {
- return false;
- }
-
- Entity var4 = (Entity) var3.next();
- var5 = (EntityOcelot) var4;
- } while (!var5.isSitting());
-
- return true;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- BlockPosition position = new BlockPosition(x, y, z);
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- if (world.isStatic) {
- return true;
- }
-
- BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).b == 1 ?
- Block.getByName("trapped_chest") : Block.getByName("chest"));
-
- TileEntity tileEntity = world.getTileEntity(position);
- if (!(tileEntity instanceof TileEntityChest)) {
- return true;
- }
-
- ITileInventory tileInventory = (ITileInventory) tileEntity;
- if (!anychest && this.topBlocking(world, position)) {
- return true;
- }
-
- for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
- BlockPosition side = position.shift(direction);
- Block block = world.getType(side).getBlock();
- if (block == chest) {
- if (!anychest && this.topBlocking(world, side)) {
- return true;
- }
-
- TileEntity sideTileEntity = world.getTileEntity(side);
- if (sideTileEntity instanceof TileEntityChest) {
- if (direction != EnumDirection.WEST && direction != EnumDirection.NORTH) {
- tileInventory = new InventoryLargeChest("container.chestDouble", tileInventory, (TileEntityChest) sideTileEntity);
- } else {
- tileInventory = new InventoryLargeChest("container.chestDouble", (TileEntityChest) sideTileEntity, tileInventory);
- }
- }
- }
- }
-
- boolean returnValue = true;
- if (silentchest) {
- tileInventory = new SilentInventory(tileInventory);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
-
- player.openContainer(tileInventory);
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/EnumDirectionList.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/EnumDirectionList.java
deleted file mode 100644
index 8d7078c..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/EnumDirectionList.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.lishid.openinv.internal.v1_8_R1;
-
-import com.google.common.collect.Iterators;
-import net.minecraft.server.v1_8_R1.*;
-
-import java.util.Iterator;
-
-public enum EnumDirectionList implements Iterable {
- HORIZONTAL(EnumDirectionLimit.HORIZONTAL),
- VERTICAL(EnumDirectionLimit.VERTICAL);
-
- private EnumDirectionLimit list;
-
- private EnumDirectionList(EnumDirectionLimit list) {
- this.list = list;
- }
-
- @Override
- public Iterator iterator() {
- return Iterators.forArray(list.a());
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/InventoryAccess.java
deleted file mode 100644
index c32a40a..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/InventoryAccess.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R1;
-
-import java.lang.reflect.Field;
-
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_8_R1.*;
-import org.bukkit.craftbukkit.v1_8_R1.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = grabInventory(inventory);
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-
- private IInventory grabInventory(Inventory inventory) {
- if(inventory instanceof CraftInventory) {
- return ((CraftInventory) inventory).getInventory();
- }
-
- //Use reflection to find the iiventory
- Class extends Inventory> clazz = inventory.getClass();
- IInventory result = null;
- for(Field f : clazz.getDeclaredFields()) {
- f.setAccessible(true);
- if(IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
- try {
- result = (IInventory) f.get(inventory);
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
- }
- }
- return result;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java
deleted file mode 100644
index 6716cf1..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/PlayerDataManager.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R1;
-
-import java.util.UUID;
-
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-import com.mojang.authlib.GameProfile;
-
-//Volatile
-import net.minecraft.server.v1_8_R1.*;
-
-import org.bukkit.craftbukkit.v1_8_R1.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- UUID uuid = matchUser(name);
- if (uuid == null) {
- return null;
- }
-
- OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
- if (player == null) {
- return null;
- }
- GameProfile profile = new GameProfile(uuid, player.getName());
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- private static UUID matchUser(String search) {
- OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(search);
- if (offlinePlayer != null && offlinePlayer.hasPlayedBefore()) {
- return offlinePlayer.getUniqueId();
- }
- UUID found = null;
-
- String lowerSearch = search.toLowerCase();
- int delta = 2147483647;
-
- OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
- for (OfflinePlayer player : offlinePlayers) {
- String name = player.getName();
-
- if (name == null){
- continue;
- }
- if (name.equalsIgnoreCase(search)){
- return player.getUniqueId();
- }
- if (name.toLowerCase().startsWith(lowerSearch)) {
- int curDelta = name.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = player.getUniqueId();
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
- }
- }
-
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SilentContainerChest.java
deleted file mode 100644
index c0f55df..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SilentContainerChest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R1;
-
-//Volatile
-import net.minecraft.server.v1_8_R1.*;
-
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2, EntityHuman human) {
- super(i1, i2, human);
- inv = i2;
- // close signal
- inv.closeContainer(human);
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SilentInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SilentInventory.java
deleted file mode 100644
index df15bd8..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SilentInventory.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package com.lishid.openinv.internal.v1_8_R1;
-
-import net.minecraft.server.v1_8_R1.*;
-import org.bukkit.craftbukkit.v1_8_R1.entity.CraftHumanEntity;
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.InventoryHolder;
-
-import java.util.List;
-
-public class SilentInventory implements ITileInventory {
- public ITileInventory inv;
-
- public SilentInventory(ITileInventory inv) {
- this.inv = inv;
- }
-
- @Override
- public boolean q_() {
- return inv.q_();
- }
-
- @Override
- public void a(ChestLock chestLock) {
- inv.a(chestLock);
- }
-
- @Override
- public ChestLock i() {
- return inv.i();
- }
-
- @Override
- public int getSize() {
- return inv.getSize();
- }
-
- @Override
- public ItemStack getItem(int i) {
- return inv.getItem(i);
- }
-
- @Override
- public ItemStack splitStack(int i, int i1) {
- return inv.splitStack(i, i1);
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- return inv.splitWithoutUpdate(i);
- }
-
- @Override
- public void setItem(int i, ItemStack itemStack) {
- inv.setItem(i, itemStack);
- }
-
- @Override
- public int getMaxStackSize() {
- return inv.getMaxStackSize();
- }
-
- @Override
- public void update() {
- inv.update();
- }
-
- @Override
- public boolean a(EntityHuman entityHuman) {
- return inv.a(entityHuman);
- }
-
- @Override
- public void startOpen(EntityHuman entityHuman) {
- //Don't do anything
- }
-
- @Override
- public void closeContainer(EntityHuman entityHuman) {
- //Don't do anything
- }
-
- @Override
- public boolean b(int i, ItemStack itemStack) {
- return inv.b(i, itemStack);
- }
-
- @Override
- public int getProperty(int i) {
- return inv.getProperty(i);
- }
-
- @Override
- public void b(int i, int i1) {
- inv.b(i, i1);
- }
-
- @Override
- public int g() {
- return inv.g();
- }
-
- @Override
- public void l() {
- inv.l();
- }
-
- @Override
- public ItemStack[] getContents() {
- return inv.getContents();
- }
-
- @Override
- public void onOpen(CraftHumanEntity craftHumanEntity) {
- inv.onOpen(craftHumanEntity);
- }
-
- @Override
- public void onClose(CraftHumanEntity craftHumanEntity) {
- inv.onClose(craftHumanEntity);
- }
-
- @Override
- public List getViewers() {
- return inv.getViewers();
- }
-
- @Override
- public InventoryHolder getOwner() {
- return inv.getOwner();
- }
-
- @Override
- public void setMaxStackSize(int i) {
- inv.setMaxStackSize(i);
- }
-
- @Override
- public String getName() {
- return inv.getName();
- }
-
- @Override
- public boolean hasCustomName() {
- return inv.hasCustomName();
- }
-
- @Override
- public IChatBaseComponent getScoreboardDisplayName() {
- return inv.getScoreboardDisplayName();
- }
-
- @Override
- public Container createContainer(PlayerInventory playerInventory, EntityHuman entityHuman) {
- //Don't let the chest itself create the container.
- return new ContainerChest(playerInventory, this, entityHuman);
- }
-
- @Override
- public String getContainerName() {
- return inv.getContainerName();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialEnderChest.java
deleted file mode 100644
index fccee15..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialEnderChest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R1;
-
-import java.lang.reflect.Field;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_8_R1.*;
-import org.bukkit.craftbukkit.v1_8_R1.entity.*;
-import org.bukkit.craftbukkit.v1_8_R1.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements ISpecialEnderChest {
- private CraftInventory inventory = new CraftInventory(this);
- private InventoryEnderChest enderChest;
- private CraftPlayer owner;
- private boolean playerOnline = false;
-
- public SpecialEnderChest(Player p, Boolean online) {
- this(p, ((CraftPlayer) p).getHandle().getEnderChest(), online);
- }
-
- public SpecialEnderChest(Player p, InventoryEnderChest enderchest, boolean online) {
- super(enderchest.getName(), enderchest.hasCustomName(), enderchest.getSize());
- this.owner = (CraftPlayer) p;
- this.enderChest = enderchest;
- this.items = enderChest.getContents();
- this.playerOnline = online;
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- private void saveOnExit() {
- if (transaction.isEmpty() && !playerOnline) {
- owner.saveData();
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- private void linkInventory(InventoryEnderChest inventory) {
- inventory.items = this.items;
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- linkInventory(((CraftPlayer) p).getHandle().getEnderChest());
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- owner.loadData();
- linkInventory(owner.getHandle().getEnderChest());
- saveOnExit();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- saveOnExit();
- }
-
- @Override
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- @Override
- public void update() {
- super.update();
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java
deleted file mode 100644
index 79a045a..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R1/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R1;
-
-import org.bukkit.entity.Player;
-
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_8_R1.*;
-import org.bukkit.craftbukkit.v1_8_R1.entity.*;
-import org.bukkit.craftbukkit.v1_8_R1.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- private CraftInventory inventory = new CraftInventory(this);
- private ItemStack[] extra = new ItemStack[5];
- private CraftPlayer owner;
- private boolean playerOnline = false;
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = (CraftPlayer) p;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- this.playerOnline = online;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- private void saveOnExit() {
- if (transaction.isEmpty() && !playerOnline) {
- owner.saveData();
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- private void linkInventory(PlayerInventory inventory) {
- inventory.items = this.items;
- inventory.armor = this.armor;
- }
-
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- linkInventory(p.getHandle().inventory);
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- owner.loadData();
- linkInventory(owner.getHandle().inventory);
- saveOnExit();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.saveOnExit();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- } else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- } else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- } else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- } else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- } else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- } else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- } else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- } else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- } else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- } else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- } else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack, true);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public boolean hasCustomName() {
- return true;
- }
-
- @Override
- public String getName() {
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- @Override
- public void update() {
- super.update();
- player.inventory.update();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/AnySilentChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/AnySilentChest.java
deleted file mode 100644
index 6eab905..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/AnySilentChest.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R2;
-
-import java.util.Iterator;
-
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IAnySilentChest;
-
-
-//Volatile
-import net.minecraft.server.v1_8_R2.*;
-
-import org.bukkit.craftbukkit.v1_8_R2.entity.*;
-
-public class AnySilentChest implements IAnySilentChest {
- public boolean IsAnyChestNeeded(Player p, int x, int y, int z) {
- // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
- BlockPosition position = new BlockPosition(x, y, z);
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).b == 1 ?
- Block.getByName("trapped_chest") : Block.getByName("chest"));
-
- // If block on top
- if (topBlocking(world, position)) {
- return true;
- }
-
- // If block next to chest is chest and has a block on top
- for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
- BlockPosition sidePosition = position.shift(direction);
- Block var8 = world.getType(sidePosition).getBlock();
- if (var8 == chest) {
- if (this.topBlocking(world, sidePosition)) {
- return true;
- }
- }
- }
-
- return false;
- }
- private boolean topBlocking(World world, BlockPosition position) {
- return this.blockOnTop(world, position) || this.ocelotOnTop(world, position);
- }
-
- private boolean blockOnTop(World world, BlockPosition position) {
- return world.getType(position.up()).getBlock().isOccluding();
- }
-
- private boolean ocelotOnTop(World world, BlockPosition position) {
- Iterator var3 = world.a(EntityOcelot.class,
- new AxisAlignedBB((double) position.getX(), (double) (position.getY() + 1),
- (double) position.getZ(), (double) (position.getX() + 1),
- (double) (position.getY() + 2), (double) (position.getZ() + 1))).iterator();
-
- EntityOcelot var5;
- do {
- if (!var3.hasNext()) {
- return false;
- }
-
- Entity var4 = (Entity) var3.next();
- var5 = (EntityOcelot) var4;
- } while (!var5.isSitting());
-
- return true;
- }
-
- public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
- BlockPosition position = new BlockPosition(x, y, z);
- EntityPlayer player = ((CraftPlayer) p).getHandle();
- World world = player.world;
- if (world.isClientSide) {
- return true;
- }
-
- BlockChest chest = (BlockChest) (((BlockChest) world.getType(position).getBlock()).b == 1 ?
- Block.getByName("trapped_chest") : Block.getByName("chest"));
-
- TileEntity tileEntity = world.getTileEntity(position);
- if (!(tileEntity instanceof TileEntityChest)) {
- return true;
- }
-
- ITileInventory tileInventory = (ITileInventory) tileEntity;
- if (!anychest && this.topBlocking(world, position)) {
- return true;
- }
-
- for (EnumDirection direction : EnumDirectionList.HORIZONTAL) {
- BlockPosition side = position.shift(direction);
- Block block = world.getType(side).getBlock();
- if (block == chest) {
- if (!anychest && this.topBlocking(world, side)) {
- return true;
- }
-
- TileEntity sideTileEntity = world.getTileEntity(side);
- if (sideTileEntity instanceof TileEntityChest) {
- if (direction != EnumDirection.WEST && direction != EnumDirection.NORTH) {
- tileInventory = new InventoryLargeChest("container.chestDouble", tileInventory, (TileEntityChest) sideTileEntity);
- } else {
- tileInventory = new InventoryLargeChest("container.chestDouble", (TileEntityChest) sideTileEntity, tileInventory);
- }
- }
- }
- }
-
- boolean returnValue = true;
- if (silentchest) {
- tileInventory = new SilentInventory(tileInventory);
- if (OpenInv.NotifySilentChest()) {
- p.sendMessage("You are opening a chest silently.");
- }
- returnValue = false;
- }
-
- player.openContainer(tileInventory);
-
- if (anychest && OpenInv.NotifyAnyChest()) {
- p.sendMessage("You are opening a blocked chest.");
- }
-
- return returnValue;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/EnumDirectionList.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/EnumDirectionList.java
deleted file mode 100644
index eae6abf..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/EnumDirectionList.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.lishid.openinv.internal.v1_8_R2;
-
-import com.google.common.collect.Iterators;
-import net.minecraft.server.v1_8_R2.EnumDirection;
-import net.minecraft.server.v1_8_R2.EnumDirection.EnumDirectionLimit;
-
-import java.util.Iterator;
-
-public enum EnumDirectionList implements Iterable {
- HORIZONTAL(EnumDirectionLimit.HORIZONTAL),
- VERTICAL(EnumDirectionLimit.VERTICAL);
-
- private EnumDirectionLimit list;
-
- private EnumDirectionList(EnumDirectionLimit list) {
- this.list = list;
- }
-
- @Override
- public Iterator iterator() {
- return Iterators.forArray(list.a());
- }
-
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/InventoryAccess.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/InventoryAccess.java
deleted file mode 100644
index 0381d3b..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/InventoryAccess.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R2;
-
-import java.lang.reflect.Field;
-
-
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.Permissions;
-import com.lishid.openinv.internal.IInventoryAccess;
-
-//Volatile
-import net.minecraft.server.v1_8_R2.*;
-import org.bukkit.craftbukkit.v1_8_R2.inventory.*;
-
-public class InventoryAccess implements IInventoryAccess {
- public boolean check(Inventory inventory, HumanEntity player) {
- IInventory inv = grabInventory(inventory);
-
- if (inv instanceof SpecialPlayerInventory) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
- return false;
- }
- }
-
- else if (inv instanceof SpecialEnderChest) {
- if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
- return false;
- }
- }
-
- return true;
- }
-
- private IInventory grabInventory(Inventory inventory) {
- if(inventory instanceof CraftInventory) {
- return ((CraftInventory) inventory).getInventory();
- }
-
- //Use reflection to find the inventory
- Class extends Inventory> clazz = inventory.getClass();
- IInventory result = null;
- for(Field f : clazz.getDeclaredFields()) {
- f.setAccessible(true);
- if(IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
- try {
- result = (IInventory) f.get(inventory);
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
- }
- }
- return result;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java
deleted file mode 100644
index 6e0eb5a..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/PlayerDataManager.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R2;
-
-import java.util.UUID;
-
-import org.bukkit.Bukkit;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.entity.Player;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.IPlayerDataManager;
-import com.mojang.authlib.GameProfile;
-
-//Volatile
-import net.minecraft.server.v1_8_R2.*;
-
-import org.bukkit.craftbukkit.v1_8_R2.*;
-
-public class PlayerDataManager implements IPlayerDataManager {
- public Player loadPlayer(String name) {
- try {
- UUID uuid = matchUser(name);
- if (uuid == null) {
- return null;
- }
-
- OfflinePlayer player = Bukkit.getOfflinePlayer(uuid);
- if (player == null) {
- return null;
- }
- GameProfile profile = new GameProfile(uuid, player.getName());
- MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
- // Create an entity to load the player data
- EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
-
- // Get the bukkit entity
- Player target = entity.getBukkitEntity();
- if (target != null) {
- // Load data
- target.loadData();
- // Return the entity
- return target;
- }
- }
- catch (Exception e) {
- OpenInv.log(e);
- }
-
- return null;
- }
-
- private static UUID matchUser(String search) {
- OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(search);
- if (offlinePlayer != null && offlinePlayer.hasPlayedBefore()) {
- return offlinePlayer.getUniqueId();
- }
- UUID found = null;
-
- String lowerSearch = search.toLowerCase();
- int delta = 2147483647;
-
- OfflinePlayer[] offlinePlayers = Bukkit.getOfflinePlayers();
- for (OfflinePlayer player : offlinePlayers) {
- String name = player.getName();
-
- if (name == null){
- continue;
- }
- if (name.equalsIgnoreCase(search)){
- return player.getUniqueId();
- }
- if (name.toLowerCase().startsWith(lowerSearch)) {
- int curDelta = name.length() - lowerSearch.length();
- if (curDelta < delta) {
- found = player.getUniqueId();
- delta = curDelta;
- }
- if (curDelta == 0) {
- break;
- }
- }
- }
-
- return found;
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SilentContainerChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SilentContainerChest.java
deleted file mode 100644
index aaed14c..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SilentContainerChest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R2;
-
-//Volatile
-import net.minecraft.server.v1_8_R2.*;
-
-
-public class SilentContainerChest extends ContainerChest {
- public IInventory inv;
-
- public SilentContainerChest(IInventory i1, IInventory i2, EntityHuman human) {
- super(i1, i2, human);
- inv = i2;
- // close signal
- inv.closeContainer(human);
- }
-
- @Override
- public void b(EntityHuman paramEntityHuman) {
- // Don't send close signal twice, might screw up
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SilentInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SilentInventory.java
deleted file mode 100644
index fb6c881..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SilentInventory.java
+++ /dev/null
@@ -1,162 +0,0 @@
-package com.lishid.openinv.internal.v1_8_R2;
-
-import net.minecraft.server.v1_8_R2.*;
-import org.bukkit.craftbukkit.v1_8_R2.entity.CraftHumanEntity;
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.inventory.InventoryHolder;
-
-import java.util.List;
-
-public class SilentInventory implements ITileInventory {
- public ITileInventory inv;
-
- public SilentInventory(ITileInventory inv) {
- this.inv = inv;
- }
-
- @Override
- public boolean r_() {
- return inv.r_();
- }
-
- @Override
- public void a(ChestLock chestLock) {
- inv.a(chestLock);
- }
-
- @Override
- public ChestLock i() {
- return inv.i();
- }
-
- @Override
- public int getSize() {
- return inv.getSize();
- }
-
- @Override
- public ItemStack getItem(int i) {
- return inv.getItem(i);
- }
-
- @Override
- public ItemStack splitStack(int i, int i1) {
- return inv.splitStack(i, i1);
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- return inv.splitWithoutUpdate(i);
- }
-
- @Override
- public void setItem(int i, ItemStack itemStack) {
- inv.setItem(i, itemStack);
- }
-
- @Override
- public int getMaxStackSize() {
- return inv.getMaxStackSize();
- }
-
- @Override
- public void update() {
- inv.update();
- }
-
- @Override
- public boolean a(EntityHuman entityHuman) {
- return inv.a(entityHuman);
- }
-
- @Override
- public void startOpen(EntityHuman entityHuman) {
- //Don't do anything
- }
-
- @Override
- public void closeContainer(EntityHuman entityHuman) {
- //Don't do anything
- }
-
- @Override
- public boolean b(int i, ItemStack itemStack) {
- return inv.b(i, itemStack);
- }
-
- @Override
- public int getProperty(int i) {
- return inv.getProperty(i);
- }
-
- @Override
- public void b(int i, int i1) {
- inv.b(i, i1);
- }
-
- @Override
- public int g() {
- return inv.g();
- }
-
- @Override
- public void l() {
- inv.l();
- }
-
- @Override
- public ItemStack[] getContents() {
- return inv.getContents();
- }
-
- @Override
- public void onOpen(CraftHumanEntity craftHumanEntity) {
- inv.onOpen(craftHumanEntity);
- }
-
- @Override
- public void onClose(CraftHumanEntity craftHumanEntity) {
- inv.onClose(craftHumanEntity);
- }
-
- @Override
- public List getViewers() {
- return inv.getViewers();
- }
-
- @Override
- public InventoryHolder getOwner() {
- return inv.getOwner();
- }
-
- @Override
- public void setMaxStackSize(int i) {
- inv.setMaxStackSize(i);
- }
-
- @Override
- public String getName() {
- return inv.getName();
- }
-
- @Override
- public boolean hasCustomName() {
- return inv.hasCustomName();
- }
-
- @Override
- public IChatBaseComponent getScoreboardDisplayName() {
- return inv.getScoreboardDisplayName();
- }
-
- @Override
- public Container createContainer(PlayerInventory playerInventory, EntityHuman entityHuman) {
- //Don't let the chest itself create the container.
- return new ContainerChest(playerInventory, this, entityHuman);
- }
-
- @Override
- public String getContainerName() {
- return inv.getContainerName();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialEnderChest.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialEnderChest.java
deleted file mode 100644
index 3e63216..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialEnderChest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R2;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialEnderChest;
-
-import org.bukkit.entity.Player;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.InventoryHolder;
-
-//Volatile
-import net.minecraft.server.v1_8_R2.*;
-import org.bukkit.craftbukkit.v1_8_R2.entity.*;
-import org.bukkit.craftbukkit.v1_8_R2.inventory.*;
-
-public class SpecialEnderChest extends InventorySubcontainer implements ISpecialEnderChest {
- private CraftInventory inventory = new CraftInventory(this);
- private InventoryEnderChest enderChest;
- private CraftPlayer owner;
- private boolean playerOnline = false;
-
- public SpecialEnderChest(Player p, Boolean online) {
- this(p, ((CraftPlayer) p).getHandle().getEnderChest(), online);
- }
-
- public SpecialEnderChest(Player p, InventoryEnderChest enderchest, boolean online) {
- super(enderchest.getName(), enderchest.hasCustomName(), enderchest.getSize());
- this.owner = (CraftPlayer) p;
- this.enderChest = enderchest;
- this.items = enderChest.getContents();
- this.playerOnline = online;
- OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
- }
-
- private void saveOnExit() {
- if (transaction.isEmpty() && !playerOnline) {
- owner.saveData();
- OpenInv.enderChests.remove(owner.getName().toLowerCase());
- }
- }
-
- private void linkInventory(InventoryEnderChest inventory) {
- inventory.items = this.items;
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- public void playerOnline(Player p) {
- if (!playerOnline) {
- linkInventory(((CraftPlayer) p).getHandle().getEnderChest());
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- owner.loadData();
- linkInventory(owner.getHandle().getEnderChest());
- saveOnExit();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- saveOnExit();
- }
-
- @Override
- public InventoryHolder getOwner() {
- return this.owner;
- }
-
- @Override
- public void update() {
- super.update();
- enderChest.update();
- }
-}
diff --git a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java b/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java
deleted file mode 100644
index dea68ae..0000000
--- a/src/main/java/com/lishid/openinv/internal/v1_8_R2/SpecialPlayerInventory.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv.internal.v1_8_R2;
-
-import org.bukkit.entity.Player;
-
-import org.bukkit.inventory.Inventory;
-
-import com.lishid.openinv.OpenInv;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-//Volatile
-import net.minecraft.server.v1_8_R2.*;
-import org.bukkit.craftbukkit.v1_8_R2.entity.*;
-import org.bukkit.craftbukkit.v1_8_R2.inventory.*;
-
-public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory {
- private CraftInventory inventory = new CraftInventory(this);
- private ItemStack[] extra = new ItemStack[5];
- private CraftPlayer owner;
- private boolean playerOnline = false;
-
- public SpecialPlayerInventory(Player p, Boolean online) {
- super(((CraftPlayer) p).getHandle());
- this.owner = (CraftPlayer) p;
- this.items = player.inventory.items;
- this.armor = player.inventory.armor;
- this.playerOnline = online;
- OpenInv.inventories.put(owner.getName().toLowerCase(), this);
- }
-
- public Inventory getBukkitInventory() {
- return inventory;
- }
-
- private void saveOnExit() {
- if (transaction.isEmpty() && !playerOnline) {
- owner.saveData();
- OpenInv.inventories.remove(owner.getName().toLowerCase());
- }
- }
-
- private void linkInventory(PlayerInventory inventory) {
- inventory.items = this.items;
- inventory.armor = this.armor;
- }
-
- public void playerOnline(Player player) {
- if (!playerOnline) {
- CraftPlayer p = (CraftPlayer) player;
- linkInventory(p.getHandle().inventory);
- p.saveData();
- playerOnline = true;
- }
- }
-
- public void playerOffline() {
- playerOnline = false;
- owner.loadData();
- linkInventory(owner.getHandle().inventory);
- saveOnExit();
- }
-
- @Override
- public void onClose(CraftHumanEntity who) {
- super.onClose(who);
- this.saveOnExit();
- }
-
- @Override
- public ItemStack[] getContents() {
- ItemStack[] C = new ItemStack[getSize()];
- System.arraycopy(items, 0, C, 0, items.length);
- System.arraycopy(armor, 0, C, items.length, armor.length);
- return C;
- }
-
- @Override
- public int getSize() {
- return super.getSize() + 5;
- }
-
- @Override
- public ItemStack getItem(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- } else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- } else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- return is[i];
- }
-
- @Override
- public ItemStack splitStack(int i, int j) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- } else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- } else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack;
-
- if (is[i].count <= j) {
- itemstack = is[i];
- is[i] = null;
- return itemstack;
- } else {
- itemstack = is[i].a(j);
- if (is[i].count == 0) {
- is[i] = null;
- }
-
- return itemstack;
- }
- } else {
- return null;
- }
- }
-
- @Override
- public ItemStack splitWithoutUpdate(int i) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- } else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- } else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- if (is[i] != null) {
- ItemStack itemstack = is[i];
-
- is[i] = null;
- return itemstack;
- } else {
- return null;
- }
- }
-
- @Override
- public void setItem(int i, ItemStack itemstack) {
- ItemStack[] is = this.items;
-
- if (i >= is.length) {
- i -= is.length;
- is = this.armor;
- } else {
- i = getReversedItemSlotNum(i);
- }
-
- if (i >= is.length) {
- i -= is.length;
- is = this.extra;
- } else if (is == this.armor) {
- i = getReversedArmorSlotNum(i);
- }
-
- // Effects
- if (is == this.extra) {
- owner.getHandle().drop(itemstack, true);
- itemstack = null;
- }
-
- is[i] = itemstack;
-
- owner.getHandle().defaultContainer.b();
- }
-
- private int getReversedItemSlotNum(int i) {
- if (i >= 27)
- return i - 27;
- else
- return i + 9;
- }
-
- private int getReversedArmorSlotNum(int i) {
- if (i == 0)
- return 3;
- if (i == 1)
- return 2;
- if (i == 2)
- return 1;
- if (i == 3)
- return 0;
- else
- return i;
- }
-
- @Override
- public boolean hasCustomName() {
- return true;
- }
-
- @Override
- public String getName() {
- return player.getName();
- }
-
- @Override
- public boolean a(EntityHuman entityhuman) {
- return true;
- }
-
- @Override
- public void update() {
- super.update();
- player.inventory.update();
- }
-}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/OpenInvEntityListener.java b/src/main/java/com/lishid/openinv/listeners/OpenInvEntityListener.java
similarity index 94%
rename from src/main/java/com/lishid/openinv/OpenInvEntityListener.java
rename to src/main/java/com/lishid/openinv/listeners/OpenInvEntityListener.java
index e2a80c5..4e1ba92 100644
--- a/src/main/java/com/lishid/openinv/OpenInvEntityListener.java
+++ b/src/main/java/com/lishid/openinv/listeners/OpenInvEntityListener.java
@@ -1,52 +1,55 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv;
-
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.Player;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-
-public class OpenInvEntityListener implements Listener {
- @EventHandler(priority = EventPriority.LOWEST)
- public void onEntityDamage(EntityDamageEvent event) {
- if (event instanceof EntityDamageByEntityEvent) {
- EntityDamageByEntityEvent evt = (EntityDamageByEntityEvent) event;
- Entity attacker = evt.getDamager();
- Entity defender = evt.getEntity();
-
- if (!(attacker instanceof Player) || !(defender instanceof Player)) {
- return;
- }
-
- Player player = (Player) attacker;
-
- if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem()) || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName())) || !OpenInv.hasPermission(player, "OpenInv.openinv")) {
- return;
- }
-
- Player target = (Player) defender;
- player.performCommand("openinv " + target.getName());
-
- evt.setDamage(0);
- evt.setCancelled(true);
- }
- }
-}
+/*
+ * Copyright (C) 2011-2014 lishid. All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.lishid.openinv.listeners;
+
+import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityDamageByEntityEvent;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+
+import com.lishid.openinv.OpenInv;
+
+@SuppressWarnings("deprecation")
+public class OpenInvEntityListener implements Listener {
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onEntityDamage(EntityDamageEvent event) {
+ if (event instanceof EntityDamageByEntityEvent) {
+ EntityDamageByEntityEvent evt = (EntityDamageByEntityEvent) event;
+ Entity attacker = evt.getDamager();
+ Entity defender = evt.getEntity();
+
+ if (!(attacker instanceof Player) || !(defender instanceof Player)) {
+ return;
+ }
+
+ Player player = (Player) attacker;
+
+ if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem()) || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName())) || !OpenInv.hasPermission(player, "OpenInv.openinv")) {
+ return;
+ }
+
+ Player target = (Player) defender;
+ player.performCommand("openinv " + target.getName());
+
+ evt.setDamage(0);
+ evt.setCancelled(true);
+ }
+ }
+}
diff --git a/src/main/java/com/lishid/openinv/OpenInvInventoryListener.java b/src/main/java/com/lishid/openinv/listeners/OpenInvInventoryListener.java
similarity index 94%
rename from src/main/java/com/lishid/openinv/OpenInvInventoryListener.java
rename to src/main/java/com/lishid/openinv/listeners/OpenInvInventoryListener.java
index 2cd6b7c..bd100c6 100644
--- a/src/main/java/com/lishid/openinv/OpenInvInventoryListener.java
+++ b/src/main/java/com/lishid/openinv/listeners/OpenInvInventoryListener.java
@@ -1,35 +1,37 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv;
-
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.InventoryClickEvent;
-
-public class OpenInvInventoryListener implements Listener {
- @EventHandler(priority = EventPriority.NORMAL)
- public void onInventoryClick(InventoryClickEvent event) {
- // If this is the top inventory
- // if (event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot())
- // {
- if (!OpenInv.inventoryAccess.check(event.getInventory(), event.getWhoClicked())) {
- event.setCancelled(true);
- }
- // }
- }
+/*
+ * Copyright (C) 2011-2014 lishid. All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.lishid.openinv.listeners;
+
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.inventory.InventoryClickEvent;
+
+import com.lishid.openinv.OpenInv;
+
+public class OpenInvInventoryListener implements Listener {
+ @EventHandler(priority = EventPriority.NORMAL)
+ public void onInventoryClick(InventoryClickEvent event) {
+ // If this is the top inventory
+ // if (event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot())
+ // {
+ if (!OpenInv.inventoryAccess.check(event.getInventory(), event.getWhoClicked())) {
+ event.setCancelled(true);
+ }
+ // }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/OpenInvPlayerListener.java b/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java
similarity index 87%
rename from src/main/java/com/lishid/openinv/OpenInvPlayerListener.java
rename to src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java
index 8141116..97a00e9 100644
--- a/src/main/java/com/lishid/openinv/OpenInvPlayerListener.java
+++ b/src/main/java/com/lishid/openinv/listeners/OpenInvPlayerListener.java
@@ -1,133 +1,139 @@
-/*
- * Copyright (C) 2011-2014 lishid. All rights reserved.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, version 3.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package com.lishid.openinv;
-
-import org.bukkit.ChatColor;
-import org.bukkit.block.Chest;
-import org.bukkit.block.Sign;
-import org.bukkit.entity.Player;
-import org.bukkit.event.Event.Result;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.Listener;
-import org.bukkit.event.block.Action;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-
-import com.lishid.openinv.internal.ISpecialEnderChest;
-import com.lishid.openinv.internal.ISpecialPlayerInventory;
-
-public class OpenInvPlayerListener implements Listener {
- @EventHandler(priority = EventPriority.LOWEST)
- public void onPlayerJoin(PlayerJoinEvent event) {
- ISpecialPlayerInventory inventory = OpenInv.inventories.get(event.getPlayer().getName().toLowerCase());
-
- if (inventory != null) {
- inventory.playerOnline(event.getPlayer());
- }
-
- ISpecialEnderChest chest = OpenInv.enderChests.get(event.getPlayer().getName().toLowerCase());
-
- if (chest != null) {
- chest.playerOnline(event.getPlayer());
- }
- }
-
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerQuit(PlayerQuitEvent event) {
- ISpecialPlayerInventory inventory = OpenInv.inventories.get(event.getPlayer().getName().toLowerCase());
- if (inventory != null) {
- inventory.playerOffline();
- }
- ISpecialEnderChest chest = OpenInv.enderChests.get(event.getPlayer().getName().toLowerCase());
- if (chest != null) {
- chest.playerOffline();
- }
- }
-
- @EventHandler(priority = EventPriority.MONITOR)
- public void onPlayerInteract(PlayerInteractEvent event) {
- Player player = event.getPlayer();
-
- if (event.getPlayer().isSneaking()) {
- return;
- }
-
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.useInteractedBlock() == Result.DENY) {
- return;
- }
-
- 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())) {
- event.setCancelled(true);
- player.openInventory(player.getEnderChest());
- }
- }
-
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getState() instanceof Chest) {
- boolean silentchest = false;
- boolean anychest = false;
- int x = event.getClickedBlock().getX();
- int y = event.getClickedBlock().getY();
- int z = event.getClickedBlock().getZ();
-
- if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.GetPlayerSilentChestStatus(player.getName())) {
- silentchest = true;
- }
-
- if (OpenInv.hasPermission(player, Permissions.PERM_ANYCHEST) && OpenInv.GetPlayerAnyChestStatus(player.getName())) {
- try {
- anychest = OpenInv.anySilentChest.IsAnyChestNeeded(player, x, y, z);
- }
- catch (Exception e) {
- player.sendMessage(ChatColor.RED + "Error while executing openinv. Unsupported CraftBukkit.");
- e.printStackTrace();
- }
- }
-
- // If the anychest or silentchest is active
- if (anychest || silentchest) {
- if (!OpenInv.anySilentChest.ActivateChest(player, anychest, silentchest, x, y, z)) {
- event.setCancelled(true);
- }
- }
- }
-
- if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getState() instanceof Sign) {
- try {
- Sign sign = ((Sign) event.getClickedBlock().getState());
- if (OpenInv.hasPermission(player, Permissions.PERM_OPENINV) && sign.getLine(0).equalsIgnoreCase("[openinv]")) {
- String text = sign.getLine(1).trim() + sign.getLine(2).trim() + sign.getLine(3).trim();
- player.performCommand("openinv " + text);
- }
- }
- catch (Exception ex) {
- player.sendMessage("Internal Error.");
- ex.printStackTrace();
- }
- }
-
- 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)) {
- return;
- }
-
- player.performCommand("openinv");
- }
- }
+/*
+ * Copyright (C) 2011-2014 lishid. All rights reserved.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.lishid.openinv.listeners;
+
+import org.bukkit.ChatColor;
+import org.bukkit.block.Chest;
+import org.bukkit.block.Sign;
+import org.bukkit.entity.Player;
+import org.bukkit.event.Event.Result;
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.EventPriority;
+import org.bukkit.event.Listener;
+import org.bukkit.event.block.Action;
+import org.bukkit.event.player.PlayerInteractEvent;
+import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
+
+import com.lishid.openinv.OpenInv;
+import com.lishid.openinv.Permissions;
+import com.lishid.openinv.internal.SpecialEnderChest;
+import com.lishid.openinv.internal.SpecialPlayerInventory;
+
+@SuppressWarnings("deprecation")
+public class OpenInvPlayerListener implements Listener {
+ @EventHandler(priority = EventPriority.LOWEST)
+ public void onPlayerJoin(PlayerJoinEvent event) {
+ Player player = event.getPlayer();
+
+ SpecialPlayerInventory inventory = OpenInv.inventories.get(player.getUniqueId());
+ if (inventory != null) {
+ inventory.playerOnline(event.getPlayer());
+ }
+
+ SpecialEnderChest chest = OpenInv.enderChests.get(player.getUniqueId());
+ if (chest != null) {
+ chest.playerOnline(event.getPlayer());
+ }
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerQuit(PlayerQuitEvent event) {
+ Player player = event.getPlayer();
+
+ SpecialPlayerInventory inventory = OpenInv.inventories.get(player.getUniqueId());
+ if (inventory != null) {
+ inventory.playerOffline();
+ }
+
+ SpecialEnderChest chest = OpenInv.enderChests.get(player.getUniqueId());
+ if (chest != null) {
+ chest.playerOffline();
+ }
+ }
+
+ @EventHandler(priority = EventPriority.MONITOR)
+ public void onPlayerInteract(PlayerInteractEvent event) {
+ Player player = event.getPlayer();
+
+ if (event.getPlayer().isSneaking()) {
+ return;
+ }
+
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.useInteractedBlock() == Result.DENY) {
+ return;
+ }
+
+ 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())) {
+ event.setCancelled(true);
+ player.openInventory(player.getEnderChest());
+ }
+ }
+
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getState() instanceof Chest) {
+ boolean silentchest = false;
+ boolean anychest = false;
+ int x = event.getClickedBlock().getX();
+ int y = event.getClickedBlock().getY();
+ int z = event.getClickedBlock().getZ();
+
+ if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.GetPlayerSilentChestStatus(player.getName())) {
+ silentchest = true;
+ }
+
+ if (OpenInv.hasPermission(player, Permissions.PERM_ANYCHEST) && OpenInv.GetPlayerAnyChestStatus(player.getName())) {
+ try {
+ anychest = OpenInv.anySilentChest.IsAnyChestNeeded(player, x, y, z);
+ }
+ catch (Exception e) {
+ player.sendMessage(ChatColor.RED + "Error while executing openinv. Unsupported CraftBukkit.");
+ e.printStackTrace();
+ }
+ }
+
+ // If the anychest or silentchest is active
+ if (anychest || silentchest) {
+ if (!OpenInv.anySilentChest.ActivateChest(player, anychest, silentchest, x, y, z)) {
+ event.setCancelled(true);
+ }
+ }
+ }
+
+ if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getState() instanceof Sign) {
+ try {
+ Sign sign = ((Sign) event.getClickedBlock().getState());
+ if (OpenInv.hasPermission(player, Permissions.PERM_OPENINV) && sign.getLine(0).equalsIgnoreCase("[openinv]")) {
+ String text = sign.getLine(1).trim() + sign.getLine(2).trim() + sign.getLine(3).trim();
+ player.performCommand("openinv " + text);
+ }
+ }
+ catch (Exception ex) {
+ player.sendMessage("Internal Error.");
+ ex.printStackTrace();
+ }
+ }
+
+ 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)) {
+ return;
+ }
+
+ player.performCommand("openinv");
+ }
+ }
}
\ No newline at end of file
diff --git a/src/main/java/com/lishid/openinv/utils/UUIDFetcher.java b/src/main/java/com/lishid/openinv/utils/UUIDFetcher.java
new file mode 100644
index 0000000..11776a3
--- /dev/null
+++ b/src/main/java/com/lishid/openinv/utils/UUIDFetcher.java
@@ -0,0 +1,98 @@
+package com.lishid.openinv.utils;
+
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.ByteBuffer;
+import java.util.*;
+import java.util.concurrent.Callable;
+
+import org.json.simple.JSONArray;
+import org.json.simple.JSONObject;
+import org.json.simple.parser.JSONParser;
+
+import com.google.common.collect.ImmutableList;
+
+public class UUIDFetcher implements Callable