From 1cfaa01f0ed4bcc40d033811dea89e8c0460e7c1 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sun, 1 Mar 2020 15:37:38 +0100 Subject: [PATCH] WorldEdit autofreeze --- .../bausystem/commands/CommandFreeze.java | 22 ++++++++++++++++++- .../bausystem/world/RegionListener.java | 8 +++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java index e518c82..71760bc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandFreeze.java @@ -1,7 +1,7 @@ package de.steamwar.bausystem.commands; import org.bukkit.event.EventHandler; -import org.bukkit.event.block.BlockPhysicsEvent; +import org.bukkit.event.block.*; public class CommandFreeze extends ToggleCommand { @@ -30,4 +30,24 @@ public class CommandFreeze extends ToggleCommand { public void onPhysicsEvent(BlockPhysicsEvent e){ e.setCancelled(true); } + + @EventHandler + public void onPistonExtend(BlockPistonExtendEvent e){ + e.setCancelled(true); + } + + @EventHandler + public void onPistonRetract(BlockPistonRetractEvent e){ + e.setCancelled(true); + } + + @EventHandler + public void onBlockGrow(BlockGrowEvent e){ + e.setCancelled(true); + } + + @EventHandler + public void onRedstoneEvent(BlockRedstoneEvent e){ + e.setNewCurrent(e.getOldCurrent()); + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java index 79cb16c..e7bb033 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/world/RegionListener.java @@ -3,7 +3,9 @@ package de.steamwar.bausystem.world; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; +import de.steamwar.bausystem.commands.CommandFreeze; import de.steamwar.core.Core; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; @@ -26,6 +28,12 @@ public class RegionListener implements Listener { if (Welt.noPermission(p, Permission.worldedit)){ p.sendMessage(BauSystem.PREFIX + "§cDu darfst hier kein WorldEdit benutzen"); e.setCancelled(true); + return; + } + + if(!CommandFreeze.getInstance().isOn()){ + CommandFreeze.getInstance().toggle(); + Bukkit.getScheduler().runTaskLater(BauSystem.getPlugin(), CommandFreeze.getInstance()::toggle, 1); } }