Skip to content
This repository has been archived by the owner on Jul 24, 2024. It is now read-only.

Commit

Permalink
chore(manager): Define the title manually if scoreboard-mode is 'SINGLE'
Browse files Browse the repository at this point in the history
  • Loading branch information
aivruu committed Apr 19, 2024
1 parent fc8fed7 commit b5a758e
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.List;
import me.qeklydev.scoreboard.cache.CachedScoreboardModel;
import me.qeklydev.scoreboard.component.ComponentUtils;
import me.qeklydev.scoreboard.config.Configuration;
import me.qeklydev.scoreboard.config.ConfigurationProvider;
import me.qeklydev.scoreboard.event.ScoreboardCloseEvent;
Expand Down Expand Up @@ -172,12 +173,24 @@ public void create(final @NotNull Player player) {
}
final var scoreboardCreateEvent = new ScoreboardCreateEvent(player, scoreboardModel);
Bukkit.getPluginManager().callEvent(scoreboardCreateEvent);
/*
* Avoid totally scoreboard creation for the player
* if the event was cancelled.
*/
if (scoreboardCreateEvent.isCancelled()) {
return;
}
final var config = this.configProvider.get();
final var scoreboardModelSidebar = scoreboardModel.internal();
// Assign the player for this sidebar object.
scoreboardModelSidebar.addPlayer(player);
/*
* Check if the scoreboard-mode defined is 'SINGLE',
* so we need to set the title manually.
*/
if (config.scoreboardMode.equals("SINGLE")) {
scoreboardModelSidebar.title(ComponentUtils.ofSingle(config.titleContent.get(0)));
}
// Store player ID and sidebar object into the scoreboard repository.
this.repository.register(player.getUniqueId().toString(), scoreboardModelSidebar);
}
Expand Down

0 comments on commit b5a758e

Please sign in to comment.