properly mark changes to claims

This commit is contained in:
Flemmli97 2020-08-25 21:50:41 +02:00
parent 233e75d141
commit a33a123c9a
2 changed files with 37 additions and 18 deletions

View File

@ -65,6 +65,7 @@ public class Claim {
this.minY = Math.max(0, minY);
this.owner = creator;
this.world = world;
this.setDirty();
}
public static Claim fromJson(JsonObject obj, UUID owner, ServerWorld world) {
@ -103,10 +104,13 @@ public class Claim {
this.maxZ = claim.maxZ;
this.minY = claim.minY;
this.removed = false;
this.setDirty();
}
public void setAdminClaim() {
this.owner = null;
this.subClaims.forEach(claim->claim.owner = null);
this.setDirty();
}
public int getPlane() {
@ -196,7 +200,6 @@ public class Claim {
}
private boolean hasPerm(EnumPermission perm) {
System.out.println("claim " + this + " perm " + perm);
if (this.parentClaim() == null)
return this.permEnabled(perm) == 1;
if (this.permEnabled(perm) == -1)
@ -225,6 +228,7 @@ public class Claim {
sub.parent = this.claimID;
sub.parentClaim = this;
this.subClaims.add(sub);
this.setDirty();
}
return conflicts;
}
@ -234,6 +238,7 @@ public class Claim {
claim.parent = this.claimID;
claim.parentClaim = this;
this.subClaims.add(claim);
this.setDirty();
}
public Claim getSubClaim(BlockPos pos) {
@ -244,6 +249,8 @@ public class Claim {
}
public boolean deleteSubClaim(Claim claim) {
claim.remove();
this.setDirty();
return this.subClaims.remove(claim);
}
@ -259,8 +266,10 @@ public class Claim {
for (Claim other : this.subClaims)
if (!claim.equals(other) && newClaim.intersects(other))
conflicts.add(other);
if (conflicts.isEmpty())
if (conflicts.isEmpty()) {
claim.copySizes(newClaim);
this.setDirty();
}
return conflicts;
}
@ -357,7 +366,13 @@ public class Claim {
return l;
}
/**
* Only marks non sub claims
*/
public void setDirty() {
if(this.parentClaim()!=null)
this.parentClaim().setDirty();
else
this.dirty = true;
}

View File

@ -124,11 +124,12 @@ public class ItemInteractEvents {
data.setEditingCorner(target);
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.resizeClaim, Formatting.GOLD), false);
} else {
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.cantClaimHere, Formatting.RED), false);
}
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
} else {
if (data.currentEdit() != null) {
if(data.editingCorner()!=target) {
Set<Claim> fl = claim.resizeSubclaim(data.currentEdit(), data.editingCorner(), target);
if (!fl.isEmpty()) {
fl.forEach(confl -> data.addDisplayClaim(confl, EnumDisplayType.MAIN, player.getBlockPos().getY()));
@ -136,7 +137,9 @@ public class ItemInteractEvents {
}
data.setEditClaim(null, 0);
data.setEditingCorner(null);
}
} else if (data.editingCorner() != null) {
if(data.editingCorner()!=target) {
Set<Claim> fl = claim.tryCreateSubClaim(data.editingCorner(), target);
data.addDisplayClaim(claim, EnumDisplayType.MAIN, player.getBlockPos().getY());
if (!fl.isEmpty()) {
@ -146,6 +149,7 @@ public class ItemInteractEvents {
player.sendMessage(PermHelper.simpleColoredText(ConfigHandler.lang.subClaimCreateSuccess, Formatting.GOLD), false);
}
data.setEditingCorner(null);
}
} else
data.setEditingCorner(target);
}