Fix some more issues

This commit is contained in:
2025-07-11 21:36:50 +02:00
parent 7e61db5e58
commit 43cca3376e
8 changed files with 65 additions and 13 deletions
@@ -109,7 +109,7 @@ public class AutostartListener implements Listener {
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player); BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
return; return;
} }
if (region.getTestblockArea().isPresent()) { if (region.getTestblockArea().isEmpty()) {
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player); BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
return; return;
} }
@@ -153,7 +153,7 @@ public class EventListener implements Listener {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if(!Permission.BUILD.hasPermission(player)) continue; if(!Permission.BUILD.hasPermission(player)) continue;
if (tntRegion.inRegion(player.getLocation())) { if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event); ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTSpawn, LuaValue.NIL, event);
} }
} }
@@ -175,7 +175,7 @@ public class EventListener implements Listener {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
if(!Permission.BUILD.hasPermission(player)) continue; if(!Permission.BUILD.hasPermission(player)) continue;
if (tntRegion.inRegion(player.getLocation())) { if (tntRegion.getArea().inRegion(player.getLocation(), false)) {
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event); ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplode, table, event);
if (inBuild) { if (inBuild) {
ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event); ScriptRunner.callEvent(player, SteamWarGlobalLuaPlugin.EventType.TNTExplodeInBuild, table, event);
@@ -85,8 +85,8 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
Set<String> hiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks"))); Set<String> hiddenBlocks = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlocks")));
Set<String> hiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities"))); Set<String> hiddenBlockEntities = Collections.unmodifiableSet(new HashSet<>(config.getStringList("Techhider.HiddenBlockEntities")));
TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> { TechHider current = new TechHider((p, cX, cY) -> {
if (rg.buildChunkOutside(cX, cY)) return true; if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
return !hidden.get(rg).contains(p); return !hidden.get(rg).contains(p);
}, Material.valueOf(obfuscateWith.toUpperCase()), hiddenBlocks.stream().map(String::toUpperCase).map(Material::valueOf).collect(Collectors.toSet()), hiddenBlockEntities); }, Material.valueOf(obfuscateWith.toUpperCase()), hiddenBlocks.stream().map(String::toUpperCase).map(Material::valueOf).collect(Collectors.toSet()), hiddenBlockEntities);
current.enable(); current.enable();
@@ -105,7 +105,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
hidden.get(region).add(player); hidden.get(region).add(player);
BauSystem.MESSAGE.sendPrefixless("TECHHIDER_ON", player, ChatMessageType.ACTION_BAR); BauSystem.MESSAGE.sendPrefixless("TECHHIDER_ON", player, ChatMessageType.ACTION_BAR);
} }
region.forEachChunk((x, z) -> { region.getBuildArea().forEachChunk((x, z) -> {
CraftbukkitWrapper.impl.sendChunk(player, x, z); CraftbukkitWrapper.impl.sendChunk(player, x, z);
}); });
} }
@@ -62,7 +62,7 @@ public class KillAllCommand extends SWCommand {
WORLD.getEntities() WORLD.getEntities()
.stream() .stream()
.filter(e -> !(e instanceof Player)) .filter(e -> !(e instanceof Player))
.filter(e -> region.inRegion(e.getLocation())) .filter(e -> region.getArea().inRegion(e.getLocation(), false))
.forEach(entity -> { .forEach(entity -> {
entity.remove(); entity.remove();
count.incrementAndGet(); count.incrementAndGet();
@@ -1,6 +1,7 @@
package de.steamwar.bausystem.features.world; package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.Region;
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.utils.ScoreboardElement; import de.steamwar.bausystem.utils.ScoreboardElement;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
@@ -101,8 +102,8 @@ public class BauScoreboard implements Listener {
Region region = Region.getRegion(player.getLocation()); Region region = Region.getRegion(player.getLocation());
if (region.getType().isGlobal()) return "§eSteam§8War"; if (region.getType().isGlobal()) return "§eSteam§8War";
String colorCode = "§e"; String colorCode = "§e";
if (region.hasFlag(Flag.COLOR).isReadable()) { if (region.getFlags().has(Flag.COLOR).isReadable()) {
colorCode = "§" + region.getFlag(Flag.COLOR).get().getColor().getColorCode(); colorCode = "§" + region.getFlags().get(Flag.COLOR).orElse(ColorMode.PINK).getColorCode();
} }
return colorCode + "■ §eSteam§8War " + colorCode + ""; // ■ return colorCode + "■ §eSteam§8War " + colorCode + ""; // ■
} }
@@ -103,7 +103,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
hidden.get(region).add(player); hidden.get(region).add(player);
BauSystem.MESSAGE.sendPrefixless("XRAY_ON", player, ChatMessageType.ACTION_BAR); BauSystem.MESSAGE.sendPrefixless("XRAY_ON", player, ChatMessageType.ACTION_BAR);
} }
region.forEachChunk((x, z) -> { region.getBuildArea().forEachChunk((x, z) -> {
CraftbukkitWrapper.impl.sendChunk(player, x, z); CraftbukkitWrapper.impl.sendChunk(player, x, z);
}); });
} }
@@ -149,7 +149,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
private TechHider createXray(Region rg, Set<Material> obfuscate) { private TechHider createXray(Region rg, Set<Material> obfuscate) {
TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> { TechHider current = new TechHider((TechHider.LocationEvaluator) (p, cX, cY) -> {
if (rg.buildChunkOutside(cX, cY)) return true; if (rg.getBuildArea().isChunkOutside(cX, cY)) return true;
return !hidden.get(rg).contains(p); return !hidden.get(rg).contains(p);
}, Material.STRUCTURE_VOID, obfuscate, new HashSet<>()); }, Material.STRUCTURE_VOID, obfuscate, new HashSet<>());
current.enable(); current.enable();
@@ -34,6 +34,8 @@ import org.bukkit.entity.Player;
@AllArgsConstructor @AllArgsConstructor
public class Point { public class Point {
public static final Point ZERO = new Point(0, 0, 0);
private final int x; private final int x;
private final int y; private final int y;
private final int z; private final int z;
@@ -46,9 +46,9 @@ public interface Region {
Area getArea(); Area getArea();
Optional<Area> getBuildArea(); Area getBuildArea();
Optional<Area> getTestblockArea(); Area getTestblockArea();
Optional<File> getGameModeConfig(); Optional<File> getGameModeConfig();
@@ -56,6 +56,55 @@ public interface Region {
interface Area { interface Area {
Area EMPTY = new Area() {
@Override
public boolean isEmpty() {
return true;
}
@Override
public Point getMinPoint(boolean extension) {
return Point.ZERO;
}
@Override
public Point getMaxPoint(boolean extension) {
return Point.ZERO;
}
@Override
public Point getCopyPoint() {
return Point.ZERO;
}
@Override
public boolean inRegion(Location location, boolean extension) {
return false;
}
@Override
public EditSession copy(boolean extension) {
return null;
}
@Override
public void reset(@Nullable SchematicNode schematicNode, boolean extension) {
}
@Override
public void forEachChunk(BiConsumer<Integer, Integer> executor) {
}
@Override
public boolean isChunkOutside(int chunkX, int chunkZ) {
return false;
}
};
default boolean isEmpty() {
return false;
}
Point getMinPoint(boolean extension); Point getMinPoint(boolean extension);
Point getMaxPoint(boolean extension); Point getMaxPoint(boolean extension);