Disabled piston pulls
This commit is contained in:
parent
38e9c458e9
commit
716bc7c9a6
@ -46,6 +46,8 @@ public final class ExtendedPistons extends JavaPlugin {
|
||||
conf.set("enabled-times.Sat",new ArrayList<String>() {{add("14:00-18:00");}});
|
||||
if(!conf.isSet("enabled-times.Sun"))
|
||||
conf.set("enabled-times.Sun",new ArrayList<String>() {{add("14:00-18:00");}});
|
||||
if(!conf.isSet("sticky-piston-pulls-chest"))
|
||||
conf.set("sticky-piston-pulls-chest",true);
|
||||
|
||||
saveConfig();
|
||||
|
||||
@ -88,6 +90,10 @@ public final class ExtendedPistons extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isStickyPistonPulls() {
|
||||
return conf.getBoolean("sticky-piston-pulls-chest");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
|
@ -5,7 +5,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.*;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@ -28,7 +27,6 @@ public class WorldListener implements Listener {
|
||||
int maxBlocks = findNearbyPlayerMaxBlocks(block.getLocation());
|
||||
|
||||
ArrayList<Block> blocks = new ArrayList<>();
|
||||
Block toBreak = null;
|
||||
boolean isMovable = true;
|
||||
Block firstBlock = block.getRelative(piston.getFacing());
|
||||
if (firstBlock.isLiquid() || firstBlock.isEmpty()) {
|
||||
@ -38,12 +36,12 @@ public class WorldListener implements Listener {
|
||||
if (b.isLiquid() || b.isEmpty()) break;
|
||||
if (b.getPistonMoveReaction().equals(PistonMoveReaction.IGNORE) || b.getPistonMoveReaction().equals(PistonMoveReaction.BLOCK)) {
|
||||
if (!(b.getType() == Material.CHEST || b.getType() == Material.FURNACE || b.getType() == Material.BURNING_FURNACE)) {
|
||||
if (ExtendedPistons.INSTANCE.isAllowedTime())
|
||||
isMovable = false;
|
||||
} else {
|
||||
blocks.add(b);
|
||||
}
|
||||
} else if (b.getPistonMoveReaction().equals(PistonMoveReaction.BREAK)) {
|
||||
toBreak = b;
|
||||
break;
|
||||
} else {
|
||||
blocks.add(b);
|
||||
@ -67,6 +65,7 @@ public class WorldListener implements Listener {
|
||||
}
|
||||
Bukkit.getScheduler().runTask(ExtendedPistons.INSTANCE, () -> {
|
||||
if (e.getOldCurrent() != 0 && e.getNewCurrent() == 0) {
|
||||
if (ExtendedPistons.INSTANCE.isStickyPistonPulls()) {
|
||||
ArrayList<BlockFace> checkedBlockFaces = new ArrayList<BlockFace>() {{
|
||||
add(BlockFace.SELF);
|
||||
add(BlockFace.UP);
|
||||
@ -90,7 +89,7 @@ public class WorldListener implements Listener {
|
||||
PistonBaseMaterial piston = (PistonBaseMaterial) state.getData();
|
||||
|
||||
Block b = block.getRelative(piston.getFacing(), 2);
|
||||
if(b.getType().equals(Material.CHEST)||b.getType().equals(Material.FURNACE)||b.getType().equals(Material.BURNING_FURNACE)) {
|
||||
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());
|
||||
Bukkit.getPluginManager().callEvent(ev);
|
||||
@ -112,6 +111,7 @@ public class WorldListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ArrayList<BlockFace> checkedBlockFaces = new ArrayList<BlockFace>() {{
|
||||
add(BlockFace.SELF);
|
||||
@ -147,6 +147,7 @@ public class WorldListener implements Listener {
|
||||
if (b.isLiquid() || b.isEmpty()) break;
|
||||
if (b.getPistonMoveReaction().equals(PistonMoveReaction.IGNORE) || b.getPistonMoveReaction().equals(PistonMoveReaction.BLOCK)) {
|
||||
if (!(b.getType() == Material.CHEST || b.getType() == Material.FURNACE || b.getType() == Material.BURNING_FURNACE)) {
|
||||
if (ExtendedPistons.INSTANCE.isAllowedTime())
|
||||
isMovable = false;
|
||||
} else {
|
||||
blocks.add(b);
|
||||
|
Reference in New Issue
Block a user