Fix many things

This commit is contained in:
2024-12-24 14:47:23 +01:00
parent 5e5bfedb52
commit 3d0e5fc28d
11 changed files with 34 additions and 24 deletions
@@ -48,12 +48,12 @@ public class DesignEndStone {
private double maxBlastResistance;
public DesignEndStone(Region region) {
this.minX = region.getMinPointBuild().getX();
this.minY = region.getMinPointBuild().getY();
this.minZ = region.getMinPointBuild().getZ();
this.maxX = region.getMaxPointBuild().getX();
this.maxY = region.getMaxPointBuild().getY();
this.maxZ = region.getMaxPointBuild().getZ();
this.minX = region.getBuildArea().getMinPoint(false).getX();
this.minY = region.getBuildArea().getMinPoint(false).getY();
this.minZ = region.getBuildArea().getMinPoint(false).getZ();
this.maxX = region.getBuildArea().getMaxPoint(false).getX();
this.maxY = region.getBuildArea().getMaxPoint(false).getY();
this.maxZ = region.getBuildArea().getMaxPoint(false).getZ();
wsOrAs = region.getName().startsWith("ws") || region.getName().startsWith("as");
maxBlastResistance = wsOrAs ? 6.1 : 9.0;
@@ -39,7 +39,7 @@ public class LoadtimerCommand extends SWCommand {
@Register(value = "start", description = {"LOADTIMER_HELP_START_2", "LOADTIMER_HELP_START_3"})
public void start(@Validator Player p, TimerMode mode) {
Region r = Region.getRegion(p.getLocation());
if (r.isGlobal()) return;
if (r.getType().isGlobal()) return;
if (!Loadtimer.hasTimer(r))
Loadtimer.createLoadtimer(r, mode == TimerMode.HALF);
}
@@ -47,7 +47,7 @@ public class LoadtimerCommand extends SWCommand {
@Register(value = "stop", description = "LOADTIMER_HELP_STOP")
public void stop(@Validator Player p) {
Region r = Region.getRegion(p.getLocation());
if (r.isGlobal()) return;
if (r.getType().isGlobal()) return;
if (Loadtimer.hasTimer(r))
Loadtimer.getTimer(r).delete();
}
@@ -46,7 +46,7 @@ public class LoadtimerGuiItem extends BauGuiItem {
@Override
public ItemStack getItem(Player player) {
Region r = Region.getRegion(player.getLocation());
if (r.isGlobal())
if (r.getType().isGlobal())
return new SWItem(Material.BOWL, BauSystem.MESSAGE.parse("LOADTIMER_GUI_GLOBAL", player)).getItemStack();
if (Loadtimer.hasTimer(r)) {
return new SWItem(Material.BOW, BauSystem.MESSAGE.parse("LOADTIMER_GUI_STOP", player)).getItemStack();
@@ -58,7 +58,7 @@ public class LoadtimerGuiItem extends BauGuiItem {
@Override
public boolean click(ClickType click, Player p) {
Region r = Region.getRegion(p.getLocation());
if (r.isGlobal()) return false;
if (r.getType().isGlobal()) return false;
if (Loadtimer.hasTimer(r)) {
p.performCommand("lt stop");
} else {
@@ -31,8 +31,8 @@ import de.steamwar.bausystem.features.util.SelectCommand;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.region.Region;
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.Flag;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.shared.Pair;
@@ -220,14 +220,14 @@ public class RegionCommand extends SWCommand {
return;
}
Point minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
Point maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.NORMAL);
Point minPoint = region.getBuildArea().getMinPoint(false);
Point maxPoint = region.getBuildArea().getMaxPoint(false);
switch (option) {
case 0:
break;
case 1:
minPoint = region.getMinPoint(RegionType.BUILD, RegionExtensionType.EXTENSION);
maxPoint = region.getMaxPoint(RegionType.BUILD, RegionExtensionType.EXTENSION);
minPoint = region.getBuildArea().getMinPoint(true);
maxPoint = region.getBuildArea().getMaxPoint(true);
break;
case 2:
Pair<Location, Location> selection = WorldEditUtils.getSelection(p);
@@ -312,7 +312,7 @@ public class RegionCommand extends SWCommand {
public List<String> tabCompletes(CommandSender commandSender, PreviousArguments previousArguments, String s) {
Player p = (Player) commandSender;
Region region = Region.getRegion(p.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
return Collections.emptyList();
}
return region.getPrototype().getSkinMap().keySet().stream().map(c -> c.replace(' ', '_')).collect(Collectors.toList());
@@ -21,6 +21,7 @@ package de.steamwar.bausystem.features.script.lua.libs;
import com.google.gson.*;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionSystem;
import de.steamwar.core.Core;
import de.steamwar.linkage.Linked;
import de.steamwar.linkage.api.Disable;
@@ -74,7 +75,7 @@ public class StorageLib implements LuaLib, Enable, Disable {
jsonObject.keySet().forEach(key -> {
map.put(key, fromJson(jsonObject.get(key)));
});
Region region = Region.getREGION_MAP().get(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length()));
Region region = RegionSystem.INSTANCE.getRegion(regionStorage.getName().substring(0, regionStorage.getName().length() - ".json".length())).orElse(null);
REGION_STORAGE.put(region, map);
} catch (Exception e) {}
}
@@ -54,7 +54,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
@Register
public void genericCommand(@Validator Player player, ShieldPrintingState shieldPrintingState) {
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
return;
}
@@ -90,7 +90,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
@Register("stop")
public void stopCommand(@Validator Player player) {
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
BauSystem.MESSAGE.send("SHIELD_PRINTING_NO_REGION", player);
return;
}
@@ -111,7 +111,7 @@ public class ShieldPrintingCommand extends SWCommand implements Listener {
return false;
}
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
messageSender.send("SHIELD_PRINTING_NO_REGION", player);
return false;
}
@@ -63,7 +63,7 @@ public class TechHiderCommand extends SWCommand implements Listener, ScoreboardE
@Register(description = "TECHHIDER_HELP")
public void toggleHider(@Validator Player player) {
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
BauSystem.MESSAGE.send("TECHHIDER_GLOBAL", player);
return;
}
@@ -1,6 +1,7 @@
package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionSystem;
import lombok.Cleanup;
import lombok.SneakyThrows;
import org.bukkit.Bukkit;
@@ -31,7 +32,8 @@ public class TraceRepository {
@Cleanup
ObjectInputStream reader = new ObjectInputStream(new GZIPInputStream(new FileInputStream(recordsFile)));
UUID uuid = UUID.fromString(reader.readUTF());
Region region = Region.getREGION_MAP().get(reader.readUTF());
Region region = RegionSystem.INSTANCE.getRegion(reader.readUTF()).orElse(null);
if (region == null) return null;
Date date = (Date) reader.readObject();
int serialisationVersion = reader.readInt();
if (serialisationVersion != SERIALISATION_VERSION) {
@@ -64,7 +64,7 @@ public class XrayCommand extends SWCommand implements Listener, ScoreboardElemen
@Register(description = "XRAY_HELP")
public void toggleHider(@Validator Player player) {
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
BauSystem.MESSAGE.send("XRAY_GLOBAL", player);
return;
}
@@ -96,6 +96,11 @@ public interface Region {
return ZERO;
}
@Override
public Point getCopyPoint() {
return ZERO;
}
@Override
public boolean inRegion(Location location, boolean extension) {
return false;
@@ -123,6 +128,8 @@ public interface Region {
Point getMaxPoint(boolean extension);
Point getCopyPoint();
boolean inRegion(Location location, boolean extension);
Optional<EditSession> copy(boolean extension);
@@ -51,7 +51,7 @@ public class BossBarService implements Listener {
.computeIfAbsent(key, k -> {
BossBar bossBar = Bukkit.createBossBar("", BarColor.WHITE, BarStyle.SOLID);
bossBar.addPlayer(player);
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
return new GlobalBossbar(bossBar);
} else {
return new RegionedBossbar(bossBar, region, player);