Compare commits
2 Commits
2.5.3-alph
...
2.5.3
Author | SHA1 | Date | |
---|---|---|---|
|
fcc9a4c0cb | ||
|
454467c20e |
@@ -9,7 +9,7 @@
|
||||
|
||||
<artifactId>openinv</artifactId>
|
||||
<name>OpenInv</name>
|
||||
<version>2.5.3-SNAPSHOT</version>
|
||||
<version>2.5.4</version>
|
||||
|
||||
<profiles>
|
||||
|
||||
|
@@ -25,7 +25,7 @@ import org.bukkit.entity.Player;
|
||||
public interface IAnySilentChest {
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link IAnySilentContainer#activateContainer(Player, boolean, boolean, int, int, int)}.
|
||||
* @deprecated Use {@link IAnySilentContainer#activateContainer(Player, boolean, int, int, int)}.
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean activateChest(Player player, boolean anychest, boolean silentchest, int x, int y, int z);
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.lishid.openinv.internal;
|
||||
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface IAnySilentContainer extends IAnySilentChest {
|
||||
|
||||
/**
|
||||
@@ -11,20 +12,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.
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -18,14 +18,19 @@ package com.lishid.openinv.internal.v1_11_R1;
|
||||
|
||||
import com.lishid.openinv.internal.IAnySilentContainer;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.BlockState;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
// Volatile
|
||||
import net.minecraft.server.v1_11_R1.AxisAlignedBB;
|
||||
import net.minecraft.server.v1_11_R1.Block;
|
||||
import net.minecraft.server.v1_11_R1.BlockChest;
|
||||
import net.minecraft.server.v1_11_R1.BlockChest.Type;
|
||||
import net.minecraft.server.v1_11_R1.BlockEnderChest;
|
||||
import net.minecraft.server.v1_11_R1.BlockPosition;
|
||||
import net.minecraft.server.v1_11_R1.BlockShulkerBox;
|
||||
import net.minecraft.server.v1_11_R1.Container;
|
||||
@@ -49,23 +54,33 @@ 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) {
|
||||
|
||||
// TODO backport to all modules? TODO change new API to activateContainer(Player, Block)? Use BlockState instead?
|
||||
if (silentchest && p.getWorld().getBlockAt(x, y, z).getType() == Material.ENDER_CHEST) {
|
||||
p.openInventory(p.getEnderChest());
|
||||
return true;
|
||||
}
|
||||
|
||||
EntityPlayer player = ((CraftPlayer) p).getHandle();
|
||||
World world = player.world;
|
||||
BlockPosition blockPosition = new BlockPosition(x, y, z);
|
||||
final World world = player.world;
|
||||
final BlockPosition blockPosition = new BlockPosition(x, y, z);
|
||||
Object tile = world.getTileEntity(blockPosition);
|
||||
|
||||
if (tile == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Block block = world.getType(new BlockPosition(x, y, z)).getBlock();
|
||||
Block block = world.getType(blockPosition).getBlock();
|
||||
Container container = null;
|
||||
|
||||
if (block instanceof BlockChest) {
|
||||
@@ -79,10 +94,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,40 +121,59 @@ 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);
|
||||
// Set value to current + 1. Ensures consistency later when resetting.
|
||||
SilentContainerShulkerBox.setOpenValue((TileEntityShulkerBox) tile,
|
||||
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tile) + 1);
|
||||
|
||||
container = new SilentContainerShulkerBox(player.inventory, (IInventory) tile, player);
|
||||
}
|
||||
}
|
||||
|
||||
if (!(tile instanceof IInventory)) {
|
||||
// TODO anyenderchest
|
||||
p.sendMessage(ChatColor.RED + "Unhandled non-IInventory for block!");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean returnValue = false;
|
||||
final IInventory iInventory = (IInventory) tile;
|
||||
|
||||
if (!silentchest || container == null) {
|
||||
player.openContainer((IInventory) tile);
|
||||
player.openContainer(iInventory);
|
||||
returnValue = true;
|
||||
} else {
|
||||
try {
|
||||
int windowId = player.nextContainerCounter();
|
||||
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, "minecraft:chest", ((IInventory) tile).getScoreboardDisplayName(), ((IInventory) tile).getSize()));
|
||||
player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(windowId, iInventory.getName(), iInventory.getScoreboardDisplayName(), iInventory.getSize()));
|
||||
player.activeContainer = container;
|
||||
player.activeContainer.windowId = windowId;
|
||||
player.activeContainer.addSlotListener(player);
|
||||
returnValue = true;
|
||||
if (tile instanceof TileEntityShulkerBox) {
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// TODO hacky
|
||||
Object tile = world.getTileEntity(blockPosition);
|
||||
if (!(tile instanceof TileEntityShulkerBox)) {
|
||||
return;
|
||||
}
|
||||
TileEntityShulkerBox box = (TileEntityShulkerBox) tile;
|
||||
// Reset back - we added 1, and calling TileEntityShulkerBox#startOpen adds 1 more.
|
||||
SilentContainerShulkerBox.setOpenValue(box,
|
||||
SilentContainerShulkerBox.getOpenValue((TileEntityShulkerBox) tile) - 2);
|
||||
}
|
||||
}.runTaskLater(Bukkit.getPluginManager().getPlugin("OpenInv"), 2);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
p.sendMessage(ChatColor.RED + "Error while sending silent chest.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -158,16 +188,31 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||
return isBlockedShulkerBox(world, blockPosition, block);
|
||||
}
|
||||
|
||||
// For reference, loot at net.minecraft.server.BlockChest
|
||||
if (block instanceof BlockEnderChest) {
|
||||
// Ender chests are not blocked by ocelots.
|
||||
return world.getType(new BlockPosition(x, y + 1, z)).m();
|
||||
}
|
||||
|
||||
// Check if chest is blocked or has an ocelot on top
|
||||
if (world.getType(new BlockPosition(x, y + 1, z)).m() || hasOcelotOnTop(world, blockPosition)) {
|
||||
if (isBlockedChest(world, blockPosition)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check for matching adjacent chests that are blocked or have an ocelot on top
|
||||
for (EnumDirection localEnumDirection : EnumDirection.EnumDirectionLimit.HORIZONTAL) {
|
||||
BlockPosition localBlockPosition = blockPosition.shift(localEnumDirection);
|
||||
if (isBlockedChest(world, block, localBlockPosition)) {
|
||||
Block localBlock = world.getType(localBlockPosition).getBlock();
|
||||
|
||||
if (localBlock != block) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TileEntity localTileEntity = world.getTileEntity(localBlockPosition);
|
||||
if (!(localTileEntity instanceof TileEntityChest)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isBlockedChest(world, localBlockPosition)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -192,18 +237,15 @@ public class AnySilentContainer implements IAnySilentContainer {
|
||||
.a(enumDirection.getAdjacentX(), enumDirection.getAdjacentY(),
|
||||
enumDirection.getAdjacentZ());
|
||||
|
||||
return !(world.b(axisAlignedBB.a(blockPosition.shift(enumDirection))));
|
||||
return world.b(axisAlignedBB.a(blockPosition.shift(enumDirection)));
|
||||
}
|
||||
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isBlockedChest(World world, Block block, BlockPosition blockPosition) {
|
||||
if (world.getType(blockPosition).getBlock() == block) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return world.getType(blockPosition).m() || hasOcelotOnTop(world, blockPosition);
|
||||
private boolean isBlockedChest(World world, BlockPosition blockPosition) {
|
||||
// For reference, loot at net.minecraft.server.BlockChest
|
||||
return world.getType(blockPosition.up()).m() || hasOcelotOnTop(world, blockPosition);
|
||||
}
|
||||
|
||||
private boolean hasOcelotOnTop(World world, BlockPosition blockPosition) {
|
||||
@@ -226,7 +268,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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -21,19 +21,20 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -30,6 +30,7 @@ import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
import org.bukkit.craftbukkit.v1_7_R2.CraftServer;
|
||||
|
||||
@SuppressWarnings("deprecation") // Deprecated methods are used properly and will not change.
|
||||
public class PlayerDataManager implements IPlayerDataManager {
|
||||
|
||||
@Override
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -107,7 +107,7 @@ public class OpenInv extends JavaPlugin {
|
||||
accessor = new InternalAccessor(this);
|
||||
// Version check
|
||||
if (!accessor.initialize(getServer())) {
|
||||
getLogger().info("Your version of CraftBukkit (" + accessor.getVersion() + ")is not supported.");
|
||||
getLogger().info("Your version of CraftBukkit (" + accessor.getVersion() + ") is not supported.");
|
||||
getLogger().info("Please look for an updated version of OpenInv.");
|
||||
pm.disablePlugin(this);
|
||||
return;
|
||||
|
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -10,30 +10,30 @@ commands:
|
||||
aliases: [oi, inv, open]
|
||||
description: Open a player's inventory
|
||||
permission: OpenInv.*;OpenInv.openinv
|
||||
usage: |
|
||||
usage: |-
|
||||
/<command> - Open last person's inventory
|
||||
/<command> <Player> - Open a player's inventory
|
||||
openender:
|
||||
aliases: [oe]
|
||||
description: Opens the enderchest of a player
|
||||
permission: OpenInv.*;OpenInv.openender
|
||||
usage: |
|
||||
usage: |-
|
||||
/<command> <Player> - Opens a player's enderchest
|
||||
searchinv:
|
||||
aliases: [si]
|
||||
description: Search and list players having a specific item
|
||||
permission: OpenInv.*;OpenInv.search
|
||||
usage: |
|
||||
usage: |-
|
||||
/<command> <Item> [MinAmount] - Item can be the Item ID or the CraftBukkit Item Name, MinAmount is the minimum amount to be considered.
|
||||
silentchest:
|
||||
aliases: [sc, silent]
|
||||
description: Toggle silent chest function, which hides the animation of a chest when opened or closed, and suppresses the sound.
|
||||
permission: OpenInv.*;OpenInv.silent
|
||||
usage: |
|
||||
usage: |-
|
||||
/<command> [Check] - Checks whether silent chest is enabled
|
||||
anychest:
|
||||
aliases: [ac]
|
||||
description: Toggle anychest function, which allows opening of blocked chests.
|
||||
permission: OpenInv.*;OpenInv.anychest
|
||||
usage: |
|
||||
usage: |-
|
||||
/<command> [Check] - Checks whether anychest is enabled
|
||||
|
Reference in New Issue
Block a user