diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java index 98021658..b0cb9935 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/region/FreezeListener.java @@ -109,6 +109,15 @@ public class FreezeListener implements Listener { } } + @EventHandler + public void onBlockPlace(BlockPlaceEvent event) { + if (Core.getVersion() < 19) return; + if (Region.getRegion(event.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + event.setCancelled(true); + event.getBlock().setType(event.getItemInHand().getType(), false); + } + } + @EventHandler public void onFluidLevelChange(FluidLevelChangeEvent e) { if (Region.getRegion(e.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { @@ -129,4 +138,11 @@ public class FreezeListener implements Listener { event.setCancelled(true); } } + + @EventHandler + public void onSpongeAbsorb(SpongeAbsorbEvent event) { + if (Region.getRegion(event.getBlock().getLocation()).get(Flag.FREEZE) == FreezeMode.ACTIVE) { + event.setCancelled(true); + } + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java index 67a76671..0e96b17f 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/Region.java @@ -21,6 +21,7 @@ package de.steamwar.bausystem.region; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.flagvalues.ColorMode; import de.steamwar.bausystem.region.flags.flagvalues.TNTMode; @@ -29,6 +30,7 @@ import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.shared.SizedStack; import de.steamwar.bausystem.utils.FlatteningWrapper; +import de.steamwar.core.Core; import de.steamwar.sql.SchematicNode; import lombok.AccessLevel; import lombok.Getter; @@ -44,6 +46,7 @@ import java.io.IOException; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.*; +import java.util.function.ObjIntConsumer; import java.util.function.Predicate; import java.util.stream.Collectors; @@ -572,4 +575,26 @@ public class Region { if (files == null || files.length == 0) return null; return files[0]; } + + public void forEachChunk(ObjIntConsumer executor) { + for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) { + for (int z = (int) Math.floor(minPoint.getZ() / 16.0); z <= (int) Math.ceil(maxPoint.getZ() / 16.0); z++) { + executor.accept(x, z); + } + } + } + + public boolean chunkOutside(int chunkX, int chunkY) { + return Math.floor(minPoint.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPoint.getX() / 16.0) || + Math.floor(minPoint.getZ() / 16.0) > chunkY || chunkY >= Math.ceil(maxPoint.getZ() / 16.0); + } + + public File gameModeConfig() { + File baseFile = new File(BauSystem.getInstance().getDataFolder().getParentFile(), "FightSystem"); + for (int version = Core.getVersion(); version > 15; version--) { + File specific = new File(baseFile, getDisplayName() + version + ".yml"); + if (specific.exists()) return specific; + } + return null; + } } \ No newline at end of file