Search in sources :

Example 1 with BackendPlaySessionHandler

use of com.velocitypowered.proxy.connection.backend.BackendPlaySessionHandler in project LimboAPI by Elytrium.

the class PlayerListItemHook method handle.

@Override
public boolean handle(MinecraftSessionHandler handler) {
    if (handler instanceof BackendPlaySessionHandler) {
        try {
            List<Item> items = this.getItems();
            for (int i = 0; i < items.size(); ++i) {
                Item item = items.get(i);
                ConnectedPlayer player = ((VelocityServerConnection) serverConnField.get(handler)).getPlayer();
                UUID initialID = this.plugin.getInitialID(player);
                if (player.getUniqueId().equals(item.getUuid())) {
                    items.set(i, new Item(initialID).setDisplayName(item.getDisplayName()).setGameMode(item.getGameMode()).setLatency(item.getLatency()).setName(item.getName()).setProperties(item.getProperties()));
                }
            }
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
    }
    return super.handle(handler);
}
Also used : PlayerListItem(com.velocitypowered.proxy.protocol.packet.PlayerListItem) BackendPlaySessionHandler(com.velocitypowered.proxy.connection.backend.BackendPlaySessionHandler) VelocityServerConnection(com.velocitypowered.proxy.connection.backend.VelocityServerConnection) ConnectedPlayer(com.velocitypowered.proxy.connection.client.ConnectedPlayer) UUID(java.util.UUID)

Aggregations

BackendPlaySessionHandler (com.velocitypowered.proxy.connection.backend.BackendPlaySessionHandler)1 VelocityServerConnection (com.velocitypowered.proxy.connection.backend.VelocityServerConnection)1 ConnectedPlayer (com.velocitypowered.proxy.connection.client.ConnectedPlayer)1 PlayerListItem (com.velocitypowered.proxy.protocol.packet.PlayerListItem)1 UUID (java.util.UUID)1