3.1 prestiging improvements
This commit is contained in:
+1
-1
@@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'sh.okx'
|
group 'sh.okx'
|
||||||
version '3.0.2'
|
version '3.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class RankList<T extends Rank> {
|
|||||||
protected final FileConfiguration config;
|
protected final FileConfiguration config;
|
||||||
protected final Set<T> ranks = new HashSet<>();
|
protected final Set<T> ranks = new HashSet<>();
|
||||||
|
|
||||||
public RankList(Rankup plugin, FileConfiguration config, Function<ConfigurationSection, T> deserializer) {
|
public RankList(FileConfiguration config, Function<ConfigurationSection, T> deserializer) {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
for (Map.Entry<String, Object> entry : config.getValues(false).entrySet()) {
|
for (Map.Entry<String, Object> entry : config.getValues(false).entrySet()) {
|
||||||
ConfigurationSection rankSection = (ConfigurationSection) entry.getValue();
|
ConfigurationSection rankSection = (ConfigurationSection) entry.getValue();
|
||||||
|
|||||||
@@ -58,9 +58,9 @@ public class Rankup extends JavaPlugin {
|
|||||||
* The registry for listing the requirements to /rankup.
|
* The registry for listing the requirements to /rankup.
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private RequirementRegistry requirementRegistry = new RequirementRegistry();
|
private RequirementRegistry requirementRegistry;
|
||||||
@Getter
|
@Getter
|
||||||
private OperationRegistry operationRegistry = new OperationRegistry();
|
private OperationRegistry operationRegistry;
|
||||||
@Getter
|
@Getter
|
||||||
private FileConfiguration messages;
|
private FileConfiguration messages;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -78,7 +78,6 @@ public class Rankup extends JavaPlugin {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
registerRequirements();
|
|
||||||
setupPermissions();
|
setupPermissions();
|
||||||
setupEconomy();
|
setupEconomy();
|
||||||
reload();
|
reload();
|
||||||
@@ -121,10 +120,10 @@ public class Rankup extends JavaPlugin {
|
|||||||
closeInventories();
|
closeInventories();
|
||||||
loadConfigs();
|
loadConfigs();
|
||||||
|
|
||||||
if (config.getInt("version") != 0) {
|
if (config.getInt("version") < 1) {
|
||||||
getLogger().severe("You are using an outdated config!");
|
getLogger().severe("You are using an outdated config!");
|
||||||
getLogger().severe("This means that some things might not work!");
|
getLogger().severe("This means that some things might not work!");
|
||||||
getLogger().severe("To update, please rename your config files (or the folder they are in),");
|
getLogger().severe("To update, please rename ALL your config files (or the folder they are in),");
|
||||||
getLogger().severe("and run /rankup3 reload to generate a new config file.");
|
getLogger().severe("and run /rankup3 reload to generate a new config file.");
|
||||||
getLogger().severe("If that does not work, restart your server.");
|
getLogger().severe("If that does not work, restart your server.");
|
||||||
getLogger().severe("You may then copy in your config values from the old config.");
|
getLogger().severe("You may then copy in your config values from the old config.");
|
||||||
@@ -150,6 +149,11 @@ public class Rankup extends JavaPlugin {
|
|||||||
private void loadConfigs() {
|
private void loadConfigs() {
|
||||||
messages = loadConfig("messages.yml");
|
messages = loadConfig("messages.yml");
|
||||||
config = loadConfig("config.yml");
|
config = loadConfig("config.yml");
|
||||||
|
refreshRanks();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void refreshRanks() {
|
||||||
|
registerRequirements();
|
||||||
rankups = new Rankups(this, loadConfig("rankups.yml"));
|
rankups = new Rankups(this, loadConfig("rankups.yml"));
|
||||||
if(config.getBoolean("prestige")) {
|
if(config.getBoolean("prestige")) {
|
||||||
prestiges = new Prestiges(this, loadConfig("prestiges.yml"));
|
prestiges = new Prestiges(this, loadConfig("prestiges.yml"));
|
||||||
@@ -165,16 +169,20 @@ public class Rankup extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void registerRequirements() {
|
private void registerRequirements() {
|
||||||
|
requirementRegistry = new RequirementRegistry();
|
||||||
requirementRegistry.addRequirement(new MoneyRequirement(this));
|
requirementRegistry.addRequirement(new MoneyRequirement(this));
|
||||||
requirementRegistry.addRequirement(new XpLevelRequirement(this));
|
requirementRegistry.addRequirement(new XpLevelRequirement(this));
|
||||||
requirementRegistry.addRequirement(new PlaytimeMinutesRequirement(this));
|
requirementRegistry.addRequirement(new PlaytimeMinutesRequirement(this));
|
||||||
requirementRegistry.addRequirement(new GroupRequirement(this));
|
requirementRegistry.addRequirement(new GroupRequirement(this));
|
||||||
requirementRegistry.addRequirement(new PermissionRequirement(this));
|
requirementRegistry.addRequirement(new PermissionRequirement(this));
|
||||||
|
|
||||||
|
operationRegistry = new OperationRegistry();
|
||||||
operationRegistry.addOperation("all", new AllOperation());
|
operationRegistry.addOperation("all", new AllOperation());
|
||||||
operationRegistry.addOperation("none", new NoneOperation());
|
operationRegistry.addOperation("none", new NoneOperation());
|
||||||
operationRegistry.addOperation("one", new OneOperation());
|
operationRegistry.addOperation("one", new OneOperation());
|
||||||
operationRegistry.addOperation("any", new AnyOperation());
|
operationRegistry.addOperation("any", new AnyOperation());
|
||||||
|
|
||||||
|
Bukkit.getPluginManager().callEvent(new RankupRegisterEvent(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupPermissions() {
|
private void setupPermissions() {
|
||||||
@@ -330,12 +338,12 @@ public class Rankup extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
permissions.playerAddGroup(null, player, prestige.getRank());
|
permissions.playerAddGroup(null, player, prestige.getRank());
|
||||||
|
|
||||||
getMessage(oldPrestige, Message.SUCCESS_PUBLIC)
|
getMessage(oldPrestige, Message.PRESTIGE_SUCCESS_PUBLIC)
|
||||||
.failIfEmpty()
|
.failIfEmpty()
|
||||||
.replaceRanks(player, oldPrestige, prestige)
|
.replaceRanks(player, oldPrestige, prestige)
|
||||||
.replaceFromTo(oldPrestige)
|
.replaceFromTo(oldPrestige)
|
||||||
.broadcast();
|
.broadcast();
|
||||||
getMessage(oldPrestige, Message.SUCCESS_PRIVATE)
|
getMessage(oldPrestige, Message.PRESTIGE_SUCCESS_PRIVATE)
|
||||||
.failIfEmpty()
|
.failIfEmpty()
|
||||||
.replaceRanks(player, oldPrestige, prestige)
|
.replaceRanks(player, oldPrestige, prestige)
|
||||||
.replaceFromTo(oldPrestige)
|
.replaceFromTo(oldPrestige)
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package sh.okx.rankup;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import sh.okx.rankup.requirements.OperationRegistry;
|
||||||
|
import sh.okx.rankup.requirements.RequirementRegistry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called immediately before rankups and prestiges are registered,
|
||||||
|
* and immediately after the built-in requirements and operations are registered.
|
||||||
|
* This is used to register custom requirements.
|
||||||
|
* This is called when the plugin is enabled, and when it is reloaded from a command.
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RankupRegisterEvent extends Event {
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
@Getter
|
||||||
|
private final Rankup plugin;
|
||||||
|
|
||||||
|
public RequirementRegistry getRequirementRegistry() {
|
||||||
|
return plugin.getRequirementRegistry();
|
||||||
|
}
|
||||||
|
|
||||||
|
public OperationRegistry getOperationRegistry() {
|
||||||
|
return plugin.getOperationRegistry();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -47,7 +47,7 @@ public class PrestigeCommand implements CommandExecutor {
|
|||||||
switch (confirmationType) {
|
switch (confirmationType) {
|
||||||
case "text":
|
case "text":
|
||||||
confirming.put(player, System.currentTimeMillis());
|
confirming.put(player, System.currentTimeMillis());
|
||||||
plugin.replaceMoneyRequirements(plugin.getMessage(prestige, Message.CONFIRMATION)
|
plugin.replaceMoneyRequirements(plugin.getMessage(prestige, Message.PRESTIGE_CONFIRMATION)
|
||||||
.replaceRanks(player, prestige, prestiges.next(prestige)), player, prestige)
|
.replaceRanks(player, prestige, prestiges.next(prestige)), player, prestige)
|
||||||
.replaceFromTo(prestige)
|
.replaceFromTo(prestige)
|
||||||
.send(player);
|
.send(player);
|
||||||
|
|||||||
@@ -24,7 +24,10 @@ public enum Message {
|
|||||||
COOLDOWN_SINGULAR("rankup.cooldown.singular"),
|
COOLDOWN_SINGULAR("rankup.cooldown.singular"),
|
||||||
COOLDOWN_PLURAL("rankup.cooldown.plural"),
|
COOLDOWN_PLURAL("rankup.cooldown.plural"),
|
||||||
MUST_PRESTIGE("rankup.must-prestige"),
|
MUST_PRESTIGE("rankup.must-prestige"),
|
||||||
NOT_HIGH_ENOUGH("prestige.not-high-enough");
|
NOT_HIGH_ENOUGH("not-high-enough"),
|
||||||
|
PRESTIGE_SUCCESS_PUBLIC("prestige.success-public"),
|
||||||
|
PRESTIGE_SUCCESS_PRIVATE("prestige.success-private"),
|
||||||
|
PRESTIGE_CONFIRMATION("prestige.confirmation");
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|||||||
@@ -57,6 +57,10 @@ public class RankupExpansion extends PlaceholderExpansion {
|
|||||||
return orElsePlaceholder(nextPrestige, Prestige::getRank, "highest-rank");
|
return orElsePlaceholder(nextPrestige, Prestige::getRank, "highest-rank");
|
||||||
case "next_prestige_name":
|
case "next_prestige_name":
|
||||||
return orElsePlaceholder(nextPrestige, Prestige::getName, "highest-rank");
|
return orElsePlaceholder(nextPrestige, Prestige::getName, "highest-rank");
|
||||||
|
case "prestige_money":
|
||||||
|
return String.valueOf(simplify(orElse(prestige, r -> r.isEligable(player) ? r.getRequirement("money").getValueDouble() : 0, 0)));
|
||||||
|
case "prestige_money_formatted":
|
||||||
|
return plugin.formatMoney(orElse(prestige, r -> r.isEligable(player) ? r.getRequirement("money").getValueDouble() : 0, 0D));
|
||||||
case "current_rank":
|
case "current_rank":
|
||||||
return orElsePlaceholder(rank, Rank::getRank, "not-in-ladder");
|
return orElsePlaceholder(rank, Rank::getRank, "not-in-ladder");
|
||||||
case "current_rank_name":
|
case "current_rank_name":
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import sh.okx.rankup.Rankup;
|
|||||||
|
|
||||||
public class Prestiges extends RankList<Prestige> {
|
public class Prestiges extends RankList<Prestige> {
|
||||||
public Prestiges(Rankup plugin, FileConfiguration config) {
|
public Prestiges(Rankup plugin, FileConfiguration config) {
|
||||||
super(plugin, config, section -> Prestige.deserialize(plugin, section));
|
super(config, section -> Prestige.deserialize(plugin, section));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -6,6 +6,6 @@ import sh.okx.rankup.Rankup;
|
|||||||
|
|
||||||
public class Rankups extends RankList<Rank> {
|
public class Rankups extends RankList<Rank> {
|
||||||
public Rankups(Rankup plugin, FileConfiguration config) {
|
public Rankups(Rankup plugin, FileConfiguration config) {
|
||||||
super(plugin, config, section -> Rank.deserialize(plugin, section));
|
super(config, section -> Rank.deserialize(plugin, section));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
# this is used for letting you know that you need to update/change your config file
|
# this is used for letting you know that you need to update/change your config file
|
||||||
version: 0
|
version: 1
|
||||||
|
|
||||||
# whether /ranks and /prestiges should be enabled (true) or disabled (false)
|
# whether /ranks and /prestiges should be enabled (true) or disabled (false)
|
||||||
# /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
|
||||||
|
# so the command will not autocomplete
|
||||||
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
|
||||||
|
# so the command will not autocomplete
|
||||||
prestige: true
|
prestige: true
|
||||||
|
|
||||||
# how people should confirm ranking up
|
# how people should confirm ranking up
|
||||||
|
|||||||
@@ -38,7 +38,14 @@ rankup:
|
|||||||
plural: "&cYou must wait {SECONDS_LEFT} more seconds to rankup again."
|
plural: "&cYou must wait {SECONDS_LEFT} more seconds to rankup again."
|
||||||
# prestige messages can also be customised
|
# prestige messages can also be customised
|
||||||
prestige:
|
prestige:
|
||||||
|
success-public: "&a{PLAYER} &ehas prestiged to: &d{RANK}"
|
||||||
|
success-private: "&aYou have prestiged to: &d{RANK}"
|
||||||
|
|
||||||
|
confirmation: |-
|
||||||
|
&eAre you sure you want to prestige to &a{RANK}&e?
|
||||||
|
&eType &c/prestige &eagain to confirm.
|
||||||
title: "Prestige to {RANK}"
|
title: "Prestige to {RANK}"
|
||||||
|
|
||||||
list:
|
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}"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
name: Rankup
|
name: Rankup
|
||||||
version: 3.0.2
|
version: 3.1
|
||||||
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