Another potential fix for construction

This commit is contained in:
Ceikry
2021-07-07 22:38:15 +00:00
parent bcde41b7c9
commit cec3f4938d
2 changed files with 24 additions and 9 deletions
@@ -267,10 +267,16 @@ public final class HouseManager {
int diffX = player.getLocation().getX() - r.getBaseLocation().getX();
int diffY = player.getLocation().getY() - r.getBaseLocation().getY();
int diffZ = player.getLocation().getZ() - r.getBaseLocation().getZ();
DynamicRegion dr = region;
DynamicRegion dd = dungeon;
RegionManager.getRegionCache().remove(dr);
RegionManager.getRegionCache().remove(dd);
region = null;
dungeon = null;
enter(player, buildingMode, false);
player.getProperties().setTeleportLocation((player.getViewport().getRegion() == dungeon ? dungeon : region).getBaseLocation().transform(diffX, diffY, diffZ));
dr.flagInactive();
dd.flagInactive();
}
/**
@@ -299,22 +299,31 @@ public class Region {
}
}
/**
* Unloads a region - compatibility method for older uses
*/
private static void unload(Region r){
unload(r, false);
}
/**
* Unloads a region.
* @param r The region.
*/
private static void unload(Region r) {
if (r.isViewed()) {
SystemLogger.logErr("Players viewing region!");
r.flagActive();
return;
}
for (RegionPlane p : r.planes) {
if (!p.getPlayers().isEmpty()) {
SystemLogger.logErr("Players still in region!");
private static void unload(Region r, boolean force) {
if(!force){
if (r.isViewed()) {
SystemLogger.logErr("Players viewing region!");
r.flagActive();
return;
}
for (RegionPlane p : r.planes) {
if (!p.getPlayers().isEmpty()) {
SystemLogger.logErr("Players still in region!");
r.flagActive();
return;
}
}
}
for (RegionPlane p : r.planes) {
p.clear();