New formatting.
This commit is contained in:
		@@ -25,40 +25,33 @@ import org.bukkit.entity.Player;
 | 
			
		||||
import com.lishid.openinv.OpenInv;
 | 
			
		||||
import com.lishid.openinv.Permissions;
 | 
			
		||||
 | 
			
		||||
public class AnyChestPluginCommand implements CommandExecutor
 | 
			
		||||
{
 | 
			
		||||
    public AnyChestPluginCommand(OpenInv plugin)
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
public class AnyChestPluginCommand implements CommandExecutor {
 | 
			
		||||
    public AnyChestPluginCommand(OpenInv plugin) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
 | 
			
		||||
    {
 | 
			
		||||
        if (!(sender instanceof Player))
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
    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))
 | 
			
		||||
        {
 | 
			
		||||
        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 (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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,105 +29,90 @@ import com.lishid.openinv.Permissions;
 | 
			
		||||
import com.lishid.openinv.internal.ISpecialEnderChest;
 | 
			
		||||
import com.lishid.openinv.internal.InternalAccessor;
 | 
			
		||||
 | 
			
		||||
public class OpenEnderPluginCommand implements CommandExecutor
 | 
			
		||||
{
 | 
			
		||||
public class OpenEnderPluginCommand implements CommandExecutor {
 | 
			
		||||
    private final OpenInv plugin;
 | 
			
		||||
    public static HashMap<Player, String> openEnderHistory = new HashMap<Player, String>();
 | 
			
		||||
    
 | 
			
		||||
    public OpenEnderPluginCommand(OpenInv plugin)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public OpenEnderPluginCommand(OpenInv plugin) {
 | 
			
		||||
        this.plugin = plugin;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
 | 
			
		||||
    {
 | 
			
		||||
        if (!(sender instanceof Player))
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
    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))
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        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("?"))
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
 | 
			
		||||
            OpenInv.ShowHelp((Player) sender);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        Player player = (Player) sender;
 | 
			
		||||
        boolean offline = false;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // History management
 | 
			
		||||
        String history = openEnderHistory.get(player);
 | 
			
		||||
        
 | 
			
		||||
        if (history == null || history == "")
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (history == null || history == "") {
 | 
			
		||||
            history = player.getName();
 | 
			
		||||
            openEnderHistory.put(player, history);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Target selecting
 | 
			
		||||
        Player target;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        String name = "";
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Read from history if target is not named
 | 
			
		||||
        if (args.length < 1)
 | 
			
		||||
        {
 | 
			
		||||
            if (history != null && history != "")
 | 
			
		||||
            {
 | 
			
		||||
        if (args.length < 1) {
 | 
			
		||||
            if (history != null && history != "") {
 | 
			
		||||
                name = history;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                sender.sendMessage(ChatColor.RED + "OpenEnder history is empty!");
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            name = args[0];
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        target = this.plugin.getServer().getPlayer(name);
 | 
			
		||||
        
 | 
			
		||||
        if (target == null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (target == null) {
 | 
			
		||||
            // Try loading the player's data
 | 
			
		||||
            target = OpenInv.playerLoader.loadPlayer(name);
 | 
			
		||||
            
 | 
			
		||||
            if (target == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (target == null) {
 | 
			
		||||
                sender.sendMessage(ChatColor.RED + "Player " + name + " not found!");
 | 
			
		||||
                return true;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (target != sender && !OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST_ALL))
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (target != sender && !OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST_ALL)) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + "You do not have permission to access other player's enderchest");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Record the target
 | 
			
		||||
        history = target.getName();
 | 
			
		||||
        openEnderHistory.put(player, history);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Create the inventory
 | 
			
		||||
        ISpecialEnderChest chest = OpenInv.enderChests.get(target.getName().toLowerCase());
 | 
			
		||||
        if (chest == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (chest == null) {
 | 
			
		||||
            chest = InternalAccessor.Instance.newSpecialEnderChest(target, !offline);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Open the inventory
 | 
			
		||||
        player.openInventory(chest.getBukkitInventory());
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,114 +29,98 @@ import com.lishid.openinv.Permissions;
 | 
			
		||||
import com.lishid.openinv.internal.ISpecialPlayerInventory;
 | 
			
		||||
import com.lishid.openinv.internal.InternalAccessor;
 | 
			
		||||
 | 
			
		||||
public class OpenInvPluginCommand implements CommandExecutor
 | 
			
		||||
{
 | 
			
		||||
public class OpenInvPluginCommand implements CommandExecutor {
 | 
			
		||||
    private final OpenInv plugin;
 | 
			
		||||
    public static HashMap<Player, String> openInvHistory = new HashMap<Player, String>();
 | 
			
		||||
    
 | 
			
		||||
    public OpenInvPluginCommand(OpenInv plugin)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public OpenInvPluginCommand(OpenInv plugin) {
 | 
			
		||||
        this.plugin = plugin;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
 | 
			
		||||
    {
 | 
			
		||||
        if (!(sender instanceof Player))
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
    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))
 | 
			
		||||
        {
 | 
			
		||||
        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("?"))
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (args.length > 0 && args[0].equalsIgnoreCase("?")) {
 | 
			
		||||
            OpenInv.ShowHelp((Player) sender);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        Player player = (Player) sender;
 | 
			
		||||
        boolean offline = false;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // History management
 | 
			
		||||
        String history = openInvHistory.get(player);
 | 
			
		||||
        
 | 
			
		||||
        if (history == null || history == "")
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (history == null || history == "") {
 | 
			
		||||
            history = player.getName();
 | 
			
		||||
            openInvHistory.put(player, history);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Target selecting
 | 
			
		||||
        Player target;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        String name = "";
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Read from history if target is not named
 | 
			
		||||
        if (args.length < 1)
 | 
			
		||||
        {
 | 
			
		||||
        if (args.length < 1) {
 | 
			
		||||
            name = history;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            name = args[0];
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        target = this.plugin.getServer().getPlayer(name);
 | 
			
		||||
        
 | 
			
		||||
        if (target == null)
 | 
			
		||||
        {
 | 
			
		||||
            if (target == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        if (target == null) {
 | 
			
		||||
            if (target == null) {
 | 
			
		||||
                // Try loading the player's data
 | 
			
		||||
                target = OpenInv.playerLoader.loadPlayer(name);
 | 
			
		||||
                
 | 
			
		||||
                if (target == null)
 | 
			
		||||
                {
 | 
			
		||||
 | 
			
		||||
                if (target == null) {
 | 
			
		||||
                    sender.sendMessage(ChatColor.RED + "Player " + name + " not found!");
 | 
			
		||||
                    return true;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Permissions checks
 | 
			
		||||
        if (!OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE) && OpenInv.hasPermission(target, Permissions.PERM_EXEMPT))
 | 
			
		||||
        {
 | 
			
		||||
        if (!OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE) && OpenInv.hasPermission(target, Permissions.PERM_EXEMPT)) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + target.getDisplayName() + "'s inventory is protected!");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Crosswork check
 | 
			
		||||
        if ((!OpenInv.hasPermission(player, Permissions.PERM_CROSSWORLD) && !OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE)) && target.getWorld() != player.getWorld())
 | 
			
		||||
        {
 | 
			
		||||
        if ((!OpenInv.hasPermission(player, Permissions.PERM_CROSSWORLD) && !OpenInv.hasPermission(player, Permissions.PERM_OVERRIDE)) && target.getWorld() != player.getWorld()) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + target.getDisplayName() + " is not in your world!");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Self-open check
 | 
			
		||||
        if (!OpenInv.hasPermission(player, Permissions.PERM_OPENSELF) && target.equals(player))
 | 
			
		||||
        {
 | 
			
		||||
        if (!OpenInv.hasPermission(player, Permissions.PERM_OPENSELF) && target.equals(player)) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + "You're not allowed to openinv yourself.");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Record the target
 | 
			
		||||
        history = target.getName();
 | 
			
		||||
        openInvHistory.put(player, history);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Create the inventory
 | 
			
		||||
        ISpecialPlayerInventory inv = OpenInv.inventories.get(target.getName().toLowerCase());
 | 
			
		||||
        if (inv == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (inv == null) {
 | 
			
		||||
            inv = InternalAccessor.Instance.newSpecialPlayerInventory(target, !offline);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Open the inventory
 | 
			
		||||
        player.openInventory(inv.getBukkitInventory());
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,62 +27,50 @@ import org.bukkit.entity.Player;
 | 
			
		||||
import com.lishid.openinv.OpenInv;
 | 
			
		||||
import com.lishid.openinv.Permissions;
 | 
			
		||||
 | 
			
		||||
public class SearchInvPluginCommand implements CommandExecutor
 | 
			
		||||
{
 | 
			
		||||
    public SearchInvPluginCommand()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
public class SearchInvPluginCommand implements CommandExecutor {
 | 
			
		||||
    public SearchInvPluginCommand() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
 | 
			
		||||
    {
 | 
			
		||||
        if (sender instanceof Player)
 | 
			
		||||
        {
 | 
			
		||||
            if (!OpenInv.hasPermission(sender, Permissions.PERM_SEARCH))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        String PlayerList = "";
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        Material material = null;
 | 
			
		||||
        int count = 1;
 | 
			
		||||
        
 | 
			
		||||
        if (args.length >= 1)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (args.length >= 1) {
 | 
			
		||||
            String[] gData = null;
 | 
			
		||||
            gData = args[0].split(":");
 | 
			
		||||
            material = Material.matchMaterial(gData[0]);
 | 
			
		||||
        }
 | 
			
		||||
        if (args.length >= 2)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        if (args.length >= 2) {
 | 
			
		||||
            try {
 | 
			
		||||
                count = Integer.parseInt(args[1]);
 | 
			
		||||
            }
 | 
			
		||||
            catch (NumberFormatException ex)
 | 
			
		||||
            {
 | 
			
		||||
            catch (NumberFormatException ex) {
 | 
			
		||||
                sender.sendMessage(ChatColor.RED + "'" + args[1] + "' is not a number!");
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (material == null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (material == null) {
 | 
			
		||||
            sender.sendMessage(ChatColor.RED + "Unknown item");
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        for (Player templayer : Bukkit.getServer().getOnlinePlayers())
 | 
			
		||||
        {
 | 
			
		||||
            if (templayer.getInventory().contains(material, count))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -25,40 +25,33 @@ import org.bukkit.entity.Player;
 | 
			
		||||
import com.lishid.openinv.OpenInv;
 | 
			
		||||
import com.lishid.openinv.Permissions;
 | 
			
		||||
 | 
			
		||||
public class SilentChestPluginCommand implements CommandExecutor
 | 
			
		||||
{
 | 
			
		||||
    public SilentChestPluginCommand(OpenInv plugin)
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
public class SilentChestPluginCommand implements CommandExecutor {
 | 
			
		||||
    public SilentChestPluginCommand(OpenInv plugin) {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
 | 
			
		||||
    {
 | 
			
		||||
        if (!(sender instanceof Player))
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
    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))
 | 
			
		||||
        {
 | 
			
		||||
        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 (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;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -26,40 +26,32 @@ import org.bukkit.entity.Player;
 | 
			
		||||
import com.lishid.openinv.OpenInv;
 | 
			
		||||
import com.lishid.openinv.Permissions;
 | 
			
		||||
 | 
			
		||||
public class ToggleOpenInvPluginCommand implements CommandExecutor
 | 
			
		||||
{
 | 
			
		||||
    
 | 
			
		||||
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
 | 
			
		||||
    {
 | 
			
		||||
        if (!(sender instanceof Player))
 | 
			
		||||
        {
 | 
			
		||||
public class ToggleOpenInvPluginCommand implements CommandExecutor {
 | 
			
		||||
 | 
			
		||||
    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))
 | 
			
		||||
        {
 | 
			
		||||
        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 (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()))
 | 
			
		||||
        {
 | 
			
		||||
        if (OpenInv.GetPlayerItemOpenInvStatus(player.getName())) {
 | 
			
		||||
            OpenInv.SetPlayerItemOpenInvStatus(player.getName(), false);
 | 
			
		||||
            player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is OFF.");
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            OpenInv.SetPlayerItemOpenInvStatus(player.getName(), true);
 | 
			
		||||
            player.sendMessage("OpenInv with " + Material.getMaterial(OpenInv.GetItemOpenInvItem()).toString() + " is ON.");
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -18,9 +18,8 @@ package com.lishid.openinv.internal;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
public interface IAnySilentChest
 | 
			
		||||
{
 | 
			
		||||
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);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,7 +19,6 @@ package com.lishid.openinv.internal;
 | 
			
		||||
import org.bukkit.entity.HumanEntity;
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
 | 
			
		||||
public interface IInventoryAccess
 | 
			
		||||
{
 | 
			
		||||
public interface IInventoryAccess {
 | 
			
		||||
    public boolean check(Inventory inventory, HumanEntity player);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -18,7 +18,6 @@ package com.lishid.openinv.internal;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
public interface IPlayerDataManager
 | 
			
		||||
{
 | 
			
		||||
public interface IPlayerDataManager {
 | 
			
		||||
    public Player loadPlayer(String name);
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,14 +19,13 @@ package com.lishid.openinv.internal;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
 | 
			
		||||
public interface ISpecialEnderChest
 | 
			
		||||
{
 | 
			
		||||
public interface ISpecialEnderChest {
 | 
			
		||||
    public Inventory getBukkitInventory();
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck();
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(Player p);
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline();
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,13 +19,12 @@ package com.lishid.openinv.internal;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.Inventory;
 | 
			
		||||
 | 
			
		||||
public interface ISpecialPlayerInventory
 | 
			
		||||
{
 | 
			
		||||
public interface ISpecialPlayerInventory {
 | 
			
		||||
    public Inventory getBukkitInventory();
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck();
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(Player p);
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,105 +21,85 @@ import org.bukkit.entity.Player;
 | 
			
		||||
 | 
			
		||||
import com.lishid.openinv.OpenInv;
 | 
			
		||||
 | 
			
		||||
public class InternalAccessor
 | 
			
		||||
{
 | 
			
		||||
public class InternalAccessor {
 | 
			
		||||
    public static InternalAccessor Instance;
 | 
			
		||||
    private String version;
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /*
 | 
			
		||||
     * Returns false if version not supported
 | 
			
		||||
     */
 | 
			
		||||
    public static boolean Initialize(Server server)
 | 
			
		||||
    {
 | 
			
		||||
    public static boolean Initialize(Server server) {
 | 
			
		||||
        Instance = new InternalAccessor();
 | 
			
		||||
        String packageName = server.getClass().getPackage().getName();
 | 
			
		||||
        Instance.version = packageName.substring(packageName.lastIndexOf('.') + 1);
 | 
			
		||||
        
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            Class.forName("com.lishid.openinv.internal." + Instance.version + ".AnySilentChest");
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PrintError()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public IPlayerDataManager newPlayerDataManager() {
 | 
			
		||||
        return (IPlayerDataManager) createObject(IPlayerDataManager.class, "PlayerDataManager");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public IInventoryAccess newInventoryAccess()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public IInventoryAccess newInventoryAccess() {
 | 
			
		||||
        return (IInventoryAccess) createObject(IInventoryAccess.class, "InventoryAccess");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public IAnySilentChest newAnySilentChest()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public IAnySilentChest newAnySilentChest() {
 | 
			
		||||
        return (IAnySilentChest) createObject(IAnySilentChest.class, "AnySilentChest");
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ISpecialPlayerInventory newSpecialPlayerInventory(Player player, boolean offline)
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
    public ISpecialPlayerInventory newSpecialPlayerInventory(Player player, boolean offline) {
 | 
			
		||||
        try {
 | 
			
		||||
            Class<?> internalClass = Class.forName("com.lishid.openinv.internal." + version + ".SpecialPlayerInventory");
 | 
			
		||||
            if (ISpecialPlayerInventory.class.isAssignableFrom(internalClass))
 | 
			
		||||
            {
 | 
			
		||||
            if (ISpecialPlayerInventory.class.isAssignableFrom(internalClass)) {
 | 
			
		||||
                return (ISpecialPlayerInventory) internalClass.getConstructor(Player.class, Boolean.class).newInstance(player, offline);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            PrintError();
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ISpecialEnderChest newSpecialEnderChest(Player player, boolean offline)
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
    public ISpecialEnderChest newSpecialEnderChest(Player player, boolean offline) {
 | 
			
		||||
        try {
 | 
			
		||||
            Class<?> internalClass = Class.forName("com.lishid.openinv.internal." + version + ".SpecialEnderChest");
 | 
			
		||||
            if (ISpecialEnderChest.class.isAssignableFrom(internalClass))
 | 
			
		||||
            {
 | 
			
		||||
            if (ISpecialEnderChest.class.isAssignableFrom(internalClass)) {
 | 
			
		||||
                return (ISpecialEnderChest) internalClass.getConstructor(Player.class, Boolean.class).newInstance(player, offline);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            PrintError();
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private Object createObject(Class<? extends Object> assignableClass, String className)
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
    private Object createObject(Class<? extends Object> assignableClass, String className) {
 | 
			
		||||
        try {
 | 
			
		||||
            Class<?> internalClass = Class.forName("com.lishid.openinv.internal." + version + "." + className);
 | 
			
		||||
            if (assignableClass.isAssignableFrom(internalClass))
 | 
			
		||||
            {
 | 
			
		||||
            if (assignableClass.isAssignableFrom(internalClass)) {
 | 
			
		||||
                return internalClass.getConstructor().newInstance();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            PrintError();
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,17 +29,15 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -49,20 +47,18 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -74,7 +70,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -83,50 +79,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int id = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
import net.minecraft.server.*;
 | 
			
		||||
import org.bukkit.craftbukkit.inventory.*;
 | 
			
		||||
 | 
			
		||||
public class InventoryAccess implements IInventoryAccess
 | 
			
		||||
{
 | 
			
		||||
    public boolean check(Inventory inventory, HumanEntity player)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
import net.minecraft.server.*;
 | 
			
		||||
import org.bukkit.craftbukkit.*;
 | 
			
		||||
 | 
			
		||||
public class PlayerDataManager implements IPlayerDataManager
 | 
			
		||||
{
 | 
			
		||||
    public Player loadPlayer(String name)
 | 
			
		||||
    {
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.craftbukkit;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.f();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ import net.minecraft.server.*;
 | 
			
		||||
import org.bukkit.craftbukkit.entity.*;
 | 
			
		||||
import org.bukkit.craftbukkit.inventory.*;
 | 
			
		||||
 | 
			
		||||
public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest
 | 
			
		||||
{
 | 
			
		||||
public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ import net.minecraft.server.*;
 | 
			
		||||
import org.bukkit.craftbukkit.entity.*;
 | 
			
		||||
import org.bukkit.craftbukkit.inventory.*;
 | 
			
		||||
 | 
			
		||||
public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.name.length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.name.length() > 16) {
 | 
			
		||||
            return player.name.substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.name;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a_(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a_(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,17 +29,15 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -49,20 +47,18 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -74,7 +70,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -83,50 +79,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int id = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
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
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_4_5;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_4_5.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.f();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.name.length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.name.length() > 16) {
 | 
			
		||||
            return player.name.substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.name;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a_(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a_(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,17 +29,15 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -49,20 +47,18 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -74,7 +70,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -85,48 +81,40 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
 | 
			
		||||
 | 
			
		||||
        boolean returnValue = true;
 | 
			
		||||
        if (!silentchest)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int id = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
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
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_4_6;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_4_6.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.f();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.name.length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.name.length() > 16) {
 | 
			
		||||
            return player.name.substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.name;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a_(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a_(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,17 +29,15 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -49,20 +47,18 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -74,7 +70,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -83,50 +79,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int id = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
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
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_4_R1;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_4_R1.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.f();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.name.length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.name.length() > 16) {
 | 
			
		||||
            return player.name.substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.name;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a_(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a_(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,19 +29,17 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -51,22 +49,20 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -78,7 +74,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -87,50 +83,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int windowId = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
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
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_5_R2;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_5_R2.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.g();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.name.length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.name.length() > 16) {
 | 
			
		||||
            return player.name.substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.name;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -31,19 +31,17 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -53,22 +51,20 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -80,7 +76,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -89,50 +85,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int windowId = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
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
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_5_R3;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_5_R3.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.g();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.name.length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.name.length() > 16) {
 | 
			
		||||
            return player.name.substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.name;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,19 +29,17 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -51,22 +49,20 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -78,7 +74,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -87,50 +83,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int windowId = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
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
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_6_R1;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_6_R1.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.g();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.getName().length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.getName().length() > 16) {
 | 
			
		||||
            return player.getName().substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.getName();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,19 +29,17 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -51,22 +49,20 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -78,7 +74,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -87,50 +83,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int windowId = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
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
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_6_R2;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_6_R2.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.g();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.getName().length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.getName().length() > 16) {
 | 
			
		||||
            return player.getName().substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.getName();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,19 +29,17 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -51,22 +49,20 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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)))
 | 
			
		||||
@@ -78,7 +74,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -87,50 +83,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int windowId = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -30,80 +30,67 @@ import com.lishid.openinv.internal.IPlayerDataManager;
 | 
			
		||||
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
 | 
			
		||||
        {
 | 
			
		||||
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())
 | 
			
		||||
            {
 | 
			
		||||
            if (!playerfolder.exists()) {
 | 
			
		||||
                return null;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
			
		||||
            
 | 
			
		||||
            if (playername == null)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
            if (target != null) {
 | 
			
		||||
                // Load data
 | 
			
		||||
                target.loadData();
 | 
			
		||||
                // Return the entity
 | 
			
		||||
                return target;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e)
 | 
			
		||||
        {
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            OpenInv.log(e);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * @author Balor (aka Antoine Aflalo)
 | 
			
		||||
     */
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search)
 | 
			
		||||
    {
 | 
			
		||||
    private static String matchUser(final Collection<File> container, final String search) {
 | 
			
		||||
        String found = null;
 | 
			
		||||
        if (search == null)
 | 
			
		||||
        {
 | 
			
		||||
        if (search == null) {
 | 
			
		||||
            return found;
 | 
			
		||||
        }
 | 
			
		||||
        final String lowerSearch = search.toLowerCase();
 | 
			
		||||
        int delta = Integer.MAX_VALUE;
 | 
			
		||||
        for (final File file : container)
 | 
			
		||||
        {
 | 
			
		||||
        for (final File file : container) {
 | 
			
		||||
            final String filename = file.getName();
 | 
			
		||||
            final String str = filename.substring(0, filename.length() - 4);
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
			
		||||
            {
 | 
			
		||||
            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
            final int curDelta = str.length() - lowerSearch.length();
 | 
			
		||||
            if (curDelta < delta)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta < delta) {
 | 
			
		||||
                found = str;
 | 
			
		||||
                delta = curDelta;
 | 
			
		||||
            }
 | 
			
		||||
            if (curDelta == 0)
 | 
			
		||||
            {
 | 
			
		||||
            if (curDelta == 0) {
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
        return found;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_6_R3;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_6_R3.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.g();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.getName().length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getName() {
 | 
			
		||||
        if (player.getName().length() > 16) {
 | 
			
		||||
            return player.getName().substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.getName();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -29,19 +29,17 @@ 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)
 | 
			
		||||
    {
 | 
			
		||||
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;
 | 
			
		||||
@@ -51,22 +49,20 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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 (!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()))
 | 
			
		||||
@@ -78,7 +74,7 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
@@ -87,50 +83,42 @@ public class AnySilentChest implements IAnySilentChest
 | 
			
		||||
            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)
 | 
			
		||||
        {
 | 
			
		||||
        if (!silentchest) {
 | 
			
		||||
            player.openContainer((IInventory) chest);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
        else {
 | 
			
		||||
            try {
 | 
			
		||||
                int windowId = 0;
 | 
			
		||||
                try
 | 
			
		||||
                {
 | 
			
		||||
                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)
 | 
			
		||||
                {}
 | 
			
		||||
                
 | 
			
		||||
                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())
 | 
			
		||||
                {
 | 
			
		||||
                if (OpenInv.NotifySilentChest()) {
 | 
			
		||||
                    p.sendMessage("You are opening a chest silently.");
 | 
			
		||||
                }
 | 
			
		||||
                returnValue = false;
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e)
 | 
			
		||||
            {
 | 
			
		||||
            catch (Exception e) {
 | 
			
		||||
                e.printStackTrace();
 | 
			
		||||
                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest())
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (anychest && OpenInv.NotifyAnyChest()) {
 | 
			
		||||
            p.sendMessage("You are opening a blocked chest.");
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return returnValue;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,28 +27,22 @@ import com.lishid.openinv.internal.IInventoryAccess;
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        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))
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
        else if (inv instanceof SpecialEnderChest) {
 | 
			
		||||
            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -19,21 +19,18 @@ package com.lishid.openinv.internal.v1_7_R1;
 | 
			
		||||
//Volatile
 | 
			
		||||
import net.minecraft.server.v1_7_R1.*;
 | 
			
		||||
 | 
			
		||||
public class SilentContainerChest extends ContainerChest
 | 
			
		||||
{
 | 
			
		||||
public class SilentContainerChest extends ContainerChest {
 | 
			
		||||
    public IInventory inv;
 | 
			
		||||
    
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SilentContainerChest(IInventory i1, IInventory i2) {
 | 
			
		||||
        super(i1, i2);
 | 
			
		||||
        inv = i2;
 | 
			
		||||
        // close signal
 | 
			
		||||
        inv.l_();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman)
 | 
			
		||||
    {
 | 
			
		||||
    public void b(EntityHuman paramEntityHuman) {
 | 
			
		||||
        // Don't send close signal twice, might screw up
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -33,17 +33,15 @@ 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 class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest {
 | 
			
		||||
    public List<HumanEntity> transaction = new ArrayList<HumanEntity>();
 | 
			
		||||
    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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    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();
 | 
			
		||||
@@ -51,98 +49,78 @@ public class SpecialEnderChest extends InventorySubcontainer implements IInvento
 | 
			
		||||
        this.items = enderChest.getContents();
 | 
			
		||||
        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOnline(Player p)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
            try
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOnline(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)
 | 
			
		||||
            {
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception e) {}
 | 
			
		||||
            p.saveData();
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        return this.items;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onOpen(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onOpen(CraftHumanEntity who) {
 | 
			
		||||
        transaction.add(who);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        transaction.remove(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public List<HumanEntity> getViewers()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public List<HumanEntity> getViewers() {
 | 
			
		||||
        return transaction;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public InventoryHolder getOwner()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public InventoryHolder getOwner() {
 | 
			
		||||
        return this.owner;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void setMaxStackSize(int size)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void setMaxStackSize(int size) {
 | 
			
		||||
        maxStack = size;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public int getMaxStackSize()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public int getMaxStackSize() {
 | 
			
		||||
        return maxStack;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void startOpen()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void startOpen() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void f()
 | 
			
		||||
    {
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
    public void f() {
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    public void update()
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public void update() {
 | 
			
		||||
        enderChest.update();
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -27,15 +27,13 @@ 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
 | 
			
		||||
{
 | 
			
		||||
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)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    public SpecialPlayerInventory(Player p, Boolean online) {
 | 
			
		||||
        super(((CraftPlayer) p).getHandle());
 | 
			
		||||
        this.owner = ((CraftPlayer) p);
 | 
			
		||||
        this.playerOnline = online;
 | 
			
		||||
@@ -43,28 +41,23 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        this.armor = player.inventory.armor;
 | 
			
		||||
        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public Inventory getBukkitInventory()
 | 
			
		||||
    {
 | 
			
		||||
    public Inventory getBukkitInventory() {
 | 
			
		||||
        return inventory;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void InventoryRemovalCheck()
 | 
			
		||||
    {
 | 
			
		||||
    public void InventoryRemovalCheck() {
 | 
			
		||||
        owner.saveData();
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
        if (transaction.isEmpty() && !playerOnline) {
 | 
			
		||||
            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOnline(Player player)
 | 
			
		||||
    {
 | 
			
		||||
        if (!playerOnline)
 | 
			
		||||
        {
 | 
			
		||||
    public void PlayerGoOnline(Player player) {
 | 
			
		||||
        if (!playerOnline) {
 | 
			
		||||
            CraftPlayer p = (CraftPlayer) player;
 | 
			
		||||
            p.getHandle().inventory.items = this.items;
 | 
			
		||||
            p.getHandle().inventory.armor = this.armor;
 | 
			
		||||
@@ -72,201 +65,167 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
            playerOnline = true;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void PlayerGoOffline()
 | 
			
		||||
    {
 | 
			
		||||
    public void PlayerGoOffline() {
 | 
			
		||||
        playerOnline = false;
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void onClose(CraftHumanEntity who)
 | 
			
		||||
    {
 | 
			
		||||
    public void onClose(CraftHumanEntity who) {
 | 
			
		||||
        super.onClose(who);
 | 
			
		||||
        this.InventoryRemovalCheck();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack[] getContents()
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack[] getContents() {
 | 
			
		||||
        ItemStack[] C = new ItemStack[getSize()];
 | 
			
		||||
        System.arraycopy(items, 0, C, 0, items.length);
 | 
			
		||||
        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
			
		||||
        return C;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public int getSize()
 | 
			
		||||
    {
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return super.getSize() + 5;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack getItem(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack getItem(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        return is[i];
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitStack(int i, int j)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitStack(int i, int j) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack;
 | 
			
		||||
            
 | 
			
		||||
            if (is[i].count <= j)
 | 
			
		||||
            {
 | 
			
		||||
 | 
			
		||||
            if (is[i].count <= j) {
 | 
			
		||||
                itemstack = is[i];
 | 
			
		||||
                is[i] = null;
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
            else {
 | 
			
		||||
                itemstack = is[i].a(j);
 | 
			
		||||
                if (is[i].count == 0)
 | 
			
		||||
                {
 | 
			
		||||
                if (is[i].count == 0) {
 | 
			
		||||
                    is[i] = null;
 | 
			
		||||
                }
 | 
			
		||||
                
 | 
			
		||||
 | 
			
		||||
                return itemstack;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i)
 | 
			
		||||
    {
 | 
			
		||||
    public ItemStack splitWithoutUpdate(int i) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (is[i] != null)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (is[i] != null) {
 | 
			
		||||
            ItemStack itemstack = is[i];
 | 
			
		||||
            
 | 
			
		||||
 | 
			
		||||
            is[i] = null;
 | 
			
		||||
            return itemstack;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack)
 | 
			
		||||
    {
 | 
			
		||||
    public void setItem(int i, ItemStack itemstack) {
 | 
			
		||||
        ItemStack[] is = this.items;
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.armor;
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        else {
 | 
			
		||||
            i = getReversedItemSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        if (i >= is.length)
 | 
			
		||||
        {
 | 
			
		||||
 | 
			
		||||
        if (i >= is.length) {
 | 
			
		||||
            i -= is.length;
 | 
			
		||||
            is = this.extra;
 | 
			
		||||
        }
 | 
			
		||||
        else if (is == this.armor)
 | 
			
		||||
        {
 | 
			
		||||
        else if (is == this.armor) {
 | 
			
		||||
            i = getReversedArmorSlotNum(i);
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        // Effects
 | 
			
		||||
        if (is == this.extra)
 | 
			
		||||
        {
 | 
			
		||||
        if (is == this.extra) {
 | 
			
		||||
            owner.getHandle().drop(itemstack, true);
 | 
			
		||||
            itemstack = null;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        is[i] = itemstack;
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        owner.getHandle().defaultContainer.b();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedItemSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedItemSlotNum(int i) {
 | 
			
		||||
        if (i >= 27)
 | 
			
		||||
            return i - 27;
 | 
			
		||||
        else
 | 
			
		||||
            return i + 9;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    private int getReversedArmorSlotNum(int i)
 | 
			
		||||
    {
 | 
			
		||||
 | 
			
		||||
    private int getReversedArmorSlotNum(int i) {
 | 
			
		||||
        if (i == 0)
 | 
			
		||||
            return 3;
 | 
			
		||||
        if (i == 1)
 | 
			
		||||
@@ -278,20 +237,17 @@ public class SpecialPlayerInventory extends PlayerInventory implements ISpecialP
 | 
			
		||||
        else
 | 
			
		||||
            return i;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public String getInventoryName()
 | 
			
		||||
    {
 | 
			
		||||
        if (player.getName().length() > 16)
 | 
			
		||||
        {
 | 
			
		||||
    public String getInventoryName() {
 | 
			
		||||
        if (player.getName().length() > 16) {
 | 
			
		||||
            return player.getName().substring(0, 16);
 | 
			
		||||
        }
 | 
			
		||||
        return player.getName();
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean a(EntityHuman entityhuman)
 | 
			
		||||
    {
 | 
			
		||||
    public boolean a(EntityHuman entityhuman) {
 | 
			
		||||
        return true;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user