Skip to content

Commit

Permalink
fix: output of /ftbchunks admin unload_everything was misleading
Browse files Browse the repository at this point in the history
Command did the right work, but output the total number of claimed
chunks, not the number of forceloaded chunks that got unforceloaded

Updated to show both numbers

FTBTeam/FTB-Mods-Issues#1398
  • Loading branch information
desht committed Nov 26, 2024
1 parent 424fa49 commit a68a4e6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
22 changes: 12 additions & 10 deletions common/src/main/java/dev/ftb/mods/ftbchunks/FTBChunksCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,8 @@ private static int setExtraForceLoadChunks(CommandSourceStack source, ServerPlay

private static int unclaimEverything(CommandSourceStack source) {
int claimedChunks = 0;
for (ClaimedChunkImpl c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
for (ClaimedChunk c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
c.getTeamData().unclaim(source, c.getPos(), false);
c.getTeamData().markDirty();
claimedChunks++;
}
int finalClaimedChunks = claimedChunks;
Expand All @@ -516,10 +515,9 @@ private static int unclaimEverything(CommandSourceStack source) {

private static int unclaimDimension(CommandSourceStack source, ResourceKey<Level> dim) {
int claimedChunks = 0;
for (ClaimedChunkImpl c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
for (ClaimedChunk c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
if (source.getLevel().dimension().equals(dim)) {
c.getTeamData().unclaim(source, c.getPos(), false);
c.getTeamData().markDirty();
claimedChunks++;
}
}
Expand All @@ -534,13 +532,17 @@ private static int unclaimDimension(CommandSourceStack source) {

private static int unloadEverything(CommandSourceStack source) {
int unloadedChunks = 0;
for (ClaimedChunkImpl c : new ArrayList<>(claimManager().getAllClaimedChunks())) {
c.getTeamData().unForceLoad(source, c.getPos(), false);
c.getTeamData().markDirty();
unloadedChunks++;
int totalChunks = 0;
for (ClaimedChunk c : claimManager().getAllClaimedChunks()) {
if (c.isForceLoaded()) {
c.getTeamData().unForceLoad(source, c.getPos(), false);
unloadedChunks++;
}
totalChunks++;
}
int finalUnloadedChunks = unloadedChunks;
source.sendSuccess(() -> Component.translatable("ftbchunks.command.unloaded", finalUnloadedChunks), true);
final int finalUnloadedChunks = unloadedChunks;
final int finalTotalChunks = totalChunks;
source.sendSuccess(() -> Component.translatable("ftbchunks.commands.unloaded", finalUnloadedChunks, finalTotalChunks), true);
return Command.SINGLE_SUCCESS;
}

Expand Down
4 changes: 2 additions & 2 deletions common/src/main/resources/assets/ftbchunks/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@
"mob_category.misc": "Misc",
"ftbchunks.commands.claimed": "Claimed chunks: %d",
"ftbchunks.commands.unclaimed": "Unclaimed chunks: %d",
"ftbchunks.commands.force_loaded": "Force-loaded chunks: %d",
"ftbchunks.command.unloaded": "Unloaded chunks: %d",
"ftbchunks.commands.force_loaded": "Forceloaded chunks: %d",
"ftbchunks.commands.unloaded": "Un-forceloaded chunks: %d (of %d total claimed)",
"ftbchunks.commands.location": "Location: %s",
"ftbchunks.commands.owner": "Owner: ",
"ftbchunks.commands.is_force_loaded": "Force Loaded: %s",
Expand Down

0 comments on commit a68a4e6

Please sign in to comment.