improve prestige customisation
add prestiges section of messages.yml add prestige gui title add first rank for prestiges
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'sh.okx'
|
group 'sh.okx'
|
||||||
version '3.0-alpha.21'
|
version '3.0-alpha.22'
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
|
|
||||||
|
|||||||
@@ -210,7 +210,7 @@ public class Rankup extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public MessageBuilder getMessage(Rank rank, Message message) {
|
public MessageBuilder getMessage(Rank rank, Message message) {
|
||||||
ConfigurationSection messages = rankups.getConfig()
|
ConfigurationSection messages = (rank instanceof Prestige ? prestiges : rankups).getConfig()
|
||||||
.getConfigurationSection(rank.getName());
|
.getConfigurationSection(rank.getName());
|
||||||
if (messages == null || !messages.isSet(message.getName())) {
|
if (messages == null || !messages.isSet(message.getName())) {
|
||||||
messages = this.messages;
|
messages = this.messages;
|
||||||
@@ -298,8 +298,7 @@ public class Rankup extends JavaPlugin {
|
|||||||
getMessage(rank, Message.NO_RANKUP);
|
getMessage(rank, Message.NO_RANKUP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
getMessage(rank, prestiges == null ? Message.NO_RANKUP :
|
getMessage(rank, prestiges == null ? Message.NO_RANKUP : prestiges.getByPlayer(player).isLast() ? Message.NO_RANKUP : Message.MUST_PRESTIGE)
|
||||||
prestiges.getByPlayer(player).isLast() ? Message.NO_RANKUP : Message.MUST_PRESTIGE)
|
|
||||||
.replaceRanks(player, rank)
|
.replaceRanks(player, rank)
|
||||||
.send(player);
|
.send(player);
|
||||||
return false;
|
return false;
|
||||||
@@ -398,8 +397,10 @@ public class Rankup extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
replaceRequirements(builder, Variable.AMOUNT, requirement, () -> simpleFormat.format(requirement.getValueDouble()));
|
replaceRequirements(builder, Variable.AMOUNT, requirement, () -> simpleFormat.format(requirement.getValueDouble()));
|
||||||
replaceRequirements(builder, Variable.AMOUNT_NEEDED, requirement, () -> simpleFormat.format(requirement.getRemaining(player)));
|
replaceRequirements(builder, Variable.AMOUNT_NEEDED, requirement, () -> simpleFormat.format(requirement.getRemaining(player)));
|
||||||
replaceRequirements(builder, Variable.PERCENT_LEFT, requirement, () -> percentFormat.format(Math.max(0, (requirement.getRemaining(player) / requirement.getValueDouble()) * 100)));
|
replaceRequirements(builder, Variable.PERCENT_LEFT, requirement,
|
||||||
replaceRequirements(builder, Variable.PERCENT_DONE, requirement, () -> percentFormat.format(Math.min(100, (1 - (requirement.getRemaining(player) / requirement.getValueDouble())) * 100)));
|
() -> percentFormat.format(Math.max(0, (requirement.getRemaining(player) / requirement.getValueDouble()) * 100)));
|
||||||
|
replaceRequirements(builder, Variable.PERCENT_DONE, requirement,
|
||||||
|
() -> percentFormat.format(Math.min(100, (1 - (requirement.getRemaining(player) / requirement.getValueDouble())) * 100)));
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -412,6 +413,7 @@ public class Rankup extends JavaPlugin {
|
|||||||
|
|
||||||
public void sendMessage(CommandSender player, Message message, Rank oldRank, Rank rank) {
|
public void sendMessage(CommandSender player, Message message, Rank oldRank, Rank rank) {
|
||||||
replaceMoneyRequirements(getMessage(oldRank, message)
|
replaceMoneyRequirements(getMessage(oldRank, message)
|
||||||
|
.replaceFirstPrestige(oldRank, prestiges, config.getString("placeholders.first-prestige-rank"))
|
||||||
.replaceRanks(player, oldRank, rank), player, oldRank)
|
.replaceRanks(player, oldRank, rank), player, oldRank)
|
||||||
.replaceFromTo(oldRank)
|
.replaceFromTo(oldRank)
|
||||||
.send(player);
|
.send(player);
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import sh.okx.rankup.Rankup;
|
|||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
import sh.okx.rankup.prestige.Prestiges;
|
import sh.okx.rankup.prestige.Prestiges;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PrestigesCommand implements CommandExecutor {
|
public class PrestigesCommand implements CommandExecutor {
|
||||||
@@ -27,8 +26,6 @@ public class PrestigesCommand implements CommandExecutor {
|
|||||||
|
|
||||||
Message message = playerRank == null ? Message.PRESTIGES_INCOMPLETE : Message.PRESTIGES_COMPLETE;
|
Message message = playerRank == null ? Message.PRESTIGES_INCOMPLETE : Message.PRESTIGES_COMPLETE;
|
||||||
Prestige prestige = prestiges.getFirst();
|
Prestige prestige = prestiges.getFirst();
|
||||||
if(!prestige.isLast()) {
|
|
||||||
prestige = prestiges.next(prestige);
|
|
||||||
while (!prestige.isLast()) {
|
while (!prestige.isLast()) {
|
||||||
Prestige next = prestiges.next(prestige);
|
Prestige next = prestiges.next(prestige);
|
||||||
if (prestige.equals(playerRank)) {
|
if (prestige.equals(playerRank)) {
|
||||||
@@ -39,7 +36,6 @@ public class PrestigesCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
prestige = next;
|
prestige = next;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
plugin.sendHeaderFooter(sender, playerRank, Message.PRESTIGES_FOOTER);
|
plugin.sendHeaderFooter(sender, playerRank, Message.PRESTIGES_FOOTER);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class Gui implements InventoryHolder {
|
|||||||
gui.cancel = getItem(config.getConfigurationSection("cancel"), player, oldRank, rank);
|
gui.cancel = getItem(config.getConfigurationSection("cancel"), player, oldRank, rank);
|
||||||
|
|
||||||
Inventory inventory = Bukkit.createInventory(gui, items.length,
|
Inventory inventory = Bukkit.createInventory(gui, items.length,
|
||||||
plugin.getMessage(rank, Message.TITLE)
|
plugin.getMessage(oldRank, gui.prestige ? Message.PRESTIGE_TITLE : Message.TITLE)
|
||||||
.replaceRanks(player, oldRank, rank)
|
.replaceRanks(player, oldRank, rank)
|
||||||
.replaceFromTo(oldRank)
|
.replaceFromTo(oldRank)
|
||||||
.toString());
|
.toString());
|
||||||
|
|||||||
@@ -10,20 +10,21 @@ public enum Message {
|
|||||||
SUCCESS_PRIVATE("rankup.success-private"),
|
SUCCESS_PRIVATE("rankup.success-private"),
|
||||||
CONFIRMATION("rankup.confirmation"),
|
CONFIRMATION("rankup.confirmation"),
|
||||||
TITLE("rankup.title"),
|
TITLE("rankup.title"),
|
||||||
RANKS_HEADER("rankup.ranks.header"),
|
RANKS_HEADER("rankup.list.header"),
|
||||||
RANKS_FOOTER("rankup.ranks.footer"),
|
RANKS_FOOTER("rankup.list.footer"),
|
||||||
RANKS_COMPLETE("rankup.ranks.complete"),
|
RANKS_COMPLETE("rankup.list.complete"),
|
||||||
RANKS_CURRENT("rankup.ranks.current"),
|
RANKS_CURRENT("rankup.list.current"),
|
||||||
RANKS_INCOMPLETE("rankup.ranks.incomplete"),
|
RANKS_INCOMPLETE("rankup.list.incomplete"),
|
||||||
PRESTIGES_HEADER("rankup.prestiges.header"),
|
PRESTIGES_HEADER("prestige.list.header"),
|
||||||
PRESTIGES_FOOTER("rankup.prestiges.footer"),
|
PRESTIGES_FOOTER("prestige.list.footer"),
|
||||||
PRESTIGES_COMPLETE("rankup.prestiges.complete"),
|
PRESTIGES_COMPLETE("prestige.list.complete"),
|
||||||
PRESTIGES_CURRENT("rankup.prestiges.current"),
|
PRESTIGES_CURRENT("prestige.list.current"),
|
||||||
PRESTIGES_INCOMPLETE("rankup.prestiges.incomplete"),
|
PRESTIGES_INCOMPLETE("prestige.list.incomplete"),
|
||||||
|
PRESTIGE_TITLE("prestige.title"),
|
||||||
COOLDOWN_SINGULAR("rankup.cooldown.singular"),
|
COOLDOWN_SINGULAR("rankup.cooldown.singular"),
|
||||||
COOLDOWN_PLURAL("rankup.cooldown.plural"),
|
COOLDOWN_PLURAL("rankup.cooldown.plural"),
|
||||||
NOT_HIGH_ENOUGH("rankup.not-high-enough"),
|
MUST_PRESTIGE("rankup.must-prestige"),
|
||||||
MUST_PRESTIGE("rankup.must-prestige");
|
NOT_HIGH_ENOUGH("prestige.not-high-enough");
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
|
import sh.okx.rankup.prestige.Prestiges;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
@@ -19,7 +20,11 @@ public class MessageBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static MessageBuilder of(ConfigurationSection config, Message message) {
|
public static MessageBuilder of(ConfigurationSection config, Message message) {
|
||||||
return new MessageBuilder(ChatColor.translateAlternateColorCodes('&', config.getString(message.getName())));
|
return MessageBuilder.of(config, message.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MessageBuilder of(ConfigurationSection config, String message) {
|
||||||
|
return new MessageBuilder(ChatColor.translateAlternateColorCodes('&', config.getString(message)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageBuilder replace(Variable variable, Object value) {
|
public MessageBuilder replace(Variable variable, Object value) {
|
||||||
@@ -33,6 +38,14 @@ public class MessageBuilder {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MessageBuilder replaceFirstPrestige(Rank rank, Prestiges prestiges, String with) {
|
||||||
|
if(prestiges.getFirst().equals(rank)) {
|
||||||
|
replace(Variable.OLD_RANK, with);
|
||||||
|
replace(Variable.OLD_RANK_NAME, with);
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public MessageBuilder replaceRanks(CommandSender player, Rank rank) {
|
public MessageBuilder replaceRanks(CommandSender player, Rank rank) {
|
||||||
replace(Variable.PLAYER, player.getName());
|
replace(Variable.PLAYER, player.getName());
|
||||||
replaceRanks(rank);
|
replaceRanks(rank);
|
||||||
|
|||||||
@@ -12,9 +12,11 @@ public class Prestiges extends RankList<Prestige> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Prestige getByPlayer(Player player) {
|
public Prestige getByPlayer(Player player) {
|
||||||
return ranks.stream()
|
Prestige prestige = super.getByPlayer(player);
|
||||||
.filter(rank -> rank.isIn(player))
|
if(prestige == null) {
|
||||||
.findFirst()
|
return getFirst();
|
||||||
.orElseGet(this::getFirst);
|
} else {
|
||||||
|
return prestige;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,8 @@ placeholders:
|
|||||||
not-in-ladder: "None"
|
not-in-ladder: "None"
|
||||||
# used in next_rank placeholders when there is no rankup
|
# used in next_rank placeholders when there is no rankup
|
||||||
highest-rank: "None"
|
highest-rank: "None"
|
||||||
|
# used in /prestiges as the {OLD_RANK} placeholder for the first prestige rank
|
||||||
|
first-prestige-rank: 'D'
|
||||||
|
|
||||||
# what to shorten money by.
|
# what to shorten money by.
|
||||||
# ie 1000 -> 1k
|
# ie 1000 -> 1k
|
||||||
|
|||||||
@@ -13,7 +13,6 @@ rankup:
|
|||||||
# used for the GUI confirmation
|
# used for the GUI confirmation
|
||||||
title: "Rankup to {RANK}"
|
title: "Rankup to {RANK}"
|
||||||
|
|
||||||
not-high-enough: "&cYou cannot prestige at your rank!"
|
|
||||||
must-prestige: "&cYou must prestige to /rankup further!"
|
must-prestige: "&cYou must prestige to /rankup further!"
|
||||||
|
|
||||||
# you can (and probably should) you override these in rankups.yml
|
# you can (and probably should) you override these in rankups.yml
|
||||||
@@ -22,26 +21,33 @@ rankup:
|
|||||||
# {MONEY} {MONEY_NEEDED} {PERCENT_DONE <requirement>} {PERCENT_LEFT <requirement>} {AMOUNT <requirement>} {AMOUNT_NEEDED <requirement>}
|
# {MONEY} {MONEY_NEEDED} {PERCENT_DONE <requirement>} {PERCENT_LEFT <requirement>} {AMOUNT <requirement>} {AMOUNT_NEEDED <requirement>}
|
||||||
# {MONEY} and {MONEY_NEEDED} are different from {AMOUNT money} and {AMOUNT_NEEDED money} in that they use a different format.
|
# {MONEY} and {MONEY_NEEDED} are different from {AMOUNT money} and {AMOUNT_NEEDED money} in that they use a different format.
|
||||||
# here is an example of showing the requirements for just money:
|
# here is an example of showing the requirements for just money:
|
||||||
#ranks:
|
#list:
|
||||||
# complete: "&7{OLD_RANK} &8\xbb &7{RANK} &efor &7${MONEY}"
|
# complete: "&7{OLD_RANK} &8\xbb &7{RANK} &efor &7${MONEY}"
|
||||||
# current: "&c{OLD_RANK} &e\xbb &c{RANK} &efor &a${MONEY} &e{PERCENT_DONE money}%"
|
# current: "&c{OLD_RANK} &e\xbb &c{RANK} &efor &a${MONEY} &e{PERCENT_DONE money}%"
|
||||||
# incomplete: "&r{OLD_RANK} &e\xbb &r{RANK} &efor &a${MONEY}"
|
# incomplete: "&r{OLD_RANK} &e\xbb &r{RANK} &efor &a${MONEY}"
|
||||||
ranks:
|
list:
|
||||||
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
||||||
current: "&c{OLD_RANK} &e\xbb &c{RANK}"
|
current: "&c{OLD_RANK} &e\xbb &c{RANK}"
|
||||||
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK}"
|
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK}"
|
||||||
# an empty string disables the header/footer
|
# an empty string disables the header/footer
|
||||||
header: ''
|
header: ""
|
||||||
footer: ''
|
footer: ""
|
||||||
prestiges:
|
# sent when a player tries to rankup when they are on cooldown
|
||||||
|
cooldown:
|
||||||
|
singular: "&cYou must wait {SECONDS_LEFT} more second to rankup again."
|
||||||
|
plural: "&cYou must wait {SECONDS_LEFT} more seconds to rankup again."
|
||||||
|
# prestige messages can also be customised
|
||||||
|
prestige:
|
||||||
|
title: "Prestige to {RANK}"
|
||||||
|
list:
|
||||||
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
||||||
current: "&c{OLD_RANK} &e\xbb &c{RANK}"
|
current: "&c{OLD_RANK} &e\xbb &c{RANK}"
|
||||||
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK}"
|
incomplete: "&r{OLD_RANK} &e\xbb &r{RANK}"
|
||||||
header: ''
|
header: ""
|
||||||
footer: ''
|
footer: ""
|
||||||
# sent when a player tries to rankup when they are on cooldown
|
|
||||||
cooldown:
|
cooldown:
|
||||||
singular: '&cYou must wait {SECONDS_LEFT} more second to rankup again.'
|
singular: "&cYou must wait {SECONDS_LEFT} second to prestige again."
|
||||||
plural: '&cYou must wait {SECONDS_LEFT} more seconds to rankup again.'
|
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."
|
not-in-ladder: "&cSorry, but we could not find any rankups for the group(s) you are in."
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
name: Rankup
|
name: Rankup
|
||||||
version: 3.0-alpha.21
|
version: 3.0-alpha.22
|
||||||
main: sh.okx.rankup.Rankup
|
main: sh.okx.rankup.Rankup
|
||||||
author: Okx
|
author: Okx
|
||||||
depend: [Vault]
|
depend: [Vault]
|
||||||
|
|||||||
Reference in New Issue
Block a user