From 7c065b33d6adca848358fa46b5d79630402be8fc Mon Sep 17 00:00:00 2001 From: KingRainbow44 Date: Wed, 10 May 2023 19:22:32 -0400 Subject: [PATCH] Re-apply changes which were discarded from running Spotless --- .../java/emu/grasscutter/game/world/Scene.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/emu/grasscutter/game/world/Scene.java b/src/main/java/emu/grasscutter/game/world/Scene.java index aa1d82019..50cc30c2a 100644 --- a/src/main/java/emu/grasscutter/game/world/Scene.java +++ b/src/main/java/emu/grasscutter/game/world/Scene.java @@ -796,23 +796,21 @@ public final class Scene { return true; } - public synchronized void checkGroups() { + public void checkGroups() { Set visible = this.players.stream() - .map(player -> this.getPlayerActiveGroups(player)) + .map(this::getPlayerActiveGroups) .flatMap(Collection::stream) .collect(Collectors.toSet()); - Iterator it = this.loadedGroups.iterator(); - while (it.hasNext()) { - SceneGroup group = it.next(); + for (var group : this.loadedGroups) { if (!visible.contains(group.id) && !group.dynamic_load) unloadGroup(scriptManager.getBlocks().get(group.block_id), group.id); } - List toLoad = + var toLoad = visible.stream() - .filter(g -> this.loadedGroups.stream().filter(gr -> gr.id == g).count() == 0) + .filter(g -> this.loadedGroups.stream().noneMatch(gr -> gr.id == g)) .map( g -> { for (var b : scriptManager.getBlocks().values()) { @@ -834,7 +832,7 @@ public final class Scene { this.getScriptManager().loadBlockFromScript(block); scriptManager.getLoadedGroupSetPerBlock().put(block.id, new HashSet<>()); - Grasscutter.getLogger().debug("Scene {} Block {} loaded.", this.getId(), block.id); + Grasscutter.getLogger().trace("Scene {} block {} loaded.", this.getId(), block.id); } public int loadDynamicGroup(int group_id) { @@ -1004,7 +1002,7 @@ public final class Scene { if (this.scriptManager.getLoadedGroupSetPerBlock().get(block.id).isEmpty()) { this.scriptManager.getLoadedGroupSetPerBlock().remove(block.id); - Grasscutter.getLogger().debug("Scene {} Block {} is unloaded.", this.getId(), block.id); + Grasscutter.getLogger().trace("Scene {} block {} is unloaded.", this.getId(), block.id); } this.broadcastPacket(new PacketGroupUnloadNotify(List.of(group_id)));