Skip to content

Commit

Permalink
Promote & Demote: Improved upon reporting issues with the command. Th…
Browse files Browse the repository at this point in the history
…ere were few situations where the command would exit without reporting why, which was leading to difficulties with using the command effectively.
  • Loading branch information
rbluer committed Mar 10, 2024
1 parent fa10d0a commit f9a35a3
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 28 deletions.
4 changes: 4 additions & 0 deletions docs/changelog_v3.3.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ These change logs represent the work that has been going on within prison.
**3.3.0-alpha.16c 2024-03-10**


* **Promote & Demote: Improved upon reporting issues with the command.**
There were few situations where the command would exit without reporting why, which was leading to difficulties with using the command effectively.


* **New feature: TopN customization now possible. The messages and placeholders that you can use are located in the core multi-language files.**
See the bottom of the files for instructions on usage.
TopN data is set to delay load so it does not lengthen the startup process. As such, it now reports that the data is being loaded so it is now clear why there are no entries in the list initially.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,34 +768,43 @@ public void promotePlayer(CommandSender sender,
UUID playerUuid = player.getUUID();

ladder = confirmLadder( sender, ladder );
if ( ladder == null ) {
return;
}

RankPlayerFactory rankPlayerFactory = new RankPlayerFactory();

RankPlayer rankPlayer = getRankPlayer( sender, playerUuid, player.getName() );
PlayerRank playerRank = rankPlayerFactory.getRank( rankPlayer, ladder );

if ( playerRank != null ) {
if ( rankPlayer != null && playerRank != null ) {

Rank pRank = playerRank.getRank();
if ( pRank == null ) {
sender.sendMessage( "Promote: There was an error trying to access the "
+ "current rank of the player. Try viewing the player's "
+ "details: '/ranks player help'.");
return;
}

// Get currency if it exists, otherwise it will be null if the Rank has no currency:
String currency = rankPlayer == null || pRank == null ? null : pRank.getCurrency();
String currency = pRank.getCurrency();

List<PrisonCommandTaskData> cmdTasks = new ArrayList<>();

RankupResults results = new RankUtil().promotePlayer(player, rankPlayer, ladder,
player.getName(), sender.getName(), pForceCharge, cmdTasks );

// submit cmdTasks...
submitCmdTasks( player, cmdTasks );

processResults( sender, player.getName(), results, null, ladder, currency, null );

if ( ladder != null && rankPlayer != null ) {

List<PrisonCommandTaskData> cmdTasks = new ArrayList<>();

RankupResults results = new RankUtil().promotePlayer(player, rankPlayer, ladder,
player.getName(), sender.getName(), pForceCharge, cmdTasks );

// submit cmdTasks...
submitCmdTasks( player, cmdTasks );

processResults( sender, player.getName(), results, null, ladder, currency, null );
}
}
else {
// Message: Player is not on the ladder
sender.sendMessage( "Promote: Player is not on the specified ladder. "
+ "Try using '/ranks set rank' to add them.");
}
}

Expand Down Expand Up @@ -842,28 +851,34 @@ public void demotePlayer(CommandSender sender,
RankPlayer rankPlayer = getRankPlayer( sender, playerUuid, player.getName() );
PlayerRank playerRank = rankPlayerFactory.getRank( rankPlayer, ladder );

if ( playerRank != null ) {
if ( rankPlayer != null && playerRank != null ) {

Rank pRank = playerRank.getRank();
if ( pRank == null ) {
sender.sendMessage( "Demote: There was an error trying to access the "
+ "current rank of the player. Try viewing the player's "
+ "details: '/ranks player help'.");
return;
}

// Get currency if it exists, otherwise it will be null if the Rank has no currency:
String currency = rankPlayer == null || pRank == null ? null : pRank.getCurrency();
String currency = pRank.getCurrency();

List<PrisonCommandTaskData> cmdTasks = new ArrayList<>();

RankupResults results = new RankUtil().demotePlayer(player, rankPlayer, ladder,
player.getName(), sender.getName(), pForceCharge, cmdTasks );

// submit cmdTasks
submitCmdTasks( player, cmdTasks );

processResults( sender, player.getName(), results, null, ladder, currency, null );

if ( ladder != null && rankPlayer != null ) {

List<PrisonCommandTaskData> cmdTasks = new ArrayList<>();

RankupResults results = new RankUtil().demotePlayer(player, rankPlayer, ladder,
player.getName(), sender.getName(), pForceCharge, cmdTasks );

// submit cmdTasks
submitCmdTasks( player, cmdTasks );

processResults( sender, player.getName(), results, null, ladder, currency, null );
}
}
else {
// Message: Player is not on the ladder
sender.sendMessage( "Demote: Player is not on the specified ladder. "
+ "Try using '/ranks set rank' to add them.");
}
}

Expand Down

0 comments on commit f9a35a3

Please sign in to comment.