Skip to content

Commit 47730bc

Browse files
committed
Fix /rsc to update existing subdivisions in main claims
1 parent d13566f commit 47730bc

File tree

5 files changed

+15
-70
lines changed

5 files changed

+15
-70
lines changed

src/main/java/me/ryanhamshire/GriefPrevention/DataStore.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ synchronized void addClaim(Claim newClaim, boolean writeToStorage) {
439439
this.claimIDMap.put(newClaim.id, newClaim);
440440
for (Claim child : newClaim.children) {
441441
this.claimIDMap.put(child.id, child);
442+
child.inDataStore = true;
442443
// 3D subdivisions need to be in chunk claim map so getClaimAt can find them
443444
if (child.is3D()) {
444445
addToChunkClaimMap(child);

src/main/java/me/ryanhamshire/GriefPrevention/DatabaseDataStore.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,6 @@ else if (parentId == -1)
423423
childClaim.parent = topLevelClaim;
424424
topLevelClaim.children.add(childClaim);
425425
childClaim.inDataStore = true;
426-
// Migration: first-child 3D subdivisions should inherit (inheritNothing=false)
427-
if (childClaim.is3D() && childClaim.getSubclaimRestrictions() && topLevelClaim.parent == null) {
428-
childClaim.setSubclaimRestrictions(false);
429-
}
430426
}
431427

432428
for (Claim claim : claimsToRemove)

src/main/java/me/ryanhamshire/GriefPrevention/FlatFileDataStore.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -626,10 +626,6 @@ private Claim deserializeChild(ConfigurationSection section, Claim parent, List<
626626

627627
boolean inheritNothing = section.getBoolean("inheritNothing");
628628
boolean is3D = section.getBoolean("Is3D", false);
629-
// Migration: first-child 3D subdivisions should inherit (inheritNothing=false)
630-
if (is3D && inheritNothing && parent != null && parent.parent == null) {
631-
inheritNothing = false;
632-
}
633629
boolean explosivesAllowed = section.getBoolean("Explosives Allowed", false);
634630

635631
Long childID = null;

src/main/java/me/ryanhamshire/GriefPrevention/GriefPrevention.java

Lines changed: 12 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1857,66 +1857,7 @@ else if (cmd.getName().equalsIgnoreCase("permissiontrust") && player != null) {
18571857

18581858
// restrictsubclaim
18591859
else if (cmd.getName().equalsIgnoreCase("restrictsubclaim") && player != null) {
1860-
PlayerData playerData = this.dataStore.getPlayerData(player.getUniqueId());
1861-
Claim claim = this.dataStore.getClaimAt(player.getLocation(), true, playerData.lastClaim);
1862-
if (claim == null) {
1863-
GriefPrevention.sendMessage(player, TextMode.Err, Messages.StandInSubclaim);
1864-
return true;
1865-
}
1866-
1867-
// If in a main claim (no parent), toggle the flag for future subdivisions
1868-
if (claim.parent == null) {
1869-
// If admin claim, fail if this user is not an admin
1870-
// If not an admin claim, fail if this user is not the owner
1871-
if (!playerData.ignoreClaims && (claim.isAdminClaim() ? !player.hasPermission("griefprevention.adminclaims") : !player.getUniqueId().equals(claim.ownerID))) {
1872-
GriefPrevention.sendMessage(player, TextMode.Err, Messages.OnlyOwnersModifyClaims, claim.getOwnerName());
1873-
return true;
1874-
}
1875-
1876-
if (claim.getInheritNothingForNewSubdivisions()) {
1877-
claim.setInheritNothingForNewSubdivisions(false);
1878-
// Also unrestrict all existing subdivisions
1879-
for (Claim child : claim.children) {
1880-
if (child.getSubclaimRestrictions()) {
1881-
child.setSubclaimRestrictions(false);
1882-
this.dataStore.saveClaim(child);
1883-
}
1884-
}
1885-
GriefPrevention.sendMessage(player, TextMode.Success, Messages.MainClaimSubdivisionInheritEnabled);
1886-
} else {
1887-
claim.setInheritNothingForNewSubdivisions(true);
1888-
// Also restrict all existing subdivisions
1889-
for (Claim child : claim.children) {
1890-
if (!child.getSubclaimRestrictions()) {
1891-
removeInheritedPermissions(child);
1892-
child.setSubclaimRestrictions(true);
1893-
this.dataStore.saveClaim(child);
1894-
}
1895-
}
1896-
GriefPrevention.sendMessage(player, TextMode.Success, Messages.MainClaimSubdivisionInheritDisabled);
1897-
}
1898-
this.dataStore.saveClaim(claim);
1899-
return true;
1900-
}
1901-
1902-
// If player has /ignoreclaims on, continue
1903-
// If admin claim, fail if this user is not an admin
1904-
// If not an admin claim, fail if this user is not the owner
1905-
if (!playerData.ignoreClaims && (claim.isAdminClaim() ? !player.hasPermission("griefprevention.adminclaims") : !player.getUniqueId().equals(claim.parent.ownerID))) {
1906-
GriefPrevention.sendMessage(player, TextMode.Err, Messages.OnlyOwnersModifyClaims, claim.getOwnerName());
1907-
return true;
1908-
}
1909-
1910-
if (claim.getSubclaimRestrictions()) {
1911-
claim.setSubclaimRestrictions(false);
1912-
GriefPrevention.sendMessage(player, TextMode.Success, Messages.SubclaimUnrestricted);
1913-
} else {
1914-
removeInheritedPermissions(claim);
1915-
claim.setSubclaimRestrictions(true);
1916-
GriefPrevention.sendMessage(player, TextMode.Success, Messages.SubclaimRestricted);
1917-
}
1918-
this.dataStore.saveClaim(claim);
1919-
return true;
1860+
return this.handleRestrictSubclaimCommand(player, new String[]{});
19201861
}
19211862

19221863
// adminclaims
@@ -4184,9 +4125,20 @@ public boolean handleRestrictSubclaimCommand(CommandSender sender, String[] args
41844125

41854126
if (claim.getInheritNothingForNewSubdivisions()) {
41864127
claim.setInheritNothingForNewSubdivisions(false);
4128+
// Also unrestrict all existing subdivisions
4129+
for (Claim child : claim.children) {
4130+
child.setSubclaimRestrictions(false);
4131+
}
41874132
GriefPrevention.sendMessage(player, TextMode.Success, Messages.MainClaimSubdivisionInheritEnabled);
41884133
} else {
41894134
claim.setInheritNothingForNewSubdivisions(true);
4135+
// Also restrict all existing subdivisions
4136+
for (Claim child : claim.children) {
4137+
if (!child.getSubclaimRestrictions()) {
4138+
removeInheritedPermissions(child);
4139+
}
4140+
child.setSubclaimRestrictions(true);
4141+
}
41904142
GriefPrevention.sendMessage(player, TextMode.Success, Messages.MainClaimSubdivisionInheritDisabled);
41914143
}
41924144
this.dataStore.saveClaim(claim);

src/main/java/me/ryanhamshire/GriefPrevention/Messages.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,8 @@ public enum Messages
242242
StandInSubclaim("You need to be standing in a subclaim to restrict it"),
243243
SubclaimRestricted("This subclaim's permissions will no longer inherit from the parent claim"),
244244
SubclaimUnrestricted("This subclaim's permissions will now inherit from the parent claim"),
245-
MainClaimSubdivisionInheritDisabled("Future subdivisions in this claim will NOT inherit permissions."),
246-
MainClaimSubdivisionInheritEnabled("Future subdivisions in this claim will inherit permissions."),
245+
MainClaimSubdivisionInheritDisabled("All subdivisions in this claim will NOT inherit permissions."),
246+
MainClaimSubdivisionInheritEnabled("All subdivisions in this claim will inherit permissions."),
247247
NetherPortalTrapDetectionMessage("It seems you might be stuck inside a nether portal. We will rescue you in a few seconds if that is the case!", "Sent to player on join, if they left while inside a nether portal."),
248248
ClaimHelpHeader("Available /claim commands:"),
249249
ClaimHelpLegend("<> - Required, [] - Optional."),

0 commit comments

Comments
 (0)