diff --git a/BauSystem/BauSystem_Main/src/BauSystem.properties b/BauSystem/BauSystem_Main/src/BauSystem.properties index e6c490d7..334ee6a0 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem.properties @@ -52,6 +52,9 @@ FLAG_ITEMS=Items FLAG_NO_GRAVITY = No Gravity FLAG_TESTBLOCK=Testblock FLAG_CHANGED=Changed +FLAG_WATER_DESTROY=Water Block +FLAG_WATER_DESTROY_ALLOW=§coff +FLAG_WATER_DESTROY_DENY=§aon FLAG_FIRE_ALLOW=§con FLAG_FIRE_DENY=§aoff FLAG_FREEZE_ACTIVE=§aon @@ -756,6 +759,9 @@ REGION_FIRE_DISABLED=§aFire damage activated in this region REGION_FREEZE_HELP=§8/§efreeze §8- §7Toggle Freeze REGION_FREEZE_ENABLED=§cRegion frozen REGION_FREEZE_DISABLED=§aRegion thawed +REGION_WATER_HELP=§8/§ewaterblock §8- §7Toggle water damage +REGION_WATER_ENABLED=§aWater damage deactivated in this region +REGION_WATER_DISABLED=§cWater damage activated in this region REGION_ITEMS_HELP=§8/§eitems §8- §7Toggle Items REGION_ITEMS_ENABLED=§aItems enabled in this region REGION_ITEMS_DISABLED=§cItems disabled in this region diff --git a/BauSystem/BauSystem_Main/src/BauSystem_de.properties b/BauSystem/BauSystem_Main/src/BauSystem_de.properties index f0d55c5c..14248fc0 100644 --- a/BauSystem/BauSystem_Main/src/BauSystem_de.properties +++ b/BauSystem/BauSystem_Main/src/BauSystem_de.properties @@ -54,6 +54,9 @@ FLAG_FREEZE_ACTIVE=§aan FLAG_FREEZE_INACTIVE=§caus FLAG_PROTECT_ACTIVE=§aan FLAG_PROTECT_INACTIVE=§caus +FLAG_WATER_DESTROY=Wasserschaden +FLAG_WATER_DESTROY_ALLOW=§cerlaubt +FLAG_WATER_DESTROY_DENY=§aaus FLAG_TNT_ALLOW=§aan FLAG_TNT_DENY=§caus FLAG_TNT_ONLY_TB=§7Kein §eBaurahmen @@ -704,6 +707,9 @@ REGION_PROTECT_FALSE_REGION=§cDu befindest dich derzeit in keiner (M)WG-Region REGION_NO_GRAVITY_HELP = §8/§enogravity §8- §7Toggle NoGravity REGION_NO_GRAVITY_ENABLED = §aNoGravity aktiviert in dieser Region REGION_NO_GRAVITY_DISABLED = §cNoGravity deaktiviert in dieser Region +REGION_WATER_HELP=§8/§ewaterblock §8- §7Wasserschaden umschalten +REGION_WATER_ENABLED=§aWasserschaden deaktiviert +REGION_WATER_DISABLED=§cWasserschaden aktiviert REGION_REGION_HELP_UNDO=§8/§eregion undo §8- §7Mache die letzten 20 /testblock oder /reset rückgängig REGION_REGION_HELP_REDO=§8/§eregion redo §8- §7Wiederhole die letzten 20 §8/§7rg undo REGION_REGION_HELP_RESTORE=§8/§eregion restore §8- §7Setzte die Region zurück, ohne das Gebaute zu löschen diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/WaterDestroyCommand.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/WaterDestroyCommand.java new file mode 100644 index 00000000..ec2e82b9 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/WaterDestroyCommand.java @@ -0,0 +1,64 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2025 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.region; + +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.RegionUtils; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.WaterDestroyMode; +import de.steamwar.command.SWCommand; +import de.steamwar.linkage.Linked; +import org.bukkit.entity.Player; + +@Linked +public class WaterDestroyCommand extends SWCommand { + public WaterDestroyCommand() { + super("waterdestroy"); + } + + private String getEnableMessage(){ + return "REGION_WATER_ENABLED"; + } + + private String getDisableMessage(){ + return "REGION_WATER_DISABLED"; + } + + @Register(description = "REGION_WATER_HELP") + public void toggleCommand(@Validator Player p) { + Region region = Region.getRegion(p.getLocation()); + + if (toggle(region)) { + RegionUtils.actionBar(region, getEnableMessage()); + } else { + RegionUtils.actionBar(region, getDisableMessage()); + } + } + + private boolean toggle(Region region) { + if (region.getRegionData().get(Flag.WATER_DESTROY).isWithDefault(WaterDestroyMode.DENY)) { + region.getRegionData().set(Flag.WATER_DESTROY, WaterDestroyMode.ALLOW); + return false; + } else { + region.getRegionData().set(Flag.WATER_DESTROY, WaterDestroyMode.DENY); + return true; + } + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/WaterDestroyListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/WaterDestroyListener.java new file mode 100644 index 00000000..4e4ba725 --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/region/WaterDestroyListener.java @@ -0,0 +1,57 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2025 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.features.region; + +import de.steamwar.bausystem.BauSystem; +import de.steamwar.bausystem.region.Region; +import de.steamwar.bausystem.region.flags.Flag; +import de.steamwar.bausystem.region.flags.WaterDestroyMode; +import de.steamwar.bausystem.utils.ScoreboardElement; +import de.steamwar.linkage.Linked; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +import org.bukkit.event.block.BlockFromToEvent; + +@Linked +public class WaterDestroyListener implements Listener, ScoreboardElement { + + @EventHandler + public void onBlockFromTo(BlockFromToEvent event) { + if (event.getBlock().getType() == Material.WATER && event.getToBlock().getType() != Material.AIR && Region.getRegion(event.getBlock().getLocation()).getRegionData().get(Flag.WATER_DESTROY).isWithDefault(WaterDestroyMode.DENY)) event.setCancelled(true); + } + + @Override + public ScoreboardGroup getGroup() { + return ScoreboardGroup.REGION; + } + + @Override + public int order() { + return 5; + } + + @Override + public String get(Region region, Player p) { + if (region.getRegionData().get(Flag.WATER_DESTROY).isWithDefault(WaterDestroyMode.ALLOW)) return null; + return "§e" + BauSystem.MESSAGE.parse(Flag.WATER_DESTROY.getChatValue(), p) + "§8: " + BauSystem.MESSAGE.parse(region.getRegionData().get(Flag.WATER_DESTROY).getWithDefault().getChatValue(), p); + } +} diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index f2213470..5bd32444 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -43,6 +43,7 @@ public final class Flag & Flag.Value> implements EnumDispla public static final Flag NO_GRAVITY = new Flag<>("NO_GRAVITY", "FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE); public static final Flag TESTBLOCK = new Flag<>("TESTBLOCK", "FLAG_TESTBLOCK", TestblockMode.class, TestblockMode.NO_VALUE); public static final Flag CHANGED = new Flag<>("CHANGED", "FLAG_CHANGED", ChangedMode.class, ChangedMode.NO_CHANGE); + public static final Flag WATER_DESTROY = new Flag<>("WATER_DESTROY", "FLAG_WATER_DESTROY", WaterDestroyMode.class, WaterDestroyMode.ALLOW); private String name; private int ordinal; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/WaterDestroyMode.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/WaterDestroyMode.java new file mode 100644 index 00000000..1917ebea --- /dev/null +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/region/flags/WaterDestroyMode.java @@ -0,0 +1,56 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2025 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bausystem.region.flags; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public enum WaterDestroyMode implements Flag.Value { + + ALLOW("FLAG_WATER_DESTROY_ALLOW"), + DENY("FLAG_WATER_DESTROY_DENY"); + + private static WaterDestroyMode[] values; + private final String chatValue; + + @Override + public WaterDestroyMode[] getValues() { + if (WaterDestroyMode.values == null) { + WaterDestroyMode.values = WaterDestroyMode.values(); + } + return WaterDestroyMode.values; + } + + @Override + public WaterDestroyMode getValue() { + return this; + } + + @Override + public WaterDestroyMode getValueOf(final String name) { + try { + return WaterDestroyMode.valueOf(name.toUpperCase()); + } catch (IllegalArgumentException e) { + return ALLOW; + } + } +} \ No newline at end of file diff --git a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java index 4da87bd9..b42b15e7 100644 --- a/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java +++ b/BauSystem/BauSystem_RegionFixed/src/de/steamwar/bausystem/region/fixed/FixedRegionData.java @@ -34,7 +34,7 @@ public class FixedRegionData extends RegionData { @Override public @NonNull & Flag.Value> RegionFlagPolicy has(@NonNull Flag flag) { - if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED)) { + if (flag.oneOf(Flag.COLOR, Flag.TNT, Flag.FIRE, Flag.FREEZE, Flag.PROTECT, Flag.NO_GRAVITY, Flag.CHANGED, Flag.WATER_DESTROY)) { return RegionFlagPolicy.WRITABLE; } if (flag.oneOf(Flag.ITEMS) && Core.getVersion() >= 20) {