diff --git a/worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/TimeLockFlag.java b/worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/TimeLockFlag.java index 660f5be8..befe2fa2 100644 --- a/worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/TimeLockFlag.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/session/handler/TimeLockFlag.java @@ -42,7 +42,7 @@ public TimeLockFlag create(Session session) { private Long initialTime; private boolean initialRelative; - private static Pattern timePattern = Pattern.compile("(\\+|-)?\\d+"); + private static Pattern timePattern = Pattern.compile("([+\\-])?\\d+"); public TimeLockFlag(Session session) { super(session, Flags.TIME_LOCK); diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/SpongeUtil.java b/worldguard-core/src/main/java/com/sk89q/worldguard/util/SpongeUtil.java similarity index 88% rename from worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/SpongeUtil.java rename to worldguard-core/src/main/java/com/sk89q/worldguard/util/SpongeUtil.java index abb7bb5e..c4a6dd51 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/SpongeUtil.java +++ b/worldguard-core/src/main/java/com/sk89q/worldguard/util/SpongeUtil.java @@ -17,11 +17,12 @@ * along with this program. If not, see . */ -package com.sk89q.worldguard.bukkit.listener; +package com.sk89q.worldguard.util; import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.world.World; +import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldguard.WorldGuard; import com.sk89q.worldguard.config.WorldConfiguration; @@ -31,6 +32,12 @@ public final class SpongeUtil { private SpongeUtil() { } + private static boolean isReplacable(BlockType blockType) { + return blockType == BlockTypes.WATER || blockType == BlockTypes.SEAGRASS + || blockType == BlockTypes.TALL_SEAGRASS || blockType == BlockTypes.KELP_PLANT + || blockType == BlockTypes.KELP; + } + /** * Remove water around a sponge. * @@ -46,7 +53,7 @@ public static void clearSpongeWater(World world, int ox, int oy, int oz) { for (int cy = -wcfg.spongeRadius; cy <= wcfg.spongeRadius; cy++) { for (int cz = -wcfg.spongeRadius; cz <= wcfg.spongeRadius; cz++) { BlockVector3 vector = BlockVector3.at(ox + cx, oy + cy, oz + cz); - if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) { + if (isReplacable(world.getBlock(vector).getBlockType())) { try { world.setBlock(vector, BlockTypes.AIR.getDefaultState()); } catch (WorldEditException e) { @@ -90,7 +97,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) { for (int cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) { for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) { BlockVector3 vector = BlockVector3.at(cx, cy, cz); - if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) { + if (isReplacable(world.getBlock(vector).getBlockType())) { try { setBlockToWater(world, cx + 1, cy, cz); } catch (WorldEditException e) { @@ -105,7 +112,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) { for (int cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) { for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) { BlockVector3 vector = BlockVector3.at(cx, cy, cz); - if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) { + if (isReplacable(world.getBlock(vector).getBlockType())) { try { setBlockToWater(world, cx - 1, cy, cz); } catch (WorldEditException e) { @@ -120,7 +127,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) { for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) { for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) { BlockVector3 vector = BlockVector3.at(cx, cy, cz); - if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) { + if (isReplacable(world.getBlock(vector).getBlockType())) { try { setBlockToWater(world, cx, cy + 1, cz); } catch (WorldEditException e) { @@ -135,7 +142,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) { for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) { for (int cz = oz - wcfg.spongeRadius - 1; cz <= oz + wcfg.spongeRadius + 1; cz++) { BlockVector3 vector = BlockVector3.at(cx, cy, cz); - if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) { + if (isReplacable(world.getBlock(vector).getBlockType())) { try { setBlockToWater(world, cx, cy - 1, cz); } catch (WorldEditException e) { @@ -150,7 +157,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) { for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) { for (cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) { BlockVector3 vector = BlockVector3.at(cx, cy, cz); - if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) { + if (isReplacable(world.getBlock(vector).getBlockType())) { try { setBlockToWater(world, cx, cy, cz + 1); } catch (WorldEditException e) { @@ -165,7 +172,7 @@ public static void addSpongeWater(World world, int ox, int oy, int oz) { for (cx = ox - wcfg.spongeRadius - 1; cx <= ox + wcfg.spongeRadius + 1; cx++) { for (cy = oy - wcfg.spongeRadius - 1; cy <= oy + wcfg.spongeRadius + 1; cy++) { BlockVector3 vector = BlockVector3.at(cx, cy, cz); - if (world.getBlock(vector).getBlockType() == BlockTypes.WATER) { + if (isReplacable(world.getBlock(vector).getBlockType())) { try { setBlockToWater(world, cx, cy, cz - 1); } catch (WorldEditException e) { diff --git a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardBlockListener.java b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardBlockListener.java index db38f745..682c397c 100644 --- a/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardBlockListener.java +++ b/worldguard-legacy/src/main/java/com/sk89q/worldguard/bukkit/listener/WorldGuardBlockListener.java @@ -29,6 +29,7 @@ import com.sk89q.worldguard.protection.association.RegionAssociable; import com.sk89q.worldguard.protection.flags.Flags; import com.sk89q.worldguard.protection.flags.StateFlag; +import com.sk89q.worldguard.util.SpongeUtil; import org.bukkit.Material; import org.bukkit.Tag; import org.bukkit.World;