3.8.2
This commit is contained in:
+3
-3
@@ -1,10 +1,10 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id "io.freefair.lombok" version "4.1.6"
|
id "io.freefair.lombok" version "5.0.1"
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'sh.okx'
|
group 'sh.okx'
|
||||||
version '3.8.1'
|
version '3.8.2'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -27,7 +27,7 @@ repositories {
|
|||||||
dependencies {
|
dependencies {
|
||||||
testImplementation group: 'junit', name: 'junit', version: '4.12'
|
testImplementation group: 'junit', name: 'junit', version: '4.12'
|
||||||
compileOnly 'org.jetbrains:annotations:16.0.2'
|
compileOnly 'org.jetbrains:annotations:16.0.2'
|
||||||
implementation 'org.spigotmc:spigot:1.15.2-R0.1-SNAPSHOT'
|
implementation 'org.spigotmc:spigot-api:1.15.2-R0.1-SNAPSHOT'
|
||||||
implementation('com.github.Realizedd:TokenManager:3.2.4') {
|
implementation('com.github.Realizedd:TokenManager:3.2.4') {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package sh.okx.rankup;
|
package sh.okx.rankup;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -17,7 +18,7 @@ public class RankList<T extends Rank> {
|
|||||||
protected final RankupPlugin plugin;
|
protected final RankupPlugin plugin;
|
||||||
@Getter
|
@Getter
|
||||||
protected final FileConfiguration config;
|
protected final FileConfiguration config;
|
||||||
protected final Set<T> ranks = new HashSet<>();
|
protected final Collection<T> ranks = new ArrayList<>();
|
||||||
|
|
||||||
public RankList(RankupPlugin plugin, FileConfiguration config, Function<ConfigurationSection, T> deserializer) {
|
public RankList(RankupPlugin plugin, FileConfiguration config, Function<ConfigurationSection, T> deserializer) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
@@ -59,7 +60,7 @@ public class RankList<T extends Rank> {
|
|||||||
for (T rank : ranks) {
|
for (T rank : ranks) {
|
||||||
// see if anything ranks up to this
|
// see if anything ranks up to this
|
||||||
for (T rank0 : ranks) {
|
for (T rank0 : ranks) {
|
||||||
if (rank0.getNext().equals(rank.getRank())) {
|
if (rank0.getNext().equalsIgnoreCase(rank.getRank())) {
|
||||||
continue OUTER;
|
continue OUTER;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.hook.PermissionProvider;
|
import sh.okx.rankup.hook.GroupProvider;
|
||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.messages.Variable;
|
import sh.okx.rankup.messages.Variable;
|
||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
@@ -20,7 +20,7 @@ public class RankupHelper {
|
|||||||
|
|
||||||
private final RankupPlugin plugin;
|
private final RankupPlugin plugin;
|
||||||
private final ConfigurationSection config;
|
private final ConfigurationSection config;
|
||||||
private final PermissionProvider permissions;
|
private final GroupProvider permissions;
|
||||||
/**
|
/**
|
||||||
* Players who cannot rankup/prestige for a certain amount of time.
|
* Players who cannot rankup/prestige for a certain amount of time.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import sh.okx.rankup.commands.RankupCommand;
|
|||||||
import sh.okx.rankup.gui.Gui;
|
import sh.okx.rankup.gui.Gui;
|
||||||
import sh.okx.rankup.gui.GuiListener;
|
import sh.okx.rankup.gui.GuiListener;
|
||||||
import sh.okx.rankup.hook.PermissionManager;
|
import sh.okx.rankup.hook.PermissionManager;
|
||||||
import sh.okx.rankup.hook.PermissionProvider;
|
import sh.okx.rankup.hook.GroupProvider;
|
||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.messages.MessageBuilder;
|
import sh.okx.rankup.messages.MessageBuilder;
|
||||||
import sh.okx.rankup.messages.NullMessageBuilder;
|
import sh.okx.rankup.messages.NullMessageBuilder;
|
||||||
@@ -79,7 +79,7 @@ import sh.okx.rankup.util.VersionChecker;
|
|||||||
public class RankupPlugin extends JavaPlugin {
|
public class RankupPlugin extends JavaPlugin {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private PermissionProvider permissions;
|
private GroupProvider permissions;
|
||||||
@Getter
|
@Getter
|
||||||
private Economy economy;
|
private Economy economy;
|
||||||
/**
|
/**
|
||||||
@@ -179,7 +179,7 @@ public class RankupPlugin extends JavaPlugin {
|
|||||||
if (autoRankup != null) {
|
if (autoRankup != null) {
|
||||||
autoRankup.cancel();
|
autoRankup.cancel();
|
||||||
}
|
}
|
||||||
long time = config.getInt("autorankup-interval") * 60 * 20;
|
long time = (long) (config.getDouble("autorankup-interval") * 60 * 20);
|
||||||
if (time > 0) {
|
if (time > 0) {
|
||||||
autoRankup = new AutoRankup(this);
|
autoRankup = new AutoRankup(this);
|
||||||
autoRankup.runTaskTimer(this, time, time);
|
autoRankup.runTaskTimer(this, time, time);
|
||||||
@@ -469,19 +469,15 @@ public class RankupPlugin extends JavaPlugin {
|
|||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void replaceRequirements(MessageBuilder builder, Variable variable,
|
private void replaceRequirements(MessageBuilder builder, Variable variable, Requirement requirement, Supplier<Object> value) {
|
||||||
Requirement requirement, Supplier<Object> value) {
|
|
||||||
Object get;
|
|
||||||
try {
|
try {
|
||||||
get = value.get();
|
|
||||||
builder.replace(variable + " " + requirement.getFullName(), value.get());
|
builder.replace(variable + " " + requirement.getFullName(), value.get());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageBuilder getMessage(CommandSender player, Message message, Rank oldRank,
|
public MessageBuilder getMessage(CommandSender player, Message message, Rank oldRank, String rankName) {
|
||||||
String rankName) {
|
|
||||||
String oldRankName;
|
String oldRankName;
|
||||||
if (oldRank instanceof Prestige && oldRank.getRank() == null) {
|
if (oldRank instanceof Prestige && oldRank.getRank() == null) {
|
||||||
oldRankName = ((Prestige) oldRank).getFrom();
|
oldRankName = ((Prestige) oldRank).getFrom();
|
||||||
|
|||||||
@@ -102,6 +102,8 @@ public class InfoCommand implements CommandExecutor {
|
|||||||
+ ChatColor.GREEN + " from " + ChatColor.GOLD + prestige.getFrom()
|
+ ChatColor.GREEN + " from " + ChatColor.GOLD + prestige.getFrom()
|
||||||
+ ChatColor.GREEN + " to " + ChatColor.GOLD + prestige.getTo());
|
+ ChatColor.GREEN + " to " + ChatColor.GOLD + prestige.getTo());
|
||||||
return true;
|
return true;
|
||||||
|
} else if(args[0].equalsIgnoreCase("rankdown") && sender.hasPermission("rankup.force")) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ public class RanksCommand implements CommandExecutor {
|
|||||||
while (rank != null) {
|
while (rank != null) {
|
||||||
String name = rank.getNext();
|
String name = rank.getNext();
|
||||||
if (rank.equals(playerRank)) {
|
if (rank.equals(playerRank)) {
|
||||||
plugin.getMessage(sender, Message.RANKS_CURRENT, rank, name).send(sender);
|
plugin.getMessage(sender, Message.RANKS_CURRENT, rank, name).failIfEmpty().send(sender);
|
||||||
message = Message.RANKS_INCOMPLETE;
|
message = Message.RANKS_INCOMPLETE;
|
||||||
} else {
|
} else {
|
||||||
plugin.getMessage(sender, message, rank, name).send(sender);
|
plugin.getMessage(sender, message, rank, name).failIfEmpty().send(sender);
|
||||||
}
|
}
|
||||||
rank = rankups.getByName(name);
|
rank = rankups.getByName(name);
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -2,7 +2,7 @@ package sh.okx.rankup.hook;
|
|||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public interface PermissionProvider {
|
public interface GroupProvider {
|
||||||
boolean inGroup(UUID uuid, String group);
|
boolean inGroup(UUID uuid, String group);
|
||||||
void addGroup(UUID uuid, String group);
|
void addGroup(UUID uuid, String group);
|
||||||
void removeGroup(UUID uuid, String group);
|
void removeGroup(UUID uuid, String group);
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.UUID;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PermissionPermissionProvider implements PermissionProvider {
|
public class PermissionGroupProvider implements GroupProvider {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean inGroup(UUID uuid, String group) {
|
public boolean inGroup(UUID uuid, String group) {
|
||||||
@@ -11,11 +11,11 @@ public class PermissionManager {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionProvider findPermissionProvider() {
|
public GroupProvider findPermissionProvider() {
|
||||||
return getVaultPermissionProvider();
|
return getVaultPermissionProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
private PermissionProvider getVaultPermissionProvider() {
|
private GroupProvider getVaultPermissionProvider() {
|
||||||
RegisteredServiceProvider<Permission> rsp = plugin.getServer().getServicesManager()
|
RegisteredServiceProvider<Permission> rsp = plugin.getServer().getServicesManager()
|
||||||
.getRegistration(Permission.class);
|
.getRegistration(Permission.class);
|
||||||
if (rsp == null) {
|
if (rsp == null) {
|
||||||
@@ -25,10 +25,10 @@ public class PermissionManager {
|
|||||||
if (!provider.hasGroupSupport()) {
|
if (!provider.hasGroupSupport()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new VaultPermissionProvider(provider);
|
return new VaultGroupProvider(provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PermissionProvider permissionOnlyProvider() {
|
public GroupProvider permissionOnlyProvider() {
|
||||||
return new PermissionPermissionProvider();
|
return new PermissionGroupProvider();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -5,10 +5,10 @@ import java.util.UUID;
|
|||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class VaultPermissionProvider implements PermissionProvider {
|
public class VaultGroupProvider implements GroupProvider {
|
||||||
private final Permission permission;
|
private final Permission permission;
|
||||||
|
|
||||||
public VaultPermissionProvider(Permission permission) {
|
public VaultGroupProvider(Permission permission) {
|
||||||
this.permission = permission;
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,6 +54,12 @@ public class RankupExpansion extends PlaceholderExpansion {
|
|||||||
amount = amount - plugin.getEconomy().getBalance(player);
|
amount = amount - plugin.getEconomy().getBalance(player);
|
||||||
}
|
}
|
||||||
return plugin.formatMoney(Math.max(0, amount));
|
return plugin.formatMoney(Math.max(0, amount));
|
||||||
|
} else if (params.startsWith("status_")) {
|
||||||
|
if (rankups.isLast(player) || rank.isIn(player)) {
|
||||||
|
return getPlaceholder("status-complete");
|
||||||
|
} else {
|
||||||
|
return getPlaceholder("status-incomplete");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (params) {
|
switch (params) {
|
||||||
|
|||||||
@@ -22,6 +22,11 @@ public class WorldRequirement extends Requirement {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getTotal(Player player) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Requirement clone() {
|
public Requirement clone() {
|
||||||
return new WorldRequirement(this);
|
return new WorldRequirement(this);
|
||||||
|
|||||||
@@ -84,6 +84,9 @@ placeholders:
|
|||||||
no-prestige: "None"
|
no-prestige: "None"
|
||||||
# used in the next_rank and next_prestige placeholders when a player is at the highest rank or prestige
|
# used in the next_rank and next_prestige placeholders when a player is at the highest rank or prestige
|
||||||
highest-rank: "None"
|
highest-rank: "None"
|
||||||
|
# used in the %rankup_status_[rank]% placeholders
|
||||||
|
status-complete: "Complete"
|
||||||
|
status-incomplete: "Incomplete"
|
||||||
|
|
||||||
# what to shorten money by.
|
# what to shorten money by.
|
||||||
# ie 1000 -> 1k
|
# ie 1000 -> 1k
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ rankup:
|
|||||||
must-prestige: "&cYou must prestige to /rankup further!"
|
must-prestige: "&cYou must prestige to /rankup further!"
|
||||||
|
|
||||||
gui:
|
gui:
|
||||||
|
rows: 1
|
||||||
title: "Rankup to {RANK}"
|
title: "Rankup to {RANK}"
|
||||||
rankup:
|
rankup:
|
||||||
material: EMERALD_BLOCK
|
material: EMERALD_BLOCK
|
||||||
|
|||||||
Reference in New Issue
Block a user