This commit is contained in:
Tim203 2021-09-30 22:16:15 +02:00
parent 59c34fbcae
commit 0f81b28630
No known key found for this signature in database
GPG key ID: 064EE9F5BF7C3EE8
2 changed files with 18 additions and 12 deletions

View file

@ -43,12 +43,12 @@ import java.util.Arrays;
@Translator(packet = ServerTeamPacket.class)
public class JavaTeamTranslator extends PacketTranslator<ServerTeamPacket> {
private final GeyserLogger LOGGER = GeyserConnector.getInstance().getLogger();
private final GeyserLogger logger = GeyserConnector.getInstance().getLogger();
@Override
public void translate(GeyserSession session, ServerTeamPacket packet) {
if (LOGGER.isDebug()) {
LOGGER.debug("Team packet " + packet.getTeamName() + " " + packet.getAction() + " " + Arrays.toString(packet.getPlayers()));
if (logger.isDebug()) {
logger.debug("Team packet " + packet.getTeamName() + " " + packet.getAction() + " " + Arrays.toString(packet.getPlayers()));
}
if ((packet.getAction() == TeamAction.ADD_PLAYER || packet.getAction() == TeamAction.REMOVE_PLAYER) && packet.getPlayers().length == 0) {
@ -60,15 +60,16 @@ public class JavaTeamTranslator extends PacketTranslator<ServerTeamPacket> {
Scoreboard scoreboard = session.getWorldCache().getScoreboard();
Team team = scoreboard.getTeam(packet.getTeamName());
switch (packet.getAction()) {
case CREATE -> scoreboard.registerNewTeam(packet.getTeamName(), packet.getPlayers())
.setName(MessageTranslator.convertMessage(packet.getDisplayName()))
.setColor(packet.getColor())
.setNameTagVisibility(packet.getNameTagVisibility())
.setPrefix(MessageTranslator.convertMessage(packet.getPrefix(), session.getLocale()))
.setSuffix(MessageTranslator.convertMessage(packet.getSuffix(), session.getLocale()));
case CREATE ->
scoreboard.registerNewTeam(packet.getTeamName(), packet.getPlayers())
.setName(MessageTranslator.convertMessage(packet.getDisplayName()))
.setColor(packet.getColor())
.setNameTagVisibility(packet.getNameTagVisibility())
.setPrefix(MessageTranslator.convertMessage(packet.getPrefix(), session.getLocale()))
.setSuffix(MessageTranslator.convertMessage(packet.getSuffix(), session.getLocale()));
case UPDATE -> {
if (team == null) {
LOGGER.debug(LanguageUtils.getLocaleStringLog(
logger.debug(LanguageUtils.getLocaleStringLog(
"geyser.network.translator.team.failed_not_registered",
packet.getAction(), packet.getTeamName()
));
@ -84,7 +85,7 @@ public class JavaTeamTranslator extends PacketTranslator<ServerTeamPacket> {
}
case ADD_PLAYER -> {
if (team == null) {
LOGGER.debug(LanguageUtils.getLocaleStringLog(
logger.debug(LanguageUtils.getLocaleStringLog(
"geyser.network.translator.team.failed_not_registered",
packet.getAction(), packet.getTeamName()
));
@ -94,7 +95,7 @@ public class JavaTeamTranslator extends PacketTranslator<ServerTeamPacket> {
}
case REMOVE_PLAYER -> {
if (team == null) {
LOGGER.debug(LanguageUtils.getLocaleStringLog(
logger.debug(LanguageUtils.getLocaleStringLog(
"geyser.network.translator.team.failed_not_registered",
packet.getAction(), packet.getTeamName()
));

View file

@ -258,6 +258,11 @@ public final class Scoreboard {
addScores.add(score.getCachedInfo());
}
// we need this as long as MCPE-143063 hasn't been fixed
if (add && score.getUpdateType() != ADD && !objectiveUpdate) {
removeScores.add(score.getCachedInfo());
}
score.setUpdateType(NOTHING);
}