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 net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.Bukkit;
|
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 (!BlockPiston.a(var1, this.a, this.c, this.d, false, this.d)) {
|
||||||
if (var1.o() == EnumPistonReaction.DESTROY) {
|
if (var1.o() == EnumPistonReaction.DESTROY) {
|
||||||
this.f.add(this.c);
|
this.f.add(this.c);
|
||||||
|
System.out.println("A");
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
System.out.println("A"+var1.getBlock().isTileEntity());
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (!this.a(this.c, this.d)) {
|
} else if (!this.a(this.c, this.d)) {
|
||||||
System.out.println("B");
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
for(int var2 = 0; var2 < this.e.size(); ++var2) {
|
for(int var2 = 0; var2 < this.e.size(); ++var2) {
|
||||||
BlockPosition var3 = (BlockPosition)this.e.get(var2);
|
BlockPosition var3 = (BlockPosition)this.e.get(var2);
|
||||||
if (this.a.getType(var3).getBlock() == Blocks.SLIME && !this.a(var3)) {
|
if (this.a.getType(var3).getBlock() == Blocks.SLIME && !this.a(var3)) {
|
||||||
System.out.println("C");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
System.out.println("B");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,7 +78,7 @@ public class PistonExtendsChecker {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
int var5 = 1;
|
int var5 = 1;
|
||||||
if (var5 + this.e.size() > maxLength) {//Надо найти почему false и сделать сундуки
|
if (var5 + this.e.size() > maxLength) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
while(var4 == Blocks.SLIME) {
|
while(var4 == Blocks.SLIME) {
|
||||||
@ -254,7 +253,11 @@ public class PistonExtendsChecker {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(block.isTileEntity()) {
|
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 {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -64,27 +64,37 @@ public class WorldListener implements Listener {
|
|||||||
BlockState state = states.get(face);
|
BlockState state = states.get(face);
|
||||||
if (state.getType().equals(Material.PISTON_STICKY_BASE)) {
|
if (state.getType().equals(Material.PISTON_STICKY_BASE)) {
|
||||||
PistonBaseMaterial piston = (PistonBaseMaterial) state.getData();
|
PistonBaseMaterial piston = (PistonBaseMaterial) state.getData();
|
||||||
|
int maxBlocks = findNearbyPlayerMaxBlocks(block.getLocation());
|
||||||
|
|
||||||
Block b = block.getRelative(piston.getFacing(), 2);
|
PistonExtendsChecker checker = new PistonExtendsChecker(e.getBlock().getWorld(),block.getLocation(),piston.getFacing(),false,maxBlocks);
|
||||||
if (ExtendedPistons.INSTANCE.isAllowedTime() && (b.getType().equals(Material.CHEST) || b.getType().equals(Material.FURNACE) || b.getType().equals(Material.BURNING_FURNACE))) {
|
boolean isMovable = checker.a();
|
||||||
Block b2 = block.getRelative(piston.getFacing());
|
List<Block> blocks = checker.getMovedBlocksObjects();
|
||||||
BlockPistonRetractEvent ev = new BlockPistonRetractEvent(block, Lists.newArrayList(b2), piston.getFacing());
|
List<Block> toBreak = checker.getBrokenBlocksObjects();
|
||||||
|
|
||||||
|
if(isMovable) {
|
||||||
|
BlockPistonRetractEvent ev = new BlockPistonRetractEvent(block, blocks, piston.getFacing());
|
||||||
Bukkit.getPluginManager().callEvent(ev);
|
Bukkit.getPluginManager().callEvent(ev);
|
||||||
if (ev.isCancelled()) continue;
|
if (ev.isCancelled()) continue;
|
||||||
b2.setType(b.getType());
|
for (Block block1 : toBreak) {
|
||||||
b2.setData(b.getData());
|
block1.breakNaturally();
|
||||||
if (b.getType().equals(Material.CHEST)) {
|
}
|
||||||
Chest oldChest = (Chest) b.getState();
|
for (Block b : blocks) {
|
||||||
Chest newChest = (Chest) b2.getState();
|
Block b2 = b.getRelative(piston.getFacing().getOppositeFace());
|
||||||
newChest.getBlockInventory().setContents(oldChest.getBlockInventory().getContents());
|
b2.setType(b.getType());
|
||||||
oldChest.getBlockInventory().clear();
|
b2.setData(b.getData());
|
||||||
} else if (b.getType().equals(Material.FURNACE) || b.getType().equals(Material.BURNING_FURNACE)) {
|
if (b.getType().equals(Material.CHEST)) {
|
||||||
Furnace oldFurnace = (Furnace) b.getState();
|
Chest oldChest = (Chest) b.getState();
|
||||||
Furnace newFurnace = (Furnace) b2.getState();
|
Chest newChest = (Chest) b2.getState();
|
||||||
newFurnace.getInventory().setContents(oldFurnace.getInventory().getContents());
|
newChest.getBlockInventory().setContents(oldChest.getBlockInventory().getContents());
|
||||||
oldFurnace.getInventory().clear();
|
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