Remove commented
This commit is contained in:
parent
76595a69ad
commit
49ac50043e
@ -38,139 +38,6 @@ public class WorldListener implements Listener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
|
||||||
public void onPhysic(BlockPhysicsEvent e) {
|
|
||||||
if (!(e.getBlock().getType().equals(Material.PISTON_STICKY_BASE) || e.getBlock().getType().equals(Material.PISTON_BASE)))
|
|
||||||
return;
|
|
||||||
if (!(e.getBlock().isBlockPowered() || e.getBlock().isBlockIndirectlyPowered())) {
|
|
||||||
if (!e.getBlock().getType().equals(Material.PISTON_STICKY_BASE)) return;
|
|
||||||
if (!ExtendedPistons.INSTANCE.isStickyPistonPulls()) return;
|
|
||||||
Block block = e.getBlock();
|
|
||||||
BlockState state = block.getState();
|
|
||||||
PistonBaseMaterial piston;
|
|
||||||
try {
|
|
||||||
piston = (PistonBaseMaterial) state.getData();
|
|
||||||
} catch (ClassCastException ex) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().runTask(ExtendedPistons.INSTANCE, () -> {
|
|
||||||
if (!(e.getBlock().isBlockPowered() || e.getBlock().isBlockIndirectlyPowered())) return;
|
|
||||||
int maxBlocks = findNearbyPlayerMaxBlocks(block.getLocation());
|
|
||||||
|
|
||||||
PistonExtendsChecker checker = new PistonExtendsChecker(e.getBlock().getWorld(), block.getLocation(), piston.getFacing(), false, maxBlocks);
|
|
||||||
boolean isMovable = checker.a();
|
|
||||||
List<Block> blocks = checker.getMovedBlocksObjects();
|
|
||||||
List<Block> toBreak = checker.getBrokenBlocksObjects();
|
|
||||||
|
|
||||||
if (isMovable) {
|
|
||||||
if (!isBlocksAllowedToInteract(copyWithAdd(blocks, toBreak), piston.getFacing()))
|
|
||||||
return;
|
|
||||||
for (Block block1 : toBreak) {
|
|
||||||
block1.breakNaturally();
|
|
||||||
}
|
|
||||||
for (Block b : blocks) {
|
|
||||||
Block b2 = b.getRelative(piston.getFacing().getOppositeFace());
|
|
||||||
b2.setType(b.getType());
|
|
||||||
b2.setData(b.getData()); //Deprecated but powerful
|
|
||||||
if (b.getType().equals(Material.CHEST)) {
|
|
||||||
Chest oldChest = (Chest) b.getState();
|
|
||||||
Chest newChest = (Chest) b2.getState();
|
|
||||||
newChest.getBlockInventory().setContents(oldChest.getBlockInventory().getContents());
|
|
||||||
oldChest.getBlockInventory().clear();
|
|
||||||
} else if (b.getType().equals(Material.FURNACE) || b.getType().equals(Material.BURNING_FURNACE)) {
|
|
||||||
Furnace oldFurnace = (Furnace) b.getState();
|
|
||||||
Furnace newFurnace = (Furnace) b2.getState();
|
|
||||||
newFurnace.getInventory().setContents(oldFurnace.getInventory().getContents());
|
|
||||||
oldFurnace.getInventory().clear();
|
|
||||||
}
|
|
||||||
b.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Block block = e.getBlock();
|
|
||||||
BlockState state = block.getState();
|
|
||||||
PistonBaseMaterial piston;
|
|
||||||
try {
|
|
||||||
piston = (PistonBaseMaterial) state.getData();
|
|
||||||
} catch (ClassCastException ex) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Bukkit.getScheduler().runTask(ExtendedPistons.INSTANCE, () -> {
|
|
||||||
if (e.getBlock().isBlockPowered() || e.getBlock().isBlockIndirectlyPowered()) return;
|
|
||||||
int maxBlocks = findNearbyPlayerMaxBlocks(block.getLocation());
|
|
||||||
|
|
||||||
PistonExtendsChecker checker = new PistonExtendsChecker(e.getBlock().getWorld(), block.getLocation(), piston.getFacing(), true, maxBlocks);
|
|
||||||
boolean isMovable = checker.a();
|
|
||||||
List<Block> blocks = checker.getMovedBlocksObjects();
|
|
||||||
List<Block> toBreak = checker.getBrokenBlocksObjects();
|
|
||||||
|
|
||||||
upper:
|
|
||||||
for (Block b : blocks) {
|
|
||||||
if (b.getType().equals(Material.CHEST)) {
|
|
||||||
Block b2 = b.getRelative(piston.getFacing());
|
|
||||||
ArrayList<BlockFace> faces = new ArrayList<BlockFace>() {{
|
|
||||||
add(BlockFace.NORTH);
|
|
||||||
add(BlockFace.SOUTH);
|
|
||||||
add(BlockFace.WEST);
|
|
||||||
add(BlockFace.EAST);
|
|
||||||
}};
|
|
||||||
faces.remove(piston.getFacing().getOppositeFace());
|
|
||||||
int chests = 0;
|
|
||||||
for (BlockFace blockFace : faces) {
|
|
||||||
Block b3 = b2.getRelative(blockFace);
|
|
||||||
if (b3.getType() == Material.CHEST) {
|
|
||||||
chests++;
|
|
||||||
Chest chest = (Chest) b3.getState();
|
|
||||||
if (chest.getInventory() instanceof DoubleChestInventory) {
|
|
||||||
isMovable = false;
|
|
||||||
break upper;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (chests > 1) {
|
|
||||||
isMovable = false;
|
|
||||||
break;
|
|
||||||
} else if (chests == 1) {
|
|
||||||
if (b.getType() == Material.CHEST) {
|
|
||||||
Chest chest = (Chest) b.getState();
|
|
||||||
if (chest.getInventory() instanceof DoubleChestInventory) {
|
|
||||||
isMovable = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isMovable) {
|
|
||||||
if (!isBlocksAllowedToInteract(copyWithAdd(blocks, toBreak), piston.getFacing())) return;
|
|
||||||
Collections.reverse(blocks);
|
|
||||||
for (Block block1 : toBreak) {
|
|
||||||
block1.breakNaturally();
|
|
||||||
}
|
|
||||||
for (Block b : blocks) {
|
|
||||||
Block b2 = b.getRelative(piston.getFacing());
|
|
||||||
b2.setType(b.getType());
|
|
||||||
b2.setData(b.getData()); //Deprecated but powerful
|
|
||||||
if (b.getType().equals(Material.CHEST)) {
|
|
||||||
Chest oldChest = (Chest) b.getState();
|
|
||||||
Chest newChest = (Chest) b2.getState();
|
|
||||||
newChest.getBlockInventory().setContents(oldChest.getBlockInventory().getContents());
|
|
||||||
oldChest.getBlockInventory().clear();
|
|
||||||
} else if (b.getType().equals(Material.FURNACE) || b.getType().equals(Material.BURNING_FURNACE)) {
|
|
||||||
Furnace oldFurnace = (Furnace) b.getState();
|
|
||||||
Furnace newFurnace = (Furnace) b2.getState();
|
|
||||||
newFurnace.getInventory().setContents(oldFurnace.getInventory().getContents());
|
|
||||||
oldFurnace.getInventory().clear();
|
|
||||||
}
|
|
||||||
b.setType(Material.AIR);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
public void onBlockBreak(BlockBreakEvent e) {
|
public void onBlockBreak(BlockBreakEvent e) {
|
||||||
Material blockType = e.getBlock().getType();
|
Material blockType = e.getBlock().getType();
|
||||||
|
Reference in New Issue
Block a user