Skip to content

Commit

Permalink
make disconnect logging look better
Browse files Browse the repository at this point in the history
  • Loading branch information
AoElite committed Jan 6, 2024
1 parent 622f52b commit 9660021
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/main/java/ac/grim/grimac/player/GrimPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import io.github.retrooper.packetevents.util.FoliaCompatUtil;
import io.github.retrooper.packetevents.util.viaversion.ViaVersionUtil;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TranslatableComponent;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand Down Expand Up @@ -407,7 +408,13 @@ public void timedOut() {
}

public void disconnect(Component reason) {
final String textReason = LegacyComponentSerializer.legacySection().serialize(reason);
String textReason;
if (reason instanceof TranslatableComponent) {
TranslatableComponent translatableComponent = (TranslatableComponent) reason;
textReason = translatableComponent.key();
} else {
textReason = LegacyComponentSerializer.legacySection().serialize(reason);
}
LogUtil.info("Disconnecting " + user.getProfile().getName() + " for " + ChatColor.stripColor(textReason));
try {
user.sendPacket(new WrapperPlayServerDisconnect(reason));
Expand Down

0 comments on commit 9660021

Please sign in to comment.