Skip to content

Commit

Permalink
Restore strings to scoreboard API
Browse files Browse the repository at this point in the history
  • Loading branch information
md-5 committed Oct 21, 2023
1 parent 0ea4679 commit 7ec9769
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
3 changes: 1 addition & 2 deletions api/src/main/java/net/md_5/bungee/api/score/Objective.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import lombok.AllArgsConstructor;
import lombok.Data;
import net.md_5.bungee.api.chat.BaseComponent;

/**
* Represents an objective entry.
Expand All @@ -19,7 +18,7 @@ public class Objective
/**
* Value of the objective.
*/
private BaseComponent value;
private String value;
/**
* Type; integer or hearts
*/
Expand Down
7 changes: 3 additions & 4 deletions api/src/main/java/net/md_5/bungee/api/score/Team.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,16 @@
import java.util.Set;
import lombok.Data;
import lombok.NonNull;
import net.md_5.bungee.api.chat.BaseComponent;

@Data
public class Team
{

@NonNull
private final String name;
private BaseComponent displayName;
private BaseComponent prefix;
private BaseComponent suffix;
private String displayName;
private String prefix;
private String suffix;
private byte friendlyFire;
private String nameTagVisibility;
private String collisionRule;
Expand Down
3 changes: 2 additions & 1 deletion proxy/src/main/java/net/md_5/bungee/ServerConnector.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import net.md_5.bungee.api.score.Score;
import net.md_5.bungee.api.score.Scoreboard;
import net.md_5.bungee.api.score.Team;
import net.md_5.bungee.chat.ComponentSerializer;
import net.md_5.bungee.connection.CancelSendSignal;
import net.md_5.bungee.connection.DownstreamBridge;
import net.md_5.bungee.connection.LoginResult;
Expand Down Expand Up @@ -278,7 +279,7 @@ public static void handleLogin(ProxyServer bungee, ChannelWrapper ch, UserConnec
Scoreboard serverScoreboard = user.getServerSentScoreboard();
for ( Objective objective : serverScoreboard.getObjectives() )
{
user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), objective.getValue(), ScoreboardObjective.HealthDisplay.fromString( objective.getType() ), (byte) 1 ) );
user.unsafe().sendPacket( new ScoreboardObjective( objective.getName(), ComponentSerializer.deserialize( objective.getValue() ), ScoreboardObjective.HealthDisplay.fromString( objective.getType() ), (byte) 1 ) );
}
for ( Score score : serverScoreboard.getScores() )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public void handle(ScoreboardObjective objective) throws Exception
switch ( objective.getAction() )
{
case 0:
serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType().toString() ) );
serverScoreboard.addObjective( new Objective( objective.getName(), ComponentSerializer.toString( objective.getValue() ), objective.getType().toString() ) );
break;
case 1:
serverScoreboard.removeObjective( objective.getName() );
Expand All @@ -192,7 +192,7 @@ public void handle(ScoreboardObjective objective) throws Exception
Objective oldObjective = serverScoreboard.getObjective( objective.getName() );
if ( oldObjective != null )
{
oldObjective.setValue( objective.getValue() );
oldObjective.setValue( ComponentSerializer.toString( objective.getValue() ) );
oldObjective.setType( objective.getType().toString() );
}
break;
Expand Down Expand Up @@ -254,9 +254,9 @@ public void handle(net.md_5.bungee.protocol.packet.Team team) throws Exception
{
if ( team.getMode() == 0 || team.getMode() == 2 )
{
t.setDisplayName( team.getDisplayName() );
t.setPrefix( team.getPrefix() );
t.setSuffix( team.getSuffix() );
t.setDisplayName( ComponentSerializer.toString( team.getDisplayName() ) );
t.setPrefix( ComponentSerializer.toString( team.getPrefix() ) );
t.setSuffix( ComponentSerializer.toString( team.getSuffix() ) );
t.setFriendlyFire( team.getFriendlyFire() );
t.setNameTagVisibility( team.getNameTagVisibility() );
t.setCollisionRule( team.getCollisionRule() );
Expand Down

0 comments on commit 7ec9769

Please sign in to comment.