SteamWar/BungeeCore
Archiviert
13
2

Queue Packets
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-09-24 08:27:47 +02:00
Ursprung e981cf5c02
Commit 65fcb5329f
2 geänderte Dateien mit 12 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -3,7 +3,6 @@ package de.steamwar.bungeecore.listeners.mods;
import de.steamwar.bungeecore.listeners.BasicListener; import de.steamwar.bungeecore.listeners.BasicListener;
import net.md_5.bungee.api.event.PostLoginEvent; import net.md_5.bungee.api.event.PostLoginEvent;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import net.md_5.bungee.protocol.packet.PluginMessage;
public class Badlion extends BasicListener { public class Badlion extends BasicListener {
@ -27,6 +26,6 @@ public class Badlion extends BasicListener {
} }
*/ */
event.getPlayer().unsafe().sendPacket(new PluginMessage("badlion:mods", ("{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"TNT Time\":{\"disabled\":true}}").getBytes(), false)); event.getPlayer().sendData("badlion:mods", ("{\"Clear Glass\":{\"disabled\":true},\"ClearWater\":{\"disabled\":true},\"FOV Changer\":{\"disabled\":true},\"Hitboxes\":{\"disabled\":true},\"MiniMap\":{\"disabled\":true},\"MLG Cobweb\":{\"disabled\":true},\"Replay\":{\"disabled\":true},\"Schematica\":{\"disabled\":true},\"ToggleSneak\":{\"disabled\":true},\"ToggleSprint\":{\"disabled\":true},\"TNT Time\":{\"disabled\":true}}").getBytes());
} }
} }

Datei anzeigen

@ -26,6 +26,7 @@ import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelPipeline; import io.netty.channel.ChannelPipeline;
import io.netty.handler.codec.MessageToMessageDecoder; import io.netty.handler.codec.MessageToMessageDecoder;
import net.md_5.bungee.ServerConnection; import net.md_5.bungee.ServerConnection;
import net.md_5.bungee.UserConnection;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.BaseComponent; import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -68,10 +69,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
if (connection == null) if (connection == null)
return; return;
player.unsafe().sendPacket(new PlayerListHeaderFooter( player.setTabHeader(header(viewer, seconds), viewer.parse(false, "TABLIST_FOOTER", connection.getInfo().getName(), ping(), ProxyServer.getInstance().getPlayers().size()));
ComponentSerializer.toString(header(viewer, seconds)),
ComponentSerializer.toString(viewer.parse(false, "TABLIST_FOOTER", connection.getInfo().getName(), ping(), ProxyServer.getInstance().getPlayers().size()))
));
List<TablistPart.Item> tablist = new ArrayList<>(); List<TablistPart.Item> tablist = new ArrayList<>();
List<TablistPart.Item> direct = new ArrayList<>(); List<TablistPart.Item> direct = new ArrayList<>();
@ -168,7 +166,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
pipeline.remove("steamwar-tablist"); pipeline.remove("steamwar-tablist");
pipeline.addBefore(PipelineUtils.BOSS_HANDLER, "steamwar-tablist", this); pipeline.addBefore(PipelineUtils.BOSS_HANDLER, "steamwar-tablist", this);
player.unsafe().sendPacket(teamPacket); sendQueued(player, teamPacket);
} }
} }
@ -312,16 +310,16 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
PlayerListItem packet = new PlayerListItem(); PlayerListItem packet = new PlayerListItem();
packet.setAction(action); packet.setAction(action);
packet.setItems(items.toArray(new PlayerListItem.Item[0])); packet.setItems(items.toArray(new PlayerListItem.Item[0]));
player.unsafe().sendPacket(packet); sendQueued(player, packet);
} else if(action == PlayerListItem.Action.REMOVE_PLAYER) { } else if(action == PlayerListItem.Action.REMOVE_PLAYER) {
PlayerListItemRemove packet = new PlayerListItemRemove(); PlayerListItemRemove packet = new PlayerListItemRemove();
packet.setUuids(items.stream().map(PlayerListItem.Item::getUuid).toArray(UUID[]::new)); packet.setUuids(items.stream().map(PlayerListItem.Item::getUuid).toArray(UUID[]::new));
player.unsafe().sendPacket(packet); sendQueued(player, packet);
} else { } else {
PlayerListItemUpdate packet = new PlayerListItemUpdate(); PlayerListItemUpdate packet = new PlayerListItemUpdate();
packet.setActions(action == PlayerListItem.Action.UPDATE_DISPLAY_NAME ? EnumSet.of(PlayerListItemUpdate.Action.UPDATE_DISPLAY_NAME, PlayerListItemUpdate.Action.UPDATE_LISTED) : EnumSet.of(PlayerListItemUpdate.Action.ADD_PLAYER, PlayerListItemUpdate.Action.UPDATE_DISPLAY_NAME, PlayerListItemUpdate.Action.UPDATE_LATENCY, PlayerListItemUpdate.Action.UPDATE_LISTED, PlayerListItemUpdate.Action.UPDATE_GAMEMODE)); packet.setActions(action == PlayerListItem.Action.UPDATE_DISPLAY_NAME ? EnumSet.of(PlayerListItemUpdate.Action.UPDATE_DISPLAY_NAME, PlayerListItemUpdate.Action.UPDATE_LISTED) : EnumSet.of(PlayerListItemUpdate.Action.ADD_PLAYER, PlayerListItemUpdate.Action.UPDATE_DISPLAY_NAME, PlayerListItemUpdate.Action.UPDATE_LATENCY, PlayerListItemUpdate.Action.UPDATE_LISTED, PlayerListItemUpdate.Action.UPDATE_GAMEMODE));
packet.setItems(items.toArray(new PlayerListItem.Item[0])); packet.setItems(items.toArray(new PlayerListItem.Item[0]));
player.unsafe().sendPacket(packet); sendQueued(player, packet);
} }
} }
} }
@ -331,7 +329,7 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
Team packet = new Team(TAB_TEAM); Team packet = new Team(TAB_TEAM);
packet.setMode((byte) (remove ? 4 : 3)); packet.setMode((byte) (remove ? 4 : 3));
packet.setPlayers(names.toArray(new String[0])); packet.setPlayers(names.toArray(new String[0]));
player.unsafe().sendPacket(packet); sendQueued(player, packet);
} }
} }
@ -357,4 +355,8 @@ public class Tablist extends MessageToMessageDecoder<PacketWrapper> {
return "§c" + ping; return "§c" + ping;
} }
} }
private static void sendQueued(ProxiedPlayer player, DefinedPacket packet) {
((UserConnection)player).sendPacketQueued(packet);
}
} }