SteamWar/BauSystem2.0
Archiviert
12
0

Add ProtectMode

Dieser Commit ist enthalten in:
yoyosource 2021-04-17 21:06:37 +02:00
Ursprung 300aa30f12
Commit 7ca44c0795
6 geänderte Dateien mit 101 neuen und 41 gelöschten Zeilen

Datei anzeigen

@ -28,9 +28,10 @@ import lombok.Getter;
public enum Flag { public enum Flag {
TNT(TNTMode.class, TNTMode.ALLOW), TNT(TNTMode.class, TNTMode.ALLOW),
FIRE(FIREMode.class, FIREMode.ALLOW), FIRE(FireMode.class, FireMode.ALLOW),
FREEZE(FREEZEMode.class, FREEZEMode.INACTIVE), FREEZE(FreezeMode.class, FreezeMode.INACTIVE),
DAMAGE(DAMAGEMode.class, DAMAGEMode.ALLOW); PROTECT(ProtectMode.class, ProtectMode.INACTIVE),
DAMAGE(DamageMode.class, DamageMode.ALLOW);
@Getter @Getter
private static final Set<Flag> flags; private static final Set<Flag> flags;

Datei anzeigen

@ -26,35 +26,33 @@ import net.md_5.bungee.api.ChatColor;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum FIREMode implements Flag.Value<FIREMode> { public enum DamageMode implements Flag.Value<DamageMode> {
ALLOW(ChatColor.RED + "an"), ALLOW(ChatColor.RED + "an"),
DENY(ChatColor.GREEN + "aus"); DENY(ChatColor.GREEN + "aus");
private static DamageMode[] values;
private static FIREMode[] values;
private final String chatValue; private final String chatValue;
@Override @Override
public FIREMode[] getValues() { public DamageMode[] getValues() {
if (FIREMode.values == null) { if (DamageMode.values == null) {
FIREMode.values = FIREMode.values(); //NOSONAR DamageMode.values = DamageMode.values(); //NOSONAR
} }
return FIREMode.values; return DamageMode.values;
} }
@Override @Override
public FIREMode getValue() { public DamageMode getValue() {
return this; return this;
} }
@Override @Override
public FIREMode getValueOf(final String name) { public DamageMode getValueOf(final String name) {
try { try {
return FIREMode.valueOf(name); return DamageMode.valueOf(name);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return FIREMode.ALLOW; return DamageMode.ALLOW;
} }
} }
} }

Datei anzeigen

@ -26,35 +26,36 @@ import net.md_5.bungee.api.ChatColor;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum DAMAGEMode implements Flag.Value<DAMAGEMode> { public enum FireMode implements Flag.Value<FireMode> {
ALLOW(ChatColor.RED + "an"), ALLOW(ChatColor.RED + "an"),
DENY(ChatColor.GREEN + "aus"); DENY(ChatColor.GREEN + "aus");
private static FireMode[] values;
private static DAMAGEMode[] values;
private final String chatValue; private final String chatValue;
@Override @Override
public DAMAGEMode[] getValues() { public FireMode[] getValues() {
if (DAMAGEMode.values == null) { if (FireMode.values == null) {
DAMAGEMode.values = DAMAGEMode.values(); //NOSONAR FireMode.values = FireMode.values(); //NOSONAR
} }
return DAMAGEMode.values; return FireMode.values;
} }
@Override @Override
public DAMAGEMode getValue() { public FireMode getValue() {
return this; return this;
} }
@Override @Override
public DAMAGEMode getValueOf(final String name) { public FireMode getValueOf(final String name) {
try { try {
return DAMAGEMode.valueOf(name); return FireMode.valueOf(name);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return DAMAGEMode.ALLOW; if (name.equalsIgnoreCase("false")) {
return FireMode.DENY;
}
return FireMode.ALLOW;
} }
} }
} }

Datei anzeigen

@ -27,36 +27,37 @@ import net.md_5.bungee.api.ChatColor;
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum FREEZEMode implements Flag.Value<FREEZEMode> { public enum FreezeMode implements Flag.Value<FreezeMode> {
ACTIVE("activate", ChatColor.GREEN + "an"), ACTIVE("activate", ChatColor.GREEN + "an"),
INACTIVE("deactivate", ChatColor.RED + "aus"); INACTIVE("deactivate", ChatColor.RED + "aus");
private static FreezeMode[] values;
private static FREEZEMode[] values;
private final String descriptor; private final String descriptor;
private final String chatValue; private final String chatValue;
@Override @Override
public FREEZEMode[] getValues() { public FreezeMode[] getValues() {
if (FREEZEMode.values == null) { if (FreezeMode.values == null) {
FREEZEMode.values = FREEZEMode.values(); //NOSONAR FreezeMode.values = FreezeMode.values(); //NOSONAR
} }
return FREEZEMode.values; return FreezeMode.values;
} }
@Override @Override
public FREEZEMode getValue() { public FreezeMode getValue() {
return this; return this;
} }
@Override @Override
public FREEZEMode getValueOf(final String name) { public FreezeMode getValueOf(final String name) {
try { try {
return FREEZEMode.valueOf(name); return FreezeMode.valueOf(name);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
return FREEZEMode.INACTIVE; if (name.equalsIgnoreCase("false")) {
return FreezeMode.INACTIVE;
}
return FreezeMode.INACTIVE;
} }
} }

Datei anzeigen

@ -0,0 +1,61 @@
/*
* 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;
import net.md_5.bungee.api.ChatColor;
@Getter
@AllArgsConstructor
public enum ProtectMode implements Flag.Value<ProtectMode> {
ACTIVE(ChatColor.GREEN + "an"),
INACTIVE(ChatColor.RED + "aus");
private static ProtectMode[] values;
private final String chatValue;
@Override
public ProtectMode[] getValues() {
if (ProtectMode.values == null) {
ProtectMode.values = ProtectMode.values(); //NOSONAR
}
return ProtectMode.values;
}
@Override
public ProtectMode getValue() {
return this;
}
@Override
public ProtectMode getValueOf(final String name) {
try {
return ProtectMode.valueOf(name);
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return ProtectMode.INACTIVE;
}
return ProtectMode.ACTIVE;
}
}
}

Datei anzeigen

@ -32,11 +32,9 @@ public enum TNTMode implements Flag.Value<TNTMode> {
DENY(ChatColor.RED + "aus"), DENY(ChatColor.RED + "aus"),
ONLY_TB(ChatColor.GRAY + "Kein " + ChatColor.YELLOW + "Baurahmen"); ONLY_TB(ChatColor.GRAY + "Kein " + ChatColor.YELLOW + "Baurahmen");
private static TNTMode[] values; private static TNTMode[] values;
private final String chatValue; private final String chatValue;
@Override @Override
public TNTMode[] getValues() { public TNTMode[] getValues() {
if (TNTMode.values == null) { if (TNTMode.values == null) {