correct update player list
This commit is contained in:
@@ -13,6 +13,7 @@ import io.netty.util.AttributeKey;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import mc.core.*;
|
||||
import mc.core.network.CSPacket;
|
||||
import mc.core.network.NetChannel;
|
||||
import mc.core.network.proto_125.netty.wrappers.WrapperNetChannel;
|
||||
import mc.core.network.proto_125.packets.*;
|
||||
import org.slf4j.Marker;
|
||||
@@ -21,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Slf4j
|
||||
@@ -109,13 +111,6 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
abilitiesPkt.setInstantDestroyBlocks(true);
|
||||
channel.write(abilitiesPkt);
|
||||
|
||||
// send Player info
|
||||
PlayerInfoPacket infoPkt = new PlayerInfoPacket();
|
||||
infoPkt.setPlayerName(player.getName());
|
||||
infoPkt.setOnline(true);
|
||||
infoPkt.setPing(4);
|
||||
channel.write(infoPkt);
|
||||
|
||||
// send Chunk allocation
|
||||
ChunkAllocationPacket chInitPkt = new ChunkAllocationPacket();
|
||||
chInitPkt.setX(0);
|
||||
@@ -152,6 +147,16 @@ public class PacketHandler extends SimpleChannelInboundHandler<CSPacket> {
|
||||
channel.attr(ATTR_PLAYER).set(player);
|
||||
player.setChannel(new WrapperNetChannel(channel));
|
||||
playerManager.joinServer(player);
|
||||
|
||||
// send Player info
|
||||
List<Player> players = playerManager.getPlayers();
|
||||
players.forEach(pl -> {
|
||||
PlayerInfoPacket infoPkt = new PlayerInfoPacket();
|
||||
infoPkt.setPlayerName(pl.getName());
|
||||
infoPkt.setOnline(true);
|
||||
infoPkt.setPing(4);
|
||||
playerManager.getBroadcastChannel().writeAndFlush(infoPkt);
|
||||
});
|
||||
}
|
||||
|
||||
public void onKickPacket(Channel channel, KickPacket packet) {
|
||||
|
||||
Reference in New Issue
Block a user