Skip to content

Commit 74c4777

Browse files
committed
Update player list view along with player list when setting player list for CraftServer
1 parent 1e03493 commit 74c4777

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

arclight-common/src/main/java/io/izzel/arclight/common/mixin/bukkit/CraftServerMixin.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package io.izzel.arclight.common.mixin.bukkit;
22

3+
import com.google.common.collect.Lists;
34
import io.izzel.arclight.common.bridge.bukkit.CraftServerBridge;
4-
import io.izzel.arclight.common.mod.server.ArclightServer;
5+
import io.izzel.arclight.common.bridge.core.entity.player.ServerPlayerEntityBridge;
56
import jline.console.ConsoleReader;
67
import net.minecraft.server.dedicated.DedicatedPlayerList;
78
import net.minecraft.server.dedicated.DedicatedServer;
@@ -12,6 +13,7 @@
1213
import org.bukkit.configuration.file.YamlConfiguration;
1314
import org.bukkit.craftbukkit.v.CraftServer;
1415
import org.bukkit.craftbukkit.v.command.CraftCommandMap;
16+
import org.bukkit.craftbukkit.v.entity.CraftPlayer;
1517
import org.bukkit.craftbukkit.v.help.SimpleHelpMap;
1618
import org.bukkit.craftbukkit.v.scheduler.CraftScheduler;
1719
import org.bukkit.event.server.ServerLoadEvent;
@@ -36,10 +38,7 @@
3638

3739
import java.io.File;
3840
import java.io.IOException;
39-
import java.util.HashMap;
40-
import java.util.List;
41-
import java.util.Locale;
42-
import java.util.Map;
41+
import java.util.*;
4342
import java.util.logging.Level;
4443
import java.util.logging.Logger;
4544

@@ -55,6 +54,7 @@ public abstract class CraftServerMixin implements CraftServerBridge {
5554
@Shadow @Final protected DedicatedServer console;
5655
@Shadow @Final @Mutable private String serverName;
5756
@Shadow @Final @Mutable protected DedicatedPlayerList playerList;
57+
@Shadow @Final @Mutable private List<CraftPlayer> playerView;
5858
@Shadow @Final private Map<String, World> worlds;
5959
@Shadow public int reloadCount;
6060
@Shadow private YamlConfiguration configuration;
@@ -101,7 +101,13 @@ public String getVersion() {
101101

102102
@Override
103103
public void bridge$setPlayerList(PlayerList playerList) {
104+
// Though I'm not sure why we need this player list setter
105+
// Player list view should be changed along with player list
106+
// Or unexpected problem may happen
104107
this.playerList = (DedicatedPlayerList) playerList;
108+
this.playerView = Collections.unmodifiableList(Lists.transform(playerList.players, player ->
109+
((ServerPlayerEntityBridge)player).bridge$getBukkitEntity()
110+
));
105111
}
106112

107113
/**

0 commit comments

Comments
 (0)