Skip to content

Commit 3aa43b9

Browse files
committed
feat: added unclaim control
1 parent dee8d56 commit 3aa43b9

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunks.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -436,6 +436,7 @@ private void playerChangedDimension(ServerPlayer serverPlayer, ResourceKey<Level
436436
}
437437

438438
private void teamConfig(TeamCollectPropertiesEvent event) {
439+
event.add(FTBChunksTeamData.OWNER_UNCLAIM);
439440
event.add(FTBChunksTeamData.ALLOW_EXPLOSIONS);
440441
event.add(FTBChunksTeamData.ALLOW_MOB_GRIEFING);
441442
event.add(FTBChunksTeamData.ALLOW_ALL_FAKE_PLAYERS);

common/src/main/java/dev/ftb/mods/ftbchunks/data/ClaimedChunk.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ public boolean allowMobGriefing() {
113113
return teamData.allowMobGriefing();
114114
}
115115

116+
public boolean ownerUnclaim() {
117+
return teamData.ownerUnclaim();
118+
}
119+
116120
public void sendUpdateToAll() {
117121
SendChunkPacket packet = new SendChunkPacket(pos.dimension, teamData.getTeamId(), new SendChunkPacket.SingleChunk(System.currentTimeMillis(), pos.x, pos.z, this));
118122
ChunkSendingUtils.sendChunkToAll(teamData.manager.getMinecraftServer(), teamData, packet);

common/src/main/java/dev/ftb/mods/ftbchunks/data/FTBChunksTeamData.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class FTBChunksTeamData {
5656
public static final PrivacyProperty NONLIVING_ENTITY_ATTACK_MODE = new PrivacyProperty(new ResourceLocation(FTBChunks.MOD_ID, "nonliving_entity_attack_mode"), PrivacyMode.ALLIES);
5757
public static final BooleanProperty ALLOW_EXPLOSIONS = new BooleanProperty(new ResourceLocation(FTBChunks.MOD_ID, "allow_explosions"), false);
5858
public static final BooleanProperty ALLOW_MOB_GRIEFING = new BooleanProperty(new ResourceLocation(FTBChunks.MOD_ID, "allow_mob_griefing"), false);
59+
public static final BooleanProperty OWNER_UNCLAIM = new BooleanProperty(new ResourceLocation(FTBChunks.MOD_ID, "owner_unclaim"), false);
5960
public static final PrivacyProperty CLAIM_VISIBILITY = new PrivacyProperty(new ResourceLocation(FTBChunks.MOD_ID, "claim_visibility"), PrivacyMode.PUBLIC);
6061

6162
// public static final PrivacyProperty MINIMAP_MODE = new PrivacyProperty(new ResourceLocation(FTBChunks.MOD_ID, "minimap_mode"), PrivacyMode.ALLIES);
@@ -178,10 +179,14 @@ public ClaimResult claim(CommandSourceStack source, ChunkDimPos pos, boolean che
178179

179180
public ClaimResult unclaim(CommandSourceStack source, ChunkDimPos pos, boolean checkOnly) {
180181
ClaimedChunk chunk = manager.getChunk(pos);
182+
boolean notAllowedToUnclaim = source.getEntity() instanceof ServerPlayer && chunk.ownerUnclaim() && !isTeamOwner(source.getEntity().getUUID());
181183

182184
if (chunk == null) {
183185
return ClaimResults.NOT_CLAIMED;
184-
} else if (chunk.teamData != this && !source.hasPermission(2) && !source.getServer().isSingleplayer()) {
186+
} else if ((chunk.teamData != this || notAllowedToUnclaim)
187+
&& !source.hasPermission(2)
188+
&& !source.getServer().isSingleplayer()
189+
) {
185190
return ClaimResults.NOT_OWNER;
186191
}
187192

@@ -281,6 +286,10 @@ public boolean isAlly(UUID p) {
281286
return team.isAlly(p);
282287
}
283288

289+
public boolean isTeamOwner(UUID p) {
290+
return team.getOwner().equals(p);
291+
}
292+
284293
public boolean canUse(ServerPlayer p, PrivacyProperty property) {
285294
PrivacyMode mode = team.getProperty(property);
286295

@@ -478,6 +487,10 @@ public boolean allowMobGriefing() {
478487
return team.getProperty(ALLOW_MOB_GRIEFING);
479488
}
480489

490+
public boolean ownerUnclaim() {
491+
return team.getProperty(OWNER_UNCLAIM);
492+
}
493+
481494
public void setLastLoginTime(long when) {
482495
this.lastLoginTime = when;
483496
save();

common/src/main/resources/assets/ftbchunks/lang/en_us.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,8 @@
122122
"ftbteamsconfig.ftbchunks.location_mode.tooltip": "Controls who can see you on the map or minimap (outside the normal vanilla tracking range)",
123123
"ftbteamsconfig.ftbchunks.claim_visibility": "Claim Visibility",
124124
"ftbteamsconfig.ftbchunks.claim_visibility.tooltip": "Controls who can see your claims on the map or minimap",
125+
"ftbteamsconfig.ftbchunks.owner_unclaim": "Owner Unclaim",
126+
"ftbteamsconfig.ftbchunks.owner_unclaim.tooltip": "When true, only team owners can unclaim chunks",
125127
"ftbchunks.fake_players": "Allow Fake Players",
126128
"ftbchunks.fake_players.tooltip": "CHECK: check fake player access like any real player\nDENY: never allow fake players\nALLOW: always allow fake players",
127129
"ftbchunks.max_claimed_chunks": "Max Claimed Chunks per Player",

0 commit comments

Comments
 (0)