/** * Transform a ScoreComponent by replacing the name and value with the * appropriate values. * * @param player the player to use for the component's name * @param component the component to transform */ private void transformScoreComponent(ProxiedPlayer player, ScoreComponent component) { Preconditions.checkArgument( !isSelectorPattern( component.getName() ), "Cannot transform entity selector patterns" ); if ( component.getValue() != null && !component.getValue().isEmpty() ) { return; // pre-defined values override scoreboard values } // check for '*' wildcard if ( component.getName().equals( "*" ) ) { component.setName( player.getName() ); } if ( player.getScoreboard().getObjective( component.getObjective() ) != null ) { Score score = player.getScoreboard().getScore( component.getName() ); if ( score != null ) { component.setValue( Integer.toString( score.getValue() ) ); } } }
@Override public void handle(ScoreboardObjective objective) throws Exception { Scoreboard serverScoreboard = con.getServerSentScoreboard(); switch ( objective.getAction() ) { case 0: serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType().toString() ) ); break; case 1: serverScoreboard.removeObjective( objective.getName() ); break; case 2: Objective oldObjective = serverScoreboard.getObjective( objective.getName() ); if ( oldObjective != null ) { oldObjective.setValue( objective.getValue() ); oldObjective.setType( objective.getType().toString() ); } break; default: throw new IllegalArgumentException( "Unknown objective action: " + objective.getAction() ); } }
@Override public void handle(ScoreboardObjective objective) throws Exception { Scoreboard serverScoreboard = con.getServerSentScoreboard(); switch ( objective.getAction() ) { case 0: serverScoreboard.addObjective( new Objective( objective.getName(), objective.getValue(), objective.getType() ) ); break; case 1: serverScoreboard.removeObjective( objective.getName() ); break; case 2: Objective oldObjective = serverScoreboard.getObjective( objective.getName() ); if ( oldObjective != null ) { oldObjective.setValue( objective.getValue() ); } break; default: throw new IllegalArgumentException( "Unknown objective action: " + objective.getAction() ); } }