Don't use reflection to increment container counter

Fixes #53 (pretty please with a cherry on top)
This commit is contained in:
Jikoo
2016-11-27 06:13:17 -05:00
parent 0bbcf6cdb2
commit 6aa25dd2dc
13 changed files with 13 additions and 133 deletions

View File

@@ -16,8 +16,6 @@
package com.lishid.openinv.internal.v1_7_R1;
import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
@@ -143,15 +141,7 @@ public class AnySilentContainer implements IAnySilentContainer {
returnValue = true;
} 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) {}
int windowId = player.nextContainerCounter();
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, 0, ((IInventory) tile).getInventoryName(), ((IInventory) tile).getSize(), true));
player.activeContainer = new SilentContainerChest(player.inventory, ((IInventory) tile));
player.activeContainer.windowId = windowId;