Skip to content

Commit

Permalink
Replace AtomicInteger with singleton array
Browse files Browse the repository at this point in the history
  • Loading branch information
xpple committed Jan 17, 2025
1 parent 79b0386 commit bdac028
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Function;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -205,18 +204,18 @@ private static int list(FabricClientCommandSource source, boolean current) {
return 0;
}

AtomicInteger count = new AtomicInteger();
int[] count = {0};
waypoints.forEach((worldIdentifier, worldWaypoints) -> {
if (worldWaypoints.isEmpty()) {
return;
}

count.addAndGet(worldWaypoints.size());
count[0] += worldWaypoints.size();

source.sendFeedback(Component.literal(worldIdentifier).append(":"));
worldWaypoints.forEach((name, waypoint) -> source.sendFeedback(Component.translatable("commands.cwaypoint.list", name, formatCoordinates(waypoint.location()), waypoint.dimension().location())));
});
return count.get();
return count[0];
}

private static void saveFile() throws CommandSyntaxException {
Expand Down

0 comments on commit bdac028

Please sign in to comment.