A DisplayScoreboard packet should also cause the scoreboard to update

This commit is contained in:
Tim203 2021-10-20 21:08:25 +02:00
parent 582da8b88a
commit 6cbbf8a8dd
No known key found for this signature in database
GPG key ID: 064EE9F5BF7C3EE8
4 changed files with 17 additions and 5 deletions

View file

@ -27,15 +27,27 @@ package org.geysermc.connector.network.translators.java.scoreboard;
import com.github.steveice10.mc.protocol.packet.ingame.server.scoreboard.ServerDisplayScoreboardPacket;
import org.geysermc.connector.network.session.GeyserSession;
import org.geysermc.connector.network.session.cache.WorldCache;
import org.geysermc.connector.network.translators.PacketTranslator;
import org.geysermc.connector.network.translators.Translator;
import org.geysermc.connector.scoreboard.Scoreboard;
import org.geysermc.connector.scoreboard.ScoreboardUpdater;
@Translator(packet = ServerDisplayScoreboardPacket.class)
public class JavaDisplayScoreboardTranslator extends PacketTranslator<ServerDisplayScoreboardPacket> {
@Override
public void translate(GeyserSession session, ServerDisplayScoreboardPacket packet) {
session.getWorldCache().getScoreboard()
.displayObjective(packet.getName(), packet.getPosition());
WorldCache worldCache = session.getWorldCache();
Scoreboard scoreboard = worldCache.getScoreboard();
int pps = worldCache.increaseAndGetScoreboardPacketsPerSecond();
scoreboard.displayObjective(packet.getName(), packet.getPosition());
// ScoreboardUpdater will handle it for us if the packets per second
// (for score and team packets) is higher than the first threshold
if (pps < ScoreboardUpdater.FIRST_SCORE_PACKETS_PER_SECOND_THRESHOLD) {
scoreboard.onUpdate();
}
}
}

View file

@ -84,7 +84,7 @@ public class JavaScoreboardObjectiveTranslator extends PacketTranslator<ServerSc
}
// ScoreboardUpdater will handle it for us if the packets per second
// (for score and team packets) is higher then the first threshold
// (for score and team packets) is higher than the first threshold
if (pps < ScoreboardUpdater.FIRST_SCORE_PACKETS_PER_SECOND_THRESHOLD) {
scoreboard.onUpdate();
}

View file

@ -138,7 +138,7 @@ public class JavaTeamTranslator extends PacketTranslator<ServerTeamPacket> {
}
// ScoreboardUpdater will handle it for us if the packets per second
// (for score and team packets) is higher then the first threshold
// (for score and team packets) is higher than the first threshold
if (pps < ScoreboardUpdater.FIRST_SCORE_PACKETS_PER_SECOND_THRESHOLD) {
scoreboard.onUpdate();
}

View file

@ -99,7 +99,7 @@ public class JavaUpdateScoreTranslator extends PacketTranslator<ServerUpdateScor
}
// ScoreboardUpdater will handle it for us if the packets per second
// (for score and team packets) is higher then the first threshold
// (for score and team packets) is higher than the first threshold
if (pps < ScoreboardUpdater.FIRST_SCORE_PACKETS_PER_SECOND_THRESHOLD) {
scoreboard.onUpdate();
}