Added 1.7.2 support, added old files.
This commit is contained in:
		@@ -22,6 +22,7 @@ import java.util.logging.Logger;
 | 
				
			|||||||
import org.bukkit.ChatColor;
 | 
					import org.bukkit.ChatColor;
 | 
				
			||||||
import org.bukkit.configuration.file.FileConfiguration;
 | 
					import org.bukkit.configuration.file.FileConfiguration;
 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.bukkit.permissions.Permissible;
 | 
				
			||||||
import org.bukkit.plugin.PluginManager;
 | 
					import org.bukkit.plugin.PluginManager;
 | 
				
			||||||
import org.bukkit.plugin.java.JavaPlugin;
 | 
					import org.bukkit.plugin.java.JavaPlugin;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -224,4 +225,16 @@ public class OpenInv extends JavaPlugin
 | 
				
			|||||||
        player.sendMessage(ChatColor.GREEN + "/silentchest - Toggle silent chest function");
 | 
					        player.sendMessage(ChatColor.GREEN + "/silentchest - Toggle silent chest function");
 | 
				
			||||||
        player.sendMessage(ChatColor.GREEN + "   (aliases: sc, silent)");
 | 
					        player.sendMessage(ChatColor.GREEN + "   (aliases: sc, silent)");
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public static boolean hasPermission(Permissible player, String permission) {
 | 
				
			||||||
 | 
					        String[] parts = permission.split("\\.");
 | 
				
			||||||
 | 
					        String perm = "";
 | 
				
			||||||
 | 
					        for(int i = 0; i < parts.length; i++) {
 | 
				
			||||||
 | 
					            if(player.hasPermission(perm + "*")) {
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            perm += parts[i] + ".";
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return player.hasPermission(permission);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -24,26 +24,21 @@ import org.bukkit.event.EventHandler;
 | 
				
			|||||||
import org.bukkit.event.EventPriority;
 | 
					import org.bukkit.event.EventPriority;
 | 
				
			||||||
import org.bukkit.event.Listener;
 | 
					import org.bukkit.event.Listener;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class OpenInvEntityListener implements Listener
 | 
					public class OpenInvEntityListener implements Listener {
 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    @EventHandler(priority = EventPriority.LOWEST)
 | 
					    @EventHandler(priority = EventPriority.LOWEST)
 | 
				
			||||||
    public void onEntityDamage(EntityDamageEvent event)
 | 
					    public void onEntityDamage(EntityDamageEvent event) {
 | 
				
			||||||
    {
 | 
					        if (event instanceof EntityDamageByEntityEvent) {
 | 
				
			||||||
        if (event instanceof EntityDamageByEntityEvent)
 | 
					 | 
				
			||||||
        {
 | 
					 | 
				
			||||||
            EntityDamageByEntityEvent evt = (EntityDamageByEntityEvent) event;
 | 
					            EntityDamageByEntityEvent evt = (EntityDamageByEntityEvent) event;
 | 
				
			||||||
            Entity attacker = evt.getDamager();
 | 
					            Entity attacker = evt.getDamager();
 | 
				
			||||||
            Entity defender = evt.getEntity();
 | 
					            Entity defender = evt.getEntity();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!(attacker instanceof Player) || !(defender instanceof Player))
 | 
					            if (!(attacker instanceof Player) || !(defender instanceof Player)) {
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            Player player = (Player) attacker;
 | 
					            Player player = (Player) attacker;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem()) || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName())) || !player.hasPermission("OpenInv.openinv"))
 | 
					            if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem()) || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName())) || !OpenInv.hasPermission(player, "OpenInv.openinv")) {
 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,12 +27,12 @@ public class OpenInvInventoryListener implements Listener
 | 
				
			|||||||
    public void onInventoryClick(InventoryClickEvent event)
 | 
					    public void onInventoryClick(InventoryClickEvent event)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        // If this is the top inventory
 | 
					        // If this is the top inventory
 | 
				
			||||||
        if (event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot())
 | 
					        // if (event.getView().convertSlot(event.getRawSlot()) == event.getRawSlot())
 | 
				
			||||||
        {
 | 
					        // {
 | 
				
			||||||
        if (!OpenInv.inventoryAccess.check(event.getInventory(), event.getWhoClicked()))
 | 
					        if (!OpenInv.inventoryAccess.check(event.getInventory(), event.getWhoClicked()))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            event.setCancelled(true);
 | 
					            event.setCancelled(true);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        }
 | 
					        // }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
@@ -20,9 +20,9 @@ import org.bukkit.ChatColor;
 | 
				
			|||||||
import org.bukkit.block.Chest;
 | 
					import org.bukkit.block.Chest;
 | 
				
			||||||
import org.bukkit.block.Sign;
 | 
					import org.bukkit.block.Sign;
 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.bukkit.event.Event.Result;
 | 
				
			||||||
import org.bukkit.event.EventHandler;
 | 
					import org.bukkit.event.EventHandler;
 | 
				
			||||||
import org.bukkit.event.EventPriority;
 | 
					import org.bukkit.event.EventPriority;
 | 
				
			||||||
import org.bukkit.event.Event.Result;
 | 
					 | 
				
			||||||
import org.bukkit.event.Listener;
 | 
					import org.bukkit.event.Listener;
 | 
				
			||||||
import org.bukkit.event.block.Action;
 | 
					import org.bukkit.event.block.Action;
 | 
				
			||||||
import org.bukkit.event.player.PlayerInteractEvent;
 | 
					import org.bukkit.event.player.PlayerInteractEvent;
 | 
				
			||||||
@@ -70,15 +70,17 @@ public class OpenInvPlayerListener implements Listener
 | 
				
			|||||||
    @EventHandler(priority = EventPriority.MONITOR)
 | 
					    @EventHandler(priority = EventPriority.MONITOR)
 | 
				
			||||||
    public void onPlayerInteract(PlayerInteractEvent event)
 | 
					    public void onPlayerInteract(PlayerInteractEvent event)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
 | 
					        Player player = event.getPlayer();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.useInteractedBlock() == Result.DENY)
 | 
					        if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.useInteractedBlock() == Result.DENY)
 | 
				
			||||||
            return;
 | 
					            return;
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == org.bukkit.Material.ENDER_CHEST)
 | 
					        if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getType() == org.bukkit.Material.ENDER_CHEST)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (event.getPlayer().hasPermission(Permissions.PERM_SILENT) && OpenInv.GetPlayerSilentChestStatus(event.getPlayer().getName()))
 | 
					            if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.GetPlayerSilentChestStatus(player.getName()))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                event.setCancelled(true);
 | 
					                event.setCancelled(true);
 | 
				
			||||||
                event.getPlayer().openInventory(event.getPlayer().getEnderChest());
 | 
					                player.openInventory(player.getEnderChest());
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
@@ -90,20 +92,20 @@ public class OpenInvPlayerListener implements Listener
 | 
				
			|||||||
            int y = event.getClickedBlock().getY();
 | 
					            int y = event.getClickedBlock().getY();
 | 
				
			||||||
            int z = event.getClickedBlock().getZ();
 | 
					            int z = event.getClickedBlock().getZ();
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if (event.getPlayer().hasPermission(Permissions.PERM_SILENT) && OpenInv.GetPlayerSilentChestStatus(event.getPlayer().getName()))
 | 
					            if (OpenInv.hasPermission(player, Permissions.PERM_SILENT) && OpenInv.GetPlayerSilentChestStatus(player.getName()))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                silentchest = true;
 | 
					                silentchest = true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            if (event.getPlayer().hasPermission(Permissions.PERM_ANYCHEST) && OpenInv.GetPlayerAnyChestStatus(event.getPlayer().getName()))
 | 
					            if (OpenInv.hasPermission(player, Permissions.PERM_ANYCHEST) && OpenInv.GetPlayerAnyChestStatus(player.getName()))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                try
 | 
					                try
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    anychest = OpenInv.anySilentChest.IsAnyChestNeeded(event.getPlayer(), x, y, z);
 | 
					                    anychest = OpenInv.anySilentChest.IsAnyChestNeeded(player, x, y, z);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                catch (Exception e)
 | 
					                catch (Exception e)
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    event.getPlayer().sendMessage(ChatColor.RED + "Error while executing openinv. Unsupported CraftBukkit.");
 | 
					                    player.sendMessage(ChatColor.RED + "Error while executing openinv. Unsupported CraftBukkit.");
 | 
				
			||||||
                    e.printStackTrace();
 | 
					                    e.printStackTrace();
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -111,7 +113,7 @@ public class OpenInvPlayerListener implements Listener
 | 
				
			|||||||
            // If the anychest or silentchest is active
 | 
					            // If the anychest or silentchest is active
 | 
				
			||||||
            if (anychest || silentchest)
 | 
					            if (anychest || silentchest)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                if (!OpenInv.anySilentChest.ActivateChest(event.getPlayer(), anychest, silentchest, x, y, z))
 | 
					                if (!OpenInv.anySilentChest.ActivateChest(player, anychest, silentchest, x, y, z))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    event.setCancelled(true);
 | 
					                    event.setCancelled(true);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
@@ -120,11 +122,10 @@ public class OpenInvPlayerListener implements Listener
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getState() instanceof Sign)
 | 
					        if (event.getAction() == Action.RIGHT_CLICK_BLOCK && event.getClickedBlock().getState() instanceof Sign)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Player player = event.getPlayer();
 | 
					 | 
				
			||||||
            try
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                Sign sign = ((Sign) event.getClickedBlock().getState());
 | 
					                Sign sign = ((Sign) event.getClickedBlock().getState());
 | 
				
			||||||
                if (player.hasPermission(Permissions.PERM_OPENINV) && sign.getLine(0).equalsIgnoreCase("[openinv]"))
 | 
					                if (OpenInv.hasPermission(player, Permissions.PERM_OPENINV) && sign.getLine(0).equalsIgnoreCase("[openinv]"))
 | 
				
			||||||
                {
 | 
					                {
 | 
				
			||||||
                    String text = sign.getLine(1).trim() + sign.getLine(2).trim() + sign.getLine(3).trim();
 | 
					                    String text = sign.getLine(1).trim() + sign.getLine(2).trim() + sign.getLine(3).trim();
 | 
				
			||||||
                    player.performCommand("openinv " + text);
 | 
					                    player.performCommand("openinv " + text);
 | 
				
			||||||
@@ -139,10 +140,8 @@ public class OpenInvPlayerListener implements Listener
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
 | 
					        if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Player player = event.getPlayer();
 | 
					 | 
				
			||||||
            
 | 
					 | 
				
			||||||
            if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem()) || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
 | 
					            if (!(player.getItemInHand().getType().getId() == OpenInv.GetItemOpenInvItem()) || (!OpenInv.GetPlayerItemOpenInvStatus(player.getName()))
 | 
				
			||||||
                    || !player.hasPermission(Permissions.PERM_OPENINV))
 | 
					                    || !OpenInv.hasPermission(player, Permissions.PERM_OPENINV))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return;
 | 
					                return;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,6 +9,7 @@ public class Permissions
 | 
				
			|||||||
    public static final String PERM_SILENT = "OpenInv.silent";
 | 
					    public static final String PERM_SILENT = "OpenInv.silent";
 | 
				
			||||||
    public static final String PERM_ANYCHEST = "OpenInv.anychest";
 | 
					    public static final String PERM_ANYCHEST = "OpenInv.anychest";
 | 
				
			||||||
    public static final String PERM_ENDERCHEST = "OpenInv.openender";
 | 
					    public static final String PERM_ENDERCHEST = "OpenInv.openender";
 | 
				
			||||||
 | 
					    public static final String PERM_ENDERCHEST_ALL = "OpenInv.openenderall";
 | 
				
			||||||
    public static final String PERM_SEARCH = "OpenInv.search";
 | 
					    public static final String PERM_SEARCH = "OpenInv.search";
 | 
				
			||||||
    public static final String PERM_EDITINV = "OpenInv.editinv";
 | 
					    public static final String PERM_EDITINV = "OpenInv.editinv";
 | 
				
			||||||
    public static final String PERM_EDITENDER = "OpenInv.editender";
 | 
					    public static final String PERM_EDITENDER = "OpenInv.editender";
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,7 +39,7 @@ public class AnyChestPluginCommand implements CommandExecutor
 | 
				
			|||||||
            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
					            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!sender.hasPermission(Permissions.PERM_ANYCHEST))
 | 
					        if (!OpenInv.hasPermission(sender, Permissions.PERM_ANYCHEST))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            sender.sendMessage(ChatColor.RED + "You do not have permission to use anychest.");
 | 
					            sender.sendMessage(ChatColor.RED + "You do not have permission to use anychest.");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,7 +47,7 @@ public class OpenEnderPluginCommand implements CommandExecutor
 | 
				
			|||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        if (!sender.hasPermission(Permissions.PERM_ENDERCHEST))
 | 
					        if (!OpenInv.hasPermission(sender, Permissions.PERM_ENDERCHEST))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            sender.sendMessage(ChatColor.RED + "You do not have permission to access player enderchest");
 | 
					            sender.sendMessage(ChatColor.RED + "You do not have permission to access player enderchest");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
@@ -108,6 +108,12 @@ public class OpenEnderPluginCommand implements CommandExecutor
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        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
 | 
					        // Record the target
 | 
				
			||||||
        history = target.getName();
 | 
					        history = target.getName();
 | 
				
			||||||
        openEnderHistory.put(player, history);
 | 
					        openEnderHistory.put(player, history);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,7 @@ public class OpenInvPluginCommand implements CommandExecutor
 | 
				
			|||||||
            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
					            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!sender.hasPermission(Permissions.PERM_OPENINV))
 | 
					        if (!OpenInv.hasPermission(sender, Permissions.PERM_OPENINV))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
 | 
					            sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
@@ -103,21 +103,21 @@ public class OpenInvPluginCommand implements CommandExecutor
 | 
				
			|||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // Permissions checks
 | 
					        // Permissions checks
 | 
				
			||||||
        if (!player.hasPermission(Permissions.PERM_OVERRIDE) && target.hasPermission(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!");
 | 
					            sender.sendMessage(ChatColor.RED + target.getDisplayName() + "'s inventory is protected!");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // Crosswork check
 | 
					        // Crosswork check
 | 
				
			||||||
        if ((!player.hasPermission(Permissions.PERM_CROSSWORLD) && !player.hasPermission(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!");
 | 
					            sender.sendMessage(ChatColor.RED + target.getDisplayName() + " is not in your world!");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
        // Self-open check
 | 
					        // Self-open check
 | 
				
			||||||
        if (!player.hasPermission(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.");
 | 
					            sender.sendMessage(ChatColor.RED + "You're not allowed to openinv yourself.");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -24,6 +24,7 @@ import org.bukkit.command.CommandExecutor;
 | 
				
			|||||||
import org.bukkit.command.CommandSender;
 | 
					import org.bukkit.command.CommandSender;
 | 
				
			||||||
import org.bukkit.entity.Player;
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
public class SearchInvPluginCommand implements CommandExecutor
 | 
					public class SearchInvPluginCommand implements CommandExecutor
 | 
				
			||||||
@@ -37,7 +38,7 @@ public class SearchInvPluginCommand implements CommandExecutor
 | 
				
			|||||||
    {
 | 
					    {
 | 
				
			||||||
        if (sender instanceof Player)
 | 
					        if (sender instanceof Player)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!sender.hasPermission(Permissions.PERM_SEARCH))
 | 
					            if (!OpenInv.hasPermission(sender, Permissions.PERM_SEARCH))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
 | 
					                sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,7 +39,7 @@ public class SilentChestPluginCommand implements CommandExecutor
 | 
				
			|||||||
            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
					            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!sender.hasPermission(Permissions.PERM_SILENT))
 | 
					        if (!OpenInv.hasPermission(sender, Permissions.PERM_SILENT))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            sender.sendMessage(ChatColor.RED + "You do not have permission to use silent chest.");
 | 
					            sender.sendMessage(ChatColor.RED + "You do not have permission to use silent chest.");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -36,7 +36,7 @@ public class ToggleOpenInvPluginCommand implements CommandExecutor
 | 
				
			|||||||
            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
					            sender.sendMessage(ChatColor.RED + "You can't use this from the console.");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (!sender.hasPermission(Permissions.PERM_OPENINV))
 | 
					        if (!OpenInv.hasPermission(sender, Permissions.PERM_OPENINV))
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
 | 
					            sender.sendMessage(ChatColor.RED + "You do not have permission to access player inventories");
 | 
				
			||||||
            return true;
 | 
					            return true;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ package com.lishid.openinv.internal.craftbukkit;
 | 
				
			|||||||
import org.bukkit.entity.HumanEntity;
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
import org.bukkit.inventory.Inventory;
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
import com.lishid.openinv.internal.IInventoryAccess;
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +35,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (inv instanceof SpecialPlayerInventory)
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITINV))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -42,7 +43,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        else if (inv instanceof SpecialEnderChest)
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITENDER))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ package com.lishid.openinv.internal.v1_4_5;
 | 
				
			|||||||
import org.bukkit.entity.HumanEntity;
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
import org.bukkit.inventory.Inventory;
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
import com.lishid.openinv.internal.IInventoryAccess;
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +35,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (inv instanceof SpecialPlayerInventory)
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITINV))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -42,7 +43,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        else if (inv instanceof SpecialEnderChest)
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITENDER))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ package com.lishid.openinv.internal.v1_4_6;
 | 
				
			|||||||
import org.bukkit.entity.HumanEntity;
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
import org.bukkit.inventory.Inventory;
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
import com.lishid.openinv.internal.IInventoryAccess;
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +35,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (inv instanceof SpecialPlayerInventory)
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITINV))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -42,7 +43,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        else if (inv instanceof SpecialEnderChest)
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITENDER))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ package com.lishid.openinv.internal.v1_4_R1;
 | 
				
			|||||||
import org.bukkit.entity.HumanEntity;
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
import org.bukkit.inventory.Inventory;
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
import com.lishid.openinv.internal.IInventoryAccess;
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +35,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (inv instanceof SpecialPlayerInventory)
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITINV))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -42,7 +43,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        else if (inv instanceof SpecialEnderChest)
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITENDER))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ package com.lishid.openinv.internal.v1_5_R2;
 | 
				
			|||||||
import org.bukkit.entity.HumanEntity;
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
import org.bukkit.inventory.Inventory;
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
import com.lishid.openinv.internal.IInventoryAccess;
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +35,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (inv instanceof SpecialPlayerInventory)
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITINV))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -42,7 +43,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        else if (inv instanceof SpecialEnderChest)
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITENDER))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ package com.lishid.openinv.internal.v1_5_R3;
 | 
				
			|||||||
import org.bukkit.entity.HumanEntity;
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
import org.bukkit.inventory.Inventory;
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
import com.lishid.openinv.internal.IInventoryAccess;
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +35,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (inv instanceof SpecialPlayerInventory)
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITINV))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -42,7 +43,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        else if (inv instanceof SpecialEnderChest)
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITENDER))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -19,6 +19,7 @@ package com.lishid.openinv.internal.v1_6_R1;
 | 
				
			|||||||
import org.bukkit.entity.HumanEntity;
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
import org.bukkit.inventory.Inventory;
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
import com.lishid.openinv.Permissions;
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
import com.lishid.openinv.internal.IInventoryAccess;
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -34,7 +35,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        if (inv instanceof SpecialPlayerInventory)
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITINV))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -42,7 +43,7 @@ public class InventoryAccess implements IInventoryAccess
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        else if (inv instanceof SpecialEnderChest)
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            if (!player.hasPermission(Permissions.PERM_EDITENDER))
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                return false;
 | 
					                return false;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										136
									
								
								src/com/lishid/openinv/internal/v1_6_R2/AnySilentChest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								src/com/lishid/openinv/internal/v1_6_R2/AnySilentChest.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,136 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.lang.reflect.Field;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.ChatColor;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IAnySilentChest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R2.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R2.entity.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class AnySilentChest implements IAnySilentChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public boolean IsAnyChestNeeded(Player p, int x, int y, int z)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
 | 
				
			||||||
 | 
					        EntityPlayer player = ((CraftPlayer) p).getHandle();
 | 
				
			||||||
 | 
					        World world = player.world;
 | 
				
			||||||
 | 
					        // If block on top
 | 
				
			||||||
 | 
					        if (world.t(x, y + 1, z))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        int id = world.getTypeId(x, y, z);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // If block next to chest is chest and has a block on top
 | 
				
			||||||
 | 
					        if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        EntityPlayer player = ((CraftPlayer) p).getHandle();
 | 
				
			||||||
 | 
					        World world = player.world;
 | 
				
			||||||
 | 
					        Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
 | 
				
			||||||
 | 
					        if (chest == null)
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        int id = world.getTypeId(x, y, z);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!anychest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (world.t(x, y + 1, z))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (world.getTypeId(x - 1, y, z) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
 | 
				
			||||||
 | 
					        if (world.getTypeId(x + 1, y, z) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
 | 
				
			||||||
 | 
					        if (world.getTypeId(x, y, z - 1) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
 | 
				
			||||||
 | 
					        if (world.getTypeId(x, y, z + 1) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        boolean returnValue = true;
 | 
				
			||||||
 | 
					        if (!silentchest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            player.openContainer((IInventory) chest);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int windowId = 0;
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Field windowID = player.getClass().getDeclaredField("containerCounter");
 | 
				
			||||||
 | 
					                    windowID.setAccessible(true);
 | 
				
			||||||
 | 
					                    windowId = windowID.getInt(player);
 | 
				
			||||||
 | 
					                    windowId = windowId % 100 + 1;
 | 
				
			||||||
 | 
					                    windowID.setInt(player, windowId);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (NoSuchFieldException e)
 | 
				
			||||||
 | 
					                {}
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                player.playerConnection.sendPacket(new Packet100OpenWindow(windowId, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize(), true));
 | 
				
			||||||
 | 
					                player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
 | 
				
			||||||
 | 
					                player.activeContainer.windowId = windowId;
 | 
				
			||||||
 | 
					                player.activeContainer.addSlotListener(player);
 | 
				
			||||||
 | 
					                if (OpenInv.NotifySilentChest())
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    p.sendMessage("You are opening a chest silently.");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                returnValue = false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception e)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (anychest && OpenInv.NotifyAnyChest())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            p.sendMessage("You are opening a blocked chest.");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return returnValue;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										54
									
								
								src/com/lishid/openinv/internal/v1_6_R2/InventoryAccess.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/com/lishid/openinv/internal/v1_6_R2/InventoryAccess.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R2.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R2.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class InventoryAccess implements IInventoryAccess
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public boolean check(Inventory inventory, HumanEntity player)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        IInventory inv = ((CraftInventory) inventory).getInventory();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										110
									
								
								src/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								src/com/lishid/openinv/internal/v1_6_R2/PlayerDataManager.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					import java.util.Arrays;
 | 
				
			||||||
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IPlayerDataManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R2.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R2.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class PlayerDataManager implements IPlayerDataManager
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public Player loadPlayer(String name)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Default player folder
 | 
				
			||||||
 | 
					            File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
 | 
				
			||||||
 | 
					            if (!playerfolder.exists())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if (playername == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            // Create an entity to load the player data
 | 
				
			||||||
 | 
					            EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager((World) server.getWorldServer(0)));
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            // Get the bukkit entity
 | 
				
			||||||
 | 
					            Player target = (entity == null) ? null : entity.getBukkitEntity();
 | 
				
			||||||
 | 
					            if (target != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // Load data
 | 
				
			||||||
 | 
					                target.loadData();
 | 
				
			||||||
 | 
					                // Return the entity
 | 
				
			||||||
 | 
					                return target;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (Exception e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OpenInv.log(e);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @author Balor (aka Antoine Aflalo)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private static String matchUser(final Collection<File> container, final String search)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        String found = null;
 | 
				
			||||||
 | 
					        if (search == null)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return found;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        final String lowerSearch = search.toLowerCase();
 | 
				
			||||||
 | 
					        int delta = Integer.MAX_VALUE;
 | 
				
			||||||
 | 
					        for (final File file : container)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            final String filename = file.getName();
 | 
				
			||||||
 | 
					            final String str = filename.substring(0, filename.length() - 4);
 | 
				
			||||||
 | 
					            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            final int curDelta = str.length() - lowerSearch.length();
 | 
				
			||||||
 | 
					            if (curDelta < delta)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                found = str;
 | 
				
			||||||
 | 
					                delta = curDelta;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (curDelta == 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return found;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R2.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SilentContainerChest extends ContainerChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public IInventory inv;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(i1, i2);
 | 
				
			||||||
 | 
					        inv = i2;
 | 
				
			||||||
 | 
					        // close signal
 | 
				
			||||||
 | 
					        inv.g();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void b(EntityHuman paramEntityHuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Don't send close signal twice, might screw up
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										148
									
								
								src/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								src/com/lishid/openinv/internal/v1_6_R2/SpecialEnderChest.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,148 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.lang.reflect.Field;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.ISpecialEnderChest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.InventoryHolder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R2.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R2.entity.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R2.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public List<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)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
 | 
				
			||||||
 | 
					        CraftPlayer player = (CraftPlayer) p;
 | 
				
			||||||
 | 
					        this.enderChest = player.getHandle().getEnderChest();
 | 
				
			||||||
 | 
					        this.owner = player;
 | 
				
			||||||
 | 
					        this.items = enderChest.getContents();
 | 
				
			||||||
 | 
					        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public Inventory getBukkitInventory()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return inventory;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void InventoryRemovalCheck()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        owner.saveData();
 | 
				
			||||||
 | 
					        if (transaction.isEmpty() && !playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void 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)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            p.saveData();
 | 
				
			||||||
 | 
					            playerOnline = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void PlayerGoOffline()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        playerOnline = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public ItemStack[] getContents()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return this.items;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void onOpen(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        transaction.add(who);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void onClose(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        transaction.remove(who);
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public List<HumanEntity> getViewers()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return transaction;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public InventoryHolder getOwner()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return this.owner;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void setMaxStackSize(int size)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        maxStack = size;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public int getMaxStackSize()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return maxStack;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public boolean a(EntityHuman entityhuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void startOpen()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void f()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void update()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        enderChest.update();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,297 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.ISpecialPlayerInventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R2.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R2.entity.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R2.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    CraftPlayer owner;
 | 
				
			||||||
 | 
					    public boolean playerOnline = false;
 | 
				
			||||||
 | 
					    private ItemStack[] extra = new ItemStack[5];
 | 
				
			||||||
 | 
					    private CraftInventory inventory = new CraftInventory(this);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public SpecialPlayerInventory(Player p, Boolean online)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(((CraftPlayer) p).getHandle());
 | 
				
			||||||
 | 
					        this.owner = ((CraftPlayer) p);
 | 
				
			||||||
 | 
					        this.playerOnline = online;
 | 
				
			||||||
 | 
					        this.items = player.inventory.items;
 | 
				
			||||||
 | 
					        this.armor = player.inventory.armor;
 | 
				
			||||||
 | 
					        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Inventory getBukkitInventory()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return inventory;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void InventoryRemovalCheck()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        owner.saveData();
 | 
				
			||||||
 | 
					        if (transaction.isEmpty() && !playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void PlayerGoOnline(Player player)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (!playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            CraftPlayer p = (CraftPlayer) player;
 | 
				
			||||||
 | 
					            p.getHandle().inventory.items = this.items;
 | 
				
			||||||
 | 
					            p.getHandle().inventory.armor = this.armor;
 | 
				
			||||||
 | 
					            p.saveData();
 | 
				
			||||||
 | 
					            playerOnline = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void PlayerGoOffline()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        playerOnline = false;
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onClose(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super.onClose(who);
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack[] getContents()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] C = new ItemStack[getSize()];
 | 
				
			||||||
 | 
					        System.arraycopy(items, 0, C, 0, items.length);
 | 
				
			||||||
 | 
					        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
				
			||||||
 | 
					        return C;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getSize()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return super.getSize() + 5;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack getItem(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return is[i];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack splitStack(int i, int j)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (is[i] != null)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ItemStack itemstack;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if (is[i].count <= j)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                itemstack = is[i];
 | 
				
			||||||
 | 
					                is[i] = null;
 | 
				
			||||||
 | 
					                return itemstack;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                itemstack = is[i].a(j);
 | 
				
			||||||
 | 
					                if (is[i].count == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    is[i] = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                return itemstack;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack splitWithoutUpdate(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (is[i] != null)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ItemStack itemstack = is[i];
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            is[i] = null;
 | 
				
			||||||
 | 
					            return itemstack;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setItem(int i, ItemStack itemstack)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // Effects
 | 
				
			||||||
 | 
					        if (is == this.extra)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            owner.getHandle().drop(itemstack);
 | 
				
			||||||
 | 
					            itemstack = null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        is[i] = itemstack;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        owner.getHandle().defaultContainer.b();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private int getReversedItemSlotNum(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (i >= 27)
 | 
				
			||||||
 | 
					            return i - 27;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            return i + 9;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private int getReversedArmorSlotNum(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (i == 0)
 | 
				
			||||||
 | 
					            return 3;
 | 
				
			||||||
 | 
					        if (i == 1)
 | 
				
			||||||
 | 
					            return 2;
 | 
				
			||||||
 | 
					        if (i == 2)
 | 
				
			||||||
 | 
					            return 1;
 | 
				
			||||||
 | 
					        if (i == 3)
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            return i;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (player.getName().length() > 16)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return player.getName().substring(0, 16);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return player.getName();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean a(EntityHuman entityhuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										136
									
								
								src/com/lishid/openinv/internal/v1_6_R3/AnySilentChest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								src/com/lishid/openinv/internal/v1_6_R3/AnySilentChest.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,136 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.lang.reflect.Field;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.ChatColor;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IAnySilentChest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R3.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R3.entity.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class AnySilentChest implements IAnySilentChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public boolean IsAnyChestNeeded(Player p, int x, int y, int z)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
 | 
				
			||||||
 | 
					        EntityPlayer player = ((CraftPlayer) p).getHandle();
 | 
				
			||||||
 | 
					        World world = player.world;
 | 
				
			||||||
 | 
					        // If block on top
 | 
				
			||||||
 | 
					        if (world.t(x, y + 1, z))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        int id = world.getTypeId(x, y, z);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // If block next to chest is chest and has a block on top
 | 
				
			||||||
 | 
					        if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        EntityPlayer player = ((CraftPlayer) p).getHandle();
 | 
				
			||||||
 | 
					        World world = player.world;
 | 
				
			||||||
 | 
					        Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
 | 
				
			||||||
 | 
					        if (chest == null)
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        int id = world.getTypeId(x, y, z);
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!anychest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (world.t(x, y + 1, z))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((world.getTypeId(x - 1, y, z) == id) && (world.t(x - 1, y + 1, z)))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((world.getTypeId(x + 1, y, z) == id) && (world.t(x + 1, y + 1, z)))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((world.getTypeId(x, y, z - 1) == id) && (world.t(x, y + 1, z - 1)))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((world.getTypeId(x, y, z + 1) == id) && (world.t(x, y + 1, z + 1)))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (world.getTypeId(x - 1, y, z) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
 | 
				
			||||||
 | 
					        if (world.getTypeId(x + 1, y, z) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
 | 
				
			||||||
 | 
					        if (world.getTypeId(x, y, z - 1) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
 | 
				
			||||||
 | 
					        if (world.getTypeId(x, y, z + 1) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        boolean returnValue = true;
 | 
				
			||||||
 | 
					        if (!silentchest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            player.openContainer((IInventory) chest);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int windowId = 0;
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Field windowID = player.getClass().getDeclaredField("containerCounter");
 | 
				
			||||||
 | 
					                    windowID.setAccessible(true);
 | 
				
			||||||
 | 
					                    windowId = windowID.getInt(player);
 | 
				
			||||||
 | 
					                    windowId = windowId % 100 + 1;
 | 
				
			||||||
 | 
					                    windowID.setInt(player, windowId);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (NoSuchFieldException e)
 | 
				
			||||||
 | 
					                {}
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                player.playerConnection.sendPacket(new Packet100OpenWindow(windowId, 0, ((IInventory) chest).getName(), ((IInventory) chest).getSize(), true));
 | 
				
			||||||
 | 
					                player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
 | 
				
			||||||
 | 
					                player.activeContainer.windowId = windowId;
 | 
				
			||||||
 | 
					                player.activeContainer.addSlotListener(player);
 | 
				
			||||||
 | 
					                if (OpenInv.NotifySilentChest())
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    p.sendMessage("You are opening a chest silently.");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                returnValue = false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception e)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (anychest && OpenInv.NotifyAnyChest())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            p.sendMessage("You are opening a blocked chest.");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return returnValue;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										54
									
								
								src/com/lishid/openinv/internal/v1_6_R3/InventoryAccess.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/com/lishid/openinv/internal/v1_6_R3/InventoryAccess.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R3.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R3.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class InventoryAccess implements IInventoryAccess
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public boolean check(Inventory inventory, HumanEntity player)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        IInventory inv = ((CraftInventory) inventory).getInventory();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										110
									
								
								src/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										110
									
								
								src/com/lishid/openinv/internal/v1_6_R3/PlayerDataManager.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,110 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					import java.util.Arrays;
 | 
				
			||||||
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IPlayerDataManager;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R3.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R3.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class PlayerDataManager implements IPlayerDataManager
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public Player loadPlayer(String name)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            // Default player folder
 | 
				
			||||||
 | 
					            File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
 | 
				
			||||||
 | 
					            if (!playerfolder.exists())
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if (playername == null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            // Create an entity to load the player data
 | 
				
			||||||
 | 
					            EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), playername, new PlayerInteractManager((World) server.getWorldServer(0)));
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            // Get the bukkit entity
 | 
				
			||||||
 | 
					            Player target = (entity == null) ? null : entity.getBukkitEntity();
 | 
				
			||||||
 | 
					            if (target != null)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                // Load data
 | 
				
			||||||
 | 
					                target.loadData();
 | 
				
			||||||
 | 
					                // Return the entity
 | 
				
			||||||
 | 
					                return target;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (Exception e)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OpenInv.log(e);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @author Balor (aka Antoine Aflalo)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private static String matchUser(final Collection<File> container, final String search)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        String found = null;
 | 
				
			||||||
 | 
					        if (search == null)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return found;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        final String lowerSearch = search.toLowerCase();
 | 
				
			||||||
 | 
					        int delta = Integer.MAX_VALUE;
 | 
				
			||||||
 | 
					        for (final File file : container)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            final String filename = file.getName();
 | 
				
			||||||
 | 
					            final String str = filename.substring(0, filename.length() - 4);
 | 
				
			||||||
 | 
					            if (!str.toLowerCase().startsWith(lowerSearch))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            final int curDelta = str.length() - lowerSearch.length();
 | 
				
			||||||
 | 
					            if (curDelta < delta)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                found = str;
 | 
				
			||||||
 | 
					                delta = curDelta;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (curDelta == 0)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return found;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R3.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SilentContainerChest extends ContainerChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public IInventory inv;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(i1, i2);
 | 
				
			||||||
 | 
					        inv = i2;
 | 
				
			||||||
 | 
					        // close signal
 | 
				
			||||||
 | 
					        inv.g();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void b(EntityHuman paramEntityHuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Don't send close signal twice, might screw up
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										148
									
								
								src/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								src/com/lishid/openinv/internal/v1_6_R3/SpecialEnderChest.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,148 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.lang.reflect.Field;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.ISpecialEnderChest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.InventoryHolder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R3.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R3.entity.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R3.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public List<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)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(((CraftPlayer) p).getHandle().getEnderChest().getName(), ((CraftPlayer) p).getHandle().getEnderChest().c(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
 | 
				
			||||||
 | 
					        CraftPlayer player = (CraftPlayer) p;
 | 
				
			||||||
 | 
					        this.enderChest = player.getHandle().getEnderChest();
 | 
				
			||||||
 | 
					        this.owner = player;
 | 
				
			||||||
 | 
					        this.items = enderChest.getContents();
 | 
				
			||||||
 | 
					        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public Inventory getBukkitInventory()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return inventory;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void InventoryRemovalCheck()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        owner.saveData();
 | 
				
			||||||
 | 
					        if (transaction.isEmpty() && !playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void 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)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            p.saveData();
 | 
				
			||||||
 | 
					            playerOnline = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void PlayerGoOffline()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        playerOnline = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public ItemStack[] getContents()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return this.items;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void onOpen(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        transaction.add(who);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void onClose(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        transaction.remove(who);
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public List<HumanEntity> getViewers()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return transaction;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public InventoryHolder getOwner()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return this.owner;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void setMaxStackSize(int size)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        maxStack = size;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public int getMaxStackSize()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return maxStack;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public boolean a(EntityHuman entityhuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void startOpen()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void f()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void update()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        enderChest.update();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,297 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_6_R3;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.ISpecialPlayerInventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_6_R3.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R3.entity.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_6_R3.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    CraftPlayer owner;
 | 
				
			||||||
 | 
					    public boolean playerOnline = false;
 | 
				
			||||||
 | 
					    private ItemStack[] extra = new ItemStack[5];
 | 
				
			||||||
 | 
					    private CraftInventory inventory = new CraftInventory(this);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public SpecialPlayerInventory(Player p, Boolean online)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(((CraftPlayer) p).getHandle());
 | 
				
			||||||
 | 
					        this.owner = ((CraftPlayer) p);
 | 
				
			||||||
 | 
					        this.playerOnline = online;
 | 
				
			||||||
 | 
					        this.items = player.inventory.items;
 | 
				
			||||||
 | 
					        this.armor = player.inventory.armor;
 | 
				
			||||||
 | 
					        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Inventory getBukkitInventory()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return inventory;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void InventoryRemovalCheck()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        owner.saveData();
 | 
				
			||||||
 | 
					        if (transaction.isEmpty() && !playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void PlayerGoOnline(Player player)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (!playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            CraftPlayer p = (CraftPlayer) player;
 | 
				
			||||||
 | 
					            p.getHandle().inventory.items = this.items;
 | 
				
			||||||
 | 
					            p.getHandle().inventory.armor = this.armor;
 | 
				
			||||||
 | 
					            p.saveData();
 | 
				
			||||||
 | 
					            playerOnline = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void PlayerGoOffline()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        playerOnline = false;
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onClose(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super.onClose(who);
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack[] getContents()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] C = new ItemStack[getSize()];
 | 
				
			||||||
 | 
					        System.arraycopy(items, 0, C, 0, items.length);
 | 
				
			||||||
 | 
					        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
				
			||||||
 | 
					        return C;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getSize()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return super.getSize() + 5;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack getItem(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return is[i];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack splitStack(int i, int j)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (is[i] != null)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ItemStack itemstack;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if (is[i].count <= j)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                itemstack = is[i];
 | 
				
			||||||
 | 
					                is[i] = null;
 | 
				
			||||||
 | 
					                return itemstack;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                itemstack = is[i].a(j);
 | 
				
			||||||
 | 
					                if (is[i].count == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    is[i] = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                return itemstack;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack splitWithoutUpdate(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (is[i] != null)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ItemStack itemstack = is[i];
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            is[i] = null;
 | 
				
			||||||
 | 
					            return itemstack;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setItem(int i, ItemStack itemstack)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // Effects
 | 
				
			||||||
 | 
					        if (is == this.extra)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            owner.getHandle().drop(itemstack);
 | 
				
			||||||
 | 
					            itemstack = null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        is[i] = itemstack;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        owner.getHandle().defaultContainer.b();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private int getReversedItemSlotNum(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (i >= 27)
 | 
				
			||||||
 | 
					            return i - 27;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            return i + 9;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private int getReversedArmorSlotNum(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (i == 0)
 | 
				
			||||||
 | 
					            return 3;
 | 
				
			||||||
 | 
					        if (i == 1)
 | 
				
			||||||
 | 
					            return 2;
 | 
				
			||||||
 | 
					        if (i == 2)
 | 
				
			||||||
 | 
					            return 1;
 | 
				
			||||||
 | 
					        if (i == 3)
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            return i;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (player.getName().length() > 16)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return player.getName().substring(0, 16);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return player.getName();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean a(EntityHuman entityhuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										136
									
								
								src/com/lishid/openinv/internal/v1_7_R1/AnySilentChest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										136
									
								
								src/com/lishid/openinv/internal/v1_7_R1/AnySilentChest.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,136 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_7_R1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.lang.reflect.Field;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.ChatColor;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IAnySilentChest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_7_R1.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_7_R1.entity.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class AnySilentChest implements IAnySilentChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public boolean IsAnyChestNeeded(Player p, int x, int y, int z)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // FOR REFERENCE, LOOK AT net.minecraft.server.BlockChest
 | 
				
			||||||
 | 
					        EntityPlayer player = ((CraftPlayer) p).getHandle();
 | 
				
			||||||
 | 
					        World world = player.world;
 | 
				
			||||||
 | 
					        // If block on top
 | 
				
			||||||
 | 
					        if (world.getType(x, y + 1, z).c())
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        int id = Block.b(world.getType(x, y, z));
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // If block next to chest is chest and has a block on top
 | 
				
			||||||
 | 
					        if ((Block.b(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((Block.b(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((Block.b(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        if ((Block.b(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public boolean ActivateChest(Player p, boolean anychest, boolean silentchest, int x, int y, int z)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        EntityPlayer player = ((CraftPlayer) p).getHandle();
 | 
				
			||||||
 | 
					        World world = player.world;
 | 
				
			||||||
 | 
					        Object chest = (TileEntityChest) world.getTileEntity(x, y, z);
 | 
				
			||||||
 | 
					        if (chest == null)
 | 
				
			||||||
 | 
					            return true;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        int id = Block.b(world.getType(x, y, z));
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (!anychest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (world.getType(x, y + 1, z).c())
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((Block.b(world.getType(x - 1, y, z)) == id) && (world.getType(x - 1, y + 1, z).c()))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((Block.b(world.getType(x + 1, y, z)) == id) && (world.getType(x + 1, y + 1, z).c()))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((Block.b(world.getType(x, y, z - 1)) == id) && (world.getType(x, y + 1, z - 1).c()))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					            if ((Block.b(world.getType(x, y, z + 1)) == id) && (world.getType(x, y + 1, z + 1).c()))
 | 
				
			||||||
 | 
					                return true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (Block.b(world.getType(x - 1, y, z)) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
 | 
				
			||||||
 | 
					        if (Block.b(world.getType(x + 1, y, z)) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
 | 
				
			||||||
 | 
					        if (Block.b(world.getType(x, y, z - 1)) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
 | 
				
			||||||
 | 
					        if (Block.b(world.getType(x, y, z + 1)) == id)
 | 
				
			||||||
 | 
					            chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        boolean returnValue = true;
 | 
				
			||||||
 | 
					        if (!silentchest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            player.openContainer((IInventory) chest);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                int windowId = 0;
 | 
				
			||||||
 | 
					                try
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    Field windowID = player.getClass().getDeclaredField("containerCounter");
 | 
				
			||||||
 | 
					                    windowID.setAccessible(true);
 | 
				
			||||||
 | 
					                    windowId = windowID.getInt(player);
 | 
				
			||||||
 | 
					                    windowId = windowId % 100 + 1;
 | 
				
			||||||
 | 
					                    windowID.setInt(player, windowId);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                catch (NoSuchFieldException e)
 | 
				
			||||||
 | 
					                {}
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, 0, ((IInventory) chest).getInventoryName(), ((IInventory) chest).getSize(), true));
 | 
				
			||||||
 | 
					                player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) chest));
 | 
				
			||||||
 | 
					                player.activeContainer.windowId = windowId;
 | 
				
			||||||
 | 
					                player.activeContainer.addSlotListener(player);
 | 
				
			||||||
 | 
					                if (OpenInv.NotifySilentChest())
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    p.sendMessage("You are opening a chest silently.");
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                returnValue = false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            catch (Exception e)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                e.printStackTrace();
 | 
				
			||||||
 | 
					                p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (anychest && OpenInv.NotifyAnyChest())
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            p.sendMessage("You are opening a blocked chest.");
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return returnValue;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										54
									
								
								src/com/lishid/openinv/internal/v1_7_R1/InventoryAccess.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								src/com/lishid/openinv/internal/v1_7_R1/InventoryAccess.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,54 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_7_R1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.Permissions;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IInventoryAccess;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_7_R1.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_7_R1.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class InventoryAccess implements IInventoryAccess
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public boolean check(Inventory inventory, HumanEntity player)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        IInventory inv = ((CraftInventory) inventory).getInventory();
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (inv instanceof SpecialPlayerInventory)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        else if (inv instanceof SpecialEnderChest)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            if (!OpenInv.hasPermission(player, Permissions.PERM_EDITENDER))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                return false;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,99 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_7_R1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.io.File;
 | 
				
			||||||
 | 
					import java.util.Arrays;
 | 
				
			||||||
 | 
					import java.util.Collection;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.Bukkit;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.IPlayerDataManager;
 | 
				
			||||||
 | 
					import net.minecraft.util.com.mojang.authlib.GameProfile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_7_R1.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_7_R1.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class PlayerDataManager implements IPlayerDataManager {
 | 
				
			||||||
 | 
					    public Player loadPlayer(String name) {
 | 
				
			||||||
 | 
					        try {
 | 
				
			||||||
 | 
					            // Default player folder
 | 
				
			||||||
 | 
					            File playerfolder = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "players");
 | 
				
			||||||
 | 
					            if (!playerfolder.exists()) {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            String playername = matchUser(Arrays.asList(playerfolder.listFiles()), name);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            if (playername == null) {
 | 
				
			||||||
 | 
					                return null;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            MinecraftServer server = ((CraftServer) Bukkit.getServer()).getServer();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            GameProfile profile = new GameProfile(null, playername);
 | 
				
			||||||
 | 
					            // Create an entity to load the player data
 | 
				
			||||||
 | 
					            EntityPlayer entity = new EntityPlayer(server, server.getWorldServer(0), profile, new PlayerInteractManager(server.getWorldServer(0)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // Get the bukkit entity
 | 
				
			||||||
 | 
					            Player target = (entity == null) ? null : entity.getBukkitEntity();
 | 
				
			||||||
 | 
					            if (target != null) {
 | 
				
			||||||
 | 
					                // Load data
 | 
				
			||||||
 | 
					                target.loadData();
 | 
				
			||||||
 | 
					                // Return the entity
 | 
				
			||||||
 | 
					                return target;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (Exception e) {
 | 
				
			||||||
 | 
					            OpenInv.log(e);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return null;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    /**
 | 
				
			||||||
 | 
					     * @author Balor (aka Antoine Aflalo)
 | 
				
			||||||
 | 
					     */
 | 
				
			||||||
 | 
					    private static String matchUser(final Collection<File> container, final String search) {
 | 
				
			||||||
 | 
					        String found = null;
 | 
				
			||||||
 | 
					        if (search == null) {
 | 
				
			||||||
 | 
					            return found;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        final String lowerSearch = search.toLowerCase();
 | 
				
			||||||
 | 
					        int delta = Integer.MAX_VALUE;
 | 
				
			||||||
 | 
					        for (final File file : container) {
 | 
				
			||||||
 | 
					            final String filename = file.getName();
 | 
				
			||||||
 | 
					            final String str = filename.substring(0, filename.length() - 4);
 | 
				
			||||||
 | 
					            if (!str.toLowerCase().startsWith(lowerSearch)) {
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            final int curDelta = str.length() - lowerSearch.length();
 | 
				
			||||||
 | 
					            if (curDelta < delta) {
 | 
				
			||||||
 | 
					                found = str;
 | 
				
			||||||
 | 
					                delta = curDelta;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            if (curDelta == 0) {
 | 
				
			||||||
 | 
					                break;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return found;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,39 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_7_R1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_7_R1.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SilentContainerChest extends ContainerChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public IInventory inv;
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public SilentContainerChest(IInventory i1, IInventory i2)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(i1, i2);
 | 
				
			||||||
 | 
					        inv = i2;
 | 
				
			||||||
 | 
					        // close signal
 | 
				
			||||||
 | 
					        inv.l_();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void b(EntityHuman paramEntityHuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        // Don't send close signal twice, might screw up
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
							
								
								
									
										148
									
								
								src/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										148
									
								
								src/com/lishid/openinv/internal/v1_7_R1/SpecialEnderChest.java
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,148 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_7_R1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import java.lang.reflect.Field;
 | 
				
			||||||
 | 
					import java.util.ArrayList;
 | 
				
			||||||
 | 
					import java.util.List;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.ISpecialEnderChest;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.HumanEntity;
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.InventoryHolder;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_7_R1.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_7_R1.entity.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_7_R1.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SpecialEnderChest extends InventorySubcontainer implements IInventory, ISpecialEnderChest
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    public List<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)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(((CraftPlayer) p).getHandle().getEnderChest().getInventoryName(), ((CraftPlayer) p).getHandle().getEnderChest().k_(), ((CraftPlayer) p).getHandle().getEnderChest().getSize());
 | 
				
			||||||
 | 
					        CraftPlayer player = (CraftPlayer) p;
 | 
				
			||||||
 | 
					        this.enderChest = player.getHandle().getEnderChest();
 | 
				
			||||||
 | 
					        this.owner = player;
 | 
				
			||||||
 | 
					        this.items = enderChest.getContents();
 | 
				
			||||||
 | 
					        OpenInv.enderChests.put(owner.getName().toLowerCase(), this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public Inventory getBukkitInventory()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return inventory;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void InventoryRemovalCheck()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        owner.saveData();
 | 
				
			||||||
 | 
					        if (transaction.isEmpty() && !playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OpenInv.enderChests.remove(owner.getName().toLowerCase());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void 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)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            p.saveData();
 | 
				
			||||||
 | 
					            playerOnline = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void PlayerGoOffline()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        playerOnline = false;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public ItemStack[] getContents()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return this.items;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void onOpen(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        transaction.add(who);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void onClose(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        transaction.remove(who);
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public List<HumanEntity> getViewers()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return transaction;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public InventoryHolder getOwner()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return this.owner;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void setMaxStackSize(int size)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        maxStack = size;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public int getMaxStackSize()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return maxStack;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public boolean a(EntityHuman entityhuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void startOpen()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void f()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public void update()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        enderChest.update();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -0,0 +1,297 @@
 | 
				
			|||||||
 | 
					/*
 | 
				
			||||||
 | 
					 * Copyright (C) 2011-2012 lishid.  All rights reserved.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is free software: you can redistribute it and/or modify
 | 
				
			||||||
 | 
					 * it under the terms of the GNU General Public License as published by
 | 
				
			||||||
 | 
					 * the Free Software Foundation,  version 3.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * This program is distributed in the hope that it will be useful,
 | 
				
			||||||
 | 
					 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
				
			||||||
 | 
					 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 | 
				
			||||||
 | 
					 * GNU General Public License for more details.
 | 
				
			||||||
 | 
					 * 
 | 
				
			||||||
 | 
					 * You should have received a copy of the GNU General Public License
 | 
				
			||||||
 | 
					 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					package com.lishid.openinv.internal.v1_7_R1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import org.bukkit.entity.Player;
 | 
				
			||||||
 | 
					import org.bukkit.inventory.Inventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import com.lishid.openinv.OpenInv;
 | 
				
			||||||
 | 
					import com.lishid.openinv.internal.ISpecialPlayerInventory;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					//Volatile
 | 
				
			||||||
 | 
					import net.minecraft.server.v1_7_R1.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_7_R1.entity.*;
 | 
				
			||||||
 | 
					import org.bukkit.craftbukkit.v1_7_R1.inventory.*;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					public class SpecialPlayerInventory extends PlayerInventory implements ISpecialPlayerInventory
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    CraftPlayer owner;
 | 
				
			||||||
 | 
					    public boolean playerOnline = false;
 | 
				
			||||||
 | 
					    private ItemStack[] extra = new ItemStack[5];
 | 
				
			||||||
 | 
					    private CraftInventory inventory = new CraftInventory(this);
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    public SpecialPlayerInventory(Player p, Boolean online)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super(((CraftPlayer) p).getHandle());
 | 
				
			||||||
 | 
					        this.owner = ((CraftPlayer) p);
 | 
				
			||||||
 | 
					        this.playerOnline = online;
 | 
				
			||||||
 | 
					        this.items = player.inventory.items;
 | 
				
			||||||
 | 
					        this.armor = player.inventory.armor;
 | 
				
			||||||
 | 
					        OpenInv.inventories.put(owner.getName().toLowerCase(), this);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public Inventory getBukkitInventory()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return inventory;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void InventoryRemovalCheck()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        owner.saveData();
 | 
				
			||||||
 | 
					        if (transaction.isEmpty() && !playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            OpenInv.inventories.remove(owner.getName().toLowerCase());
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void PlayerGoOnline(Player player)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (!playerOnline)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            CraftPlayer p = (CraftPlayer) player;
 | 
				
			||||||
 | 
					            p.getHandle().inventory.items = this.items;
 | 
				
			||||||
 | 
					            p.getHandle().inventory.armor = this.armor;
 | 
				
			||||||
 | 
					            p.saveData();
 | 
				
			||||||
 | 
					            playerOnline = true;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void PlayerGoOffline()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        playerOnline = false;
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void onClose(CraftHumanEntity who)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        super.onClose(who);
 | 
				
			||||||
 | 
					        this.InventoryRemovalCheck();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack[] getContents()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] C = new ItemStack[getSize()];
 | 
				
			||||||
 | 
					        System.arraycopy(items, 0, C, 0, items.length);
 | 
				
			||||||
 | 
					        System.arraycopy(items, 0, C, items.length, armor.length);
 | 
				
			||||||
 | 
					        return C;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public int getSize()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return super.getSize() + 5;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack getItem(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        return is[i];
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack splitStack(int i, int j)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (is[i] != null)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ItemStack itemstack;
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            if (is[i].count <= j)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                itemstack = is[i];
 | 
				
			||||||
 | 
					                is[i] = null;
 | 
				
			||||||
 | 
					                return itemstack;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            else
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                itemstack = is[i].a(j);
 | 
				
			||||||
 | 
					                if (is[i].count == 0)
 | 
				
			||||||
 | 
					                {
 | 
				
			||||||
 | 
					                    is[i] = null;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					                
 | 
				
			||||||
 | 
					                return itemstack;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public ItemStack splitWithoutUpdate(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (is[i] != null)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            ItemStack itemstack = is[i];
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            is[i] = null;
 | 
				
			||||||
 | 
					            return itemstack;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public void setItem(int i, ItemStack itemstack)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        ItemStack[] is = this.items;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.armor;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedItemSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        if (i >= is.length)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i -= is.length;
 | 
				
			||||||
 | 
					            is = this.extra;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        else if (is == this.armor)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            i = getReversedArmorSlotNum(i);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        // Effects
 | 
				
			||||||
 | 
					        if (is == this.extra)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            owner.getHandle().drop(itemstack, true);
 | 
				
			||||||
 | 
					            itemstack = null;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        is[i] = itemstack;
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        owner.getHandle().defaultContainer.b();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private int getReversedItemSlotNum(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (i >= 27)
 | 
				
			||||||
 | 
					            return i - 27;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            return i + 9;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private int getReversedArmorSlotNum(int i)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (i == 0)
 | 
				
			||||||
 | 
					            return 3;
 | 
				
			||||||
 | 
					        if (i == 1)
 | 
				
			||||||
 | 
					            return 2;
 | 
				
			||||||
 | 
					        if (i == 2)
 | 
				
			||||||
 | 
					            return 1;
 | 
				
			||||||
 | 
					        if (i == 3)
 | 
				
			||||||
 | 
					            return 0;
 | 
				
			||||||
 | 
					        else
 | 
				
			||||||
 | 
					            return i;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public String getInventoryName()
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        if (player.getName().length() > 16)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return player.getName().substring(0, 16);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        return player.getName();
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    @Override
 | 
				
			||||||
 | 
					    public boolean a(EntityHuman entityhuman)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        return true;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
name: OpenInv
 | 
					name: OpenInv
 | 
				
			||||||
main: com.lishid.openinv.OpenInv
 | 
					main: com.lishid.openinv.OpenInv
 | 
				
			||||||
version: 2.0.4
 | 
					version: 2.1.0
 | 
				
			||||||
author: lishid
 | 
					author: lishid
 | 
				
			||||||
description: >
 | 
					description: >
 | 
				
			||||||
             This plugin allows you to open a player's inventory as a chest and interact with it in real time.
 | 
					             This plugin allows you to open a player's inventory as a chest and interact with it in real time.
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user