From 1cfe757acc1dda2d4482ffc017fe6318f50676b9 Mon Sep 17 00:00:00 2001 From: lishid Date: Sat, 3 Mar 2012 13:58:24 -0500 Subject: [PATCH] Updated to 1.1-R6 --- README | 2 +- src/lishid/openinv/OpenInv.java | 2 +- src/lishid/openinv/OpenInvEntityListener.java | 2 +- src/lishid/openinv/OpenInvPlayerListener.java | 24 ++++---- src/lishid/openinv/PermissionRelay.java | 2 +- .../commands/AnyChestPluginCommand.java | 2 +- .../commands/OpenInvPluginCommand.java | 4 +- .../commands/SearchInvPluginCommand.java | 2 +- .../commands/SilentChestPluginCommand.java | 2 +- .../commands/ToggleOpenInvPluginCommand.java | 2 +- .../openinv/utils/PlayerInventoryChest.java | 60 ++++++++++++++++++- .../openinv/utils/SilentContainerChest.java | 2 +- src/plugin.yml | 2 +- 13 files changed, 82 insertions(+), 26 deletions(-) diff --git a/README b/README index a0322ef..cb8f1c9 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -Copyright (C) 2011 lishid. All rights reserved. +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 diff --git a/src/lishid/openinv/OpenInv.java b/src/lishid/openinv/OpenInv.java index 272cba3..0ac9cf9 100644 --- a/src/lishid/openinv/OpenInv.java +++ b/src/lishid/openinv/OpenInv.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 diff --git a/src/lishid/openinv/OpenInvEntityListener.java b/src/lishid/openinv/OpenInvEntityListener.java index 92f35cc..b806fcd 100644 --- a/src/lishid/openinv/OpenInvEntityListener.java +++ b/src/lishid/openinv/OpenInvEntityListener.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 diff --git a/src/lishid/openinv/OpenInvPlayerListener.java b/src/lishid/openinv/OpenInvPlayerListener.java index c0ee740..439c8f4 100644 --- a/src/lishid/openinv/OpenInvPlayerListener.java +++ b/src/lishid/openinv/OpenInvPlayerListener.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 @@ -22,7 +22,6 @@ import lishid.openinv.commands.OpenInvPluginCommand; import lishid.openinv.utils.SilentContainerChest; import net.minecraft.server.Block; import net.minecraft.server.EntityPlayer; -import net.minecraft.server.ICrafting; import net.minecraft.server.IInventory; import net.minecraft.server.InventoryLargeChest; import net.minecraft.server.Packet100OpenWindow; @@ -139,27 +138,26 @@ public class OpenInvPlayerListener implements Listener{ if(!silentchest) { - player.a((IInventory)chest); + player.openContainer((IInventory)chest); } else { try{ - Field windowID; + int id = 0; try{ - windowID = player.getClass().getDeclaredField("cl"); + Field windowID = player.getClass().getDeclaredField("containerCounter"); + windowID.setAccessible(true); + id = windowID.getInt(player); + id = id % 100 + 1; + windowID.setInt(player, id); } 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 = id; - player.activeContainer.a((ICrafting)player); + player.activeContainer.addSlotListener(player); //event.getPlayer().sendMessage("You are opening a chest silently."); event.setUseInteractedBlock(Result.DENY); event.setCancelled(true); diff --git a/src/lishid/openinv/PermissionRelay.java b/src/lishid/openinv/PermissionRelay.java index 1e17790..604543d 100644 --- a/src/lishid/openinv/PermissionRelay.java +++ b/src/lishid/openinv/PermissionRelay.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 diff --git a/src/lishid/openinv/commands/AnyChestPluginCommand.java b/src/lishid/openinv/commands/AnyChestPluginCommand.java index fad8722..287cb28 100644 --- a/src/lishid/openinv/commands/AnyChestPluginCommand.java +++ b/src/lishid/openinv/commands/AnyChestPluginCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 diff --git a/src/lishid/openinv/commands/OpenInvPluginCommand.java b/src/lishid/openinv/commands/OpenInvPluginCommand.java index b67321b..a7f47ea 100644 --- a/src/lishid/openinv/commands/OpenInvPluginCommand.java +++ b/src/lishid/openinv/commands/OpenInvPluginCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 @@ -181,7 +181,7 @@ public class OpenInvPluginCommand implements CommandExecutor { } //Open the inventory - entityplayer.a(inv); + entityplayer.openContainer(inv); return true; } diff --git a/src/lishid/openinv/commands/SearchInvPluginCommand.java b/src/lishid/openinv/commands/SearchInvPluginCommand.java index 3ccec11..11a9dd1 100644 --- a/src/lishid/openinv/commands/SearchInvPluginCommand.java +++ b/src/lishid/openinv/commands/SearchInvPluginCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 diff --git a/src/lishid/openinv/commands/SilentChestPluginCommand.java b/src/lishid/openinv/commands/SilentChestPluginCommand.java index f5565c3..20346ac 100644 --- a/src/lishid/openinv/commands/SilentChestPluginCommand.java +++ b/src/lishid/openinv/commands/SilentChestPluginCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 diff --git a/src/lishid/openinv/commands/ToggleOpenInvPluginCommand.java b/src/lishid/openinv/commands/ToggleOpenInvPluginCommand.java index cfdf456..4659b6d 100644 --- a/src/lishid/openinv/commands/ToggleOpenInvPluginCommand.java +++ b/src/lishid/openinv/commands/ToggleOpenInvPluginCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 diff --git a/src/lishid/openinv/utils/PlayerInventoryChest.java b/src/lishid/openinv/utils/PlayerInventoryChest.java index a632854..6a1d682 100644 --- a/src/lishid/openinv/utils/PlayerInventoryChest.java +++ b/src/lishid/openinv/utils/PlayerInventoryChest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 @@ -16,7 +16,13 @@ package lishid.openinv.utils; +import java.util.ArrayList; +import java.util.List; + +import org.bukkit.craftbukkit.entity.CraftHumanEntity; +import org.bukkit.entity.HumanEntity; import org.bukkit.entity.Player; +import org.bukkit.inventory.InventoryHolder; import lishid.openinv.commands.OpenInvPluginCommand; import net.minecraft.server.EntityHuman; @@ -133,6 +139,39 @@ public class PlayerInventoryChest implements IInventory } } + 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; + } + } + public void setItem(int i, ItemStack itemstack) { ItemStack[] is = this.items; @@ -224,4 +263,23 @@ public class PlayerInventoryChest implements IInventory { } + + public List transaction = new ArrayList(); + + public void onOpen(CraftHumanEntity who) { + transaction.add(who); + } + + public void onClose(CraftHumanEntity who) { + transaction.remove(who); + } + + public List getViewers() { + return transaction; + } + + @Override + public InventoryHolder getOwner() { + return null; + } } \ No newline at end of file diff --git a/src/lishid/openinv/utils/SilentContainerChest.java b/src/lishid/openinv/utils/SilentContainerChest.java index 2e22430..aac4a42 100644 --- a/src/lishid/openinv/utils/SilentContainerChest.java +++ b/src/lishid/openinv/utils/SilentContainerChest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 lishid. All rights reserved. + * 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 diff --git a/src/plugin.yml b/src/plugin.yml index 0248ab9..b456b12 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: OpenInv main: lishid.openinv.OpenInv -version: 1.7.6 +version: 1.8.1 author: lishid website: http://forums.bukkit.org/threads/15379/ description: >