Remove TNTMode.ONLY_BUILD

This commit is contained in:
2025-08-02 07:57:19 +02:00
parent 0763e4b189
commit 144975d977
10 changed files with 120 additions and 36 deletions
@@ -23,20 +23,20 @@ import de.steamwar.bausystem.region.FlagOptional;
import de.steamwar.bausystem.region.FlagStorage;
import de.steamwar.bausystem.region.RegionFlagPolicy;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.TestblockMode;
import de.steamwar.core.Core;
import lombok.NonNull;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
public class FixedFlagStorage implements FlagStorage {
private TestblockMode testBlockMode;
private Map<Flag<?>, Flag.Value<?>> flagMap = new HashMap<>();
public static FlagStorage createFromFile(File file) {
// throw new IllegalStateException("Not implemented yet");
return new FixedFlagStorage();
public FixedFlagStorage(TestblockMode testblockMode) {
this.testBlockMode = testblockMode;
}
@Override
@@ -44,16 +44,26 @@ public class FixedFlagStorage implements FlagStorage {
if (flag.oneOf(Flag.ITEMS) && Core.getVersion() < 20) {
return RegionFlagPolicy.NOT_APPLICABLE;
}
if (flag.oneOf(Flag.TESTBLOCK)) {
return RegionFlagPolicy.READ_ONLY;
}
return RegionFlagPolicy.WRITABLE;
}
@Override
public <T extends Enum<T> & Flag.Value<T>> boolean set(@NonNull Flag<T> flag, @NonNull T value) {
return flagMap.put(flag, value) != value;
if (has(flag).isWritable()) {
return flagMap.put(flag, value) != value;
} else {
return false;
}
}
@Override
public @NonNull <T extends Enum<T> & Flag.Value<T>> FlagOptional<T> get(@NonNull Flag<T> flag) {
if (flag.oneOf(Flag.TESTBLOCK)) {
return FlagOptional.of((Flag) flag, testBlockMode);
}
return FlagOptional.of(flag, (T) flagMap.get(flag));
}
@@ -0,0 +1,80 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2020 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.fixed;
import de.steamwar.bausystem.region.*;
import lombok.NonNull;
import java.nio.charset.StandardCharsets;
import java.util.UUID;
public class FixedRegion implements Region {
private UUID uuid;
public FixedRegion(String name) {
uuid = UUID.nameUUIDFromBytes(name.getBytes(StandardCharsets.UTF_8));
}
@Override
public @NonNull UUID getID() {
return uuid;
}
@Override
public @NonNull RegionType getType() {
return RegionType.NORMAL;
}
@Override
public @NonNull FlagStorage getFlags() {
return null;
}
@Override
public @NonNull Area getArea() {
return null;
}
@Override
public @NonNull Area getBuildArea() {
return null;
}
@Override
public @NonNull Area getTestblockArea() {
return null;
}
@Override
public @NonNull RegionConfig getGameModeConfig() {
return null;
}
@Override
public @NonNull RegionHistory getHistory() {
return null;
}
@Override
public @NonNull RegionBackups getBackups() {
return null;
}
}