Update Region System of BauSystem

This commit is contained in:
2024-12-21 19:30:31 +01:00
parent 8427ae36f2
commit 6822dc796f
73 changed files with 927 additions and 1796 deletions
@@ -44,7 +44,6 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
@Linked
@@ -106,11 +105,11 @@ public class AutostartListener implements Listener {
public void activate(Player player) {
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
return;
}
if (!region.hasType(RegionType.TESTBLOCK)) {
if (region.getTestblockArea().isPresent()) {
BauSystem.MESSAGE.send("AUTOSTART_MESSAGE_NO_REGION", player);
return;
}
@@ -131,8 +130,7 @@ public class AutostartListener implements Listener {
event.blockList().forEach(block -> {
Region region = Region.getRegion(block.getLocation());
if (!regionStartTime.containsKey(region)) return;
if (!region.hasType(RegionType.TESTBLOCK)) return;
if (!region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) return;
if (!region.getTestblockArea().inRegion(block.getLocation(), true)) return;
long tickDiff = TPSUtils.currentRealTick.get() - regionStartTime.remove(region);
long preFightDurationInSeconds = getPreFightDurationInSeconds(region);
RegionUtils.message(region, "AUTOSTART_MESSAGE_RESULT1", tickDiff);
@@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.backup;
import com.sk89q.worldedit.EditSession;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.tags.Tag;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.SWCommand;
import de.steamwar.command.SWCommandUtils;
@@ -49,7 +49,7 @@ public class BackupCommand extends SWCommand {
}
static boolean checkGlobalRegion(Region region, Player p) {
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
BauSystem.MESSAGE.send("BACKUP_REGION_NO_REGION", p);
return true;
}
@@ -62,11 +62,11 @@ public class BackupCommand extends SWCommand {
if (checkGlobalRegion(region, p)) {
return;
}
if (!region.get(Tag.CHANGED)) {
if (region.getFlag(Flag.CHANGED).isPresent()) {
BauSystem.MESSAGE.send("BACKUP_CREATE_NO_CHANGE", p);
return;
}
if (region.backup()) {
if (region.backup(false)) {
BauSystem.MESSAGE.send("BACKUP_CREATE_SUCCESS", p);
} else {
BauSystem.MESSAGE.send("BACKUP_CREATE_FAILURE", p);
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.cannon.depth.Depth;
import de.steamwar.bausystem.features.cannon.depth.DepthManager;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
import org.bukkit.entity.TNTPrimed;
@@ -85,8 +84,8 @@ public class CannonDetector implements Listener {
grouped.forEach((cannonKey, tntPrimeds) -> {
if (tntPrimeds.size() <= 5) return;
Region region = Region.getRegion(tntPrimeds.get(0).getLocation());
if (region.isGlobal()) return;
if (!region.hasType(RegionType.TESTBLOCK)) return;
if (region.getType().isGlobal()) return;
if (region.getTestblockArea().isEmpty()) return;
Depth depth = new Depth(region);
DepthManager.init(tntPrimeds, depth);
});
@@ -23,8 +23,6 @@ import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.configplayer.Config;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
@@ -50,7 +48,7 @@ public class Depth {
public void update(List<Block> blocks) {
List<Block> blocksList = blocks.stream()
.filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION))
.filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true))
.collect(Collectors.toList());
tntCount++;
for (Block block : blocksList) {
@@ -20,7 +20,7 @@
package de.steamwar.bausystem.features.countingwand;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.shared.Pair;
import de.steamwar.bausystem.utils.ItemUtils;
import de.steamwar.inventory.SWItem;
@@ -19,7 +19,7 @@
package de.steamwar.bausystem.features.countingwand;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import de.steamwar.linkage.Linked;
import org.bukkit.FluidCollisionMode;
import org.bukkit.event.EventHandler;
@@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.design.endstone;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.utils.BauMemberUpdateEvent;
import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked;
@@ -49,7 +48,7 @@ public class DesignEndStoneCommand extends SWCommand implements Listener {
@Register(description = "DESIGN_ENDSTONE_COMMAND_HELP")
public void genericCommand(@Validator Player player) {
Region region = Region.getRegion(player.getLocation());
if (!region.hasType(RegionType.BUILD)) {
if (region.getBuildArea().isEmpty()) {
BauSystem.MESSAGE.send("DESIGN_ENDSTONE_REGION_ERROR", player);
return;
}
@@ -20,7 +20,7 @@
package de.steamwar.bausystem.features.killchecker;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
@@ -20,7 +20,7 @@
package de.steamwar.bausystem.features.observer;
import de.steamwar.Reflection;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
@@ -28,7 +28,7 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.session.ClipboardHolder;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.util.SelectCommand;
import de.steamwar.bausystem.regionnew.Point;
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;
@@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.region.items;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.Permission;
import de.steamwar.bausystem.linkage.specific.BauGuiItem;
import de.steamwar.bausystem.regionnew.Color;
import de.steamwar.bausystem.region.Color;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.ColorMode;
@@ -19,7 +19,7 @@
package de.steamwar.bausystem.features.script.lua.libs;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import lombok.AllArgsConstructor;
import org.bukkit.entity.Player;
import org.luaj.vm2.*;
@@ -22,7 +22,7 @@ package de.steamwar.bausystem.features.script.lua.libs;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.bukkit.BukkitPlayer;
import com.sk89q.worldedit.math.BlockVector3;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import de.steamwar.linkage.Linked;
import org.bukkit.entity.Player;
@@ -23,7 +23,6 @@ import de.steamwar.bausystem.features.simulator.data.SimulatorPhase;
import de.steamwar.bausystem.features.simulator.execute.SimulatorAction;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.region.flags.flagvalues.FreezeMode;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@@ -65,7 +64,7 @@ public final class TNTPhase extends SimulatorPhase {
@Override
public void accept(World world) {
Location location = position.toLocation(world);
if (Region.getRegion(location).get(Flag.FREEZE) == FreezeMode.ACTIVE) return;
if (Region.getRegion(location).getFlag(Flag.FREEZE).isPresent()) return;
TNTPrimed tnt = world.spawn(location, TNTPrimed.class);
if (!xJump) tnt.setVelocity(tnt.getVelocity().setX(0));
if (!yJump) tnt.setVelocity(tnt.getVelocity().setY(0));
@@ -19,7 +19,7 @@
package de.steamwar.bausystem.features.slaves.laufbau;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -27,7 +27,7 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -26,7 +26,7 @@ import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
import de.steamwar.bausystem.features.tracer.TNTPoint;
import de.steamwar.bausystem.features.tracer.Trace;
import de.steamwar.bausystem.features.tracer.TraceManager;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.utils.FlatteningWrapper;
import org.bukkit.Location;
import org.bukkit.World;
@@ -21,9 +21,7 @@ package de.steamwar.bausystem.features.team;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.features.team.boundary.BoundaryViewer;
import de.steamwar.bausystem.region.Prototype;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.PreviousArguments;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
@@ -69,14 +67,14 @@ public class SkinCommand extends SWCommand {
return;
}
Region region = Region.getRegion(p.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
BauSystem.MESSAGE.send("SKIN_NO_REGION", p);
return;
}
String name = String.join(" ", names);
File arenaFile = new File("sections19/" + name + "/" + typeKuerzel + "Arena.schem");
File testblockFile = region.hasType(RegionType.TESTBLOCK) ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null;
File testblockFile = region.getTestblockArea().isPresent() ? new File("sections19/" + name + "/" + typeKuerzel + "Testblock.schem") : null;
arenaFile.getParentFile().mkdirs();
if (testblockFile != null) {
@@ -48,21 +48,18 @@ public class BoundaryViewer implements Listener {
}
viewers.forEach(player -> {
Region region = Region.getRegion(player.getLocation());
if (region.isGlobal()) return;
if (region.getType().isGlobal()) return;
showRegion(region, player);
if (region.getLinkedRegion() != null) {
showRegion(region.getLinkedRegion(), player);
}
});
}, 20, 20);
}
private void showRegion(Region region, Player player) {
drawCuboid(player, TrickyParticleWrapper.impl.getVillagerHappy(), region.getMinPoint(), region.getMaxPoint());
if (region.hasType(RegionType.TESTBLOCK)) {
if (region.getTestblockArea().isPresent()) {
drawCuboid(player, Particle.END_ROD, region.getMinPointTestblockExtension(), region.getMaxPointTestblockExtension());
}
if (region.hasType(RegionType.BUILD)) {
if (region.getBuildArea().isPresent()) {
drawCuboid(player, Particle.END_ROD, region.getMinPointBuildExtension(), region.getMaxPointBuildExtension());
}
}
@@ -20,8 +20,6 @@
package de.steamwar.bausystem.features.testblock.blockcounter;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.linkage.Linked;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
@@ -37,11 +35,13 @@ public class BlockCounterListener implements Listener {
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
Region region = Region.getRegion(event.getLocation());
if (region.isGlobal()) {
if (region.getType().isGlobal()) {
return;
}
List<Block> blockList = event.blockList();
blockList = blockList.stream().filter(block -> region.inRegion(block.getLocation(), RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)).collect(Collectors.toList());
blockList = blockList.stream()
.filter(block -> region.getTestblockArea().inRegion(block.getLocation(), true))
.collect(Collectors.toList());
if (blockList.isEmpty()) {
return;
}
@@ -20,8 +20,6 @@
package de.steamwar.bausystem.features.tracer;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.core.Core;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
@@ -39,7 +37,7 @@ import java.util.Optional;
*/
@AllArgsConstructor(access = AccessLevel.PACKAGE)
@Getter
public class TNTPoint{
public class TNTPoint {
/**
* Unique number to identify records being of the same tnt
*/
@@ -99,7 +97,7 @@ public class TNTPoint{
* Constructor for object creation in trace recording
*/
protected TNTPoint(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart,
List<TNTPoint> history, List<Block> destroyedBlocks) {
List<TNTPoint> history, List<Block> destroyedBlocks) {
this.tntId = tntId;
this.explosion = explosion;
if (Core.getVersion() > 15) {
@@ -117,12 +115,10 @@ public class TNTPoint{
boolean buildDestroy = false;
boolean testblockDestroy = false;
for (Block destroyedBlock : destroyedBlocks) {
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(), RegionType.BUILD,
RegionExtensionType.EXTENSION)) {
if (Region.getRegion(destroyedBlock.getLocation()).getBuildArea().inRegion(destroyedBlock.getLocation(), true)) {
buildDestroy = true;
}
if (Region.getRegion(destroyedBlock.getLocation()).inRegion(destroyedBlock.getLocation(),
RegionType.TESTBLOCK, RegionExtensionType.EXTENSION)) {
if (Region.getRegion(destroyedBlock.getLocation()).getTestblockArea().inRegion(destroyedBlock.getLocation(), true)) {
testblockDestroy = true;
}
}
@@ -21,12 +21,9 @@ package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.SWUtils;
import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionSelectionType;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.bausystem.region.RegionUtils;
import de.steamwar.command.SWCommand;
import de.steamwar.linkage.Linked;
import org.bukkit.Bukkit;
@@ -53,7 +50,7 @@ public class KillAllCommand extends SWCommand {
public void genericCommand(@Validator Player player, RegionSelectionType regionSelectionType) {
Region region = Region.getRegion(player.getLocation());
AtomicLong count = new AtomicLong(0);
if (regionSelectionType == RegionSelectionType.GLOBAL || GlobalRegion.getInstance() == region) {
if (regionSelectionType == RegionSelectionType.GLOBAL || region.getType().isGlobal()) {
WORLD.getEntities()
.stream()
.filter(e -> !(e instanceof Player))
@@ -66,7 +63,7 @@ public class KillAllCommand extends SWCommand {
WORLD.getEntities()
.stream()
.filter(e -> !(e instanceof Player))
.filter(e -> region.inRegion(e.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL))
.filter(e -> region.inRegion(e.getLocation()))
.forEach(entity -> {
entity.remove();
count.incrementAndGet();
@@ -74,5 +71,4 @@ public class KillAllCommand extends SWCommand {
RegionUtils.actionBar(region, "OTHER_KILLALL_REGION", count.get());
}
}
}
@@ -1,7 +1,7 @@
package de.steamwar.bausystem.features.util;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.regionnew.Point;
import de.steamwar.bausystem.region.Point;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionExtensionType;
import de.steamwar.bausystem.region.utils.RegionType;
@@ -1,7 +1,5 @@
package de.steamwar.bausystem.features.world;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.region.GlobalRegion;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.flags.Flag;
import de.steamwar.bausystem.utils.ScoreboardElement;
@@ -101,8 +99,11 @@ public class BauScoreboard implements Listener {
@Override
public String getTitle() {
Region region = Region.getRegion(player.getLocation());
if (GlobalRegion.getInstance() == region) return "§eSteam§8War";
String colorCode = BauSystem.MESSAGE.parse(region.get(Flag.COLOR).getChatValue(), player).substring(0, 2);
if (region.getType().isGlobal()) return "§eSteam§8War";
String colorCode = "§e";
if (region.hasFlag(Flag.COLOR).isReadable()) {
colorCode = "§" + region.getFlag(Flag.COLOR).get().getColor().getColorCode();
}
return colorCode + "■ §eSteam§8War " + colorCode + ""; // ■
}
});
@@ -28,7 +28,7 @@ import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TranslatableComponent;
import de.steamwar.bausystem.features.world.WorldEditListener;
import de.steamwar.bausystem.features.worldedit.utils.SpecialReplace;
import de.steamwar.bausystem.regionnew.Color;
import de.steamwar.bausystem.region.Color;
import de.steamwar.bausystem.shared.Pair;
import de.steamwar.bausystem.utils.WorldEditUtils;
import de.steamwar.command.PreviousArguments;