fix allowed time
This commit is contained in:
parent
d60b1aa716
commit
20c21a497a
@ -1,4 +1,4 @@
|
||||
package ru.redguy.extendedpistons; //TODO: Block 3th chest is his at the sides, slime blocks, power supply remove, refactor
|
||||
package ru.redguy.extendedpistons; //TODO: Block 3th chests, slime sides chests move, power supply remove, refactor
|
||||
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -46,22 +46,21 @@ public class PistonExtendsChecker {
|
||||
if (!BlockPiston.a(var1, this.a, this.c, this.d, false, this.d)) {
|
||||
if (var1.o() == EnumPistonReaction.DESTROY) {
|
||||
this.f.add(this.c);
|
||||
System.out.println("A");
|
||||
return true;
|
||||
} else {
|
||||
System.out.println("A"+var1.getBlock().isTileEntity());
|
||||
return false;
|
||||
}
|
||||
} else if (!this.a(this.c, this.d)) {
|
||||
System.out.println("B");
|
||||
return false;
|
||||
} else {
|
||||
for(int var2 = 0; var2 < this.e.size(); ++var2) {
|
||||
BlockPosition var3 = (BlockPosition)this.e.get(var2);
|
||||
if (this.a.getType(var3).getBlock() == Blocks.SLIME && !this.a(var3)) {
|
||||
System.out.println("C");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
System.out.println("B");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -79,7 +78,7 @@ public class PistonExtendsChecker {
|
||||
return true;
|
||||
} else {
|
||||
int var5 = 1;
|
||||
if (var5 + this.e.size() > maxLength) {//Надо найти почему false и сделать сундуки
|
||||
if (var5 + this.e.size() > maxLength) {
|
||||
return false;
|
||||
} else {
|
||||
while(var4 == Blocks.SLIME) {
|
||||
@ -254,7 +253,11 @@ public class PistonExtendsChecker {
|
||||
}
|
||||
|
||||
if(block.isTileEntity()) {
|
||||
return block == Blocks.CHEST || block == Blocks.FURNACE || block == Blocks.LIT_FURNACE;
|
||||
if(block == Blocks.CHEST || block == Blocks.FURNACE || block == Blocks.LIT_FURNACE) {
|
||||
return ExtendedPistons.INSTANCE.isAllowedTime();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
@ -64,27 +64,37 @@ public class WorldListener implements Listener {
|
||||
BlockState state = states.get(face);
|
||||
if (state.getType().equals(Material.PISTON_STICKY_BASE)) {
|
||||
PistonBaseMaterial piston = (PistonBaseMaterial) state.getData();
|
||||
int maxBlocks = findNearbyPlayerMaxBlocks(block.getLocation());
|
||||
|
||||
Block b = block.getRelative(piston.getFacing(), 2);
|
||||
if (ExtendedPistons.INSTANCE.isAllowedTime() && (b.getType().equals(Material.CHEST) || b.getType().equals(Material.FURNACE) || b.getType().equals(Material.BURNING_FURNACE))) {
|
||||
Block b2 = block.getRelative(piston.getFacing());
|
||||
BlockPistonRetractEvent ev = new BlockPistonRetractEvent(block, Lists.newArrayList(b2), piston.getFacing());
|
||||
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) {
|
||||
BlockPistonRetractEvent ev = new BlockPistonRetractEvent(block, blocks, piston.getFacing());
|
||||
Bukkit.getPluginManager().callEvent(ev);
|
||||
if (ev.isCancelled()) continue;
|
||||
b2.setType(b.getType());
|
||||
b2.setData(b.getData());
|
||||
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();
|
||||
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());
|
||||
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);
|
||||
}
|
||||
b.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user