Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.19] added unclaim control #257

Open
wants to merge 1 commit into
base: 1.19/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunks.java
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ private void playerChangedDimension(ServerPlayer serverPlayer, ResourceKey<Level
}

private void teamConfig(TeamCollectPropertiesEvent event) {
event.add(FTBChunksTeamData.OWNER_UNCLAIM);
event.add(FTBChunksTeamData.ALLOW_EXPLOSIONS);
event.add(FTBChunksTeamData.ALLOW_MOB_GRIEFING);
event.add(FTBChunksTeamData.ALLOW_ALL_FAKE_PLAYERS);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public boolean allowMobGriefing() {
return teamData.allowMobGriefing();
}

public boolean ownerUnclaim() {
return teamData.ownerUnclaim();
}

public void sendUpdateToAll() {
SendChunkPacket packet = new SendChunkPacket(pos.dimension, teamData.getTeamId(), new SendChunkPacket.SingleChunk(System.currentTimeMillis(), pos.x, pos.z, this));
ChunkSendingUtils.sendChunkToAll(teamData.manager.getMinecraftServer(), teamData, packet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class FTBChunksTeamData {
public static final PrivacyProperty NONLIVING_ENTITY_ATTACK_MODE = new PrivacyProperty(new ResourceLocation(FTBChunks.MOD_ID, "nonliving_entity_attack_mode"), PrivacyMode.ALLIES);
public static final BooleanProperty ALLOW_EXPLOSIONS = new BooleanProperty(new ResourceLocation(FTBChunks.MOD_ID, "allow_explosions"), false);
public static final BooleanProperty ALLOW_MOB_GRIEFING = new BooleanProperty(new ResourceLocation(FTBChunks.MOD_ID, "allow_mob_griefing"), false);
public static final BooleanProperty OWNER_UNCLAIM = new BooleanProperty(new ResourceLocation(FTBChunks.MOD_ID, "owner_unclaim"), false);
public static final PrivacyProperty CLAIM_VISIBILITY = new PrivacyProperty(new ResourceLocation(FTBChunks.MOD_ID, "claim_visibility"), PrivacyMode.PUBLIC);

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

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

if (chunk == null) {
return ClaimResults.NOT_CLAIMED;
} else if (chunk.teamData != this && !source.hasPermission(2) && !source.getServer().isSingleplayer()) {
} else if ((chunk.teamData != this || notAllowedToUnclaim)
&& !source.hasPermission(2)
&& !source.getServer().isSingleplayer()
) {
return ClaimResults.NOT_OWNER;
}

Expand Down Expand Up @@ -281,6 +286,10 @@ public boolean isAlly(UUID p) {
return team.isAlly(p);
}

public boolean isTeamOwner(UUID p) {
return team.getOwner().equals(p);
}

public boolean canUse(ServerPlayer p, PrivacyProperty property) {
PrivacyMode mode = team.getProperty(property);

Expand Down Expand Up @@ -478,6 +487,10 @@ public boolean allowMobGriefing() {
return team.getProperty(ALLOW_MOB_GRIEFING);
}

public boolean ownerUnclaim() {
return team.getProperty(OWNER_UNCLAIM);
}

public void setLastLoginTime(long when) {
this.lastLoginTime = when;
save();
Expand Down
2 changes: 2 additions & 0 deletions common/src/main/resources/assets/ftbchunks/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@
"ftbteamsconfig.ftbchunks.location_mode.tooltip": "Controls who can see you on the map or minimap (outside the normal vanilla tracking range)",
"ftbteamsconfig.ftbchunks.claim_visibility": "Claim Visibility",
"ftbteamsconfig.ftbchunks.claim_visibility.tooltip": "Controls who can see your claims on the map or minimap",
"ftbteamsconfig.ftbchunks.owner_unclaim": "Owner Unclaim",
"ftbteamsconfig.ftbchunks.owner_unclaim.tooltip": "When true, only team owners can unclaim chunks",
"ftbchunks.fake_players": "Allow Fake Players",
"ftbchunks.fake_players.tooltip": "CHECK: check fake player access like any real player\nDENY: never allow fake players\nALLOW: always allow fake players",
"ftbchunks.max_claimed_chunks": "Max Claimed Chunks per Player",
Expand Down