From fa528c3715125f245b1a5ae717ae6df558fb802c Mon Sep 17 00:00:00 2001 From: Rothes <449181985@qq.com> Date: Fri, 27 Jan 2023 23:37:02 +0800 Subject: [PATCH] Fix scoreboard title handling for 1.8-1.12 --- .../server/scoreboard/ScoreBoardObjective.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/main/java/me/rothes/protocolstringreplacer/packetlisteners/server/scoreboard/ScoreBoardObjective.java b/src/main/java/me/rothes/protocolstringreplacer/packetlisteners/server/scoreboard/ScoreBoardObjective.java index 4f2385cf..ccb7371e 100644 --- a/src/main/java/me/rothes/protocolstringreplacer/packetlisteners/server/scoreboard/ScoreBoardObjective.java +++ b/src/main/java/me/rothes/protocolstringreplacer/packetlisteners/server/scoreboard/ScoreBoardObjective.java @@ -8,6 +8,7 @@ import me.rothes.protocolstringreplacer.ProtocolStringReplacer; import me.rothes.protocolstringreplacer.api.user.PsrUser; import me.rothes.protocolstringreplacer.replacer.ListenType; +import org.jetbrains.annotations.NotNull; public class ScoreBoardObjective extends AbstractScoreBoardListener { @@ -15,7 +16,7 @@ public ScoreBoardObjective() { super(PacketType.Play.Server.SCOREBOARD_OBJECTIVE, ListenType.SCOREBOARD); } - protected void process(PacketEvent packetEvent) { + protected void process(@NotNull PacketEvent packetEvent) { PsrUser user = getEventUser(packetEvent); if (user == null) { return; @@ -23,7 +24,7 @@ protected void process(PacketEvent packetEvent) { PacketContainer packet = packetEvent.getPacket(); if (packet.getIntegers().read(0) != 1) { - if (ProtocolStringReplacer.getInstance().getServerMajorVersion() > 12) { + if (ProtocolStringReplacer.getInstance().getServerMajorVersion() >= 13) { StructureModifier wrappedChatComponentStructureModifier = packet.getChatComponents(); WrappedChatComponent wrappedChatComponent = wrappedChatComponentStructureModifier.read(0); String replaced = getReplacedJson(packetEvent, user, listenType, wrappedChatComponent.getJson(), titleFilter); @@ -32,9 +33,9 @@ protected void process(PacketEvent packetEvent) { } } else { StructureModifier strings = packet.getStrings(); - String replaced = getReplacedText(packetEvent, user, listenType, strings.read(0), titleFilter); + String replaced = getReplacedText(packetEvent, user, listenType, strings.read(1), titleFilter); if (replaced != null) - strings.write(0, replaced); + strings.write(1, replaced); } } }