Update Region System of BauSystem

This commit is contained in:
2024-12-21 19:30:31 +01:00
parent 8427ae36f2
commit 6822dc796f
73 changed files with 927 additions and 1796 deletions
@@ -0,0 +1,57 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 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;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum ChangedMode implements Flag.Value<ChangedMode> {
NO_CHANGE("FLAG_CHANGED_NO_CHANGE", false),
HAS_CHANGE("FLAG_CHANGED_HAS_CHANGE", true);
private static ChangedMode[] values;
private final String chatValue;
private final Boolean changed;
@Override
public ChangedMode[] getValues() {
if (ChangedMode.values == null) {
ChangedMode.values = ChangedMode.values(); //NOSONAR
}
return ChangedMode.values;
}
@Override
public ChangedMode getValue() {
return this;
}
@Override
public ChangedMode getValueOf(final String name) {
try {
return ChangedMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return NO_CHANGE;
}
}
}
@@ -1,26 +1,25 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2024 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 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.
* 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/>.
* 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;
package de.steamwar.bausystem.region.flags;
import de.steamwar.bausystem.regionnew.Color;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.Color;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -0,0 +1,59 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 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;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum FireMode implements Flag.Value<FireMode> {
ALLOW("FLAG_FIRE_ALLOW"),
DENY("FLAG_FIRE_DENY");
private static FireMode[] values;
private final String chatValue;
@Override
public FireMode[] getValues() {
if (FireMode.values == null) {
FireMode.values = FireMode.values(); //NOSONAR
}
return FireMode.values;
}
@Override
public FireMode getValue() {
return this;
}
@Override
public FireMode getValueOf(final String name) {
try {
return FireMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return FireMode.DENY;
}
return FireMode.ALLOW;
}
}
}
@@ -1,85 +1,103 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* 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 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.
* 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/>.
* 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;
import de.steamwar.bausystem.region.flags.flagvalues.*;
import de.steamwar.bausystem.shared.EnumDisplay;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.EnumSet;
import java.util.HashSet;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.concurrent.atomic.AtomicInteger;
@Getter
@AllArgsConstructor
public enum Flag implements EnumDisplay {
public final class Flag<T extends Enum<T> & Flag.Value<T>> implements EnumDisplay {
COLOR("FLAG_COLOR", ColorMode.class, ColorMode.YELLOW, false),
TNT("FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB, true),
FIRE("FLAG_FIRE", FireMode.class, FireMode.ALLOW, true),
FREEZE("FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE, true),
PROTECT("FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE, true),
ITEMS("FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE, true),
NO_GRAVITY("FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE, true),
;
public static final Flag<ColorMode> COLOR = new Flag<>("COLOR", "FLAG_COLOR", ColorMode.class, ColorMode.YELLOW);
public static final Flag<TNTMode> TNT = new Flag<>("TNT", "FLAG_TNT", TNTMode.class, TNTMode.ONLY_TB);
public static final Flag<FireMode> FIRE = new Flag<>("FIRE", "FLAG_FIRE", FireMode.class, FireMode.ALLOW);
public static final Flag<FreezeMode> FREEZE = new Flag<>("FREEZE", "FLAG_FREEZE", FreezeMode.class, FreezeMode.INACTIVE);
public static final Flag<ProtectMode> PROTECT = new Flag<>("PROTECT", "FLAG_PROTECT", ProtectMode.class, ProtectMode.ACTIVE);
public static final Flag<ItemMode> ITEMS = new Flag<>("ITEMS", "FLAG_ITEMS", ItemMode.class, ItemMode.INACTIVE);
public static final Flag<NoGravityMode> NO_GRAVITY = new Flag<>("NO_GRAVITY", "FLAG_NO_GRAVITY", NoGravityMode.class, NoGravityMode.INACTIVE);
public static final Flag<TestblockMode> TESTBLOCK = new Flag<>("TESTBLOCK", "FLAG_TESTBLOCK", TestblockMode.class, TestblockMode.NO_VALUE);
public static final Flag<ChangedMode> CHANGED = new Flag<>("CHANGED", "FLAG_CHANGED", ChangedMode.class, ChangedMode.NO_CHANGE);
@Getter
private static final Set<Flag> flags;
@Getter
private static final Set<Flag> resetFlags;
@Getter
private static final Set<Flag> flags = new HashSet<>();
static {
flags = EnumSet.allOf(Flag.class);
resetFlags = flags.stream().filter(flag -> flag.reset).collect(Collectors.toUnmodifiableSet());
}
private static AtomicInteger counter = new AtomicInteger(0);
private final String chatValue;
private final Class<? extends Value<?>> valueType;
private final Flag.Value<?> defaultValue;
private final boolean reset;
private String name;
private int ordinal;
public Value<?> getFlagValueOf(final String name) {
return this.defaultValue.getValueOf(name);
}
@Getter
private String chatValue;
@Override
public String toString() {
return this.name().toLowerCase();
}
@Getter
private final Class<? extends Flag.Value<T>> valueType;
@Override
public String getChatValue() {
return chatValue;
}
@Getter
private final Flag.Value<?> defaultValue;
public interface Value<T extends Enum<T> & Value<T>> extends EnumDisplay {
@Getter
private final Flag.Value<?>[] values;
T getValue();
private Flag(String name, String chatValue, Class<? extends Flag.Value<T>> valueType, Value<T> defaultValue) {
flags.add(this);
T getValueOf(final String name);
this.name = name;
this.ordinal = counter.getAndIncrement();
this.chatValue = chatValue;
T[] getValues();
this.valueType = valueType;
this.defaultValue = defaultValue;
this.values = defaultValue.getValues();
}
default String getName() {
return this.getValue().name().toLowerCase();
}
}
}
public String name() {
return name;
}
public int ordinal() {
return ordinal;
}
public boolean oneOf(Flag<?>... flags) {
for (Flag<?> flag : flags) {
if (flag == this) {
return true;
}
}
return false;
}
public interface Value<T extends Enum<T> & Value<T>> extends EnumDisplay {
T getValue();
T getValueOf(final String name);
T[] getValues();
default String getName() {
return this.getValue().name().toLowerCase();
}
}
}
@@ -0,0 +1,60 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 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;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum FreezeMode implements Flag.Value<FreezeMode> {
ACTIVE("FLAG_FREEZE_ACTIVE"),
INACTIVE("FLAG_FREEZE_INACTIVE");
private static FreezeMode[] values;
private final String chatValue;
@Override
public FreezeMode[] getValues() {
if (FreezeMode.values == null) {
FreezeMode.values = FreezeMode.values(); //NOSONAR
}
return FreezeMode.values;
}
@Override
public FreezeMode getValue() {
return this;
}
@Override
public FreezeMode getValueOf(final String name) {
try {
return FreezeMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return FreezeMode.INACTIVE;
}
return FreezeMode.INACTIVE;
}
}
}
@@ -1,25 +1,24 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2024 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 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.
* 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/>.
* 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;
package de.steamwar.bausystem.region.flags;
import de.steamwar.bausystem.region.flags.Flag;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -1,25 +1,24 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2024 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 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.
* 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/>.
* 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;
package de.steamwar.bausystem.region.flags;
import de.steamwar.bausystem.region.flags.Flag;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -1,25 +1,24 @@
/*
* This file is a part of the SteamWar software.
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
* Copyright (C) 2024 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 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.
* 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/>.
* 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;
package de.steamwar.bausystem.region.flags;
import de.steamwar.bausystem.region.flags.Flag;
import lombok.AllArgsConstructor;
import lombok.Getter;
@@ -0,0 +1,58 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 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;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum TNTMode implements Flag.Value<TNTMode> {
ALLOW("FLAG_TNT_ALLOW"),
DENY("FLAG_TNT_DENY"),
ONLY_TB("FLAG_TNT_ONLY_TB"),
ONLY_BUILD("FLAG_TNT_ONLY_BUILD");
private static TNTMode[] values;
private final String chatValue;
@Override
public TNTMode[] getValues() {
if (TNTMode.values == null) {
TNTMode.values = TNTMode.values(); //NOSONAR
}
return TNTMode.values;
}
@Override
public TNTMode getValue() {
return this;
}
@Override
public TNTMode getValueOf(final String name) {
try {
return TNTMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return TNTMode.ALLOW;
}
}
}
@@ -0,0 +1,58 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2024 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;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum TestblockMode implements Flag.Value<TestblockMode> {
NO_VALUE("FLAG_TESTBLOCK_NO_VALUE", false),
NORTH("FLAG_TESTBLOCK_NORTH", true),
SOUTH("FLAG_TESTBLOCK_SOUTH", false);
private static TestblockMode[] values;
private final String chatValue;
private final boolean north;
@Override
public TestblockMode[] getValues() {
if (TestblockMode.values == null) {
TestblockMode.values = TestblockMode.values(); //NOSONAR
}
return TestblockMode.values;
}
@Override
public TestblockMode getValue() {
return this;
}
@Override
public TestblockMode getValueOf(final String name) {
try {
return TestblockMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return NO_VALUE;
}
}
}
@@ -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 FireMode implements Flag.Value<FireMode> {
ALLOW("FLAG_FIRE_ALLOW"),
DENY("FLAG_FIRE_DENY");
private static FireMode[] values;
private final String chatValue;
@Override
public FireMode[] getValues() {
if (FireMode.values == null) {
FireMode.values = FireMode.values(); //NOSONAR
}
return FireMode.values;
}
@Override
public FireMode getValue() {
return this;
}
@Override
public FireMode getValueOf(final String name) {
try {
return FireMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return FireMode.DENY;
}
return FireMode.ALLOW;
}
}
}
@@ -1,61 +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 FreezeMode implements Flag.Value<FreezeMode> {
ACTIVE("FLAG_FREEZE_ACTIVE"),
INACTIVE("FLAG_FREEZE_INACTIVE");
private static FreezeMode[] values;
private final String chatValue;
@Override
public FreezeMode[] getValues() {
if (FreezeMode.values == null) {
FreezeMode.values = FreezeMode.values(); //NOSONAR
}
return FreezeMode.values;
}
@Override
public FreezeMode getValue() {
return this;
}
@Override
public FreezeMode getValueOf(final String name) {
try {
return FreezeMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
if (name.equalsIgnoreCase("false")) {
return FreezeMode.INACTIVE;
}
return FreezeMode.INACTIVE;
}
}
}
@@ -1,59 +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 TNTMode implements Flag.Value<TNTMode> {
ALLOW("FLAG_TNT_ALLOW"),
DENY("FLAG_TNT_DENY"),
ONLY_TB("FLAG_TNT_ONLY_TB"),
ONLY_BUILD("FLAG_TNT_ONLY_BUILD");
private static TNTMode[] values;
private final String chatValue;
@Override
public TNTMode[] getValues() {
if (TNTMode.values == null) {
TNTMode.values = TNTMode.values(); //NOSONAR
}
return TNTMode.values;
}
@Override
public TNTMode getValue() {
return this;
}
@Override
public TNTMode getValueOf(final String name) {
try {
return TNTMode.valueOf(name.toUpperCase());
} catch (IllegalArgumentException e) {
return TNTMode.ALLOW;
}
}
}