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