Fix SPIGOT-2806 for silent chests, various other issues

* Fixed anychest message spam
* Changed AnySilentContainer again to reduce duplicate checks
 * #isAnyContainerNeeded should be checked before calling #activateContainer
 * reorganized ifs for doublechest creation into reverse-order if elses to prevent creating extras when someone's broken Minecraft and put 3+ adjacent to each other
* Fixed incorrect block being checked for anychest in 1.11
* Progress on SilentContainerShulkerBox (we're getting there!)

anychest and silentchest aren't quite at 100% after all these changes, but it won't be a priority to revisit logic until shulker boxes are done
This commit is contained in:
Jikoo
2016-11-22 03:30:34 -05:00
parent 476171911a
commit 454467c20e
42 changed files with 407 additions and 370 deletions

View File

@@ -1,6 +1,6 @@
package com.lishid.openinv.internal;
import org.bukkit.block.BlockState;
import org.bukkit.block.Block;
import org.bukkit.entity.Player;
public interface IAnySilentContainer extends IAnySilentChest {
@@ -11,20 +11,21 @@ public interface IAnySilentContainer extends IAnySilentChest {
* @param block the BlockState
* @return true if the Block is a supported container
*/
public boolean isAnySilentContainer(BlockState block);
public boolean isAnySilentContainer(Block block);
/**
* Opens the container at the given coordinates for the Player.
* Opens the container at the given coordinates for the Player. If you do not want blocked
* containers to open, be sure to check {@link #isAnyContainerNeeded(Player, int, int, int)}
* first.
*
* @param player
* @param anychest whether compatibility for blocked containers is to be used
* @param silentchest whether the container's noise is to be silenced
* @param x the x coordinate
* @param y the y coordinate
* @param z the z coordinate
* @return true if the container can be opened
*/
public boolean activateContainer(Player player, boolean anychest, boolean silentchest, int x, int y, int z);
public boolean activateContainer(Player player, boolean silentchest, int x, int y, int z);
/**
* Checks if the container at the given coordinates is blocked.

View File

@@ -19,7 +19,7 @@ package com.lishid.openinv.internal.v1_10_R1;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -41,32 +41,31 @@ import org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(new BlockPosition(x, y, z));
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id)
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z + 1)));
} else if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
} else if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
} else if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -97,8 +96,9 @@ public class AnySilentContainer implements IAnySilentContainer {
World world = player.world;
// If block or ocelot on top
if (world.getType(new BlockPosition(x, y + 1, z)).l() || hasOcelotOnTop(world, x, y, z))
if (world.getType(new BlockPosition(x, y + 1, z)).l() || hasOcelotOnTop(world, x, y, z)) {
return true;
}
int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
@@ -133,12 +133,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -31,10 +31,11 @@ import net.minecraft.server.v1_10_R1.IInventory;
import org.bukkit.craftbukkit.v1_10_R1.inventory.CraftInventory;
public class InventoryAccess implements IInventoryAccess {
@Override
public boolean check(Inventory inventory, HumanEntity player) {
IInventory inv = grabInventory(inventory);
if (inv instanceof SpecialPlayerInventory) {
if (!OpenInv.hasPermission(player, Permissions.PERM_EDITINV)) {
return false;
@@ -51,24 +52,24 @@ public class InventoryAccess implements IInventoryAccess {
}
private IInventory grabInventory(Inventory inventory) {
if(inventory instanceof CraftInventory) {
if (inventory instanceof CraftInventory) {
return ((CraftInventory) inventory).getInventory();
}
//Use reflection to find the iinventory
// Use reflection to find the iinventory
Class<? extends Inventory> clazz = inventory.getClass();
IInventory result = null;
for(Field f : clazz.getDeclaredFields()) {
for (Field f : clazz.getDeclaredFields()) {
f.setAccessible(true);
if(IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
if (IInventory.class.isAssignableFrom(f.getDeclaringClass())) {
try {
result = (IInventory) f.get(inventory);
}
catch (Exception e) {
} catch (Exception e) {
e.printStackTrace();
}
}
}
return result;
}
}

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_10_R1;
import net.minecraft.server.v1_10_R1.ContainerChest;
import net.minecraft.server.v1_10_R1.EntityHuman;
import net.minecraft.server.v1_10_R1.IInventory;
import net.minecraft.server.v1_10_R1.ItemStack;
import net.minecraft.server.v1_10_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -19,6 +19,8 @@ package com.lishid.openinv.internal.v1_11_R1;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.BlockState;
import org.bukkit.entity.Player;
// Volatile
@@ -49,12 +51,16 @@ import org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(org.bukkit.block.BlockState block) {
return block instanceof org.bukkit.block.Chest || block instanceof org.bukkit.block.ShulkerBox;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
if (block.getType() == Material.ENDER_CHEST) {
return true;
}
BlockState state = block.getState();
return state instanceof org.bukkit.block.Chest || state instanceof org.bukkit.block.ShulkerBox;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
@@ -79,10 +85,6 @@ public class AnySilentContainer implements IAnySilentContainer {
continue;
}
if (!anychest && isBlockedChest(world, localBlock, localBlockPosition)) {
return false;
}
TileEntity localTileEntity = world.getTileEntity(localBlockPosition);
if (!(localTileEntity instanceof TileEntityChest)) {
continue;
@@ -110,17 +112,21 @@ public class AnySilentContainer implements IAnySilentContainer {
}
if (block instanceof BlockShulkerBox) {
if (!anychest && isBlockedShulkerBox(world, blockPosition, block)) {
return false;
}
player.b(StatisticList.ae);
if (silentchest && tile instanceof TileEntityShulkerBox) {
// TODO: This fixes sound, but the box is then silent for anyone until the tile entity is recreated
SilentContainerShulkerBox.increaseOpenQuantity((TileEntityShulkerBox) tile);
container = new SilentContainerShulkerBox(player.inventory, ((IInventory) tile), player);
SilentContainerShulkerBox.decreaseOpenQuantity((TileEntityShulkerBox) tile);
// TODO: End state allows for silent opening by other players while open (not close)
// increases by 1 when animation is scheduled to complete, even though animation does not occur
// Can't set value lower than 0, it corrects.
// Could schedule a reset for a couple seconds later when the animation finishes.
// Could say "that's good enough" and get some rest
int value = SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tile);
if (value < 1) {
SilentContainerShulkerBox.setOpenValue((TileEntityShulkerBox) tile, 2);
}
container = new SilentContainerShulkerBox(player.inventory, (IInventory) tile, player);
// Reset value to start
SilentContainerShulkerBox.setOpenValue((TileEntityShulkerBox) tile, value);
}
}
@@ -203,7 +209,7 @@ public class AnySilentContainer implements IAnySilentContainer {
return false;
}
return world.getType(blockPosition).m() || hasOcelotOnTop(world, blockPosition);
return world.getType(blockPosition.up()).m() || hasOcelotOnTop(world, blockPosition);
}
private boolean hasOcelotOnTop(World world, BlockPosition blockPosition) {
@@ -226,7 +232,7 @@ public class AnySilentContainer implements IAnySilentContainer {
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -37,9 +37,10 @@ public class SilentContainerChest extends ContainerChest {
// Don't send close signal twice, might screw up
PlayerInventory playerinventory = entityHuman.inventory;
if (!playerinventory.getCarried().isEmpty()) {
entityHuman.drop(playerinventory.getCarried(), false);
if (playerinventory.getCarried() != ItemStack.a) {
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(ItemStack.a);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -21,29 +21,41 @@ public class SilentContainerShulkerBox extends ContainerShulkerBox {
return h;
}
public static void increaseOpenQuantity(TileEntityShulkerBox containerShulkerBox) {
public static void setOpenValue(TileEntityShulkerBox tileShulkerBox, Object value) {
try {
exposeOpenStatus().set(containerShulkerBox, ((Integer) exposeOpenStatus().get(containerShulkerBox)) + 1);
exposeOpenStatus().set(tileShulkerBox, value);
} catch (Exception e) {
e.printStackTrace();
}
}
public static void decreaseOpenQuantity(TileEntityShulkerBox containerShulkerBox) {
public static Integer getOpenValue(TileEntityShulkerBox tileShulkerBox) {
try {
exposeOpenStatus().set(containerShulkerBox, ((Integer) exposeOpenStatus().get(containerShulkerBox)) - 1);
return (Integer) exposeOpenStatus().get(tileShulkerBox);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
private final TileEntityShulkerBox tile;
public SilentContainerShulkerBox(PlayerInventory playerInventory, IInventory iInventory,
EntityHuman entityHuman) {
super(playerInventory, iInventory, entityHuman);
if (iInventory instanceof TileEntityShulkerBox) {
tile = (TileEntityShulkerBox) iInventory;
} else {
tile = null;
}
}
@Override
public void b(EntityHuman entityHuman) {
if (tile != null) {
setOpenValue(tile, tile.getViewers().size());
}
PlayerInventory playerinventory = entityHuman.inventory;
if (!playerinventory.getCarried().isEmpty()) {

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -40,30 +40,29 @@ import org.bukkit.craftbukkit.v1_4_5.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
if (world.getTypeId(x, y, z + 1) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(world.getTypeId(x, y, z - 1) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (world.getTypeId(x + 1, y, z) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (world.getTypeId(x - 1, y, z) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -134,12 +133,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_4_5;
import net.minecraft.server.v1_4_5.ContainerChest;
import net.minecraft.server.v1_4_5.EntityHuman;
import net.minecraft.server.v1_4_5.IInventory;
import net.minecraft.server.v1_4_5.ItemStack;
import net.minecraft.server.v1_4_5.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried());
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -40,30 +40,28 @@ import org.bukkit.craftbukkit.v1_4_6.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
if (world.getTypeId(x, y, z + 1) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(world.getTypeId(x, y, z - 1) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (world.getTypeId(x + 1, y, z) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (world.getTypeId(x - 1, y, z) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -134,12 +132,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_4_6;
import net.minecraft.server.v1_4_6.ContainerChest;
import net.minecraft.server.v1_4_6.EntityHuman;
import net.minecraft.server.v1_4_6.IInventory;
import net.minecraft.server.v1_4_6.ItemStack;
import net.minecraft.server.v1_4_6.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried());
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -40,30 +40,29 @@ import org.bukkit.craftbukkit.v1_4_R1.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
if (world.getTypeId(x - 1, y, z) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
if (world.getTypeId(x + 1, y, z) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
if (world.getTypeId(x, y, z - 1) == Block.CHEST.id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
if (world.getTypeId(x, y, z + 1) == Block.CHEST.id)
if (world.getTypeId(x, y, z + 1) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(world.getTypeId(x, y, z - 1) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (world.getTypeId(x + 1, y, z) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (world.getTypeId(x - 1, y, z) == Block.CHEST.id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -134,12 +133,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_4_R1;
import net.minecraft.server.v1_4_R1.ContainerChest;
import net.minecraft.server.v1_4_R1.EntityHuman;
import net.minecraft.server.v1_4_R1.IInventory;
import net.minecraft.server.v1_4_R1.ItemStack;
import net.minecraft.server.v1_4_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried());
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -39,32 +39,31 @@ import org.bukkit.craftbukkit.v1_5_R2.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = world.getTypeId(x, y, z);
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)
if (world.getTypeId(x, y, z + 1) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(world.getTypeId(x, y, z - 1) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (world.getTypeId(x + 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (world.getTypeId(x - 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -137,12 +136,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_5_R2;
import net.minecraft.server.v1_5_R2.ContainerChest;
import net.minecraft.server.v1_5_R2.EntityHuman;
import net.minecraft.server.v1_5_R2.IInventory;
import net.minecraft.server.v1_5_R2.ItemStack;
import net.minecraft.server.v1_5_R2.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried());
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
//Volatile
@@ -39,32 +39,31 @@ import org.bukkit.craftbukkit.v1_5_R3.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = world.getTypeId(x, y, z);
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)
if (world.getTypeId(x, y, z + 1) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(world.getTypeId(x, y, z - 1) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (world.getTypeId(x + 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (world.getTypeId(x - 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -137,12 +136,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_5_R3;
import net.minecraft.server.v1_5_R3.ContainerChest;
import net.minecraft.server.v1_5_R3.EntityHuman;
import net.minecraft.server.v1_5_R3.IInventory;
import net.minecraft.server.v1_5_R3.ItemStack;
import net.minecraft.server.v1_5_R3.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried());
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -39,32 +39,31 @@ import org.bukkit.craftbukkit.v1_6_R1.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = world.getTypeId(x, y, z);
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)
if (world.getTypeId(x, y, z + 1) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(world.getTypeId(x, y, z - 1) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (world.getTypeId(x + 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (world.getTypeId(x - 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -137,12 +136,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_6_R1;
import net.minecraft.server.v1_6_R1.ContainerChest;
import net.minecraft.server.v1_6_R1.EntityHuman;
import net.minecraft.server.v1_6_R1.IInventory;
import net.minecraft.server.v1_6_R1.ItemStack;
import net.minecraft.server.v1_6_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried());
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -39,32 +39,31 @@ import org.bukkit.craftbukkit.v1_6_R2.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = world.getTypeId(x, y, z);
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)
if (world.getTypeId(x, y, z + 1) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(world.getTypeId(x, y, z - 1) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (world.getTypeId(x + 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (world.getTypeId(x - 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -137,12 +136,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_6_R2;
import net.minecraft.server.v1_6_R2.ContainerChest;
import net.minecraft.server.v1_6_R2.EntityHuman;
import net.minecraft.server.v1_6_R2.IInventory;
import net.minecraft.server.v1_6_R2.ItemStack;
import net.minecraft.server.v1_6_R2.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried());
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -39,32 +39,31 @@ import org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = world.getTypeId(x, y, z);
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)
if (world.getTypeId(x, y, z + 1) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(world.getTypeId(x, y, z - 1) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (world.getTypeId(x + 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (world.getTypeId(x - 1, y, z) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -137,12 +136,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_6_R3;
import net.minecraft.server.v1_6_R3.ContainerChest;
import net.minecraft.server.v1_6_R3.EntityHuman;
import net.minecraft.server.v1_6_R3.IInventory;
import net.minecraft.server.v1_6_R3.ItemStack;
import net.minecraft.server.v1_6_R3.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried());
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
//Volatile
@@ -40,32 +40,31 @@ import org.bukkit.craftbukkit.v1_7_R1.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.b(world.getType(x, y, z));
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)
if (Block.b(world.getType(x, y, z + 1)) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(Block.b(world.getType(x, y, z - 1)) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (Block.b(world.getType(x + 1, y, z)) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (Block.b(world.getType(x - 1, y, z)) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -138,12 +137,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_7_R1;
import net.minecraft.server.v1_7_R1.ContainerChest;
import net.minecraft.server.v1_7_R1.EntityHuman;
import net.minecraft.server.v1_7_R1.IInventory;
import net.minecraft.server.v1_7_R1.ItemStack;
import net.minecraft.server.v1_7_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
//Volatile
@@ -40,32 +40,31 @@ import org.bukkit.craftbukkit.v1_7_R2.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.b(world.getType(x, y, z));
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)
if (Block.b(world.getType(x, y, z + 1)) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(Block.b(world.getType(x, y, z - 1)) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (Block.b(world.getType(x + 1, y, z)) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (Block.b(world.getType(x - 1, y, z)) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -138,12 +137,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_7_R2;
import net.minecraft.server.v1_7_R2.ContainerChest;
import net.minecraft.server.v1_7_R2.EntityHuman;
import net.minecraft.server.v1_7_R2.IInventory;
import net.minecraft.server.v1_7_R2.ItemStack;
import net.minecraft.server.v1_7_R2.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -40,32 +40,31 @@ import org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.b(world.getType(x, y, z));
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)
if (Block.b(world.getType(x, y, z + 1)) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(Block.b(world.getType(x, y, z - 1)) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (Block.b(world.getType(x + 1, y, z)) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (Block.b(world.getType(x - 1, y, z)) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -138,12 +137,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_7_R3;
import net.minecraft.server.v1_7_R3.ContainerChest;
import net.minecraft.server.v1_7_R3.EntityHuman;
import net.minecraft.server.v1_7_R3.IInventory;
import net.minecraft.server.v1_7_R3.ItemStack;
import net.minecraft.server.v1_7_R3.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -21,7 +21,7 @@ import java.lang.reflect.Field;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -40,32 +40,31 @@ import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(x, y, z);
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.getId(world.getType(x, y, z));
if (Block.getId(world.getType(x - 1, y, z)) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
if (Block.getId(world.getType(x + 1, y, z)) == id)
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
if (Block.getId(world.getType(x, y, z - 1)) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
if (Block.getId(world.getType(x, y, z + 1)) == id)
if (Block.getId(world.getType(x, y, z + 1)) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x, y, z + 1));
} else if(Block.getId(world.getType(x, y, z - 1)) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x, y, z - 1), (IInventory) chest);
} else if (Block.getId(world.getType(x + 1, y, z)) == id) {
chest = new InventoryLargeChest("Large chest", (IInventory) chest, (TileEntityChest) world.getTileEntity(x + 1, y, z));
} else if (Block.getId(world.getType(x - 1, y, z)) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(x - 1, y, z), (IInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -138,12 +137,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_7_R4;
import net.minecraft.server.v1_7_R4.ContainerChest;
import net.minecraft.server.v1_7_R4.EntityHuman;
import net.minecraft.server.v1_7_R4.IInventory;
import net.minecraft.server.v1_7_R4.ItemStack;
import net.minecraft.server.v1_7_R4.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -19,7 +19,7 @@ package com.lishid.openinv.internal.v1_8_R1;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
//Volatile
@@ -40,32 +40,31 @@ import org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(new BlockPosition(x, y, z));
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id)
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z + 1)));
} else if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
} else if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
} else if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -131,12 +130,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_8_R1;
import net.minecraft.server.v1_8_R1.ContainerChest;
import net.minecraft.server.v1_8_R1.EntityHuman;
import net.minecraft.server.v1_8_R1.IInventory;
import net.minecraft.server.v1_8_R1.ItemStack;
import net.minecraft.server.v1_8_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -19,7 +19,7 @@ package com.lishid.openinv.internal.v1_8_R2;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
//Volatile
@@ -40,32 +40,31 @@ import org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(new BlockPosition(x, y, z));
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id)
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z + 1)));
} else if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
} else if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
} else if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -131,12 +130,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_8_R2;
import net.minecraft.server.v1_8_R2.ContainerChest;
import net.minecraft.server.v1_8_R2.EntityHuman;
import net.minecraft.server.v1_8_R2.IInventory;
import net.minecraft.server.v1_8_R2.ItemStack;
import net.minecraft.server.v1_8_R2.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -19,7 +19,7 @@ package com.lishid.openinv.internal.v1_8_R3;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
//Volatile
@@ -40,32 +40,31 @@ import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(new BlockPosition(x, y, z));
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id)
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z + 1)));
} else if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
} else if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
} else if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -131,12 +130,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_8_R3;
import net.minecraft.server.v1_8_R3.ContainerChest;
import net.minecraft.server.v1_8_R3.EntityHuman;
import net.minecraft.server.v1_8_R3.IInventory;
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -19,7 +19,7 @@ package com.lishid.openinv.internal.v1_9_R1;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -41,32 +41,31 @@ import org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(new BlockPosition(x, y, z));
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id)
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z + 1)));
} else if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
} else if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
} else if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -133,12 +132,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_9_R1;
import net.minecraft.server.v1_9_R1.ContainerChest;
import net.minecraft.server.v1_9_R1.EntityHuman;
import net.minecraft.server.v1_9_R1.IInventory;
import net.minecraft.server.v1_9_R1.ItemStack;
import net.minecraft.server.v1_9_R1.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -19,7 +19,7 @@ package com.lishid.openinv.internal.v1_9_R2;
import com.lishid.openinv.internal.IAnySilentContainer;
import org.bukkit.ChatColor;
import org.bukkit.block.BlockState;
import org.bukkit.Material;
import org.bukkit.entity.Player;
// Volatile
@@ -41,32 +41,31 @@ import org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer;
public class AnySilentContainer implements IAnySilentContainer {
@Override
public boolean isAnySilentContainer(BlockState block) {
return block instanceof org.bukkit.block.Chest;
public boolean isAnySilentContainer(org.bukkit.block.Block block) {
return block.getType() == Material.ENDER_CHEST || block.getState() instanceof org.bukkit.block.Chest;
}
@Override
public boolean activateContainer(Player p, boolean anychest, boolean silentchest, int x, int y, int z) {
public boolean activateContainer(Player p, boolean silentchest, int x, int y, int z) {
EntityPlayer player = ((CraftPlayer) p).getHandle();
World world = player.world;
Object chest = world.getTileEntity(new BlockPosition(x, y, z));
if (chest == null)
return false;
if (!anychest && isAnyContainerNeeded(p, x, y, z)) {
if (chest == null) {
return false;
}
int id = Block.getId(world.getType(new BlockPosition(x, y, z)).getBlock());
if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id)
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id)
if (Block.getId(world.getType(new BlockPosition(x, y, z + 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z + 1)));
} else if (Block.getId(world.getType(new BlockPosition(x, y, z - 1)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x, y, z - 1)), (ITileInventory) chest);
} else if (Block.getId(world.getType(new BlockPosition(x + 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (ITileInventory) chest, (TileEntityChest) world.getTileEntity(new BlockPosition(x + 1, y, z)));
} else if (Block.getId(world.getType(new BlockPosition(x - 1, y, z)).getBlock()) == id) {
chest = new InventoryLargeChest("Large chest", (TileEntityChest) world.getTileEntity(new BlockPosition(x - 1, y, z)), (ITileInventory) chest);
}
boolean returnValue = false;
if (!silentchest) {
@@ -133,12 +132,12 @@ public class AnySilentContainer implements IAnySilentContainer {
}
/**
* @deprecated Use {@link #activateContainer(Player, boolean, boolean, int, int, int)}.
* @deprecated Use {@link #activateContainer(Player, boolean, int, int, int)}.
*/
@Deprecated
@Override
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z) {
return !activateContainer(player, anychest, silentchest, x, y, z);
return !activateContainer(player, silentchest, x, y, z);
}
/**

View File

@@ -20,6 +20,7 @@ package com.lishid.openinv.internal.v1_9_R2;
import net.minecraft.server.v1_9_R2.ContainerChest;
import net.minecraft.server.v1_9_R2.EntityHuman;
import net.minecraft.server.v1_9_R2.IInventory;
import net.minecraft.server.v1_9_R2.ItemStack;
import net.minecraft.server.v1_9_R2.PlayerInventory;
public class SilentContainerChest extends ContainerChest {
@@ -38,8 +39,9 @@ public class SilentContainerChest extends ContainerChest {
PlayerInventory playerinventory = entityHuman.inventory;
if (playerinventory.getCarried() != null) {
entityHuman.drop(playerinventory.getCarried(), false);
ItemStack carried = playerinventory.getCarried();
playerinventory.setCarried(null);
entityHuman.drop(carried, false);
}
}
}

View File

@@ -47,45 +47,43 @@ public class OpenInvPlayerListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerInteract(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getPlayer().isSneaking()
|| event.useInteractedBlock() == Result.DENY) {
|| event.useInteractedBlock() == Result.DENY
|| !plugin.getAnySilentContainer().isAnySilentContainer(event.getClickedBlock())) {
return;
}
Player player = event.getPlayer();
boolean anychest = OpenInv.hasPermission(player, Permissions.PERM_ANYCHEST) && plugin.getPlayerAnyChestStatus(player);
int x = event.getClickedBlock().getX();
int y = event.getClickedBlock().getY();
int z = event.getClickedBlock().getZ();
boolean needsAnyChest = plugin.getAnySilentContainer().isAnyContainerNeeded(player, x, y, z);
if (!anychest && needsAnyChest) {
return;
}
boolean silentchest = OpenInv.hasPermission(player, Permissions.PERM_SILENT) && plugin.getPlayerSilentChestStatus(player);
if (event.getClickedBlock().getType() == org.bukkit.Material.ENDER_CHEST) {
if (OpenInv.hasPermission(player, Permissions.PERM_SILENT)
&& plugin.getPlayerSilentChestStatus(player)) {
// TODO: Bypasses blocks on top, anychest also does not work
if (silentchest || anychest) {
// TODO: anychest is silent
event.setCancelled(true);
player.openInventory(player.getEnderChest());
}
return;
}
if (plugin.getAnySilentContainer().isAnySilentContainer(event.getClickedBlock().getState())) {
boolean silentchest = OpenInv.hasPermission(player, Permissions.PERM_SILENT) && plugin.getPlayerSilentChestStatus(player);
boolean anychest = OpenInv.hasPermission(player, Permissions.PERM_ANYCHEST) && plugin.getPlayerAnyChestStatus(player);
int x = event.getClickedBlock().getX();
int y = event.getClickedBlock().getY();
int z = event.getClickedBlock().getZ();
// If anychest or silentchest is active
if (anychest || silentchest) {
if (plugin.getAnySilentContainer().activateContainer(player, anychest, silentchest, x, y, z)) {
if (silentchest && plugin.notifySilentChest() && anychest && plugin.notifyAnyChest()) {
player.sendMessage("You are opening a blocked chest silently.");
} else if (silentchest && plugin.notifySilentChest()) {
player.sendMessage("You are opening a chest silently.");
} else if (anychest && plugin.notifyAnyChest()) {
// TODO fix anychest always claiming chest is blocked
player.sendMessage("You are opening a blocked chest.");
}
event.setCancelled(true);
}
// If anychest or silentchest is active
if ((anychest || silentchest) && plugin.getAnySilentContainer().activateContainer(player, silentchest, x, y, z)) {
if (silentchest && plugin.notifySilentChest() && needsAnyChest && plugin.notifyAnyChest()) {
player.sendMessage("You are opening a blocked chest silently.");
} else if (silentchest && plugin.notifySilentChest()) {
player.sendMessage("You are opening a chest silently.");
} else if (needsAnyChest && plugin.notifyAnyChest()) {
player.sendMessage("You are opening a blocked chest.");
}
event.setCancelled(true);
}
}