Skip to content

Commit

Permalink
scoreboard
Browse files Browse the repository at this point in the history
  • Loading branch information
Faithcaio committed Feb 11, 2024
1 parent efb4768 commit 891db56
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion SpongeAPI
Original file line number Diff line number Diff line change
@@ -31,6 +31,7 @@
import org.spongepowered.api.command.Command;
import org.spongepowered.api.command.CommandResult;
import org.spongepowered.api.command.parameter.CommandContext;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.server.ServerPlayer;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.lifecycle.RegisterCommandEvent;
@@ -73,9 +74,9 @@ public CommandResult doScoreboardStuff(CommandContext ctx) {
scoreboard.addObjective(test);
scoreboard.updateDisplaySlot(test, DisplaySlots.SIDEBAR);

final Score score = test.findOrCreateScore("testScore");
score.setScore(1);
score.setDisplay(Component.text("TestScoreDisplay"));
final Score score1 = test.findOrCreateScore("testScore");
score1.setScore(1);
score1.setDisplay(Component.text("TestScoreDisplay"));

final Score score2 = test.findOrCreateScore("testScoreBlank");
score2.setScore(2);
@@ -85,13 +86,22 @@ public CommandResult doScoreboardStuff(CommandContext ctx) {
final Score score3 = test.findOrCreateScore("testScoreFixed");
score3.setScore(3);
score3.setDisplay(Component.text("TestScoreDisplay Fixed"));
score3.setNumberFormat(ScoreFormat.fixed(Component.text("Fix")));
score3.setNumberFormat(ScoreFormat.fixed(Component.text("Fixed Value")));

final Score score4 = test.findOrCreateScore("testScoreStyled");
score4.setScore(4);
score4.setDisplay(Component.text("TestScoreDisplay Styled"));
score4.setNumberFormat(ScoreFormat.styled(Style.style(NamedTextColor.GREEN)));

final Score score5 = test.findOrCreateScore(player.profile());
score5.setScore(5);
score5.setDisplay(Component.text("Profile " + score5.name()));

player.world().nearbyEntities(player.position(), 20).stream().filter(e -> !(e instanceof Player)).findFirst().ifPresent(entity -> {
final Score score6 = test.findOrCreateScore(entity);
score6.setScore(6);
score6.setDisplay(Component.text( "Entity " + score6.name()));
});

ctx.sendMessage(Component.text("Objective set"));
});

0 comments on commit 891db56

Please sign in to comment.