From 0fc3e6c6054f8d898905bbe1a74981ed5e8632fe Mon Sep 17 00:00:00 2001 From: rbluer <665978+rbluer@users.noreply.github.com> Date: Sun, 24 Sep 2023 18:10:15 -0400 Subject: [PATCH] TopNPlayer: Task could not startup if ranks are enabled but there are no default ranks. Log a message in the console that the task cannot start because ranks are enabled and there are no ranks. Request that Ranks module is disabled, or add default ranks and then restart the server. --- docs/changelog_v3.3.x.md | 7 ++++++- .../mcprison/prison/ranks/data/TopNPlayers.java | 14 +++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/docs/changelog_v3.3.x.md b/docs/changelog_v3.3.x.md index 8e2ed53fb..384dde584 100644 --- a/docs/changelog_v3.3.x.md +++ b/docs/changelog_v3.3.x.md @@ -23,7 +23,12 @@ These change logs represent the work that has been going on within prison. * **Changed the default color code from `&9` (dark blue) to `&b` (light blue) for debug logging since the dark blue could be difficult to see on some consoles. -**v3.3.0-alpha.15f 2023-09-23** +**v3.3.0-alpha.15f 2023-09-24** + + +* **TopNPlayer: Task could not startup if ranks are enabled but there are no default ranks.** +Log a message in the console that the task cannot start because ranks are enabled and there are no ranks. +Request that Ranks module is disabled, or add default ranks and then restart the server. * **Prison Support: Added a more secure method and server (privatebin) for submitting server information under prison support submit commands.** diff --git a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java index b11021aae..de0a28878 100644 --- a/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java +++ b/prison-ranks/src/main/java/tech/mcprison/prison/ranks/data/TopNPlayers.java @@ -12,6 +12,7 @@ import tech.mcprison.prison.file.FileIOData; import tech.mcprison.prison.file.JsonFileIO; import tech.mcprison.prison.internal.Player; +import tech.mcprison.prison.output.Output; import tech.mcprison.prison.ranks.PrisonRanks; import tech.mcprison.prison.ranks.tasks.TopNPlayerUpdateAsyncTask; @@ -132,7 +133,9 @@ private void launchTopNPlayerUpdateAsyncTask() { if ( PrisonRanks.getInstance() != null && PrisonRanks.getInstance().isEnabled() && - PrisonRanks.getInstance().getPlayerManager() != null ) { + PrisonRanks.getInstance().getPlayerManager() != null && + PrisonRanks.getInstance().getDefaultLadder().getRanks().size() > 0 + ) { Long delayTicks = Prison.get().getPlatform().getConfigLong( "topNPlayers.refresh.delay-ticks", DELAY_THIRTY_SECONDS_TICKS ); @@ -142,6 +145,15 @@ private void launchTopNPlayerUpdateAsyncTask() { TopNPlayerUpdateAsyncTask.submitTaskTimerAsync( this, delayTicks, intervalTicks ); } + else if ( PrisonRanks.getInstance() != null && + PrisonRanks.getInstance().isEnabled() && + PrisonRanks.getInstance().getDefaultLadder().getRanks().size() == 0 ) { + + Output.get().logWarn( "TopNPlayer: Cannot start the TopNPlayer task. Ranks are " + + "enabled, but there are no default ranks setup. " + + "Either turn off the Ranks Module, or add ranks and " + + "then restart the server to get the TopNPlayer task running."); + } }