|
41 | 41 | import org.bukkit.util.EulerAngle; |
42 | 42 | import org.bukkit.util.Vector; |
43 | 43 |
|
| 44 | +import java.util.Arrays; |
44 | 45 | import java.util.Collection; |
45 | 46 | import java.util.Collections; |
46 | 47 | import java.util.HashSet; |
47 | 48 | import java.util.List; |
48 | 49 | import java.util.Set; |
49 | 50 | import java.util.UUID; |
50 | 51 | import java.util.stream.Collectors; |
51 | | -import java.util.stream.Stream; |
52 | 52 |
|
53 | 53 | public class InteractionVisualizerAPI { |
54 | 54 |
|
@@ -113,13 +113,19 @@ public static Collection<Player> getPlayerModuleList(Modules module, EntryKey en |
113 | 113 | */ |
114 | 114 | public static Collection<Player> getPlayerModuleList(Modules module, EntryKey entry, boolean excludeDisabledWorlds, Player... excludes) { |
115 | 115 | Collection<Player> players = InteractionVisualizer.preferenceManager.getPlayerList(module, entry); |
116 | | - Set<Player> excludedPlayers = Stream.of(excludes).collect(Collectors.toSet()); |
117 | | - if (excludeDisabledWorlds) { |
118 | | - Set<String> disabledWorlds = getDisabledWorlds(); |
119 | | - players = SynchronizedFilteredCollection.filter(players, each -> !excludedPlayers.contains(each) && !disabledWorlds.contains(each.getWorld().getName())); |
120 | | - } else { |
121 | | - players = SynchronizedFilteredCollection.filter(players, each -> !excludedPlayers.contains(each)); |
| 116 | + Set<String> disabledWorlds = excludeDisabledWorlds |
| 117 | + ? InteractionVisualizer.disabledWorlds : Set.of(); |
| 118 | + if (excludes.length == 0 && disabledWorlds.isEmpty()) { |
| 119 | + return players; |
122 | 120 | } |
| 121 | + Set<Player> excludedPlayers = excludes.length == 0 |
| 122 | + ? Set.of() |
| 123 | + : excludes.length == 1 ? Collections.singleton(excludes[0]) |
| 124 | + : new HashSet<>(Arrays.asList(excludes)); |
| 125 | + players = SynchronizedFilteredCollection.filter(players, |
| 126 | + each -> !excludedPlayers.contains(each) |
| 127 | + && (disabledWorlds.isEmpty() |
| 128 | + || !disabledWorlds.contains(each.getWorld().getName()))); |
123 | 129 | return SynchronizedFilteredCollection.unmodifiableCollection(players); |
124 | 130 | } |
125 | 131 |
|
@@ -176,7 +182,8 @@ public static boolean hasPlayerEnabledModule(UUID uuid, Modules module, EntryKey |
176 | 182 | return hasPlayerEnabledModule(player, module, entry); |
177 | 183 | } else { |
178 | 184 | InteractionVisualizer.preferenceManager.loadPlayer(uuid, "", false); |
179 | | - boolean value = hasPlayerEnabledModule(player, module, entry); |
| 185 | + boolean value = InteractionVisualizer.preferenceManager |
| 186 | + .getPlayerPreference(uuid, module, entry); |
180 | 187 | InteractionVisualizer.preferenceManager.unloadPlayerWithoutSaving(uuid); |
181 | 188 | return value; |
182 | 189 | } |
|
0 commit comments