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
This commit is contained in:
okx-code
2018-10-03 15:43:55 +01:00
parent cad5280006
commit ae52d94fe8
9 changed files with 36 additions and 15 deletions
+1 -1
View File
@@ -4,7 +4,7 @@ plugins {
} }
group 'sh.okx' group 'sh.okx'
version '3.1.1' version '3.1.2'
repositories { repositories {
mavenCentral() mavenCentral()
@@ -32,6 +32,14 @@ public class RanksCommand implements CommandExecutor {
plugin.sendMessage(sender, Message.RANKS_CURRENT, rank, next); plugin.sendMessage(sender, Message.RANKS_CURRENT, rank, next);
message = Message.RANKS_INCOMPLETE; message = Message.RANKS_INCOMPLETE;
} else { } 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); plugin.sendMessage(sender, message, rank, next);
} }
rank = next; rank = next;
@@ -32,8 +32,14 @@ public class RankupCommand implements CommandExecutor {
Rankups rankups = plugin.getRankups(); Rankups rankups = plugin.getRankups();
Rank rank = rankups.getByPlayer(player); Rank rank = rankups.getByPlayer(player);
Rank next = rankups.next(rank);
if (!plugin.checkRankup(player)) { if (!plugin.checkRankup(player)) {
return true; 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(); FileConfiguration config = plugin.getConfig();
@@ -52,11 +58,11 @@ public class RankupCommand implements CommandExecutor {
case "text": case "text":
confirming.put(player, System.currentTimeMillis()); confirming.put(player, System.currentTimeMillis());
plugin.replaceMoneyRequirements(plugin.getMessage(rank, Message.CONFIRMATION) plugin.replaceMoneyRequirements(plugin.getMessage(rank, Message.CONFIRMATION)
.replaceRanks(player, rank, rankups.next(rank)), player, rank) .replaceRanks(player, rank, next), player, rank)
.send(player); .send(player);
break; break;
case "gui": case "gui":
Gui.of(player, rank, rankups.next(rank), plugin).open(player); Gui.of(player, rank, next, plugin).open(player);
break; break;
case "none": case "none":
plugin.rankup(player); plugin.rankup(player);
@@ -27,7 +27,8 @@ public enum Message {
NOT_HIGH_ENOUGH("not-high-enough"), NOT_HIGH_ENOUGH("not-high-enough"),
PRESTIGE_SUCCESS_PUBLIC("prestige.success-public"), PRESTIGE_SUCCESS_PUBLIC("prestige.success-public"),
PRESTIGE_SUCCESS_PRIVATE("prestige.success-private"), PRESTIGE_SUCCESS_PRIVATE("prestige.success-private"),
PRESTIGE_CONFIRMATION("prestige.confirmation"); PRESTIGE_CONFIRMATION("prestige.confirmation"),
INVALID_RANKUP("invalid-rankup");
@Getter @Getter
private final String name; private final String name;
@@ -29,8 +29,12 @@ public class RankupExpansion extends PlaceholderExpansion {
Rank nextRank = rank == null ? null : rankups.next(rank); Rank nextRank = rank == null ? null : rankups.next(rank);
Prestiges prestiges = plugin.getPrestiges(); Prestiges prestiges = plugin.getPrestiges();
Prestige prestige = prestiges.getByPlayer(player); Prestige prestige = null;
Prestige nextPrestige = prestiges.next(prestige); Prestige nextPrestige = null;
if(prestiges != null) {
prestige = prestiges.getByPlayer(player);
nextPrestige = prestiges.next(prestige);
}
if (params.startsWith("requirement_")) { if (params.startsWith("requirement_")) {
String[] parts = params.split("_", 3); String[] parts = params.split("_", 3);
@@ -11,6 +11,7 @@ import sh.okx.rankup.messages.MessageBuilder;
import sh.okx.rankup.requirements.DeductibleRequirement; import sh.okx.rankup.requirements.DeductibleRequirement;
import sh.okx.rankup.requirements.Operation; import sh.okx.rankup.requirements.Operation;
import sh.okx.rankup.requirements.Requirement; import sh.okx.rankup.requirements.Requirement;
import sh.okx.rankup.requirements.operation.AllOperation;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@@ -39,6 +40,9 @@ public class Rank {
if (requirementsSection != null) { if (requirementsSection != null) {
requirements = plugin.getRequirementRegistry().getRequirements(requirementsSection); requirements = plugin.getRequirementRegistry().getRequirements(requirementsSection);
operation = plugin.getOperationRegistry().getOperation(section.getString("operation")); 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, return new Rank(plugin,
+4 -4
View File
@@ -5,13 +5,13 @@ version: 1
# /rankup3 reload will not do anything if this is changed, # /rankup3 reload will not do anything if this is changed,
# you will have to restart your server. # you will have to restart your server.
ranks: true ranks: true
# in 1.13 you can negate the permission rankup.prestiges # you can alternatively negate the permission rankup.prestiges
# so the command will not autocomplete # this will also make the command not autocomplete in 1.13
prestiges: true prestiges: true
# whether or not /prestige and /prestiges should be enabled. # whether or not /prestige and /prestiges should be enabled.
# in 1.13 you can negate the permission rankup.prestige # you can alternatively negate the permission rankup.prestige
# so the command will not autocomplete # this will also make the command not autocomplete in 1.13
prestige: true prestige: true
# how people should confirm ranking up # how people should confirm ranking up
+1
View File
@@ -58,3 +58,4 @@ prestige:
not-high-enough: "&cYou cannot prestige at your rank!" 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." 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."
+1 -4
View File
@@ -1,5 +1,5 @@
name: Rankup name: Rankup
version: 3.1.1 version: 3.1.2
main: sh.okx.rankup.Rankup main: sh.okx.rankup.Rankup
author: Okx author: Okx
depend: [Vault] depend: [Vault]
@@ -32,7 +32,6 @@ permissions:
rankup.checkversion: true rankup.checkversion: true
rankup.ranks: true rankup.ranks: true
rankup.reload: true rankup.reload: true
rankup.ranks: true
rankup.prestige: true rankup.prestige: true
rankup.prestiges: true rankup.prestiges: true
rankup.info: rankup.info:
@@ -41,8 +40,6 @@ permissions:
default: true default: true
rankup.checkversion: rankup.checkversion:
default: op default: op
rankup.ranks:
default: true
rankup.reload: rankup.reload:
default: op default: op
rankup.ranks: rankup.ranks: