From ae20712d712f6c2ce52232d4b80c54670db1220f Mon Sep 17 00:00:00 2001 From: lishid Date: Mon, 16 Jan 2012 22:18:35 -0500 Subject: [PATCH] Latest version 1.7.2 --- src/lishid/openinv/OpenInv.java | 16 ++++++++++++-- src/lishid/openinv/OpenInvPlayerListener.java | 21 ++++++++++++------- src/plugin.yml | 2 +- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/lishid/openinv/OpenInv.java b/src/lishid/openinv/OpenInv.java index 69ac5b7..ca85000 100644 --- a/src/lishid/openinv/OpenInv.java +++ b/src/lishid/openinv/OpenInv.java @@ -2,6 +2,7 @@ package lishid.openinv; import lishid.openinv.commands.*; +import lishid.openinv.utils.Metrics; import org.bukkit.ChatColor; import org.bukkit.entity.Player; @@ -24,6 +25,8 @@ public class OpenInv extends JavaPlugin { //private final OpenInvInventoryListener inventoryListener = new OpenInvInventoryListener(this); public static PermissionHandler permissionHandler; public static OpenInv mainPlugin; + private static Metrics metrics; + public void onDisable() { } @@ -52,14 +55,23 @@ public class OpenInv extends JavaPlugin { //pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Event.Priority.Monitor, this); setupPermissions(); - PluginDescriptionFile pdfFile = this.getDescription(); - System.out.println("[" + pdfFile.getName() + "] version " + pdfFile.getVersion() + " enabled!" ); getCommand("openinv").setExecutor(new OpenInvPluginCommand(this)); getCommand("searchinv").setExecutor(new SearchInvPluginCommand(this)); getCommand("toggleopeninv").setExecutor(new ToggleOpenInvPluginCommand()); getCommand("silentchest").setExecutor(new SilentChestPluginCommand(this)); getCommand("anychest").setExecutor(new AnyChestPluginCommand(this)); + + //Metrics + try + { + metrics = new Metrics(); + metrics.beginMeasuringPlugin(this); + } + catch(Exception e){ e.printStackTrace(); } + + PluginDescriptionFile pdfFile = this.getDescription(); + System.out.println("[" + pdfFile.getName() + "] version " + pdfFile.getVersion() + " enabled!" ); } public static boolean GetPlayerItemOpenInvStatus(String name) diff --git a/src/lishid/openinv/OpenInvPlayerListener.java b/src/lishid/openinv/OpenInvPlayerListener.java index 74c9d65..2ea9e5c 100644 --- a/src/lishid/openinv/OpenInvPlayerListener.java +++ b/src/lishid/openinv/OpenInvPlayerListener.java @@ -126,14 +126,21 @@ public class OpenInvPlayerListener extends PlayerListener{ else { try{ - Field ciField = player.getClass().getDeclaredField("ci"); - ciField.setAccessible(true); - int ci = ciField.getInt(player); - ci = ci % 100 + 1; - ciField.setInt(player, ci); - player.netServerHandler.sendPacket(new Packet100OpenWindow(ci, 0, ((IInventory)chest).getName(), ((IInventory)chest).getSize())); + Field windowID; + try{ + windowID = player.getClass().getDeclaredField("cl"); + } + catch(NoSuchFieldException e) + { + windowID = player.getClass().getDeclaredField("ci"); + } + windowID.setAccessible(true); + int id = windowID.getInt(player); + id = id % 100 + 1; + windowID.setInt(player, id); + player.netServerHandler.sendPacket(new Packet100OpenWindow(id, 0, ((IInventory)chest).getName(), ((IInventory)chest).getSize())); player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory)chest)); - player.activeContainer.windowId = ci; + player.activeContainer.windowId = id; player.activeContainer.a((ICrafting)player); event.getPlayer().sendMessage("You are opening a chest silently."); event.setUseInteractedBlock(Result.DENY); diff --git a/src/plugin.yml b/src/plugin.yml index 138e042..a58560c 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: OpenInv main: lishid.openinv.OpenInv -version: 1.6.6 +version: 1.7.2 author: lishid website: http://forums.bukkit.org/threads/15379/ description: >