Java 类net.minecraft.network.play.server.SPacketPlayerListItem 实例源码

项目:ForgeHax    文件:ScoreboardListenerService.java   
@SubscribeEvent
public void onScoreboardEvent(PacketEvent.Incoming.Pre event) {
    if(event.getPacket() instanceof SPacketPlayerListItem
            && getWorld() != null
            && System.currentTimeMillis() > waitTime) {
        final SPacketPlayerListItem packet = (SPacketPlayerListItem) event.getPacket();
        packet.getEntries().stream()
                .filter(Objects::nonNull)
                .filter(data -> data.getProfile() != null)
                .filter(data -> !Strings.isNullOrEmpty(data.getProfile().getName()))
                .forEach(data -> {
                    final String name = data.getProfile().getName();
                    PlayerInfoHelper.invokeEfficiently(name, new FutureCallback<PlayerInfo>() {
                        @Override
                        public void onSuccess(@Nullable PlayerInfo result) {
                            if(result != null) fireEvents(packet.getAction(), result, data.getProfile());
                        }

                        @Override
                        public void onFailure(Throwable t) {

                        }
                    });
                });
    }
}
项目:Backmemed    文件:PlayerList.java   
/**
 * Called when a player successfully logs in. Reads player data from disk and inserts the player into the world.
 */
public void playerLoggedIn(EntityPlayerMP playerIn)
{
    this.playerEntityList.add(playerIn);
    this.uuidToPlayerMap.put(playerIn.getUniqueID(), playerIn);
    this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {playerIn}));
    WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);

    for (int i = 0; i < this.playerEntityList.size(); ++i)
    {
        playerIn.connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {(EntityPlayerMP)this.playerEntityList.get(i)}));
    }

    worldserver.spawnEntityInWorld(playerIn);
    this.preparePlayer(playerIn, (WorldServer)null);
}
项目:CustomWorldGen    文件:PlayerList.java   
/**
 * Called when a player successfully logs in. Reads player data from disk and inserts the player into the world.
 */
public void playerLoggedIn(EntityPlayerMP playerIn)
{
    this.playerEntityList.add(playerIn);
    this.uuidToPlayerMap.put(playerIn.getUniqueID(), playerIn);
    this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {playerIn}));
    WorldServer worldserver = this.mcServer.worldServerForDimension(playerIn.dimension);

    for (int i = 0; i < this.playerEntityList.size(); ++i)
    {
        playerIn.connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, new EntityPlayerMP[] {(EntityPlayerMP)this.playerEntityList.get(i)}));
    }

    net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount());
    worldserver.spawnEntityInWorld(playerIn);
    this.preparePlayer(playerIn, (WorldServer)null);
}
项目:ForgeHax    文件:ScoreboardListenerService.java   
private void fireEvents(SPacketPlayerListItem.Action action, PlayerInfo info, GameProfile profile) {
    switch (action) {
        case ADD_PLAYER: {
            MinecraftForge.EVENT_BUS.post(new PlayerConnectEvent.Join(info, profile));
            break;
        }
        case REMOVE_PLAYER: {
            MinecraftForge.EVENT_BUS.post(new PlayerConnectEvent.Leave(info, profile));
            break;
        }
    }
}
项目:Backmemed    文件:NetworkPlayerInfo.java   
public NetworkPlayerInfo(SPacketPlayerListItem.AddPlayerData entry)
{
    this.gameProfile = entry.getProfile();
    this.gameType = entry.getGameMode();
    this.responseTime = entry.getPing();
    this.displayName = entry.getDisplayName();
}
项目:Backmemed    文件:PlayerList.java   
/**
 * Called when a player disconnects from the game. Writes player data to disk and removes them from the world.
 */
public void playerLoggedOut(EntityPlayerMP playerIn)
{
    WorldServer worldserver = playerIn.getServerWorld();
    playerIn.addStat(StatList.LEAVE_GAME);
    this.writePlayerData(playerIn);

    if (playerIn.isRiding())
    {
        Entity entity = playerIn.getLowestRidingEntity();

        if (entity.getRecursivePassengersByType(EntityPlayerMP.class).size() == 1)
        {
            LOG.debug("Removing player mount");
            playerIn.dismountRidingEntity();
            worldserver.removeEntityDangerously(entity);

            for (Entity entity1 : entity.getRecursivePassengers())
            {
                worldserver.removeEntityDangerously(entity1);
            }

            worldserver.getChunkFromChunkCoords(playerIn.chunkCoordX, playerIn.chunkCoordZ).setChunkModified();
        }
    }

    worldserver.removeEntity(playerIn);
    worldserver.getPlayerChunkMap().removePlayer(playerIn);
    this.playerEntityList.remove(playerIn);
    UUID uuid = playerIn.getUniqueID();
    EntityPlayerMP entityplayermp = (EntityPlayerMP)this.uuidToPlayerMap.get(uuid);

    if (entityplayermp == playerIn)
    {
        this.uuidToPlayerMap.remove(uuid);
        this.playerStatFiles.remove(uuid);
    }

    this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.REMOVE_PLAYER, new EntityPlayerMP[] {playerIn}));
}
项目:Backmemed    文件:PlayerList.java   
/**
 * self explanitory
 */
public void onTick()
{
    if (++this.playerPingIndex > 600)
    {
        this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_LATENCY, this.playerEntityList));
        this.playerPingIndex = 0;
    }
}
项目:Backmemed    文件:PlayerInteractionManager.java   
public void setGameType(GameType type)
{
    this.gameType = type;
    type.configurePlayerCapabilities(this.thisPlayerMP.capabilities);
    this.thisPlayerMP.sendPlayerAbilities();
    this.thisPlayerMP.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_GAME_MODE, new EntityPlayerMP[] {this.thisPlayerMP}));
    this.theWorld.updateAllPlayersSleepingFlag();
}
项目:CustomWorldGen    文件:NetworkPlayerInfo.java   
public NetworkPlayerInfo(SPacketPlayerListItem.AddPlayerData entry)
{
    this.gameProfile = entry.getProfile();
    this.gameType = entry.getGameMode();
    this.responseTime = entry.getPing();
    this.displayName = entry.getDisplayName();
}
项目:CustomWorldGen    文件:PlayerList.java   
/**
 * self explanitory
 */
public void onTick()
{
    if (++this.playerPingIndex > 600)
    {
        this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_LATENCY, this.playerEntityList));
        this.playerPingIndex = 0;
    }
}
项目:CustomWorldGen    文件:PlayerInteractionManager.java   
public void setGameType(GameType type)
{
    this.gameType = type;
    type.configurePlayerCapabilities(this.thisPlayerMP.capabilities);
    this.thisPlayerMP.sendPlayerAbilities();
    this.thisPlayerMP.mcServer.getPlayerList().sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.UPDATE_GAME_MODE, new EntityPlayerMP[] {this.thisPlayerMP}));
    this.theWorld.updateAllPlayersSleepingFlag();
}
项目:FountainVanilla    文件:WetEntityPlayer.java   
@Override
public void hide(org.fountainmc.api.entity.Entity fountainToHide) {
    Entity toHide = ((WetEntity) checkNotNull(fountainToHide, "Null entity")).getHandle();
    checkArgument(!toHide.equals(getHandle()), "Cant hide player %s from itself!", this);
    if (isConnected() && hiddenEntities.add(toHide) && getHandle().worldObj.equals(toHide.worldObj)) {
        EntityTrackerEntry trackerEntry = ((WorldServer) getHandle().worldObj).theEntityTracker.getTrackerEntry(toHide);
        if (trackerEntry != null) {
            trackerEntry.removeTrackedPlayerSymmetric(this.getHandle());
            if (toHide instanceof Player) {
                ((EntityPlayerMP) toHide).connection.sendPacket(new SPacketPlayerListItem(SPacketPlayerListItem.a.REMOVE_PLAYER, (EntityPlayerMP) toHide));
            }
        }
    }
}
项目:ExpandedRailsMod    文件:NetworkPlayerInfo.java   
public NetworkPlayerInfo(SPacketPlayerListItem.AddPlayerData entry)
{
    this.gameProfile = entry.getProfile();
    this.gameType = entry.getGameMode();
    this.responseTime = entry.getPing();
    this.displayName = entry.getDisplayName();
}
项目:Zombe-Modpack    文件:NetHandlerPlayClient.java   
@SuppressWarnings("incomplete-switch")
public void handlePlayerListItem(SPacketPlayerListItem packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    for (SPacketPlayerListItem.AddPlayerData spacketplayerlistitem$addplayerdata : packetIn.getEntries())
    {
        if (packetIn.getAction() == SPacketPlayerListItem.Action.REMOVE_PLAYER)
        {
            this.playerInfoMap.remove(spacketplayerlistitem$addplayerdata.getProfile().getId());
        }
        else
        {
            NetworkPlayerInfo networkplayerinfo = (NetworkPlayerInfo)this.playerInfoMap.get(spacketplayerlistitem$addplayerdata.getProfile().getId());

            if (packetIn.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER)
            {
                networkplayerinfo = new NetworkPlayerInfo(spacketplayerlistitem$addplayerdata);
                this.playerInfoMap.put(networkplayerinfo.getGameProfile().getId(), networkplayerinfo);
            }

            if (networkplayerinfo != null)
            {
                switch (packetIn.getAction())
                {
                    case ADD_PLAYER:
                        networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
                        networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
                        break;

                    case UPDATE_GAME_MODE:
                        networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
                        break;

                    case UPDATE_LATENCY:
                        networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
                        break;

                    case UPDATE_DISPLAY_NAME:
                        networkplayerinfo.setDisplayName(spacketplayerlistitem$addplayerdata.getDisplayName());
                }
            }
        }
    }
}
项目:Backmemed    文件:NetHandlerPlayClient.java   
@SuppressWarnings("incomplete-switch")
public void handlePlayerListItem(SPacketPlayerListItem packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    for (SPacketPlayerListItem.AddPlayerData spacketplayerlistitem$addplayerdata : packetIn.getEntries())
    {
        if (packetIn.getAction() == SPacketPlayerListItem.Action.REMOVE_PLAYER)
        {
            this.playerInfoMap.remove(spacketplayerlistitem$addplayerdata.getProfile().getId());
        }
        else
        {
            NetworkPlayerInfo networkplayerinfo = (NetworkPlayerInfo)this.playerInfoMap.get(spacketplayerlistitem$addplayerdata.getProfile().getId());

            if (packetIn.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER)
            {
                networkplayerinfo = new NetworkPlayerInfo(spacketplayerlistitem$addplayerdata);
                this.playerInfoMap.put(networkplayerinfo.getGameProfile().getId(), networkplayerinfo);
            }

            if (networkplayerinfo != null)
            {
                switch (packetIn.getAction())
                {
                    case ADD_PLAYER:
                        networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
                        networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
                        break;

                    case UPDATE_GAME_MODE:
                        networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
                        break;

                    case UPDATE_LATENCY:
                        networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
                        break;

                    case UPDATE_DISPLAY_NAME:
                        networkplayerinfo.setDisplayName(spacketplayerlistitem$addplayerdata.getDisplayName());
                }
            }
        }
    }
}
项目:CustomWorldGen    文件:NetHandlerPlayClient.java   
@SuppressWarnings("incomplete-switch")
public void handlePlayerListItem(SPacketPlayerListItem packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    for (SPacketPlayerListItem.AddPlayerData spacketplayerlistitem$addplayerdata : packetIn.getEntries())
    {
        if (packetIn.getAction() == SPacketPlayerListItem.Action.REMOVE_PLAYER)
        {
            this.playerInfoMap.remove(spacketplayerlistitem$addplayerdata.getProfile().getId());
        }
        else
        {
            NetworkPlayerInfo networkplayerinfo = (NetworkPlayerInfo)this.playerInfoMap.get(spacketplayerlistitem$addplayerdata.getProfile().getId());

            if (packetIn.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER)
            {
                networkplayerinfo = new NetworkPlayerInfo(spacketplayerlistitem$addplayerdata);
                this.playerInfoMap.put(networkplayerinfo.getGameProfile().getId(), networkplayerinfo);
            }

            if (networkplayerinfo != null)
            {
                switch (packetIn.getAction())
                {
                    case ADD_PLAYER:
                        networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
                        networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
                        break;
                    case UPDATE_GAME_MODE:
                        networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
                        break;
                    case UPDATE_LATENCY:
                        networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
                        break;
                    case UPDATE_DISPLAY_NAME:
                        networkplayerinfo.setDisplayName(spacketplayerlistitem$addplayerdata.getDisplayName());
                }
            }
        }
    }
}
项目:CustomWorldGen    文件:PlayerList.java   
/**
 * Called when a player disconnects from the game. Writes player data to disk and removes them from the world.
 */
public void playerLoggedOut(EntityPlayerMP playerIn)
{
    net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerLoggedOut(playerIn);
    WorldServer worldserver = playerIn.getServerWorld();
    playerIn.addStat(StatList.LEAVE_GAME);
    this.writePlayerData(playerIn);

    if (playerIn.isRiding())
    {
        Entity entity = playerIn.getLowestRidingEntity();

        if (entity.getRecursivePassengersByType(EntityPlayerMP.class).size() == 1)
        {
            LOG.debug("Removing player mount");
            playerIn.dismountRidingEntity();
            worldserver.removeEntityDangerously(entity);

            for (Entity entity1 : entity.getRecursivePassengers())
            {
                worldserver.removeEntityDangerously(entity1);
            }

            worldserver.getChunkFromChunkCoords(playerIn.chunkCoordX, playerIn.chunkCoordZ).setChunkModified();
        }
    }

    worldserver.removeEntity(playerIn);
    worldserver.getPlayerChunkMap().removePlayer(playerIn);
    this.playerEntityList.remove(playerIn);
    UUID uuid = playerIn.getUniqueID();
    EntityPlayerMP entityplayermp = (EntityPlayerMP)this.uuidToPlayerMap.get(uuid);

    if (entityplayermp == playerIn)
    {
        this.uuidToPlayerMap.remove(uuid);
        this.playerStatFiles.remove(uuid);
    }
    net.minecraftforge.common.chunkio.ChunkIOExecutor.adjustPoolSize(this.getCurrentPlayerCount());

    this.sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.REMOVE_PLAYER, new EntityPlayerMP[] {playerIn}));
}
项目:Keygrip    文件:Action.java   
public boolean createState(WorldServer world, double x, double y, double z)
{
    if(state == null || state.ent == null)
    {
        try
        {
            EntityPlayerMP playerDummy = new FakePlayer(world, EntityHelper.getDummyGameProfile());
            NBTTagCompound tag = CompressedStreamTools.readCompressed(new ByteArrayInputStream(this.nbtToRead));
            playerDummy.readFromNBT(tag);
            playerDummy.setLocationAndAngles(x, y, z, playerDummy.rotationYaw, playerDummy.rotationPitch);
            playerDummy.writeToNBT(tag);
            this.state = new EntityState(playerDummy);

            if(this.entityType.startsWith("player::"))
            {
                this.state.ent = new FakePlayer(world, EntityHelper.getGameProfile(this.entityType.substring("player::".length())));
                this.state.ent.readFromNBT(tag);
                new FakeNetHandlerPlayServer(FMLCommonHandler.instance().getMinecraftServerInstance(), new NetworkManager(EnumPacketDirection.CLIENTBOUND), (FakePlayer)this.state.ent);
                FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().sendPacketToAllPlayers(new SPacketPlayerListItem(SPacketPlayerListItem.Action.ADD_PLAYER, (FakePlayer)this.state.ent));
                state.ent.getDataWatcher().updateObject(10, (byte)127);
            }
            else
            {
                this.state.ent = (EntityLivingBase)Class.forName(this.entityType).getConstructor(World.class).newInstance(world);
                this.state.ent.setSprinting(playerDummy.isSprinting());
                this.state.ent.setSneaking(playerDummy.isSneaking());
                for(int i = 0; i < state.ent.getInventory().length; i++)
                {
                    this.state.ent.setCurrentItemOrArmor(i, playerDummy.getEquipmentInSlot(i));
                }
            }

            if(state.ent instanceof EntityLiving)
            {
                ((EntityLiving)state.ent).setNoAI(true);
                ((EntityLiving)state.ent).tasks.taskEntries.clear();
                ((EntityLiving)state.ent).targetTasks.taskEntries.clear();
            }
            return true;
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    return false;
}
项目:ExpandedRailsMod    文件:NetHandlerPlayClient.java   
@SuppressWarnings("incomplete-switch")
public void handlePlayerListItem(SPacketPlayerListItem packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);

    for (SPacketPlayerListItem.AddPlayerData spacketplayerlistitem$addplayerdata : packetIn.getEntries())
    {
        if (packetIn.getAction() == SPacketPlayerListItem.Action.REMOVE_PLAYER)
        {
            this.playerInfoMap.remove(spacketplayerlistitem$addplayerdata.getProfile().getId());
        }
        else
        {
            NetworkPlayerInfo networkplayerinfo = (NetworkPlayerInfo)this.playerInfoMap.get(spacketplayerlistitem$addplayerdata.getProfile().getId());

            if (packetIn.getAction() == SPacketPlayerListItem.Action.ADD_PLAYER)
            {
                networkplayerinfo = new NetworkPlayerInfo(spacketplayerlistitem$addplayerdata);
                this.playerInfoMap.put(networkplayerinfo.getGameProfile().getId(), networkplayerinfo);
            }

            if (networkplayerinfo != null)
            {
                switch (packetIn.getAction())
                {
                    case ADD_PLAYER:
                        networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
                        networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
                        break;
                    case UPDATE_GAME_MODE:
                        networkplayerinfo.setGameType(spacketplayerlistitem$addplayerdata.getGameMode());
                        break;
                    case UPDATE_LATENCY:
                        networkplayerinfo.setResponseTime(spacketplayerlistitem$addplayerdata.getPing());
                        break;
                    case UPDATE_DISPLAY_NAME:
                        networkplayerinfo.setDisplayName(spacketplayerlistitem$addplayerdata.getDisplayName());
                }
            }
        }
    }
}
项目:Backmemed    文件:INetHandlerPlayClient.java   
void handlePlayerListItem(SPacketPlayerListItem packetIn);
项目:CustomWorldGen    文件:INetHandlerPlayClient.java   
void handlePlayerListItem(SPacketPlayerListItem packetIn);