public UpstreamBridge(ProxyServer bungee, UserConnection con) { this.bungee = bungee; this.con = con; BungeeCord.getInstance().addConnection(con); con.getTabList().onConnect(); con.unsafe().sendPacket(BungeeCord.getInstance().registerChannels()); }
public UpstreamBridge(ProxyServer bungee, UserConnection con) { this.bungee = bungee; this.con = con; BungeeCord.getInstance().addConnection(con); bungee.getTabListHandler().onConnect(con); con.unsafe().sendPacket(BungeeCord.getInstance().registerChannels()); TexturePackInfo texture = con.getPendingConnection().getListener().getTexturePack(); if (texture != null) { con.setTexturePack(texture); } }
@Command( aliases = {"serverlist"}, desc = "List all BungeeCord servers", usage = "[page]", min = 0, max = 1) @CommandPermissions("bungeeutils.serverlist") public static void serverlist(final CommandContext args, CommandSender sender) throws CommandException { final Collection<ServerInfo> servers = BungeeCord.getInstance().getServers().values(); new SimplePaginatedResult<ServerInfo>("BungeeCord Servers") { @Override public String format(ServerInfo server, int index) { return (index + 1) + ". " + ChatColor.RED + server.getName() + ChatColor.GREEN + server.getAddress().getHostString() + ":" + server.getAddress().getPort(); } }.display(new BungeeWrappedCommandSender(sender), servers, args.getInteger(0, 1) /* page */); }
@Override public void onPingChange(int ping) { if (!sentPing) { sentPing = true; BungeeCord.getInstance() .broadcast( new PacketC9PlayerListItem( getPlayer().getDisplayName(), true, (short) getPlayer().getPing())); } }
@Override public void disconnected(ChannelWrapper channel) throws Exception { // We lost connection to the client PlayerDisconnectEvent event = new PlayerDisconnectEvent(con); bungee.getPluginManager().callEvent(event); con.getTabList().onDisconnect(); BungeeCord.getInstance().removeConnection(con); if (con.getServer() != null) { con.getServer().disconnect("Quitting"); } }
@Override public void onConnect() { for (ProxiedPlayer p : ProxyServer.getInstance().getPlayers()) { getPlayer() .unsafe() .sendPacket(new PacketC9PlayerListItem(p.getDisplayName(), true, (short) p.getPing())); } BungeeCord.getInstance() .broadcast( new PacketC9PlayerListItem( getPlayer().getDisplayName(), true, (short) getPlayer().getPing())); }
@Override public void rewriteServerbound(ByteBuf packet, int oldId, int newId) { super.rewriteServerbound(packet, oldId, newId); // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt(packet); int packetIdLength = packet.readerIndex() - readerIndex; if (packetId == 0x18 /* Spectate */) { UUID uuid = DefinedPacket.readUUID(packet); ProxiedPlayer player; if ((player = BungeeCord.getInstance().getPlayer(uuid)) != null) { int previous = packet.writerIndex(); packet.readerIndex(readerIndex); packet.writerIndex(readerIndex + packetIdLength); DefinedPacket.writeUUID( ((UserConnection) player).getPendingConnection().getOfflineId(), packet); packet.writerIndex(previous); } } packet.readerIndex(readerIndex); }
@Override @SuppressFBWarnings("DLS_DEAD_LOCAL_STORE") public void rewriteClientbound(ByteBuf packet, int oldId, int newId) { super.rewriteClientbound(packet, oldId, newId); // Special cases int readerIndex = packet.readerIndex(); int packetId = DefinedPacket.readVarInt(packet); int packetIdLength = packet.readerIndex() - readerIndex; if (packetId == 0x0D /* Collect Item */) { DefinedPacket.readVarInt(packet); rewriteVarInt(packet, oldId, newId, packet.readerIndex()); } else if (packetId == 0x1B /* Attach Entity */) { rewriteInt(packet, oldId, newId, readerIndex + packetIdLength + 4); } else if (packetId == 0x13 /* Destroy Entities */) { int count = DefinedPacket.readVarInt(packet); int[] ids = new int[count]; for (int i = 0; i < count; i++) { ids[i] = DefinedPacket.readVarInt(packet); } packet.readerIndex(readerIndex + packetIdLength); packet.writerIndex(readerIndex + packetIdLength); DefinedPacket.writeVarInt(count, packet); for (int id : ids) { if (id == oldId) { id = newId; } else if (id == newId) { id = oldId; } DefinedPacket.writeVarInt(id, packet); } } else if (packetId == 0x0E /* Spawn Object */) { DefinedPacket.readVarInt(packet); int type = packet.readUnsignedByte(); if (type == 60 || type == 90) { packet.skipBytes(14); int position = packet.readerIndex(); int readId = packet.readInt(); int changedId = -1; if (readId == oldId) { packet.setInt(position, newId); changedId = newId; } else if (readId == newId) { packet.setInt(position, oldId); changedId = oldId; } if (changedId != -1) { if (changedId == 0 && readId != 0) { // Trim off the extra data packet.readerIndex(readerIndex); packet.writerIndex(packet.readableBytes() - 6); } else if (changedId != 0 && readId == 0) { // Add on the extra data packet.readerIndex(readerIndex); packet.capacity(packet.readableBytes() + 6); packet.writerIndex(packet.readableBytes() + 6); } } } } else if (packetId == 0x0C /* Spawn Player */) { DefinedPacket.readVarInt(packet); // Entity ID int idLength = packet.readerIndex() - readerIndex - packetIdLength; UUID uuid = DefinedPacket.readUUID(packet); ProxiedPlayer player; if ((player = BungeeCord.getInstance().getPlayerByOfflineUUID(uuid)) != null) { int previous = packet.writerIndex(); packet.readerIndex(readerIndex); packet.writerIndex(readerIndex + packetIdLength + idLength); DefinedPacket.writeUUID(player.getUniqueId(), packet); packet.writerIndex(previous); } } else if (packetId == 0x42 /* Combat Event */) { int event = packet.readUnsignedByte(); if (event == 1 /* End Combat*/) { DefinedPacket.readVarInt(packet); rewriteInt(packet, oldId, newId, packet.readerIndex()); } else if (event == 2 /* Entity Dead */) { int position = packet.readerIndex(); rewriteVarInt(packet, oldId, newId, packet.readerIndex()); packet.readerIndex(position); DefinedPacket.readVarInt(packet); rewriteInt(packet, oldId, newId, packet.readerIndex()); } } packet.readerIndex(readerIndex); }
public ProxiedPlayer getPlayer() { return BungeeCord.getInstance().getPlayer(kicked); }
public ProxiedPlayer getPlayer() { return BungeeCord.getInstance().getPlayer(getReported()); }
/** * Will be executed on player disconnect * * @author Simonsator * @version 1.0.0 * @param e * The disconnect event * @throws SQLException * Can throw a {@link SQLException} */ @EventHandler public void onPlayerDisconnect(PlayerDisconnectEvent e) throws SQLException { ProxiedPlayer player = e.getPlayer(); if (PartyManager.getParty(player) != null) { PlayerParty party = PartyManager.getParty(player); if (party.isleader(player)) { ArrayList<ProxiedPlayer> liste = party.getPlayer(); if (liste.size() > 1) { ProxiedPlayer newLeader = liste.get(0); for (ProxiedPlayer p : party.getPlayer()) { if (Main.main.language.equalsIgnoreCase("english")) { p.sendMessage(new TextComponent(Main.main.partyPrefix + "The Leader has left the Party. The new Leader is " + newLeader.getDisplayName() + ".")); } else { if (Main.main.language.equalsIgnoreCase("own")) { p.sendMessage(new TextComponent(Main.main.partyPrefix + Main.main.messagesYml.getString("Party.Command.Leave.NewLeaderIs") .replace("[NEWLEADER]", newLeader.getDisplayName()))); } else { p.sendMessage(new TextComponent(Main.main.partyPrefix + "Der Leader hat die Party verlassen. Der neue Leader ist " + newLeader.getDisplayName() + ".")); } } } party.setLeader(newLeader); liste.remove(newLeader); party.setPlayer(liste); } else { for (ProxiedPlayer p : party.getPlayer()) { if (Main.main.language.equalsIgnoreCase("english")) { p.sendMessage(new TextComponent(Main.main.partyPrefix + "�he �arty �as �issolved �ecause �f �o �ess �layers.")); } else { if (Main.main.language.equalsIgnoreCase("own")) { p.sendMessage(new TextComponent(Main.main.partyPrefix + Main.main.messagesYml .getString("Party.Command.General.DissolvedPartyCauseOfNotEnoughPlayers"))); } else { p.sendMessage(new TextComponent(Main.main.partyPrefix + "�ie �arty �urde �egen �u �enig �itgliedern �ufgel鰏t.")); } } } PartyManager.deleteParty(party); } } else { party.removePlayer(player); for (ProxiedPlayer p : party.getPlayer()) { if (Main.main.language.equalsIgnoreCase("english")) { p.sendMessage(new TextComponent(Main.main.partyPrefix + "The player � + player.getDisplayName() + " has left the party.")); } else { if (Main.main.language.equalsIgnoreCase("own")) { p.sendMessage(new TextComponent(Main.main.partyPrefix + Main.main.messagesYml.getString("Party.Command.General.PlayerHasLeftTheParty") .replace("[PLAYER]", player.getDisplayName()))); } else { p.sendMessage(new TextComponent(Main.main.partyPrefix + "Der Spieler � + player.getDisplayName() + " hat die Party verlassen.")); } } } if (Main.main.language.equalsIgnoreCase("english")) { party.getleader().sendMessage(new TextComponent(Main.main.partyPrefix + "The player � + player.getDisplayName() + " has left the party.")); } else { if (Main.main.language.equalsIgnoreCase("own")) { party.getleader() .sendMessage(new TextComponent(Main.main.partyPrefix + Main.main.messagesYml.getString("Party.Command.General.PlayerHasLeftTheParty") .replace("[PLAYER]", player.getDisplayName()))); } else { party.getleader().sendMessage(new TextComponent(Main.main.partyPrefix + "Der Spieler � + player.getDisplayName() + " hat die Party verlassen.")); } } ArrayList<ProxiedPlayer> liste = party.getPlayer(); if (liste.size() == 1) { if (Main.main.language.equalsIgnoreCase("english")) { party.getleader().sendMessage(new TextComponent(Main.main.partyPrefix + "�he �arty �as �issolved �ecause �f �o �ess �layers.")); } else { if (Main.main.language.equalsIgnoreCase("own")) { party.getleader() .sendMessage(new TextComponent(Main.main.partyPrefix + Main.main.messagesYml .getString("Party.Command.General.DissolvedPartyCauseOfNotEnoughPlayers"))); } else { party.getleader().sendMessage(new TextComponent(Main.main.partyPrefix + "�ie �arty �urde �egen �u �enig �itgliedern �ufgel鰏t.")); } } } } } try { int[] freundeArrayID = Main.main.verbindung .getFreundeArray(Main.main.verbindung.getIDByPlayerName(player.getName())); if (freundeArrayID.length == 0) { return; } for (int i = 0; i < freundeArrayID.length; i++) { String befreundeterSpieler = Main.main.verbindung.getNameDesSpielers(freundeArrayID[i]); ProxiedPlayer freundGeladen = BungeeCord.getInstance().getPlayer(befreundeterSpieler); if (freundGeladen != null) { if (Main.main.language.equalsIgnoreCase("english")) { freundGeladen.sendMessage(new TextComponent("��Friends�" + ChatColor.RESET + " �our friend " + player.getDisplayName() + " �s �ow offline.")); } else { if (Main.main.language.equalsIgnoreCase("own")) { freundGeladen.sendMessage(new TextComponent(Main.main.friendsPrefix + Main.main.messagesYml.getString("Friends.General.PlayerIsNowOffline") .replace("[PLAYER]", player.getDisplayName()))); } else { freundGeladen.sendMessage(new TextComponent("��Friends�" + ChatColor.RESET + " �er Freund " + player.getDisplayName() + " �st �un Offline.")); } } } } } catch (NullPointerException exceptionNull) { } }
@Override public void onDisconnect() { BungeeCord.getInstance() .broadcast(new PacketC9PlayerListItem(getPlayer().getDisplayName(), false, (short) 9999)); }