下面列出了org.bukkit.block.Chest#getY ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public void addChest(Chest chest, ChestPlacementType cpt) {
ArrayList<CoordLoc> list;
if (cpt == ChestPlacementType.NORMAL) {
list = chests;
} else {
list = centerChests;
}
InventoryHolder ih = chest.getInventory().getHolder();
if (ih instanceof DoubleChest) {
DoubleChest dc = (DoubleChest) ih;
Chest left = (Chest) dc.getLeftSide();
Chest right = (Chest) dc.getRightSide();
CoordLoc locLeft = new CoordLoc(left.getX(), left.getY(), left.getZ());
CoordLoc locRight = new CoordLoc(right.getX(), right.getY(), right.getZ());
if (!(list.contains(locLeft) || list.contains(locRight))) {
addChest(locLeft, cpt, true);
}
} else {
CoordLoc loc = new CoordLoc(chest.getX(), chest.getY(), chest.getZ());
if (!list.contains(loc)){
addChest(loc, cpt, true);
}
}
}
public void removeChest(Chest chest) {
InventoryHolder ih = chest.getInventory().getHolder();
if (ih instanceof DoubleChest) {
DoubleChest dc = (DoubleChest) ih;
Chest left = (Chest) dc.getLeftSide();
Chest right = (Chest) dc.getRightSide();
CoordLoc locLeft = new CoordLoc(left.getX(), left.getY(), left.getZ());
CoordLoc locRight = new CoordLoc(right.getX(), right.getY(), right.getZ());
chests.remove(locLeft);
centerChests.remove(locLeft);
chests.remove(locRight);
centerChests.remove(locLeft);
saveArenaData();
} else {
CoordLoc loc = new CoordLoc(chest.getX(), chest.getY(), chest.getZ());
chests.remove(loc);
centerChests.remove(loc);
saveArenaData();
}
}