use of com.almuradev.almura.feature.hud.network.ClientboundPlayerCountPacket in project Almura by AlmuraDev.
the class ServerHeadUpDisplayManager method clientDisconnect.
@Listener(order = Order.LAST)
public void clientDisconnect(final ClientConnectionEvent.Disconnect event) {
final Player player = event.getTargetEntity();
final ClientboundPlayerCountPacket packet = this.createPlayerCountPacket(true);
for (final Player viewer : this.game.getServer().getOnlinePlayers()) {
if (viewer.getUniqueId().equals(player.getUniqueId())) {
continue;
}
this.network.sendTo(viewer, packet);
}
}
use of com.almuradev.almura.feature.hud.network.ClientboundPlayerCountPacket in project Almura by AlmuraDev.
the class ServerHeadUpDisplayManager method createPlayerCountPacket.
private ClientboundPlayerCountPacket createPlayerCountPacket(final boolean disconnect) {
final Server server = this.game.getServer();
// Subtract one from the online player count when a player is disconnecting
// due to the player not being removed from the online players list until
// after the disconnect event has been posted.
final int online = server.getOnlinePlayers().size() - (disconnect ? 1 : 0);
return new ClientboundPlayerCountPacket(online, server.getMaxPlayers());
}
use of com.almuradev.almura.feature.hud.network.ClientboundPlayerCountPacket in project Almura by AlmuraDev.
the class ServerHeadUpDisplayManager method clientJoin.
@Listener(order = Order.LAST)
public void clientJoin(final ClientConnectionEvent.Join event) {
final Player player = event.getTargetEntity();
this.network.sendTo(player, this.createWorldNamePacket(player.getTransform()));
final ClientboundPlayerCountPacket packet = this.createPlayerCountPacket(false);
for (final Player viewer : this.game.getServer().getOnlinePlayers()) {
this.network.sendTo(viewer, packet);
}
this.network.sendTo(player, packet);
final ClientboundPlayerCurrencyPacket currPacket = this.createPlayerCurrencyPacket(player);
if (currPacket != null) {
this.network.sendTo(player, currPacket);
}
}
Aggregations