Mirror von
https://github.com/PaperMC/Velocity.git
synchronisiert 2024-11-17 05:20:14 +01:00
Cleaned up client plugin message logic.
Dieser Commit ist enthalten in:
Ursprung
84947564e4
Commit
ab568405dd
@ -252,8 +252,8 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
return serverBossBars;
|
return serverBossBars;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleClientPluginMessage(PluginMessage packet) {
|
private void handleClientPluginMessage(PluginMessage packet) {
|
||||||
if (packet.getChannel().equals("REGISTER") || packet.getChannel().equals("minecraft:register")) {
|
if (PluginMessageUtil.isMCRegister(packet)) {
|
||||||
List<String> actuallyRegistered = new ArrayList<>();
|
List<String> actuallyRegistered = new ArrayList<>();
|
||||||
List<String> channels = PluginMessageUtil.getChannels(packet);
|
List<String> channels = PluginMessageUtil.getChannels(packet);
|
||||||
for (String channel : channels) {
|
for (String channel : channels) {
|
||||||
@ -270,21 +270,13 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
PluginMessage newRegisterPacket = PluginMessageUtil.constructChannelsPacket(packet.getChannel(), actuallyRegistered);
|
PluginMessage newRegisterPacket = PluginMessageUtil.constructChannelsPacket(packet.getChannel(), actuallyRegistered);
|
||||||
player.getConnectedServer().getMinecraftConnection().write(newRegisterPacket);
|
player.getConnectedServer().getMinecraftConnection().write(newRegisterPacket);
|
||||||
}
|
}
|
||||||
|
} else if (PluginMessageUtil.isMCUnregister(packet)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (packet.getChannel().equals("UNREGISTER") || packet.getChannel().equals("minecraft:unregister")) {
|
|
||||||
List<String> channels = PluginMessageUtil.getChannels(packet);
|
List<String> channels = PluginMessageUtil.getChannels(packet);
|
||||||
clientPluginMsgChannels.removeAll(channels);
|
clientPluginMsgChannels.removeAll(channels);
|
||||||
}
|
player.getConnectedServer().getMinecraftConnection().write(packet);
|
||||||
|
} else if (PluginMessageUtil.isMCBrand(packet)) {
|
||||||
if (PluginMessageUtil.isMCBrand(packet)) {
|
|
||||||
player.getConnectedServer().getMinecraftConnection().write(PluginMessageUtil.rewriteMCBrand(packet));
|
player.getConnectedServer().getMinecraftConnection().write(PluginMessageUtil.rewriteMCBrand(packet));
|
||||||
return;
|
} else if (player.getConnectedServer().isLegacyForge() && !player.getConnectedServer().hasCompletedJoin()) {
|
||||||
}
|
|
||||||
|
|
||||||
if (player.getConnectedServer().isLegacyForge() && !player.getConnectedServer().hasCompletedJoin()) {
|
|
||||||
if (packet.getChannel().equals(VelocityConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) {
|
if (packet.getChannel().equals(VelocityConstants.FORGE_LEGACY_HANDSHAKE_CHANNEL)) {
|
||||||
// Always forward the FML handshake to the remote server.
|
// Always forward the FML handshake to the remote server.
|
||||||
player.getConnectedServer().getMinecraftConnection().write(packet);
|
player.getConnectedServer().getMinecraftConnection().write(packet);
|
||||||
@ -294,15 +286,14 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler {
|
|||||||
// be sent once the JoinGame packet has been received by the proxy.
|
// be sent once the JoinGame packet has been received by the proxy.
|
||||||
loginPluginMessages.add(packet);
|
loginPluginMessages.add(packet);
|
||||||
}
|
}
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
MessageHandler.ForwardStatus status = server.getChannelRegistrar().handlePluginMessage(player,
|
MessageHandler.ForwardStatus status = server.getChannelRegistrar().handlePluginMessage(player,
|
||||||
ChannelSide.FROM_CLIENT, packet);
|
ChannelSide.FROM_CLIENT, packet);
|
||||||
if (status == MessageHandler.ForwardStatus.FORWARD) {
|
if (status == MessageHandler.ForwardStatus.FORWARD) {
|
||||||
player.getConnectedServer().writeIfJoined(packet);
|
player.getConnectedServer().writeIfJoined(packet);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Set<String> getClientPluginMsgChannels() {
|
public Set<String> getClientPluginMsgChannels() {
|
||||||
return clientPluginMsgChannels;
|
return clientPluginMsgChannels;
|
||||||
|
@ -20,13 +20,20 @@ public enum PluginMessageUtil {
|
|||||||
return message.getChannel().equals("MC|Brand") || message.getChannel().equals("minecraft:brand");
|
return message.getChannel().equals("MC|Brand") || message.getChannel().equals("minecraft:brand");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isMCRegister(PluginMessage message) {
|
||||||
|
Preconditions.checkNotNull(message, "message");
|
||||||
|
return message.getChannel().equals("REGISTER") || message.getChannel().equals("minecraft:register");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isMCUnregister(PluginMessage message) {
|
||||||
|
Preconditions.checkNotNull(message, "message");
|
||||||
|
return message.getChannel().equals("UNREGISTER") || message.getChannel().equals("minecraft:unregister");
|
||||||
|
}
|
||||||
|
|
||||||
public static List<String> getChannels(PluginMessage message) {
|
public static List<String> getChannels(PluginMessage message) {
|
||||||
Preconditions.checkNotNull(message, "message");
|
Preconditions.checkNotNull(message, "message");
|
||||||
Preconditions.checkArgument(message.getChannel().equals("REGISTER") ||
|
Preconditions.checkArgument(isMCRegister(message) || isMCUnregister(message),"Unknown channel type %s",
|
||||||
message.getChannel().equals("UNREGISTER") ||
|
message.getChannel());
|
||||||
message.getChannel().equals("minecraft:register") ||
|
|
||||||
message.getChannel().equals("minecraft:unregister"),
|
|
||||||
"Unknown channel type " + message.getChannel());
|
|
||||||
String channels = new String(message.getData(), StandardCharsets.UTF_8);
|
String channels = new String(message.getData(), StandardCharsets.UTF_8);
|
||||||
return ImmutableList.copyOf(channels.split("\0"));
|
return ImmutableList.copyOf(channels.split("\0"));
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren