Skip to content

Commit 013bfa8

Browse files
committed
Probably fix async player looping (#62)
1 parent 2116d9c commit 013bfa8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/ch/njol/skript/bukkitutil/PlayerUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
import org.bukkit.entity.Player;
3434
import org.eclipse.jdt.annotation.Nullable;
3535

36+
import com.google.common.collect.ImmutableList;
37+
3638
import ch.njol.skript.Skript;
3739
import ch.njol.skript.util.Task;
3840

@@ -74,7 +76,7 @@ public void run() {
7476
@SuppressWarnings({"null", "unchecked"})
7577
public final static Collection<? extends Player> getOnlinePlayers() {
7678
if (hasCollecionGetOnlinePlayers) {
77-
return Bukkit.getOnlinePlayers();
79+
return ImmutableList.copyOf(Bukkit.getOnlinePlayers());
7880
} else {
7981
if (getOnlinePlayers == null) {
8082
try {
@@ -88,9 +90,9 @@ public final static Collection<? extends Player> getOnlinePlayers() {
8890
try {
8991
final Object o = getOnlinePlayers.invoke(null);
9092
if (o instanceof Collection<?>)
91-
return (Collection<? extends Player>) o;
93+
return ImmutableList.copyOf((Collection<? extends Player>) o);
9294
else
93-
return Arrays.asList((Player[]) o);
95+
return Arrays.asList(((Player[]) o).clone());
9496
} catch (final IllegalAccessException e) {
9597
Skript.outdatedError(e);
9698
} catch (final IllegalArgumentException e) {

0 commit comments

Comments
 (0)