forked from SteamWar/SteamWar
Remove TNTMode.ONLY_BUILD
This commit is contained in:
@@ -738,12 +738,10 @@ REGION_ITEM_RESET=§eReset
|
||||
REGION_ITEM_TESTBLOCK=§eDummy
|
||||
REGION_ITEM_TNT_OFF=§7TNT: §eDeactivated
|
||||
REGION_ITEM_TNT_ONLY_TB=§7TNT: §eonly dummy
|
||||
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §eonly build
|
||||
REGION_ITEM_TNT_ON=§7TNT: §eActivated
|
||||
REGION_ITEM_SELECTOR_TITLE=Tnt Mode
|
||||
REGION_ITEM_SELECTOR_ON=§eActivate
|
||||
REGION_ITEM_SELECTOR_ONLY_TB=§eonly dummy
|
||||
REGION_ITEM_SELECTOR_ONLY_BUILD=§eonly build
|
||||
REGION_ITEM_SELECTOR_OFF=§eDeactivate
|
||||
#Region
|
||||
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Sets the color of the region
|
||||
|
||||
@@ -681,12 +681,10 @@ REGION_ITEM_RESET=§eReset
|
||||
REGION_ITEM_TESTBLOCK=§eTestblock
|
||||
REGION_ITEM_TNT_OFF=§7TNT: §eAusgeschaltet
|
||||
REGION_ITEM_TNT_ONLY_TB=§7TNT: §enur Testblock
|
||||
REGION_ITEM_TNT_ONLY_BUILD=§7TNT: §enur Baubereich
|
||||
REGION_ITEM_TNT_ON=§7TNT: §eEingeschaltet
|
||||
REGION_ITEM_SELECTOR_TITLE=Tnt Modus
|
||||
REGION_ITEM_SELECTOR_ON=§eEinschalten
|
||||
REGION_ITEM_SELECTOR_ONLY_TB=§enur Testblock
|
||||
REGION_ITEM_SELECTOR_ONLY_BUILD=§enur Baubereich
|
||||
REGION_ITEM_SELECTOR_OFF=§eAusschalten
|
||||
#Region
|
||||
REGION_COLOR_HELP_COLOR=§8/§ecolor §8[§7Color§8] §8- §7Setze die Farbe der Region
|
||||
|
||||
@@ -72,9 +72,6 @@ public class TNTCommand extends SWCommand {
|
||||
case ONLY_TB:
|
||||
requestedMessage = getTestblockEnableMessage();
|
||||
break;
|
||||
case ONLY_BUILD:
|
||||
requestedMessage = getBuildEnableMessage();
|
||||
break;
|
||||
}
|
||||
tntToggle(region, tntMode, requestedMessage);
|
||||
}
|
||||
@@ -90,9 +87,8 @@ public class TNTCommand extends SWCommand {
|
||||
Map<String, TNTMode> tntModeMap = new HashMap<>(tntModeMapReduced);
|
||||
tntModeMap.put("testblock", TNTMode.ONLY_TB);
|
||||
tntModeMap.put("tb", TNTMode.ONLY_TB);
|
||||
tntModeMap.put("build", TNTMode.ONLY_BUILD);
|
||||
|
||||
return new TypeMapper<TNTMode>() {
|
||||
return new TypeMapper<>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||
Region region = Region.getRegion(((Player) sender).getLocation());
|
||||
@@ -140,7 +136,6 @@ public class TNTCommand extends SWCommand {
|
||||
switch (region.getFlags().get(Flag.TNT).getWithDefault()) {
|
||||
case ALLOW:
|
||||
case ONLY_TB:
|
||||
case ONLY_BUILD:
|
||||
region.getFlags().set(Flag.TNT, TNTMode.DENY);
|
||||
RegionUtils.actionBar(region, getDisableMessage());
|
||||
break;
|
||||
|
||||
@@ -50,11 +50,6 @@ public class TNTListener implements Listener, ScoreboardElement {
|
||||
RegionUtils.actionBar(region, "REGION_TNT_BUILD_DESTROY");
|
||||
return true;
|
||||
}
|
||||
} else if (value == TNTMode.ONLY_BUILD) {
|
||||
if (region.getTestblockArea().inRegion(block.getLocation(), true)) {
|
||||
RegionUtils.actionBar(region, "REGION_TNT_TB_DESTROY");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return value == TNTMode.DENY;
|
||||
});
|
||||
|
||||
-10
@@ -25,7 +25,6 @@ import de.steamwar.bausystem.linkage.specific.BauGuiItem;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.bausystem.region.flags.Flag;
|
||||
import de.steamwar.bausystem.region.flags.TNTMode;
|
||||
import de.steamwar.bausystem.region.utils.RegionType;
|
||||
import de.steamwar.inventory.SWInventory;
|
||||
import de.steamwar.inventory.SWItem;
|
||||
import de.steamwar.linkage.Linked;
|
||||
@@ -48,8 +47,6 @@ public class TntBauGuiItem extends BauGuiItem {
|
||||
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
|
||||
case ONLY_TB:
|
||||
return new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_TB", player)).getItemStack();
|
||||
case ONLY_BUILD:
|
||||
return new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ONLY_BUILD", player)).getItemStack();
|
||||
default:
|
||||
return new SWItem(Material.TNT, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_ON", player)).getItemStack();
|
||||
}
|
||||
@@ -82,10 +79,6 @@ public class TntBauGuiItem extends BauGuiItem {
|
||||
updateTntMode(TNTMode.ONLY_TB, p);
|
||||
p.closeInventory();
|
||||
}));
|
||||
selector.setItem(5, new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_BUILD", p), clickType -> {
|
||||
updateTntMode(TNTMode.ONLY_BUILD, p);
|
||||
p.closeInventory();
|
||||
}));
|
||||
}
|
||||
selector.setItem(7, new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_OFF", p), clickType -> {
|
||||
updateTntMode(TNTMode.DENY, p);
|
||||
@@ -101,9 +94,6 @@ public class TntBauGuiItem extends BauGuiItem {
|
||||
case ONLY_TB:
|
||||
p.performCommand("tnt tb");
|
||||
break;
|
||||
case ONLY_BUILD:
|
||||
p.performCommand("tnt build");
|
||||
break;
|
||||
case ALLOW:
|
||||
p.performCommand("tnt on");
|
||||
break;
|
||||
|
||||
-1
@@ -57,7 +57,6 @@ public class RegionLib implements LuaLib {
|
||||
tntLib.set("mode", getter(() -> region.get().getFlags().get(Flag.TNT).nameWithDefault()));
|
||||
tntLib.set("enabled", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) != TNTMode.DENY));
|
||||
tntLib.set("onlyTb", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_TB));
|
||||
tntLib.set("onlyBuild", getter(() -> region.get().getFlags().get(Flag.TNT).orElse(null) == TNTMode.ONLY_BUILD));
|
||||
table.set("tnt", tntLib);
|
||||
|
||||
table.set("fire", getter(() -> region.get().getFlags().get(Flag.FIRE).orElse(null) == FireMode.ALLOW));
|
||||
|
||||
@@ -136,7 +136,14 @@ public interface Region {
|
||||
@NonNull
|
||||
Point getCopyPoint();
|
||||
|
||||
boolean inRegion(Location location, boolean extension);
|
||||
default boolean inRegion(Location location, boolean extension) {
|
||||
Point minPoint = getMinPoint(extension);
|
||||
Point maxPoint = getMaxPoint(extension);
|
||||
if (location.getBlockX() < minPoint.getX() || location.getBlockX() > maxPoint.getX()) return false;
|
||||
if (location.getBlockY() < minPoint.getY() || location.getBlockY() > maxPoint.getY()) return false;
|
||||
if (location.getBlockZ() < minPoint.getZ() || location.getBlockZ() > maxPoint.getZ()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
EditSession copy(boolean extension);
|
||||
@@ -146,8 +153,21 @@ public interface Region {
|
||||
|
||||
void reset(PasteBuilder pasteBuilder, boolean extension);
|
||||
|
||||
void forEachChunk(BiConsumer<Integer, Integer> executor);
|
||||
default void forEachChunk(BiConsumer<Integer, Integer> executor) {
|
||||
Point minPoint = getMinPoint(false);
|
||||
Point maxPoint = getMaxPoint(false);
|
||||
for (int x = (int) Math.floor(minPoint.getX() / 16.0); x <= (int) Math.ceil(maxPoint.getX() / 16.0); x++) {
|
||||
for (int z = (int) Math.floor(minPoint.getZ() / 16.0); z <= (int) Math.ceil(maxPoint.getZ() / 16.0); z++) {
|
||||
executor.accept(x, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean isChunkOutside(int chunkX, int chunkZ);
|
||||
default boolean isChunkOutside(int chunkX, int chunkZ) {
|
||||
Point minPoint = getMinPoint(true);
|
||||
Point maxPoint = getMaxPoint(true);
|
||||
return Math.floor(minPoint.getX() / 16.0) > chunkX || chunkX >= Math.ceil(maxPoint.getX() / 16.0) ||
|
||||
Math.floor(minPoint.getZ() / 16.0) > chunkZ || chunkZ >= Math.ceil(maxPoint.getZ() / 16.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,8 +28,7 @@ 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");
|
||||
ONLY_TB("FLAG_TNT_ONLY_TB");
|
||||
|
||||
private static TNTMode[] values;
|
||||
private final String chatValue;
|
||||
|
||||
+15
-5
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
+80
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user