Fix runtime errors

This commit is contained in:
2026-03-04 19:19:08 +01:00
parent 09be2b434d
commit 2116e1ee8d
10 changed files with 79 additions and 79 deletions
@@ -23,14 +23,12 @@ import de.steamwar.bausystem.features.region.RegionCommand;
import de.steamwar.bausystem.region.dynamic.DynamicRegion;
import de.steamwar.bausystem.region.dynamic.Tile;
import de.steamwar.bausystem.region.dynamic.path.PathRegion;
import de.steamwar.bausystem.region.dynamic.path.PathRegionData;
import de.steamwar.bausystem.utils.PasteBuilder;
import de.steamwar.command.AbstractSWCommand;
import de.steamwar.command.SWCommand;
import org.bukkit.entity.Player;
import java.util.UUID;
import java.util.stream.Collectors;
@AbstractSWCommand.PartOf(RegionCommand.class)
public class DynamicRegionCommand extends SWCommand {
@@ -43,22 +41,20 @@ public class DynamicRegionCommand extends SWCommand {
public void placeRegion(Player player) {
Region region = DynamicRegionSystem.INSTANCE.get(player.getLocation());
if (!region.getType().isGlobal()) return;
Tile tile = Tile.fromLocation(player.getLocation()).validOrNull();
Tile tile = Tile.fromLocation(player.getLocation()).orElse(null);
if (tile == null) return;
// TODO: Replace!
PathRegion dynamicRegion = new PathRegion(UUID.randomUUID(), tile.getMinX(), tile.getMinZ());
dynamicRegion.setRegionData(new PathRegionData(dynamicRegion));
dynamicRegion.getArea().reset(new PasteBuilder(new PasteBuilder.FileProvider(dynamicRegion.getArea().getResetFile())), false);
DynamicRegionSystem.INSTANCE.getNeighbours(dynamicRegion).collect(Collectors.toList())
.forEach(r -> r.update(dynamicRegion));
DynamicRegionSystem.INSTANCE.getNeighbours(dynamicRegion).forEach(r -> r.update(dynamicRegion));
}
@Register({"dynamic", "delete"})
public void deleteRegion(Player player) {
Region region = DynamicRegionSystem.INSTANCE.get(player.getLocation());
if (region.getType().isCannotDelete()) return;
if (!region.getType().isDeletable()) return;
((DynamicRegion) region).delete();
}
}