make group changes world specific
This commit is contained in:
@@ -12,7 +12,7 @@ public class AutoRankup extends BukkitRunnable {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if(player.hasPermission("rankup.auto")) {
|
||||
if (player.hasPermission("rankup.auto")) {
|
||||
if (rankup.checkRankup(player, false)) {
|
||||
rankup.rankup(player);
|
||||
} else if (rankup.getPrestiges() != null && rankup.checkPrestige(player, false)) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class RankList<T extends Rank> {
|
||||
T t = getFirst();
|
||||
do {
|
||||
t = next(t);
|
||||
} while(!t.isLast());
|
||||
} while (!t.isLast());
|
||||
return t;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package sh.okx.rankup;
|
||||
|
||||
import com.gmail.nossr50.datatypes.skills.SkillType;
|
||||
import com.google.common.base.Preconditions;
|
||||
import lombok.Getter;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
@@ -15,7 +14,11 @@ import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import sh.okx.rankup.commands.*;
|
||||
import sh.okx.rankup.commands.InfoCommand;
|
||||
import sh.okx.rankup.commands.PrestigeCommand;
|
||||
import sh.okx.rankup.commands.PrestigesCommand;
|
||||
import sh.okx.rankup.commands.RanksCommand;
|
||||
import sh.okx.rankup.commands.RankupCommand;
|
||||
import sh.okx.rankup.gui.Gui;
|
||||
import sh.okx.rankup.gui.GuiListener;
|
||||
import sh.okx.rankup.messages.EmptyMessageBuilder;
|
||||
@@ -30,22 +33,26 @@ import sh.okx.rankup.ranks.Rankups;
|
||||
import sh.okx.rankup.requirements.OperationRegistry;
|
||||
import sh.okx.rankup.requirements.Requirement;
|
||||
import sh.okx.rankup.requirements.RequirementRegistry;
|
||||
import sh.okx.rankup.requirements.operation.*;
|
||||
import sh.okx.rankup.requirements.requirement.*;
|
||||
import sh.okx.rankup.requirements.requirement.advancedachievements.*;
|
||||
import sh.okx.rankup.requirements.requirement.mcmmo.*;
|
||||
import sh.okx.rankup.requirements.operation.AllOperation;
|
||||
import sh.okx.rankup.requirements.operation.AnyOperation;
|
||||
import sh.okx.rankup.requirements.operation.NoneOperation;
|
||||
import sh.okx.rankup.requirements.operation.OneOperation;
|
||||
import sh.okx.rankup.requirements.requirement.GroupRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.MoneyRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.PermissionRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.PlaceholderRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.PlaytimeMinutesRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.XpLevelRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsAchievementRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.advancedachievements.AdvancedAchievementsTotalRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.mcmmo.McMMOPowerLevelRequirement;
|
||||
import sh.okx.rankup.requirements.requirement.mcmmo.McMMOSkillRequirement;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@@ -318,8 +325,8 @@ public class Rankup extends JavaPlugin {
|
||||
|
||||
oldRank.applyRequirements(player);
|
||||
|
||||
permissions.playerRemoveGroup(null, player, oldRank.getRank());
|
||||
permissions.playerAddGroup(null, player, rank.getRank());
|
||||
permissions.playerRemoveGroup(player, oldRank.getRank());
|
||||
permissions.playerAddGroup(player, rank.getRank());
|
||||
|
||||
getMessage(oldRank, Message.SUCCESS_PUBLIC)
|
||||
.failIfEmpty()
|
||||
@@ -393,12 +400,12 @@ public class Rankup extends JavaPlugin {
|
||||
|
||||
oldPrestige.applyRequirements(player);
|
||||
|
||||
permissions.playerRemoveGroup(null, player, oldPrestige.getFrom());
|
||||
permissions.playerAddGroup(null, player, oldPrestige.getTo());
|
||||
permissions.playerRemoveGroup(player, oldPrestige.getFrom());
|
||||
permissions.playerAddGroup(player, oldPrestige.getTo());
|
||||
if (oldPrestige.getRank() != null) {
|
||||
permissions.playerRemoveGroup(null, player, oldPrestige.getRank());
|
||||
permissions.playerRemoveGroup(player, oldPrestige.getRank());
|
||||
}
|
||||
permissions.playerAddGroup(null, player, prestige.getRank());
|
||||
permissions.playerAddGroup(player, prestige.getRank());
|
||||
|
||||
getMessage(oldPrestige, Message.PRESTIGE_SUCCESS_PUBLIC)
|
||||
.failIfEmpty()
|
||||
|
||||
@@ -21,6 +21,10 @@ public class RankupRegisterEvent extends Event {
|
||||
@Getter
|
||||
private final Rankup plugin;
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public RequirementRegistry getRequirementRegistry() {
|
||||
return plugin.getRequirementRegistry();
|
||||
}
|
||||
@@ -41,8 +45,4 @@ public class RankupRegisterEvent extends Event {
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public class RanksCommand implements CommandExecutor {
|
||||
message = Message.RANKS_INCOMPLETE;
|
||||
} else {
|
||||
// helpful message to say there is a null rankup
|
||||
if(next == null) {
|
||||
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.");
|
||||
|
||||
@@ -36,7 +36,7 @@ public class RankupCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
Rank next = rankups.next(rank);
|
||||
if(next == null) {
|
||||
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);
|
||||
|
||||
@@ -28,7 +28,7 @@ public class GuiListener implements Listener {
|
||||
|
||||
if (gui.getRankup().isSimilar(e.getCurrentItem())) {
|
||||
Bukkit.getScheduler().runTask(plugin, player::closeInventory);
|
||||
if(gui.isPrestige()) {
|
||||
if (gui.isPrestige()) {
|
||||
plugin.prestige(player);
|
||||
} else {
|
||||
plugin.rankup(player);
|
||||
|
||||
@@ -39,11 +39,11 @@ public class MessageBuilder {
|
||||
}
|
||||
|
||||
public MessageBuilder replaceFirstPrestige(Rank rank, Prestiges prestiges, String with) {
|
||||
if(prestiges != null && prestiges.getFirst().equals(rank)) {
|
||||
replace(Variable.OLD_RANK, with);
|
||||
replace(Variable.OLD_RANK_NAME, with);
|
||||
}
|
||||
return this;
|
||||
if (prestiges != null && prestiges.getFirst().equals(rank)) {
|
||||
replace(Variable.OLD_RANK, with);
|
||||
replace(Variable.OLD_RANK_NAME, with);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder replaceRanks(CommandSender player, Rank rank) {
|
||||
@@ -72,7 +72,7 @@ public class MessageBuilder {
|
||||
}
|
||||
|
||||
public MessageBuilder replaceFromTo(Rank rank) {
|
||||
if(rank instanceof Prestige) {
|
||||
if (rank instanceof Prestige) {
|
||||
Prestige prestige = (Prestige) rank;
|
||||
replace(Variable.FROM, prestige.getFrom());
|
||||
replace(Variable.TO, prestige.getTo());
|
||||
|
||||
@@ -2,28 +2,20 @@ package sh.okx.rankup.placeholders;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import sh.okx.rankup.Rankup;
|
||||
import sh.okx.rankup.prestige.Prestige;
|
||||
import sh.okx.rankup.prestige.Prestiges;
|
||||
import sh.okx.rankup.ranks.Rank;
|
||||
import sh.okx.rankup.ranks.Rankups;
|
||||
import sh.okx.rankup.requirements.Requirement;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class Placeholders {
|
||||
private final Rankup plugin;
|
||||
private boolean registered;
|
||||
@Getter
|
||||
private final DecimalFormat moneyFormat;
|
||||
@Getter
|
||||
private final DecimalFormat percentFormat;
|
||||
@Getter
|
||||
private final DecimalFormat simpleFormat;
|
||||
private boolean registered;
|
||||
|
||||
public Placeholders(Rankup plugin) {
|
||||
this.plugin = plugin;
|
||||
@@ -42,7 +34,7 @@ public class Placeholders {
|
||||
}
|
||||
|
||||
public void unregister() {
|
||||
if(registered) {
|
||||
if (registered) {
|
||||
PlaceholderAPI.unregisterPlaceholderHook("rankup");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ public class RankupExpansion extends PlaceholderExpansion {
|
||||
Prestiges prestiges = plugin.getPrestiges();
|
||||
Prestige prestige = null;
|
||||
Prestige nextPrestige = null;
|
||||
if(prestiges != null) {
|
||||
if (prestiges != null) {
|
||||
prestige = prestiges.getByPlayer(player);
|
||||
nextPrestige = prestiges.next(prestige);
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public class Prestige extends Rank {
|
||||
}
|
||||
|
||||
public boolean isEligable(Player player) {
|
||||
String[] groups = plugin.getPermissions().getPlayerGroups(null, player);
|
||||
String[] groups = plugin.getPermissions().getPlayerGroups(player);
|
||||
for (String group : groups) {
|
||||
if (group.equalsIgnoreCase(from)) {
|
||||
return true;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class Prestiges extends RankList<Prestige> {
|
||||
@Override
|
||||
public Prestige getByPlayer(Player player) {
|
||||
Prestige prestige = super.getByPlayer(player);
|
||||
if(prestige == null) {
|
||||
if (prestige == null) {
|
||||
return getFirst();
|
||||
} else {
|
||||
return prestige;
|
||||
|
||||
@@ -11,7 +11,6 @@ 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;
|
||||
@@ -40,7 +39,7 @@ public class Rank {
|
||||
if (requirementsSection != null) {
|
||||
requirements = plugin.getRequirementRegistry().getRequirements(requirementsSection);
|
||||
operation = plugin.getOperationRegistry().getOperation(section.getString("operation"));
|
||||
} else if(section.contains("next")) {
|
||||
} else if (section.contains("next")) {
|
||||
plugin.getLogger().severe("Rank " + section.getName() + " has no requirements.");
|
||||
return null;
|
||||
}
|
||||
@@ -61,7 +60,7 @@ public class Rank {
|
||||
}
|
||||
|
||||
public boolean isIn(Player player) {
|
||||
String[] groups = plugin.getPermissions().getPlayerGroups(null, player);
|
||||
String[] groups = plugin.getPermissions().getPlayerGroups(player);
|
||||
for (String group : groups) {
|
||||
if (group.equalsIgnoreCase(rank)) {
|
||||
return true;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package sh.okx.rankup.requirements;
|
||||
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -23,7 +23,7 @@ public class GroupRequirement extends Requirement {
|
||||
int matched = 0;
|
||||
String[] groups = getValueString().split(" ");
|
||||
for (String requiredGroup : groups) {
|
||||
for (String group : plugin.getPermissions().getPlayerGroups(null, player)) {
|
||||
for (String group : plugin.getPermissions().getPlayerGroups(player)) {
|
||||
if (group.equalsIgnoreCase(requiredGroup)) {
|
||||
matched++;
|
||||
break;
|
||||
|
||||
@@ -22,8 +22,8 @@ public class PermissionRequirement extends Requirement {
|
||||
public double getRemaining(Player player) {
|
||||
int matched = 0;
|
||||
String[] permissions = getValueString().split(" ");
|
||||
for(String permission : permissions) {
|
||||
if(player.hasPermission(permission)) {
|
||||
for (String permission : permissions) {
|
||||
if (player.hasPermission(permission)) {
|
||||
matched++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class PlaceholderRequirement extends Requirement {
|
||||
public boolean check(Player player) {
|
||||
String[] parts = getValueString().split(" ");
|
||||
String parsed = PlaceholderAPI.setPlaceholders(player, parts[0]);
|
||||
if(!PlaceholderAPI.containsPlaceholders(parts[0]) || parsed.equals(parts[0])) {
|
||||
if (!PlaceholderAPI.containsPlaceholders(parts[0]) || parsed.equals(parts[0])) {
|
||||
throw new IllegalArgumentException(parts[0] + " is not a PlaceholderAPI placeholder!");
|
||||
} else if (parts.length < 3) {
|
||||
throw new IllegalArgumentException("Placeholder requirements must be in the form %placeholder% <operation> string");
|
||||
@@ -26,7 +26,7 @@ public class PlaceholderRequirement extends Requirement {
|
||||
String value = parts[2];
|
||||
|
||||
// string operations
|
||||
switch(parts[1]) {
|
||||
switch (parts[1]) {
|
||||
case "=":
|
||||
return parsed.equals(value);
|
||||
}
|
||||
@@ -34,7 +34,7 @@ public class PlaceholderRequirement extends Requirement {
|
||||
// numeric operations
|
||||
double p = Double.parseDouble(parsed);
|
||||
double v = Double.parseDouble(value);
|
||||
switch(parts[1]) {
|
||||
switch (parts[1]) {
|
||||
case ">":
|
||||
return p > v;
|
||||
case ">=":
|
||||
|
||||
Reference in New Issue
Block a user