Reduce to 34 compiler errors

This commit is contained in:
2025-07-30 18:49:54 +02:00
parent 0287881e33
commit 598daadd33
24 changed files with 84 additions and 95 deletions
@@ -22,6 +22,7 @@ package de.steamwar.bausystem.features.backup;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.ChangedMode;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
@@ -62,7 +63,7 @@ public class BackupCommand extends SWCommand {
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
} }
if (region.getFlag(Flag.CHANGED).isPresent()) { if (region.getFlags().get(Flag.CHANGED).isWithDefault(ChangedMode.NO_CHANGE)) {
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p); BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
return; return;
} }
@@ -86,12 +87,12 @@ public class BackupCommand extends SWCommand {
return; return;
} }
EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile)) EditSession editSession = new PasteBuilder(new PasteBuilder.FileProvider(backupFile))
.pastePoint(region.getMinPoint().add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2)) .pastePoint(region.getArea().getMinPoint(false).add(region.getPrototype().getSizeX() / 2, 0, region.getPrototype().getSizeZ() / 2))
.minPoint(region.getMinPoint()) .minPoint(region.getArea().getMinPoint(false))
.maxPoint(region.getMaxPoint()) .maxPoint(region.getArea().getMaxPoint(false))
.waterLevel(region.getWaterLevel()) .waterLevel(region.getWaterLevel())
.run(); .run();
region.remember(editSession); region.getHistory().remember(editSession);
BauSystem.MESSAGE.send("BACKUP_LOAD", p); BauSystem.MESSAGE.send("BACKUP_LOAD", p);
} }
@@ -23,6 +23,7 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.bausystem.region.FlagOptional;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.core.Core; import de.steamwar.core.Core;
@@ -62,9 +63,9 @@ public class BauInfoBauGuiItem extends BauGuiItem {
if (flag == Flag.ITEMS && Core.getVersion() < 19) { if (flag == Flag.ITEMS && Core.getVersion() < 19) {
continue; continue;
} }
Flag.Value<?> value = region.get(flag); FlagOptional<?> value = region.getFlags().get(flag);
if (value != null) { if (value.isPresent()) {
stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getChatValue(), player))); stringList.add(BauSystem.MESSAGE.parse("BAU_INFO_ITEM_LORE_" + flag.name(), player, BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), player)));
} }
} }
itemStack.setLore(stringList); itemStack.setLore(stringList);
@@ -3,6 +3,7 @@ package de.steamwar.bausystem.features.bau;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.region.FlagOptional;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
@@ -33,9 +34,9 @@ public class InfoCommand extends SWCommand {
if (flag == Flag.PROTECT && region.getFloorLevel() == 0) { if (flag == Flag.PROTECT && region.getFloorLevel() == 0) {
continue; continue;
} }
Flag.Value<?> value = region.get(flag); FlagOptional<?> value = region.getFlags().get(flag);
if (value != null) { if (value.isPresent()) {
BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getChatValue(), p)); BauSystem.MESSAGE.send("BAU_INFO_COMMAND_FLAG", p, BauSystem.MESSAGE.parse(flag.getChatValue(), p), BauSystem.MESSAGE.parse(value.getWithDefault().getChatValue(), p));
} }
} }
@@ -52,7 +52,9 @@ public class ColorCommand extends SWCommand {
@Register(description = "REGION_COLOR_HELP_COLOR_TYPE") @Register(description = "REGION_COLOR_HELP_COLOR_TYPE")
public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) { public void genericColorSet(@Validator Player p, ColorMode color, ColorizationType colorizationType) {
if (colorizationType == ColorizationType.GLOBAL) { if (colorizationType == ColorizationType.GLOBAL) {
Region.setGlobal(Flag.COLOR, color); Region.getRegions().forEach(region -> {
region.getFlags().set(Flag.COLOR, color);
});
BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p)); BauSystem.MESSAGE.send("REGION_COLOR_GLOBAL", p, BauSystem.MESSAGE.parse(color.getChatValue(), p));
return; return;
} }
@@ -61,13 +63,13 @@ public class ColorCommand extends SWCommand {
BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p); BauSystem.MESSAGE.send("REGION_COLOR_NO_REGION", p);
return; return;
} }
region.setFlag(Flag.COLOR, color); region.getFlags().set(Flag.COLOR, color);
try { try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
.ignoreAir(true) .ignoreAir(true)
.onlyColors(true) .onlyColors(true)
.color(color.getColor()); .color(color);
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); region.getArea().reset(pasteBuilder, false);
RegionUtils.message(region, "REGION_REGION_COLORED"); RegionUtils.message(region, "REGION_REGION_COLORED");
RegionUtils.message(region, "REGION_REGION_COLORED_FAILED"); RegionUtils.message(region, "REGION_REGION_COLORED_FAILED");
} catch (SecurityException e) { } catch (SecurityException e) {
@@ -55,11 +55,11 @@ public class ItemsCommand extends SWCommand {
} }
private boolean toggle(Region region) { private boolean toggle(Region region) {
if (region.isFlag(Flag.ITEMS, ItemMode.ACTIVE)) { if (region.getFlags().get(Flag.ITEMS).isWithDefault(ItemMode.ACTIVE)) {
region.setFlag(Flag.ITEMS, ItemMode.INACTIVE); region.getFlags().set(Flag.ITEMS, ItemMode.INACTIVE);
return false; return false;
} else { } else {
region.setFlag(Flag.ITEMS, ItemMode.ACTIVE); region.getFlags().set(Flag.ITEMS, ItemMode.ACTIVE);
return true; return true;
} }
} }
@@ -31,9 +31,7 @@ import de.steamwar.bausystem.features.util.SelectCommand;
import de.steamwar.bausystem.region.Point; import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.ColorMode;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.shared.Pair; import de.steamwar.bausystem.shared.Pair;
import de.steamwar.bausystem.utils.FlatteningWrapper; import de.steamwar.bausystem.utils.FlatteningWrapper;
@@ -83,7 +81,7 @@ public class RegionCommand extends SWCommand {
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (checkGlobalRegion(region, p)) return; if (checkGlobalRegion(region, p)) return;
if (region.undo()) { if (region.getHistory().undo()) {
RegionUtils.message(region, "REGION_REGION_UNDID"); RegionUtils.message(region, "REGION_REGION_UNDID");
} else { } else {
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_UNDO", p); BauSystem.MESSAGE.send("REGION_REGION_NOTHING_UNDO", p);
@@ -97,7 +95,7 @@ public class RegionCommand extends SWCommand {
return; return;
} }
if (region.redo()) { if (region.getHistory().redo()) {
RegionUtils.message(region, "REGION_REGION_REDID"); RegionUtils.message(region, "REGION_REGION_REDID");
} else { } else {
BauSystem.MESSAGE.send("REGION_REGION_NOTHING_REDO", p); BauSystem.MESSAGE.send("REGION_REGION_NOTHING_REDO", p);
@@ -112,8 +110,8 @@ public class RegionCommand extends SWCommand {
try { try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
.ignoreAir(true) .ignoreAir(true)
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); .color(region.getFlags().get(Flag.COLOR).getWithDefault());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); region.getArea().reset(pasteBuilder, true);
RegionUtils.message(region, "REGION_REGION_RESTORED"); RegionUtils.message(region, "REGION_REGION_RESTORED");
} catch (SecurityException e) { } catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p); BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
@@ -134,8 +132,8 @@ public class RegionCommand extends SWCommand {
try { try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node)) PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
.ignoreAir(true) .ignoreAir(true)
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); .color(region.getFlags().get(Flag.COLOR).getWithDefault());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); region.getArea().reset(pasteBuilder, true);
RegionUtils.message(region, "REGION_REGION_RESTORED"); RegionUtils.message(region, "REGION_REGION_RESTORED");
} catch (SecurityException e) { } catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p); BauSystem.MESSAGE.send("REGION_REGION_FAILED_RESTORE", p);
@@ -149,11 +147,11 @@ public class RegionCommand extends SWCommand {
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
} }
if (region.getCopyPoint() == null) { if (region.getBuildArea().isEmpty()) {
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p); BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
return; return;
} }
p.teleport(region.getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND); p.teleport(region.getBuildArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
BauSystem.MESSAGE.send("REGION_REGION_TP_COPY", p); BauSystem.MESSAGE.send("REGION_REGION_TP_COPY", p);
} }
@@ -164,11 +162,11 @@ public class RegionCommand extends SWCommand {
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
} }
if (region.getTestBlockPoint() == null) { if (region.getTestblockArea().isEmpty()) {
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p); BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
return; return;
} }
p.teleport(region.getTestBlockPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND); p.teleport(region.getTestblockArea().getCopyPoint().toLocation(p, 0.5, 0, 0.5), PlayerTeleportEvent.TeleportCause.COMMAND);
BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p); BauSystem.MESSAGE.send("REGION_REGION_TP_TEST_BLOCK", p);
} }
@@ -211,14 +209,10 @@ public class RegionCommand extends SWCommand {
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
} }
if (!region.hasType(RegionType.BUILD)) { if (region.getBuildArea().isEmpty()) {
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p); BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
return; return;
} }
if (region.getCopyPoint() == null) {
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
return;
}
Point minPoint = region.getBuildArea().getMinPoint(false); Point minPoint = region.getBuildArea().getMinPoint(false);
Point maxPoint = region.getBuildArea().getMaxPoint(false); Point maxPoint = region.getBuildArea().getMaxPoint(false);
@@ -238,7 +232,7 @@ public class RegionCommand extends SWCommand {
break; break;
} }
Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getCopyPoint()); Clipboard clipboard = FlatteningWrapper.impl.copy(minPoint, maxPoint, region.getBuildArea().getCopyPoint());
WorldEdit.getInstance() WorldEdit.getInstance()
.getSessionManager() .getSessionManager()
.get(BukkitAdapter.adapt(p)) .get(BukkitAdapter.adapt(p))
@@ -252,14 +246,10 @@ public class RegionCommand extends SWCommand {
if (checkGlobalRegion(region, p)) { if (checkGlobalRegion(region, p)) {
return; return;
} }
if (!region.hasType(RegionType.BUILD)) { if (region.getBuildArea().isEmpty()) {
BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p); BauSystem.MESSAGE.send("REGION_REGION_NO_BUILD", p);
return; return;
} }
if (region.getCopyPoint() == null) {
BauSystem.MESSAGE.send("REGION_REGION_TP_UNKNOWN", p);
return;
}
ClipboardHolder clipboardHolder = WorldEdit.getInstance() ClipboardHolder clipboardHolder = WorldEdit.getInstance()
.getSessionManager() .getSessionManager()
@@ -287,13 +277,13 @@ public class RegionCommand extends SWCommand {
} }
try (EditSession e = WorldEditUtils.getEditSession(p)) { try (EditSession e = WorldEditUtils.getEditSession(p)) {
Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getCopyPoint())).build()); Operations.completeBlindly(clipboardHolder.createPaste(e).ignoreAirBlocks(ignoreAir).to(toBlockVector3(region.getBuildArea().getCopyPoint())).build());
WorldEditUtils.addToPlayer(p, e); WorldEditUtils.addToPlayer(p, e);
if (selectPasted) { if (selectPasted) {
Clipboard clipboard = clipboardHolder.getClipboards().get(0); Clipboard clipboard = clipboardHolder.getClipboards().get(0);
BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint())); BlockVector3 minPointSelection = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint()));
BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getCopyPoint())); BlockVector3 maxPointSelection = clipboard.getRegion().getMaximumPoint().subtract(clipboard.getOrigin()).add(toBlockVector3(region.getBuildArea().getCopyPoint()));
FlatteningWrapper.impl.setSelection(p, Point.fromBlockVector3(minPointSelection), Point.fromBlockVector3(maxPointSelection)); FlatteningWrapper.impl.setSelection(p, Point.fromBlockVector3(minPointSelection), Point.fromBlockVector3(maxPointSelection));
} }
BauSystem.MESSAGE.send("REGION_REGION_PASTE_DONE", p); BauSystem.MESSAGE.send("REGION_REGION_PASTE_DONE", p);
@@ -24,9 +24,8 @@ import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionSystem; import de.steamwar.bausystem.region.RegionSystem;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.ColorMode; import de.steamwar.bausystem.region.flags.ColorMode;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
@@ -56,10 +55,10 @@ public class ResetCommand extends SWCommand {
if (region == null) return; if (region == null) return;
try { try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL))) PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.FileProvider(region.getResetFile(RegionType.NORMAL)))
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); .color(region.getFlags().get(Flag.COLOR).getWithDefault());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); region.getArea().reset(pasteBuilder, false);
for (Flag value : Flag.getResetFlags()) { for (Flag value : Flag.getResetFlags()) {
region.set(value, value.getDefaultValue()); region.getFlags().set(value, value.getDefaultValue());
} }
RegionUtils.message(region, "REGION_RESET_RESETED"); RegionUtils.message(region, "REGION_RESET_RESETED");
} catch (SecurityException e) { } catch (SecurityException e) {
@@ -88,8 +87,8 @@ public class ResetCommand extends SWCommand {
} }
try { try {
PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node)) PasteBuilder pasteBuilder = new PasteBuilder(new PasteBuilder.SchematicProvider(node))
.color(region.getPlain(Flag.COLOR, ColorMode.class).getColor()); .color(region.getFlags().get(Flag.COLOR).getWithDefault());
region.reset(pasteBuilder, RegionType.NORMAL, RegionExtensionType.NORMAL); region.getArea().reset(pasteBuilder, true);
RegionUtils.message(region, "REGION_RESET_RESETED"); RegionUtils.message(region, "REGION_RESET_RESETED");
} catch (SecurityException e) { } catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_RESET_ERROR", p); BauSystem.MESSAGE.send("REGION_RESET_ERROR", p);
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.config.BauServer;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils; import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.flags.ColorMode;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.utils.RegionExtensionType; import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType; import de.steamwar.bausystem.region.utils.RegionType;
@@ -101,8 +100,8 @@ public class TestblockCommand extends SWCommand {
.onlyColors(onlyColors) .onlyColors(onlyColors)
.removeTNT(removeTNT) .removeTNT(removeTNT)
.removeWater(removeWater) .removeWater(removeWater)
.color(region.getFlag(Flag.COLOR).orElse(ColorMode.YELLOW).getColor()); .color(region.getFlags().get(Flag.COLOR).getWithDefault());
region.reset(pasteBuilder, RegionType.TESTBLOCK, regionExtensionType); region.getTestblockArea().reset(pasteBuilder, regionExtensionType == RegionExtensionType.EXTENSION);
RegionUtils.message(region, "REGION_TB_DONE"); RegionUtils.message(region, "REGION_TB_DONE");
} catch (SecurityException e) { } catch (SecurityException e) {
BauSystem.MESSAGE.send("REGION_TB_ERROR", p); BauSystem.MESSAGE.send("REGION_TB_ERROR", p);
@@ -155,7 +154,7 @@ public class TestblockCommand extends SWCommand {
private Region regionCheck(Player player) { private Region regionCheck(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (!region.hasType(RegionType.TESTBLOCK)) { if (region.getTestblockArea().isEmpty()) {
BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player); BauSystem.MESSAGE.send("REGION_TB_NO_REGION", player);
return null; return null;
} }
@@ -42,10 +42,10 @@ public class FireBauGuiItem extends BauGuiItem {
@Override @Override
public ItemStack getItem(Player player) { public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (!region.hasFlag(Flag.FIRE).isApplicable()) { if (!region.getFlags().has(Flag.FIRE).isApplicable()) {
return new SWItem(Material.BARRIER, "").getItemStack(); return new SWItem(Material.BARRIER, "").getItemStack();
} }
if (region.isFlag(Flag.FIRE, FireMode.ALLOW)) { if (region.getFlags().get(Flag.FIRE).isWithDefault(FireMode.ALLOW)) {
return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack(); return new SWItem(Material.FIRE_CHARGE, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_ALLOW", player)).getItemStack();
} else { } else {
return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack(); return new SWItem(Material.FIREWORK_STAR, BauSystem.MESSAGE.parse("REGION_ITEM_FIRE_DISALLOW", player)).getItemStack();
@@ -42,10 +42,10 @@ public class FreezeBauGuiItem extends BauGuiItem {
@Override @Override
public ItemStack getItem(Player player) { public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (!region.hasFlag(Flag.FREEZE).isApplicable()) { if (!region.getFlags().has(Flag.FREEZE).isApplicable()) {
return new SWItem(Material.BARRIER, "").getItemStack(); return new SWItem(Material.BARRIER, "").getItemStack();
} }
if (region.isFlag(Flag.FREEZE, FreezeMode.ACTIVE)) { if (region.getFlags().get(Flag.FREEZE).isWithDefault(FreezeMode.ACTIVE)) {
return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack(); return new SWItem(Material.GUNPOWDER, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_ALLOW", player)).getItemStack();
} else { } else {
return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack(); return new SWItem(Material.REDSTONE, BauSystem.MESSAGE.parse("REGION_ITEM_FREEZE_DISALLOW", player)).getItemStack();
@@ -43,10 +43,10 @@ public class ProtectBauGuiItem extends BauGuiItem {
@Override @Override
public ItemStack getItem(Player player) { public ItemStack getItem(Player player) {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (!region.hasFlag(Flag.PROTECT).isApplicable()) { if (!region.getFlags().has(Flag.PROTECT).isApplicable()) {
return new SWItem(Material.BARRIER, "").getItemStack(); return new SWItem(Material.BARRIER, "").getItemStack();
} }
if (region.isFlag(Flag.PROTECT, ProtectMode.ACTIVE)) { if (region.getFlags().get(Flag.PROTECT).isWithDefault(ProtectMode.ACTIVE)) {
return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack(); return SWUtils.setCustomModelData(new SWItem(Material.OBSIDIAN, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_ALLOW", player)), 1).getItemStack();
} else { } else {
return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack(); return SWUtils.setCustomModelData(new SWItem(Material.STONE, BauSystem.MESSAGE.parse("REGION_ITEM_PROTECT_DISALLOW", player)), 1).getItemStack();
@@ -43,7 +43,7 @@ public class TntBauGuiItem extends BauGuiItem {
@Override @Override
public ItemStack getItem(Player player) { public ItemStack getItem(Player player) {
switch (Region.getRegion(player.getLocation()).getPlain(Flag.TNT, TNTMode.class)) { switch (Region.getRegion(player.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
case DENY: case DENY:
return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack(); return new SWItem(Material.MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_TNT_OFF", player)).getItemStack();
case ONLY_TB: case ONLY_TB:
@@ -58,12 +58,12 @@ public class TntBauGuiItem extends BauGuiItem {
@Override @Override
public boolean click(ClickType click, Player p) { public boolean click(ClickType click, Player p) {
if (click == ClickType.LEFT) { if (click == ClickType.LEFT) {
switch (Region.getRegion(p.getLocation()).getPlain(Flag.TNT, TNTMode.class)) { switch (Region.getRegion(p.getLocation()).getFlags().get(Flag.TNT).getWithDefault()) {
case DENY: case DENY:
updateTntMode(TNTMode.ALLOW, p); updateTntMode(TNTMode.ALLOW, p);
break; break;
case ALLOW: case ALLOW:
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) { if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) {
updateTntMode(TNTMode.ONLY_TB, p); updateTntMode(TNTMode.ONLY_TB, p);
break; break;
} }
@@ -77,7 +77,7 @@ public class TntBauGuiItem extends BauGuiItem {
updateTntMode(TNTMode.ALLOW, p); updateTntMode(TNTMode.ALLOW, p);
p.closeInventory(); p.closeInventory();
})); }));
if (Region.getRegion(p.getLocation()).hasType(RegionType.BUILD) && Region.getRegion(p.getLocation()).hasType(RegionType.TESTBLOCK)) { if (!Region.getRegion(p.getLocation()).getBuildArea().isEmpty() && !Region.getRegion(p.getLocation()).getTestblockArea().isEmpty()) {
selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> { selector.setItem(3, new SWItem(Material.TNT_MINECART, BauSystem.MESSAGE.parse("REGION_ITEM_SELECTOR_ONLY_TB", p), clickType -> {
updateTntMode(TNTMode.ONLY_TB, p); updateTntMode(TNTMode.ONLY_TB, p);
p.closeInventory(); p.closeInventory();
@@ -64,7 +64,7 @@ public final class TNTPhase extends SimulatorPhase {
@Override @Override
public void accept(World world) { public void accept(World world) {
Location location = position.toLocation(world); Location location = position.toLocation(world);
if (Region.getRegion(location).getFlag(Flag.FREEZE).isPresent()) return; if (Region.getRegion(location).getFlags().get(Flag.FREEZE).isPresent()) return;
TNTPrimed tnt = world.spawn(location, TNTPrimed.class); TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0)); if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0)); if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
@@ -45,7 +45,7 @@ public class StabDirection extends StabStep {
@Override @Override
protected void start() { protected void start() {
try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) { try (EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorlds().get(0)), -1)) {
e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getMinPointTestblockExtension().toBlockVector3(), data.region.getMaxPointTestblockExtension().toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock()); e.setBlocks((com.sk89q.worldedit.regions.Region) new CuboidRegion(data.region.getTestblockArea().getMinPoint(true).toBlockVector3(), data.region.getTestblockArea().getMaxPoint(true).toBlockVector3()), Objects.requireNonNull(BlockTypes.AIR).getDefaultState().toBaseBlock());
} }
Trace trace = TraceRecorder.instance.startRecording(data.region); Trace trace = TraceRecorder.instance.startRecording(data.region);
@@ -20,10 +20,7 @@
package de.steamwar.bausystem.features.simulator.execute; package de.steamwar.bausystem.features.simulator.execute;
import de.steamwar.bausystem.features.tracer.TraceRecorder; import de.steamwar.bausystem.features.tracer.TraceRecorder;
import de.steamwar.bausystem.region.flags.ColorMode;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
@@ -38,10 +35,10 @@ public class StabFinalizer extends StabStep {
try { try {
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard); PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider); PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
if (data.region.hasFlag(Flag.COLOR).isReadable()) { if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
pasteBuilder.color(data.region.getFlag(Flag.COLOR).get().getColor()); pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
} }
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION); data.region.getTestblockArea().reset(pasteBuilder, true);
} catch (SecurityException e) { } catch (SecurityException e) {
stop(); stop();
throw e; throw e;
@@ -22,8 +22,6 @@ package de.steamwar.bausystem.features.simulator.execute;
import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase; import de.steamwar.bausystem.features.simulator.data.tnt.TNTPhase;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag; import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.PasteBuilder; import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar; import de.steamwar.bausystem.utils.bossbar.BauSystemBossbar;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -55,7 +53,7 @@ public class StabGenerator extends StabStep implements Listener {
public void onEntityExplode(EntityExplodeEvent event) { public void onEntityExplode(EntityExplodeEvent event) {
if (Region.getRegion(event.getEntity().getLocation()) == data.region) { if (Region.getRegion(event.getEntity().getLocation()) == data.region) {
event.blockList().forEach(block -> { event.blockList().forEach(block -> {
if (!data.region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) if (!data.region.getTestblockArea().inRegion(block.getLocation(), true))
return; return;
int component = data.direction.component.apply(block.getLocation().toVector()); int component = data.direction.component.apply(block.getLocation().toVector());
destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>()) destroyedBlocksPerSlice.computeIfAbsent(component, __ -> new HashSet<>())
@@ -73,10 +71,10 @@ public class StabGenerator extends StabStep implements Listener {
try { try {
PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard); PasteBuilder.ClipboardProvider clipboardProvider = new PasteBuilder.ClipboardProviderImpl(data.clipboard);
PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider); PasteBuilder pasteBuilder = new PasteBuilder(clipboardProvider);
if (data.region.hasFlag(Flag.COLOR).isReadable()) { if (data.region.getFlags().has(Flag.COLOR).isReadable()) {
pasteBuilder.color(data.region.getFlag(Flag.COLOR).get().getColor()); pasteBuilder.color(data.region.getFlags().get(Flag.COLOR).getWithDefault());
} }
data.region.reset(pasteBuilder, RegionType.TESTBLOCK, RegionExtensionType.EXTENSION); data.region.getTestblockArea().reset(pasteBuilder, true);
} catch (SecurityException e) { } catch (SecurityException e) {
stop(); stop();
throw e; throw e;
@@ -72,7 +72,7 @@ public class StabSetup extends StabStep {
if (TraceRecorder.instance.isAutoTraceEnabledInRegion(data.region)) { if (TraceRecorder.instance.isAutoTraceEnabledInRegion(data.region)) {
TraceRecorder.instance.removeAutoTraceRegion(data.region); TraceRecorder.instance.removeAutoTraceRegion(data.region);
} }
data.clipboard = FlatteningWrapper.impl.copy(data.region.getMinPointTestblockExtension(), data.region.getMaxPointTestblockExtension(), data.region.getTestBlockPoint()); data.clipboard = FlatteningWrapper.impl.copy(data.region.getTestblockArea().getMinPoint(true), data.region.getTestblockArea().getMaxPoint(true), data.region.getTestblockArea().getCopyPoint());
new StabDirection(data); new StabDirection(data);
} }
@@ -89,9 +89,9 @@ public class SkinCommand extends SWCommand {
return; return;
} }
Region.copy(region.getMinPoint(), region.getMaxPoint(), arenaFile); Region.copy(region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false), arenaFile);
if (testblockFile != null) { if (testblockFile != null) {
Region.copy(region.getMinPointTestblock(), region.getMaxPointTestblock(), testblockFile); Region.copy(region.getTestblockArea().getMinPoint(false), region.getTestblockArea().getMaxPoint(false), testblockFile);
} }
YAPIONObject yapionObject = new YAPIONObject(); YAPIONObject yapionObject = new YAPIONObject();
@@ -53,11 +53,11 @@ public class BoundaryViewer implements Listener {
} }
private void showRegion(Region region, Player player) { private void showRegion(Region region, Player player) {
drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getMinPoint(), region.getMaxPoint()); drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getArea().getMinPoint(false), region.getArea().getMaxPoint(false));
if (region.getTestblockArea().isPresent()) { if (!region.getTestblockArea().isEmpty()) {
drawCuboid(player, Particle.END_ROD, region.getTestblockArea().getMinPoint(true), region.getTestblockArea().getMaxPoint(true)); drawCuboid(player, Particle.END_ROD, region.getTestblockArea().getMinPoint(true), region.getTestblockArea().getMaxPoint(true));
} }
if (region.getBuildArea().isPresent()) { if (!region.getBuildArea().isEmpty()) {
drawCuboid(player, Particle.END_ROD, region.getBuildArea().getMinPoint(true), region.getBuildArea().getMaxPoint(true)); drawCuboid(player, Particle.END_ROD, region.getBuildArea().getMinPoint(true), region.getBuildArea().getMaxPoint(true));
} }
} }
@@ -21,10 +21,7 @@ package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.Permission;
import de.steamwar.entity.CWireframe; import de.steamwar.entity.*;
import de.steamwar.entity.REntity;
import de.steamwar.entity.REntityServer;
import de.steamwar.entity.RTextDisplay;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
import de.steamwar.linkage.MinVersion; import de.steamwar.linkage.MinVersion;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -91,11 +91,11 @@ public class WarpListener implements Listener {
locations.put(warp.getName(), warp.getLocation()); locations.put(warp.getName(), warp.getLocation());
}); });
Region region = Region.getRegion(p.getLocation()); Region region = Region.getRegion(p.getLocation());
if (region.getCopyPoint() != null) { if (region.getBuildArea().getCopyPoint() != null) {
locations.put("Copy", region.getCopyPoint().toLocation(p).add(0.5, 0, 0.5)); locations.put("Copy", region.getBuildArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5));
} }
if (region.getTestBlockPoint() != null) { if (region.getTestblockArea().getCopyPoint() != null) {
locations.put("TestBlock", region.getTestBlockPoint().toLocation(p).add(0.5, 0, 0.5)); locations.put("TestBlock", region.getTestblockArea().getCopyPoint().toLocation(p).add(0.5, 0, 0.5));
} }
} }
@@ -28,9 +28,13 @@ import java.io.File;
import java.util.Optional; import java.util.Optional;
import java.util.UUID; import java.util.UUID;
import java.util.function.BiConsumer; import java.util.function.BiConsumer;
import java.util.stream.Stream;
public interface Region { public interface Region {
static Stream<Region> getRegions() {
return RegionSystem.INSTANCE.getRegions();
}
static Region getRegion(Location location) { static Region getRegion(Location location) {
return RegionSystem.INSTANCE.get(location); return RegionSystem.INSTANCE.get(location);
} }
@@ -41,7 +41,7 @@ public class RegionUtils {
public void forEachInRegion(Region region, Consumer<Player> consumer) { public void forEachInRegion(Region region, Consumer<Player> consumer) {
Bukkit.getOnlinePlayers() Bukkit.getOnlinePlayers()
.stream() .stream()
.filter(player -> region.inRegion(player.getLocation())) .filter(player -> region.getArea().inRegion(player.getLocation(), false))
.filter(player -> !region.getType().isGlobal() || Region.getRegion(player.getLocation()).getType().isGlobal()) .filter(player -> !region.getType().isGlobal() || Region.getRegion(player.getLocation()).getType().isGlobal())
.forEach(consumer); .forEach(consumer);
} }
@@ -118,7 +118,7 @@ public class RegionedBossbar implements BauSystemBossbar, Listener {
@EventHandler @EventHandler
public void onPlayerMove(PlayerMoveEvent event) { public void onPlayerMove(PlayerMoveEvent event) {
if (event.getPlayer() != player) return; if (event.getPlayer() != player) return;
if (region.inRegion(event.getTo())) { if (region.getArea().inRegion(event.getTo(), false)) {
bossBar.addPlayer(player); bossBar.addPlayer(player);
} else { } else {
bossBar.removePlayer(player); bossBar.removePlayer(player);