From bcd354bbf21c9960a30aa6a663fb14989d689099 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 16 Apr 2022 20:43:43 +0200 Subject: [PATCH] Remove Damage flag Signed-off-by: yoyosource --- .../features/region/DamageCommand.java | 91 ------------------- .../features/region/DamageListener.java | 40 -------- .../util/items/WaterVisionBauGuiItem.java | 60 ------------ .../steamwar/bausystem/region/flags/Flag.java | 1 - .../region/flags/flagvalues/DamageMode.java | 60 ------------ 5 files changed, 252 deletions(-) delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageCommand.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageListener.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionBauGuiItem.java delete mode 100644 BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/DamageMode.java diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageCommand.java deleted file mode 100644 index cedb7851..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageCommand.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -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.flagvalues.DamageMode; -import de.steamwar.command.GuardCheckType; -import de.steamwar.command.GuardChecker; -import de.steamwar.command.GuardResult; -import de.steamwar.command.SWCommand; -import org.bukkit.entity.Player; - - -@Linked(LinkageType.COMMAND) -public class DamageCommand extends SWCommand { - - protected DamageCommand() { - super("damage", "dmg"); - } - - @Register(description = "REGION_DAMAGE_HELP") - public void toggleCommand(@Guard Player p) { - Region region = Region.getRegion(p.getLocation()); - if (toggle(region)) { - RegionUtils.actionBar(region, getEnableMessage()); - } else { - RegionUtils.actionBar(region, getDisableMessage()); - } - } - - private String getNoPermMessage() { - return "REGION_DAMAGE_NO_PERMS"; - } - - private String getEnableMessage() { - return "REGION_DAMAGE_ENABLED"; - } - - private String getDisableMessage() { - return "REGION_DAMAGE_DISABLED"; - } - - private boolean toggle(Region region) { - switch (region.getPlain(Flag.DAMAGE, DamageMode.class)) { - case ALLOW: - region.set(Flag.DAMAGE, DamageMode.DENY); - return true; - default: - case DENY: - region.set(Flag.DAMAGE, DamageMode.ALLOW); - return false; - } - } - - @ClassGuard(value = Player.class, local = true) - public GuardChecker guard() { - return (commandSender, guardCheckType, strings, s) -> { - Player player = (Player) commandSender; - if (!Permission.hasPermission(player, Permission.WORLD)) { - if (guardCheckType != GuardCheckType.TAB_COMPLETE) { - BauSystem.MESSAGE.send(getNoPermMessage(), player); - } - return GuardResult.DENIED; - } - return GuardResult.ALLOWED; - }; - } -} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageListener.java b/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageListener.java deleted file mode 100644 index 0441d310..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/region/DamageListener.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.region.Region; -import de.steamwar.bausystem.region.flags.Flag; -import de.steamwar.bausystem.region.flags.flagvalues.DamageMode; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.entity.EntityDamageEvent; - - -@Linked(LinkageType.LISTENER) -public class DamageListener implements Listener { - - @EventHandler - public void onPlayerDamage(EntityDamageEvent e) { - if (e.getEntity() instanceof Player && Region.getRegion(e.getEntity().getLocation()).get(Flag.DAMAGE) == DamageMode.DENY) e.setCancelled(true); - } -} \ No newline at end of file diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionBauGuiItem.java deleted file mode 100644 index b6b6b290..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/items/WaterVisionBauGuiItem.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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.util.items; - -import de.steamwar.bausystem.BauSystem; -import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.linkage.LinkageType; -import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.bausystem.linkage.specific.BauGuiItem; -import de.steamwar.inventory.SWItem; -import org.bukkit.Material; -import org.bukkit.entity.Player; -import org.bukkit.event.inventory.ClickType; -import org.bukkit.inventory.ItemStack; -import org.bukkit.potion.PotionEffectType; - -@Linked(LinkageType.BAU_GUI_ITEM) -public class WaterVisionBauGuiItem extends BauGuiItem { - - public WaterVisionBauGuiItem() { - super(18); - } - - @Override - public ItemStack getItem(Player player) { - if (player.hasPotionEffect(PotionEffectType.WATER_BREATHING)) { - return new SWItem(Material.WATER_BUCKET, BauSystem.MESSAGE.parse("WATER_VISION_ITEM_ENABLE", player)).getItemStack(); - } else { - return new SWItem(Material.BUCKET, BauSystem.MESSAGE.parse("WATER_VISION_ITEM_DISABLE", player)).getItemStack(); - } - } - - @Override - public boolean click(ClickType click, Player p) { - p.performCommand("wv"); - return true; - } - - @Override - public Permission permission() { - return Permission.MEMBER; - } -} diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java index 4d3b9a2c..800c7a77 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/Flag.java @@ -34,7 +34,6 @@ public enum Flag implements EnumDisplay { COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, region -> false), TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, region -> true), FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, region -> true), - DAMAGE("FLAG_DAMAGE", DamageMode.class, DamageMode.ALLOW, region -> false), FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, region -> true), PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE, region -> region.getFloorLevel() != 0); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/DamageMode.java b/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/DamageMode.java deleted file mode 100644 index 071fd5fe..00000000 --- a/BauSystem_Main/src/de/steamwar/bausystem/region/flags/flagvalues/DamageMode.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2021 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.flagvalues; - -import de.steamwar.bausystem.region.flags.Flag; -import lombok.AllArgsConstructor; -import lombok.Getter; - -@Getter -@AllArgsConstructor -public enum DamageMode implements Flag.Value { - - ALLOW("FLAG_DAMAGE_ALLOW"), - DENY("FLAG_DAMAGE_DENY"); - - private static DamageMode[] values; - private final String chatValue; - - @Override - public DamageMode[] getValues() { - if (DamageMode.values == null) { - DamageMode.values = DamageMode.values(); //NOSONAR - } - return DamageMode.values; - } - - @Override - public DamageMode getValue() { - return this; - } - - @Override - public DamageMode getValueOf(final String name) { - try { - return DamageMode.valueOf(name.toUpperCase()); - } catch (IllegalArgumentException e) { - if (name.equalsIgnoreCase("false")) { - return DamageMode.DENY; - } - return DamageMode.ALLOW; - } - } -} \ No newline at end of file