geforkt von Mirrors/Velocity
Add MessageRaw support to BungeeCordMessageResponder
Dieser Commit ist enthalten in:
Ursprung
f6bdab8e53
Commit
21ad6a433f
@ -17,7 +17,11 @@ import io.netty.buffer.ByteBuf;
|
|||||||
import io.netty.buffer.Unpooled;
|
import io.netty.buffer.Unpooled;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.StringJoiner;
|
import java.util.StringJoiner;
|
||||||
import net.kyori.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.Component;
|
||||||
|
import net.kyori.adventure.text.TextComponent;
|
||||||
|
import net.kyori.adventure.text.serializer.ComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||||
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
|
|
||||||
class BungeeCordMessageResponder {
|
class BungeeCordMessageResponder {
|
||||||
|
|
||||||
@ -134,15 +138,24 @@ class BungeeCordMessageResponder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void processMessage(ByteBufDataInput in) {
|
private void processMessage(ByteBufDataInput in) {
|
||||||
|
processMessage0(in, LegacyComponentSerializer.legacy());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processMessageRaw(ByteBufDataInput in) {
|
||||||
|
processMessage0(in, GsonComponentSerializer.gson());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void processMessage0(ByteBufDataInput in,
|
||||||
|
ComponentSerializer<Component, ?, String> serializer) {
|
||||||
String target = in.readUTF();
|
String target = in.readUTF();
|
||||||
String message = in.readUTF();
|
String message = in.readUTF();
|
||||||
|
|
||||||
|
Component messageComponent = serializer.deserialize(message);
|
||||||
if (target.equals("ALL")) {
|
if (target.equals("ALL")) {
|
||||||
for (Player player : proxy.getAllPlayers()) {
|
proxy.sendMessage(messageComponent);
|
||||||
player.sendMessage(LegacyComponentSerializer.INSTANCE.deserialize(message));
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
proxy.getPlayer(target).ifPresent(player -> {
|
proxy.getPlayer(target).ifPresent(player -> {
|
||||||
player.sendMessage(LegacyComponentSerializer.INSTANCE.deserialize(message));
|
player.sendMessage(messageComponent);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -197,7 +210,7 @@ class BungeeCordMessageResponder {
|
|||||||
private void processKick(ByteBufDataInput in) {
|
private void processKick(ByteBufDataInput in) {
|
||||||
proxy.getPlayer(in.readUTF()).ifPresent(player -> {
|
proxy.getPlayer(in.readUTF()).ifPresent(player -> {
|
||||||
String kickReason = in.readUTF();
|
String kickReason = in.readUTF();
|
||||||
player.disconnect(LegacyComponentSerializer.INSTANCE.deserialize(kickReason));
|
player.disconnect(LegacyComponentSerializer.legacy().deserialize(kickReason));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -312,6 +325,9 @@ class BungeeCordMessageResponder {
|
|||||||
case "Message":
|
case "Message":
|
||||||
this.processMessage(in);
|
this.processMessage(in);
|
||||||
break;
|
break;
|
||||||
|
case "MessageRaw":
|
||||||
|
this.processMessageRaw(in);
|
||||||
|
break;
|
||||||
case "GetServer":
|
case "GetServer":
|
||||||
this.processGetServer();
|
this.processGetServer();
|
||||||
break;
|
break;
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren