From ae52d94fe8d8ee775a707dc6d9fb108277092e2d Mon Sep 17 00:00:00 2001 From: okx-code Date: Wed, 3 Oct 2018 15:43:55 +0100 Subject: [PATCH] 3.1.2 bugfixes (see long description) - add messages in /rank and /rankup for when the configuration has a rankup to a non-existent rank. - add invalid rankup message - fix error for placeholders when prestiging is disabled - add message for when a rank has no requirements --- build.gradle | 2 +- src/main/java/sh/okx/rankup/commands/RanksCommand.java | 8 ++++++++ .../java/sh/okx/rankup/commands/RankupCommand.java | 10 ++++++++-- src/main/java/sh/okx/rankup/messages/Message.java | 3 ++- .../sh/okx/rankup/placeholders/RankupExpansion.java | 8 ++++++-- src/main/java/sh/okx/rankup/ranks/Rank.java | 4 ++++ src/main/resources/config.yml | 8 ++++---- src/main/resources/messages.yml | 3 ++- src/main/resources/plugin.yml | 5 +---- 9 files changed, 36 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index ad69f92..7ab5001 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'sh.okx' -version '3.1.1' +version '3.1.2' repositories { mavenCentral() diff --git a/src/main/java/sh/okx/rankup/commands/RanksCommand.java b/src/main/java/sh/okx/rankup/commands/RanksCommand.java index d679c61..8e9b761 100644 --- a/src/main/java/sh/okx/rankup/commands/RanksCommand.java +++ b/src/main/java/sh/okx/rankup/commands/RanksCommand.java @@ -32,6 +32,14 @@ public class RanksCommand implements CommandExecutor { plugin.sendMessage(sender, Message.RANKS_CURRENT, rank, next); message = Message.RANKS_INCOMPLETE; } else { + // helpful message to say there is a null rankup + if(next == null) { + plugin.getMessage(Message.INVALID_RANKUP).failIfEmpty().send(sender); + plugin.getLogger().severe("Rankup from " + rank.getName() + " to " + rank.getNext() + + " is defined but " + rank.getNext() + " does not exist."); + return true; + } + plugin.sendMessage(sender, message, rank, next); } rank = next; diff --git a/src/main/java/sh/okx/rankup/commands/RankupCommand.java b/src/main/java/sh/okx/rankup/commands/RankupCommand.java index c30afd6..ec9c840 100644 --- a/src/main/java/sh/okx/rankup/commands/RankupCommand.java +++ b/src/main/java/sh/okx/rankup/commands/RankupCommand.java @@ -32,8 +32,14 @@ public class RankupCommand implements CommandExecutor { Rankups rankups = plugin.getRankups(); Rank rank = rankups.getByPlayer(player); + Rank next = rankups.next(rank); if (!plugin.checkRankup(player)) { return true; + } else if(next == null) { + plugin.getLogger().severe("Rankup from " + rank.getName() + " to " + rank.getNext() + + " is defined but " + rank.getNext() + " does not exist."); + plugin.getMessage(Message.INVALID_RANKUP).failIfEmpty().send(player); + return true; } FileConfiguration config = plugin.getConfig(); @@ -52,11 +58,11 @@ public class RankupCommand implements CommandExecutor { case "text": confirming.put(player, System.currentTimeMillis()); plugin.replaceMoneyRequirements(plugin.getMessage(rank, Message.CONFIRMATION) - .replaceRanks(player, rank, rankups.next(rank)), player, rank) + .replaceRanks(player, rank, next), player, rank) .send(player); break; case "gui": - Gui.of(player, rank, rankups.next(rank), plugin).open(player); + Gui.of(player, rank, next, plugin).open(player); break; case "none": plugin.rankup(player); diff --git a/src/main/java/sh/okx/rankup/messages/Message.java b/src/main/java/sh/okx/rankup/messages/Message.java index 446e871..495c9ce 100644 --- a/src/main/java/sh/okx/rankup/messages/Message.java +++ b/src/main/java/sh/okx/rankup/messages/Message.java @@ -27,7 +27,8 @@ public enum Message { NOT_HIGH_ENOUGH("not-high-enough"), PRESTIGE_SUCCESS_PUBLIC("prestige.success-public"), PRESTIGE_SUCCESS_PRIVATE("prestige.success-private"), - PRESTIGE_CONFIRMATION("prestige.confirmation"); + PRESTIGE_CONFIRMATION("prestige.confirmation"), + INVALID_RANKUP("invalid-rankup"); @Getter private final String name; diff --git a/src/main/java/sh/okx/rankup/placeholders/RankupExpansion.java b/src/main/java/sh/okx/rankup/placeholders/RankupExpansion.java index dc86c9f..f21bacf 100644 --- a/src/main/java/sh/okx/rankup/placeholders/RankupExpansion.java +++ b/src/main/java/sh/okx/rankup/placeholders/RankupExpansion.java @@ -29,8 +29,12 @@ public class RankupExpansion extends PlaceholderExpansion { Rank nextRank = rank == null ? null : rankups.next(rank); Prestiges prestiges = plugin.getPrestiges(); - Prestige prestige = prestiges.getByPlayer(player); - Prestige nextPrestige = prestiges.next(prestige); + Prestige prestige = null; + Prestige nextPrestige = null; + if(prestiges != null) { + prestige = prestiges.getByPlayer(player); + nextPrestige = prestiges.next(prestige); + } if (params.startsWith("requirement_")) { String[] parts = params.split("_", 3); diff --git a/src/main/java/sh/okx/rankup/ranks/Rank.java b/src/main/java/sh/okx/rankup/ranks/Rank.java index f6ba8ab..f631e83 100644 --- a/src/main/java/sh/okx/rankup/ranks/Rank.java +++ b/src/main/java/sh/okx/rankup/ranks/Rank.java @@ -11,6 +11,7 @@ import sh.okx.rankup.messages.MessageBuilder; import sh.okx.rankup.requirements.DeductibleRequirement; import sh.okx.rankup.requirements.Operation; import sh.okx.rankup.requirements.Requirement; +import sh.okx.rankup.requirements.operation.AllOperation; import java.util.HashSet; import java.util.List; @@ -39,6 +40,9 @@ public class Rank { if (requirementsSection != null) { requirements = plugin.getRequirementRegistry().getRequirements(requirementsSection); operation = plugin.getOperationRegistry().getOperation(section.getString("operation")); + } else if(section.contains("next")) { + plugin.getLogger().severe("Rank " + section.getName() + " has no requirements."); + return null; } return new Rank(plugin, diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c4a0596..25fb02f 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -5,13 +5,13 @@ version: 1 # /rankup3 reload will not do anything if this is changed, # you will have to restart your server. ranks: true -# in 1.13 you can negate the permission rankup.prestiges -# so the command will not autocomplete +# you can alternatively negate the permission rankup.prestiges +# this will also make the command not autocomplete in 1.13 prestiges: true # whether or not /prestige and /prestiges should be enabled. -# in 1.13 you can negate the permission rankup.prestige -# so the command will not autocomplete +# you can alternatively negate the permission rankup.prestige +# this will also make the command not autocomplete in 1.13 prestige: true # how people should confirm ranking up diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index db1d2b2..6b84cc9 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -57,4 +57,5 @@ prestige: plural: "&cYou must wait {SECONDS_LEFT} more seconds to prestige again." not-high-enough: "&cYou cannot prestige at your rank!" -not-in-ladder: "&cSorry, but we could not find any rankups for the group(s) you are in." \ No newline at end of file +not-in-ladder: "&cSorry, but we could not find any rankups for the group(s) you are in." +invalid-rankup: "Invalid rankup defined in config, please check console." \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index a49e580..15a4841 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: Rankup -version: 3.1.1 +version: 3.1.2 main: sh.okx.rankup.Rankup author: Okx depend: [Vault] @@ -32,7 +32,6 @@ permissions: rankup.checkversion: true rankup.ranks: true rankup.reload: true - rankup.ranks: true rankup.prestige: true rankup.prestiges: true rankup.info: @@ -41,8 +40,6 @@ permissions: default: true rankup.checkversion: default: op - rankup.ranks: - default: true rankup.reload: default: op rankup.ranks: