Skip to content

Commit

Permalink
Fix scoreboard title handling for 1.8-1.12
Browse files Browse the repository at this point in the history
  • Loading branch information
Rothes committed Jan 27, 2023
1 parent 443e731 commit fa528c3
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,23 @@
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 {

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;
}
PacketContainer packet = packetEvent.getPacket();

if (packet.getIntegers().read(0) != 1) {
if (ProtocolStringReplacer.getInstance().getServerMajorVersion() > 12) {
if (ProtocolStringReplacer.getInstance().getServerMajorVersion() >= 13) {
StructureModifier<WrappedChatComponent> wrappedChatComponentStructureModifier = packet.getChatComponents();
WrappedChatComponent wrappedChatComponent = wrappedChatComponentStructureModifier.read(0);
String replaced = getReplacedJson(packetEvent, user, listenType, wrappedChatComponent.getJson(), titleFilter);
Expand All @@ -32,9 +33,9 @@ protected void process(PacketEvent packetEvent) {
}
} else {
StructureModifier<String> 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);
}
}
}
Expand Down

0 comments on commit fa528c3

Please sign in to comment.