This commit is contained in:
Riley Park 2021-02-22 00:03:03 -08:00
parent db0dd75a20
commit b856bf08b9
4 changed files with 11 additions and 10 deletions

View file

@ -22,7 +22,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
+ public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage, @Nullable QuitReason quitReason) { + public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage, @Nullable QuitReason quitReason) {
super(who); super(who);
this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : net.kyori.adventure.text.Component.empty(); // Paper this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper
+ this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason; + this.reason = quitReason == null ? QuitReason.DISCONNECTED : quitReason;
} }
// Paper start // Paper start

View file

@ -1594,7 +1594,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper end + @Deprecated // Paper end
public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final String joinMessage) { public PlayerJoinEvent(@NotNull final Player playerJoined, @Nullable final String joinMessage) {
super(playerJoined); super(playerJoined);
+ this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : net.kyori.adventure.text.Component.empty(); // Paper end + this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper end
+ } + }
+ +
+ // Paper start + // Paper start
@ -1639,7 +1639,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setJoinMessage(@Nullable String joinMessage) { public void setJoinMessage(@Nullable String joinMessage) {
- this.joinMessage = joinMessage; - this.joinMessage = joinMessage;
+ this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : net.kyori.adventure.text.Component.empty(); // Paper + this.joinMessage = joinMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(joinMessage) : null; // Paper
} }
@NotNull @NotNull
@ -2042,7 +2042,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage) { public PlayerQuitEvent(@NotNull final Player who, @Nullable final String quitMessage) {
super(who); super(who);
+ this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : net.kyori.adventure.text.Component.empty(); // Paper + this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper
+ } + }
+ // Paper start + // Paper start
+ public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage) { + public PlayerQuitEvent(@NotNull final Player who, @Nullable final net.kyori.adventure.text.Component quitMessage) {
@ -2091,7 +2091,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ @Deprecated // Paper + @Deprecated // Paper
public void setQuitMessage(@Nullable String quitMessage) { public void setQuitMessage(@Nullable String quitMessage) {
- this.quitMessage = quitMessage; - this.quitMessage = quitMessage;
+ this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : net.kyori.adventure.text.Component.empty(); // Paper + this.quitMessage = quitMessage != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(quitMessage) : null; // Paper
} }
@NotNull @NotNull

View file

@ -1156,7 +1156,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
- this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage)); - this.minecraftServer.getPlayerList().sendMessage(CraftChatMessage.fromString(quitMessage));
+ // Paper start - Adventure + // Paper start - Adventure
+ net.kyori.adventure.text.Component quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player); + net.kyori.adventure.text.Component quitMessage = this.minecraftServer.getPlayerList().disconnect(this.player);
+ if ((quitMessage != null) && (quitMessage.equals(net.kyori.adventure.text.Component.empty()))) { + if ((quitMessage != null) && !quitMessage.equals(net.kyori.adventure.text.Component.empty())) {
+ this.minecraftServer.getPlayerList().sendMessage(PaperAdventure.asVanilla(quitMessage)); + this.minecraftServer.getPlayerList().sendMessage(PaperAdventure.asVanilla(quitMessage));
+ // Paper end + // Paper end
} }
@ -1284,13 +1284,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
} }
- joinMessage = playerJoinEvent.getJoinMessage(); - joinMessage = playerJoinEvent.getJoinMessage();
+ joinMessage = PaperAdventure.asVanilla(playerJoinEvent.joinMessage()); // Paper - Adventure + final net.kyori.adventure.text.Component jm = playerJoinEvent.joinMessage();
- if (joinMessage != null && joinMessage.length() > 0) { - if (joinMessage != null && joinMessage.length() > 0) {
- for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) { - for (IChatBaseComponent line : org.bukkit.craftbukkit.util.CraftChatMessage.fromString(joinMessage)) {
- server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b)); - server.getPlayerList().sendAll(new PacketPlayOutChat(line, ChatMessageType.SYSTEM, SystemUtils.b));
- } - }
+ if (playerJoinEvent.joinMessage() != net.kyori.adventure.text.Component.empty()) { // Paper - Adventure + if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
+ joinMessage = PaperAdventure.asVanilla(playerJoinEvent.joinMessage()); // Paper - Adventure
+ server.getPlayerList().sendAll(new PacketPlayOutChat(joinMessage, ChatMessageType.SYSTEM, SystemUtils.b)); // Paper - Adventure + server.getPlayerList().sendAll(new PacketPlayOutChat(joinMessage, ChatMessageType.SYSTEM, SystemUtils.b)); // Paper - Adventure
} }
// CraftBukkit end // CraftBukkit end

View file

@ -9,9 +9,9 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/server/PlayerList.java --- a/src/main/java/net/minecraft/server/PlayerList.java
+++ b/src/main/java/net/minecraft/server/PlayerList.java +++ b/src/main/java/net/minecraft/server/PlayerList.java
@@ -0,0 +0,0 @@ public abstract class PlayerList { @@ -0,0 +0,0 @@ public abstract class PlayerList {
joinMessage = PaperAdventure.asVanilla(playerJoinEvent.joinMessage()); // Paper - Adventure
if (playerJoinEvent.joinMessage() != net.kyori.adventure.text.Component.empty()) { // Paper - Adventure if (jm != null && !jm.equals(net.kyori.adventure.text.Component.empty())) { // Paper - Adventure
joinMessage = PaperAdventure.asVanilla(playerJoinEvent.joinMessage()); // Paper - Adventure
- server.getPlayerList().sendAll(new PacketPlayOutChat(joinMessage, ChatMessageType.SYSTEM, SystemUtils.b)); // Paper - Adventure - server.getPlayerList().sendAll(new PacketPlayOutChat(joinMessage, ChatMessageType.SYSTEM, SystemUtils.b)); // Paper - Adventure
+ // Paper start - Removed sendAll for loop and broadcasted to console also + // Paper start - Removed sendAll for loop and broadcasted to console also
+ server.getPlayerList().sendMessage(joinMessage); // Paper - Adventure + server.getPlayerList().sendMessage(joinMessage); // Paper - Adventure