mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
A DisplayScoreboard packet should also cause the scoreboard to update
This commit is contained in:
parent
582da8b88a
commit
6cbbf8a8dd
4 changed files with 17 additions and 5 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue