SteamWar/BauSystem2.0
Archiviert
12
0

Remove Damage flag
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-04-16 20:43:43 +02:00
Ursprung 02c5c261e7
Commit bcd354bbf2
5 geänderte Dateien mit 0 neuen und 252 gelöschten Zeilen

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
};
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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);
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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;
}
}

Datei anzeigen

@ -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);

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<DamageMode> {
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;
}
}
}