3.6.2
- gui now configurable per rank - fix item requirement
This commit is contained in:
@@ -10,3 +10,5 @@ gradle-app.setting
|
|||||||
!gradle-wrapper.jar
|
!gradle-wrapper.jar
|
||||||
|
|
||||||
out/
|
out/
|
||||||
|
|
||||||
|
spigot/
|
||||||
+22
-12
@@ -1,11 +1,10 @@
|
|||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
id "io.freefair.lombok" version "4.1.6"
|
id "io.freefair.lombok" version "4.1.6"
|
||||||
id 'maven'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'sh.okx'
|
group 'sh.okx'
|
||||||
version '3.6'
|
version '3.6.2'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@@ -22,40 +21,51 @@ repositories {
|
|||||||
maven {
|
maven {
|
||||||
url 'https://raw.github.com/PyvesB/AdvancedAchievements/mvn-repo/'
|
url 'https://raw.github.com/PyvesB/AdvancedAchievements/mvn-repo/'
|
||||||
}
|
}
|
||||||
|
// for plugins without repos, namely mcmmo, votingplugin, and towny
|
||||||
maven {
|
maven {
|
||||||
url 'https://jitpack.io'
|
url 'https://jitpack.io'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
testImplementation group: 'junit', name: 'junit', version: '4.12'
|
||||||
compile 'org.spigotmc:spigot-api:1.15.1-R0.1-SNAPSHOT'
|
compileOnly 'org.jetbrains:annotations:16.0.2'
|
||||||
compile('com.github.Realizedd:TokenManager:3.2.4') {
|
implementation 'org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT'
|
||||||
|
implementation('com.github.Realizedd:TokenManager:3.2.4') {
|
||||||
transitive = false
|
transitive = false
|
||||||
}
|
}
|
||||||
|
|
||||||
compile('net.milkbowl.vault:VaultAPI:1.7') {
|
implementation('net.milkbowl.vault:VaultAPI:1.7') {
|
||||||
exclude group: 'org.bukkit'
|
exclude group: 'org.bukkit'
|
||||||
}
|
}
|
||||||
compile 'me.clip:placeholderapi:2.9.2'
|
implementation 'me.clip:placeholderapi:2.9.2'
|
||||||
compile 'com.hm.achievement:advanced-achievements-api:1.1.0'
|
implementation 'com.hm.achievement:advanced-achievements-api:1.1.0'
|
||||||
compile ('com.github.mcMMO-Dev:mcMMO:601297') {
|
implementation('com.github.mcMMO-Dev:mcMMO:601297') {
|
||||||
exclude group: 'com.sk89q.worldguard'
|
exclude group: 'com.sk89q.worldguard'
|
||||||
}
|
}
|
||||||
compile 'com.github.Ben12345rocks:VotingPlugin:5.18.2'
|
implementation 'com.github.Ben12345rocks:VotingPlugin:5.18.2'
|
||||||
compile 'com.github.LlmDl:Towny:25fc18a'
|
implementation 'com.github.LlmDl:Towny:25fc18a'
|
||||||
}
|
}
|
||||||
|
|
||||||
// automatically copy the version to plugin.yml
|
// automatically copy the version to plugin.yml
|
||||||
processResources {
|
processResources {
|
||||||
|
// do this again whenever version changes
|
||||||
inputs.property 'version', project.version
|
inputs.property 'version', project.version
|
||||||
|
|
||||||
|
// copy plugin.yml and replace version
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
include 'plugin.yml'
|
include 'plugin.yml'
|
||||||
expand 'version':project.version
|
expand 'version': project.version
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// copy everything else
|
||||||
from(sourceSets.main.resources.srcDirs) {
|
from(sourceSets.main.resources.srcDirs) {
|
||||||
exclude 'plugin.yml'
|
exclude 'plugin.yml'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task spigot(type: Jar) {
|
||||||
|
from sourceSets.main.runtimeClasspath
|
||||||
|
destinationDirectory = file("./spigot/plugins/")
|
||||||
|
archiveFileName = "Rankup.jar"
|
||||||
|
}
|
||||||
Vendored
BIN
Binary file not shown.
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
#Thu Apr 11 23:41:41 GMT+01:00 2019
|
#Sun Apr 05 14:05:23 BST 2020
|
||||||
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
|||||||
@@ -1,5 +1,21 @@
|
|||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
|
|
||||||
|
#
|
||||||
|
# Copyright 2015 the original author or authors.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
##
|
##
|
||||||
## Gradle start up script for UN*X
|
## Gradle start up script for UN*X
|
||||||
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
|||||||
APP_BASE_NAME=`basename "$0"`
|
APP_BASE_NAME=`basename "$0"`
|
||||||
|
|
||||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
DEFAULT_JVM_OPTS=""
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD="maximum"
|
MAX_FD="maximum"
|
||||||
|
|||||||
Vendored
+17
-1
@@ -1,3 +1,19 @@
|
|||||||
|
@rem
|
||||||
|
@rem Copyright 2015 the original author or authors.
|
||||||
|
@rem
|
||||||
|
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
@rem you may not use this file except in compliance with the License.
|
||||||
|
@rem You may obtain a copy of the License at
|
||||||
|
@rem
|
||||||
|
@rem http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
@rem
|
||||||
|
@rem Unless required by applicable law or agreed to in writing, software
|
||||||
|
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
@rem See the License for the specific language governing permissions and
|
||||||
|
@rem limitations under the License.
|
||||||
|
@rem
|
||||||
|
|
||||||
@if "%DEBUG%" == "" @echo off
|
@if "%DEBUG%" == "" @echo off
|
||||||
@rem ##########################################################################
|
@rem ##########################################################################
|
||||||
@rem
|
@rem
|
||||||
@@ -14,7 +30,7 @@ set APP_BASE_NAME=%~n0
|
|||||||
set APP_HOME=%DIRNAME%
|
set APP_HOME=%DIRNAME%
|
||||||
|
|
||||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||||
set DEFAULT_JVM_OPTS=
|
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||||
|
|
||||||
@rem Find java.exe
|
@rem Find java.exe
|
||||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class AutoRankup extends BukkitRunnable {
|
public class AutoRankup extends BukkitRunnable {
|
||||||
private final Rankup rankup;
|
private final RankupPlugin rankup;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|||||||
@@ -10,18 +10,20 @@ import sh.okx.rankup.util.UpdateNotifier;
|
|||||||
public class JoinUpdateNotifier implements Listener {
|
public class JoinUpdateNotifier implements Listener {
|
||||||
private final UpdateNotifier notifier;
|
private final UpdateNotifier notifier;
|
||||||
private final Supplier<Boolean> enabledSupplier;
|
private final Supplier<Boolean> enabledSupplier;
|
||||||
|
private final String permission;
|
||||||
|
|
||||||
public JoinUpdateNotifier(UpdateNotifier notifier,
|
public JoinUpdateNotifier(UpdateNotifier notifier,
|
||||||
Supplier<Boolean> enabledSupplier) {
|
Supplier<Boolean> enabledSupplier, String permission) {
|
||||||
this.notifier = notifier;
|
this.notifier = notifier;
|
||||||
this.enabledSupplier = enabledSupplier;
|
this.enabledSupplier = enabledSupplier;
|
||||||
|
this.permission = permission;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(PlayerJoinEvent e) {
|
public void on(PlayerJoinEvent e) {
|
||||||
if (enabledSupplier.get()) {
|
if (enabledSupplier.get()) {
|
||||||
Player player = e.getPlayer();
|
Player player = e.getPlayer();
|
||||||
if (player.hasPermission("rankup.notify")) {
|
if (player.hasPermission(permission)) {
|
||||||
notifier.notify(player, true);
|
notifier.notify(player, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,8 +25,15 @@ public class RankList<T extends Rank> {
|
|||||||
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();
|
||||||
validateSection(rankSection);
|
validateSection(rankSection);
|
||||||
ranks.add(deserializer.apply(rankSection));
|
T apply = deserializer.apply(rankSection);
|
||||||
|
if (apply != null) {
|
||||||
|
ranks.add(apply);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
List<T> ordered = getOrderedList();
|
||||||
|
Set<T> provisionalRanks = new HashSet<>(ordered);
|
||||||
|
this.ranks.clear();
|
||||||
|
this.ranks.addAll(provisionalRanks);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void validateSection(ConfigurationSection section) {
|
protected void validateSection(ConfigurationSection section) {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public class RankupHelper {
|
public class RankupHelper {
|
||||||
|
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
private final ConfigurationSection config;
|
private final ConfigurationSection config;
|
||||||
private final Permission permissions;
|
private final Permission permissions;
|
||||||
/**
|
/**
|
||||||
@@ -27,7 +27,7 @@ public class RankupHelper {
|
|||||||
*/
|
*/
|
||||||
private Map<Player, Long> cooldowns = new HashMap<>();
|
private Map<Player, Long> cooldowns = new HashMap<>();
|
||||||
|
|
||||||
public RankupHelper(Rankup plugin) {
|
public RankupHelper(RankupPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = plugin.getConfig();
|
this.config = plugin.getConfig();
|
||||||
this.permissions = plugin.getPermissions();
|
this.permissions = plugin.getPermissions();
|
||||||
@@ -136,8 +136,7 @@ public class RankupHelper {
|
|||||||
Rank rank = rankups.getByPlayer(player);
|
Rank rank = rankups.getByPlayer(player);
|
||||||
if (rankups.isLast(permissions, player)) {
|
if (rankups.isLast(permissions, player)) {
|
||||||
Prestiges prestiges = plugin.getPrestiges();
|
Prestiges prestiges = plugin.getPrestiges();
|
||||||
plugin.getMessage(prestiges == null ? Message.NO_RANKUP
|
plugin.getMessage(prestiges == null || prestiges.isLast(permissions, player) ? Message.NO_RANKUP : Message.MUST_PRESTIGE)
|
||||||
: prestiges.isLast(permissions, player) ? Message.NO_RANKUP : Message.MUST_PRESTIGE)
|
|
||||||
.failIf(!message)
|
.failIf(!message)
|
||||||
.replaceRanks(player, rankups.getLast())
|
.replaceRanks(player, rankups.getLast())
|
||||||
.send(player);
|
.send(player);
|
||||||
|
|||||||
+31
-19
@@ -1,11 +1,5 @@
|
|||||||
package sh.okx.rankup;
|
package sh.okx.rankup;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
@@ -73,7 +67,14 @@ import sh.okx.rankup.requirements.requirement.votingplugin.VotingPluginVotesRequ
|
|||||||
import sh.okx.rankup.util.UpdateNotifier;
|
import sh.okx.rankup.util.UpdateNotifier;
|
||||||
import sh.okx.rankup.util.VersionChecker;
|
import sh.okx.rankup.util.VersionChecker;
|
||||||
|
|
||||||
public class Rankup extends JavaPlugin {
|
import java.io.File;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class RankupPlugin extends JavaPlugin {
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private Permission permissions;
|
private Permission permissions;
|
||||||
@@ -108,7 +109,7 @@ public class Rankup extends JavaPlugin {
|
|||||||
|
|
||||||
Metrics metrics = new Metrics(this);
|
Metrics metrics = new Metrics(this);
|
||||||
metrics.addCustomChart(new Metrics.SimplePie("confirmation",
|
metrics.addCustomChart(new Metrics.SimplePie("confirmation",
|
||||||
() -> config.getString("confirmation.type")));
|
() -> config.getString("confirmation-type", "unknown")));
|
||||||
metrics.addCustomChart(new Metrics.AdvancedPie("requirements", () -> {
|
metrics.addCustomChart(new Metrics.AdvancedPie("requirements", () -> {
|
||||||
Map<String, Integer> map = new HashMap<>();
|
Map<String, Integer> map = new HashMap<>();
|
||||||
addAll(map, rankups);
|
addAll(map, rankups);
|
||||||
@@ -117,6 +118,8 @@ public class Rankup extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}));
|
}));
|
||||||
|
metrics.addCustomChart(new Metrics.SimplePie("prestige",
|
||||||
|
() -> config.getBoolean("prestige") ? "enabled" : "disabled"));
|
||||||
|
|
||||||
if (config.getBoolean("ranks")) {
|
if (config.getBoolean("ranks")) {
|
||||||
getCommand("ranks").setExecutor(new RanksCommand(this));
|
getCommand("ranks").setExecutor(new RanksCommand(this));
|
||||||
@@ -135,7 +138,7 @@ public class Rankup extends JavaPlugin {
|
|||||||
getCommand("rankup3").setExecutor(new InfoCommand(this, notifier));
|
getCommand("rankup3").setExecutor(new InfoCommand(this, notifier));
|
||||||
getServer().getPluginManager().registerEvents(new GuiListener(this), this);
|
getServer().getPluginManager().registerEvents(new GuiListener(this), this);
|
||||||
getServer().getPluginManager().registerEvents(
|
getServer().getPluginManager().registerEvents(
|
||||||
new JoinUpdateNotifier(notifier, () -> getConfig().getBoolean("notify-update")), this);
|
new JoinUpdateNotifier(notifier, () -> getConfig().getBoolean("notify-update"), "rankup.notify"), this);
|
||||||
|
|
||||||
placeholders = new Placeholders(this);
|
placeholders = new Placeholders(this);
|
||||||
placeholders.register();
|
placeholders.register();
|
||||||
@@ -169,15 +172,15 @@ public class Rankup extends JavaPlugin {
|
|||||||
autoRankup.runTaskTimer(this, time, time);
|
autoRankup.runTaskTimer(this, time, time);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.getInt("version") < 5) {
|
if (config.getInt("version") < 6) {
|
||||||
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()
|
getLogger().severe("To update, please rename ALL your config files (or the folder they are in),");
|
||||||
.severe("To update, please rename ALL your config files (or the folder they are in),");
|
getLogger().severe("and run /pru 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 manually from the old config.");
|
||||||
getLogger().severe("Check the changelog on the Rankup spigot page to see the changes.");
|
getLogger().severe("Check the changelog on the Rankup spigot page to see the changes.");
|
||||||
|
getLogger().severe("https://www.spigotmc.org/resources/rankup.17933/updates");
|
||||||
}
|
}
|
||||||
|
|
||||||
helper = new RankupHelper(this);
|
helper = new RankupHelper(this);
|
||||||
@@ -206,6 +209,7 @@ public class Rankup extends JavaPlugin {
|
|||||||
for (String line : errorMessage.split("\n")) {
|
for (String line : errorMessage.split("\n")) {
|
||||||
getLogger().severe(line);
|
getLogger().severe(line);
|
||||||
}
|
}
|
||||||
|
getLogger().severe("More information can be found in the console log at startup");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -257,26 +261,26 @@ public class Rankup extends JavaPlugin {
|
|||||||
|
|
||||||
rankups = new Rankups(this, loadConfig("rankups.yml"));
|
rankups = new Rankups(this, loadConfig("rankups.yml"));
|
||||||
// check rankups are not in an infinite loop
|
// check rankups are not in an infinite loop
|
||||||
rankups.getOrderedList();
|
// rankups.getOrderedList();
|
||||||
|
|
||||||
if (config.getBoolean("prestige")) {
|
if (config.getBoolean("prestige")) {
|
||||||
prestiges = new Prestiges(this, loadConfig("prestiges.yml"));
|
prestiges = new Prestiges(this, loadConfig("prestiges.yml"));
|
||||||
prestiges.getOrderedList();
|
// prestiges.getOrderedList();
|
||||||
} else {
|
} else {
|
||||||
prestiges = null;
|
prestiges = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
this.errorMessage = e.getMessage();
|
this.errorMessage = e.getClass().getName() + ": " + e.getMessage();
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveLocales() {
|
private void saveLocales() {
|
||||||
saveLocale("en");
|
saveLocale("en");
|
||||||
saveLocale("pt-br");
|
saveLocale("pt_br");
|
||||||
saveLocale("ru");
|
saveLocale("ru");
|
||||||
saveLocale("zh_CN");
|
saveLocale("zh_cn");
|
||||||
saveLocale("fr");
|
saveLocale("fr");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -387,6 +391,14 @@ public class Rankup extends JavaPlugin {
|
|||||||
return placeholders.getMoneyFormat().format(money) + suffix;
|
return placeholders.getMoneyFormat().format(money) + suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ConfigurationSection getSection(Rank rank, String path) {
|
||||||
|
ConfigurationSection messages = rank.getSection();
|
||||||
|
if (messages == null || !messages.isConfigurationSection(path)) {
|
||||||
|
return this.messages.getConfigurationSection(path);
|
||||||
|
}
|
||||||
|
return messages.getConfigurationSection(path);
|
||||||
|
}
|
||||||
|
|
||||||
public MessageBuilder getMessage(Rank rank, Message message) {
|
public MessageBuilder getMessage(Rank rank, Message message) {
|
||||||
ConfigurationSection messages = rank.getSection();
|
ConfigurationSection messages = rank.getSection();
|
||||||
if (messages == null || !messages.isSet(message.getName())) {
|
if (messages == null || !messages.isSet(message.getName())) {
|
||||||
@@ -17,7 +17,7 @@ import sh.okx.rankup.requirements.RequirementRegistry;
|
|||||||
public class RankupRegisterEvent extends Event {
|
public class RankupRegisterEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
@Getter
|
@Getter
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
import sh.okx.rankup.prestige.Prestiges;
|
import sh.okx.rankup.prestige.Prestiges;
|
||||||
@@ -16,11 +16,11 @@ import sh.okx.rankup.ranks.Rankups;
|
|||||||
import sh.okx.rankup.util.UpdateNotifier;
|
import sh.okx.rankup.util.UpdateNotifier;
|
||||||
|
|
||||||
public class InfoCommand implements CommandExecutor {
|
public class InfoCommand implements CommandExecutor {
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
private final UpdateNotifier notifier;
|
private final UpdateNotifier notifier;
|
||||||
|
|
||||||
public InfoCommand(Rankup plugin, UpdateNotifier notifier) {
|
public InfoCommand(RankupPlugin plugin, UpdateNotifier notifier) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.notifier = notifier;
|
this.notifier = notifier;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,13 +5,13 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.RankupHelper;
|
import sh.okx.rankup.RankupHelper;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class MaxRankupCommand implements CommandExecutor {
|
public class MaxRankupCommand implements CommandExecutor {
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.gui.Gui;
|
import sh.okx.rankup.gui.Gui;
|
||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
@@ -18,7 +18,7 @@ import java.util.WeakHashMap;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PrestigeCommand implements CommandExecutor {
|
public class PrestigeCommand implements CommandExecutor {
|
||||||
private final Map<Player, Long> confirming = new WeakHashMap<>();
|
private final Map<Player, Long> confirming = new WeakHashMap<>();
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
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;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class PrestigesCommand implements CommandExecutor {
|
public class PrestigesCommand implements CommandExecutor {
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import sh.okx.rankup.ranks.Rankups;
|
import sh.okx.rankup.ranks.Rankups;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class RanksCommand implements CommandExecutor {
|
public class RanksCommand implements CommandExecutor {
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import org.bukkit.command.CommandExecutor;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.gui.Gui;
|
import sh.okx.rankup.gui.Gui;
|
||||||
import sh.okx.rankup.messages.Message;
|
import sh.okx.rankup.messages.Message;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
@@ -20,7 +20,7 @@ public class RankupCommand implements CommandExecutor {
|
|||||||
// weak hash maps so players going offline are automatically removed.
|
// weak hash maps so players going offline are automatically removed.
|
||||||
// otherwise there is a potential (albeit small) memory leak.
|
// otherwise there is a potential (albeit small) memory leak.
|
||||||
private final Map<Player, Long> confirming = new WeakHashMap<>();
|
private final Map<Player, Long> confirming = new WeakHashMap<>();
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import org.bukkit.inventory.Inventory;
|
|||||||
import org.bukkit.inventory.InventoryHolder;
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
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.prestige.Prestige;
|
import sh.okx.rankup.prestige.Prestige;
|
||||||
@@ -34,20 +34,22 @@ public class Gui implements InventoryHolder {
|
|||||||
@Getter
|
@Getter
|
||||||
private boolean prestige;
|
private boolean prestige;
|
||||||
|
|
||||||
public static Gui of(Player player, Rank oldRank, String rank, Rankup plugin) {
|
public static Gui of(Player player, Rank oldRank, String rank, RankupPlugin plugin) {
|
||||||
ConfigurationSection config = plugin.getConfig().getConfigurationSection("gui");
|
Gui gui = new Gui();
|
||||||
ItemStack[] items = new ItemStack[config.getInt("rows") * 9];
|
gui.prestige = oldRank instanceof Prestige;
|
||||||
|
|
||||||
ItemStack fill = getItem(plugin, "fill", player, oldRank, rank);
|
String type = gui.prestige ? "prestige" : "rankup";
|
||||||
ItemStack cancel = getItem(plugin, "cancel", player, oldRank, rank);
|
ConfigurationSection config = plugin.getSection(oldRank, type + ".gui");
|
||||||
ItemStack rankup = getItem(plugin, "rankup", player, oldRank, rank);
|
ItemStack[] items = new ItemStack[config.getInt("rows", 1) * 9];
|
||||||
|
|
||||||
|
ItemStack fill = getItem(plugin, config, "fill", player, oldRank, rank);
|
||||||
|
ItemStack cancel = getItem(plugin, config, "cancel", player, oldRank, rank);
|
||||||
|
ItemStack rankup = getItem(plugin, config, "rankup", player, oldRank, rank);
|
||||||
|
|
||||||
addItem(items, config.getConfigurationSection("rankup"), rankup);
|
addItem(items, config.getConfigurationSection("rankup"), rankup);
|
||||||
addItem(items, config.getConfigurationSection("cancel"), cancel);
|
addItem(items, config.getConfigurationSection("cancel"), cancel);
|
||||||
addItem(items, config.getConfigurationSection("fill"), fill);
|
addItem(items, config.getConfigurationSection("fill"), fill);
|
||||||
|
|
||||||
Gui gui = new Gui();
|
|
||||||
gui.prestige = oldRank instanceof Prestige;
|
|
||||||
gui.rankup = rankup;
|
gui.rankup = rankup;
|
||||||
gui.cancel = cancel;
|
gui.cancel = cancel;
|
||||||
|
|
||||||
@@ -62,8 +64,8 @@ public class Gui implements InventoryHolder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
private static ItemStack getItem(Rankup plugin, String name, Player player, Rank oldRank, String rank) {
|
private static ItemStack getItem(RankupPlugin plugin, ConfigurationSection parent, String name, Player player, Rank oldRank, String rank) {
|
||||||
ConfigurationSection section = plugin.getConfig().getConfigurationSection("gui").getConfigurationSection(name);
|
ConfigurationSection section = parent.getConfigurationSection(name);
|
||||||
|
|
||||||
String materialName = section.getString("material").toUpperCase();
|
String materialName = section.getString("material").toUpperCase();
|
||||||
|
|
||||||
@@ -102,7 +104,7 @@ public class Gui implements InventoryHolder {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String format(Rankup plugin, String message, Player player, Rank oldRank, String rank) {
|
private static String format(RankupPlugin plugin, String message, Player player, Rank oldRank, String rank) {
|
||||||
return plugin.replaceMoneyRequirements(new MessageBuilder(ChatColor.translateAlternateColorCodes('&', message))
|
return plugin.replaceMoneyRequirements(new MessageBuilder(ChatColor.translateAlternateColorCodes('&', message))
|
||||||
.replaceRanks(player, oldRank, rank), player, oldRank)
|
.replaceRanks(player, oldRank, rank), player, oldRank)
|
||||||
.toString();
|
.toString();
|
||||||
|
|||||||
@@ -7,11 +7,11 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class GuiListener implements Listener {
|
public class GuiListener implements Listener {
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(InventoryClickEvent e) {
|
public void on(InventoryClickEvent e) {
|
||||||
|
|||||||
@@ -3,13 +3,12 @@ package sh.okx.rankup.placeholders;
|
|||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.Rankup;
|
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
public class Placeholders {
|
public class Placeholders {
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
@Getter
|
@Getter
|
||||||
private final DecimalFormat moneyFormat;
|
private final DecimalFormat moneyFormat;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -20,7 +19,7 @@ public class Placeholders {
|
|||||||
private RankupExpansion expansion;
|
private RankupExpansion expansion;
|
||||||
private boolean registered;
|
private boolean registered;
|
||||||
|
|
||||||
public Placeholders(Rankup plugin) {
|
public Placeholders(RankupPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.moneyFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.money-format"));
|
this.moneyFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.money-format"));
|
||||||
this.percentFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.percent-format"));
|
this.percentFormat = new DecimalFormat(plugin.getConfig().getString("placeholders.percent-format"));
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package sh.okx.rankup.placeholders;
|
|||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
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;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
@@ -19,7 +19,7 @@ import java.util.regex.Pattern;
|
|||||||
public class RankupExpansion extends PlaceholderExpansion {
|
public class RankupExpansion extends PlaceholderExpansion {
|
||||||
private static final Pattern PATTERN = Pattern.compile("(.*)#(.*)");
|
private static final Pattern PATTERN = Pattern.compile("(.*)#(.*)");
|
||||||
|
|
||||||
private final Rankup plugin;
|
private final RankupPlugin plugin;
|
||||||
private final Placeholders placeholders;
|
private final Placeholders placeholders;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -211,4 +211,9 @@ public class RankupExpansion extends PlaceholderExpansion {
|
|||||||
public boolean persist() {
|
public boolean persist() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canRegister() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import lombok.Getter;
|
|||||||
import lombok.ToString;
|
import lombok.ToString;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.ranks.Rank;
|
import sh.okx.rankup.ranks.Rank;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
@@ -20,13 +20,13 @@ public class Prestige extends Rank {
|
|||||||
@Getter
|
@Getter
|
||||||
private final String to;
|
private final String to;
|
||||||
|
|
||||||
private Prestige(ConfigurationSection section, Rankup plugin, String next, String rank, Set<Requirement> requirements, List<String> commands, String from, String to) {
|
private Prestige(ConfigurationSection section, RankupPlugin plugin, String next, String rank, Set<Requirement> requirements, List<String> commands, String from, String to) {
|
||||||
super(section, plugin, next, rank, requirements, commands);
|
super(section, plugin, next, rank, requirements, commands);
|
||||||
this.from = from;
|
this.from = from;
|
||||||
this.to = to;
|
this.to = to;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Prestige deserialize(Rankup plugin, ConfigurationSection section) {
|
public static Prestige deserialize(RankupPlugin plugin, ConfigurationSection section) {
|
||||||
List<String> requirementsList = section.getStringList("requirements");
|
List<String> requirementsList = section.getStringList("requirements");
|
||||||
Set<Requirement> requirements = plugin.getRequirements().getRequirements(requirementsList);
|
Set<Requirement> requirements = plugin.getRequirements().getRequirements(requirementsList);
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,11 @@
|
|||||||
package sh.okx.rankup.prestige;
|
package sh.okx.rankup.prestige;
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import sh.okx.rankup.RankList;
|
import sh.okx.rankup.RankList;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
public class Prestiges extends RankList<Prestige> {
|
public class Prestiges extends RankList<Prestige> {
|
||||||
public Prestiges(Rankup plugin, FileConfiguration config) {
|
public Prestiges(RankupPlugin plugin, FileConfiguration config) {
|
||||||
super(config, section -> Prestige.deserialize(plugin, section));
|
super(config, section -> Prestige.deserialize(plugin, section));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package sh.okx.rankup.ranks;
|
package sh.okx.rankup.ranks;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import lombok.AccessLevel;
|
import lombok.AccessLevel;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@@ -9,7 +10,7 @@ import me.clip.placeholderapi.PlaceholderAPI;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.messages.MessageBuilder;
|
import sh.okx.rankup.messages.MessageBuilder;
|
||||||
import sh.okx.rankup.requirements.DeductibleRequirement;
|
import sh.okx.rankup.requirements.DeductibleRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
@@ -23,7 +24,7 @@ import java.util.Set;
|
|||||||
public class Rank {
|
public class Rank {
|
||||||
@Getter
|
@Getter
|
||||||
protected final ConfigurationSection section;
|
protected final ConfigurationSection section;
|
||||||
protected final Rankup plugin;
|
protected final RankupPlugin plugin;
|
||||||
@Getter
|
@Getter
|
||||||
protected final String next;
|
protected final String next;
|
||||||
@Getter
|
@Getter
|
||||||
@@ -32,13 +33,26 @@ public class Rank {
|
|||||||
protected final Set<Requirement> requirements;
|
protected final Set<Requirement> requirements;
|
||||||
protected final List<String> commands;
|
protected final List<String> commands;
|
||||||
|
|
||||||
public static Rank deserialize(Rankup plugin, ConfigurationSection section) {
|
public static Rank deserialize(RankupPlugin plugin, ConfigurationSection section) {
|
||||||
List<String> requirementsList = section.getStringList("requirements");
|
List<String> requirementsList;
|
||||||
|
if (section.isList("requirements")) {
|
||||||
|
requirementsList = section.getStringList("requirements");
|
||||||
|
} else {
|
||||||
|
requirementsList = Collections.singletonList(section.getString("requirements"));
|
||||||
|
}
|
||||||
Set<Requirement> requirements = plugin.getRequirements().getRequirements(requirementsList);
|
Set<Requirement> requirements = plugin.getRequirements().getRequirements(requirementsList);
|
||||||
|
|
||||||
|
String next = section.getString("next");
|
||||||
|
String rank = section.getString("rank");
|
||||||
|
|
||||||
|
if (next != null && next.isEmpty()) {
|
||||||
|
plugin.getLogger().warning("Rankup section '" + section.getName() + "' has a blank 'next' field, will be ignored.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
return new Rank(section, plugin,
|
return new Rank(section, plugin,
|
||||||
section.getString("next"),
|
next,
|
||||||
section.getString("rank"),
|
rank,
|
||||||
requirements,
|
requirements,
|
||||||
section.getStringList("commands"));
|
section.getStringList("commands"));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package sh.okx.rankup.ranks;
|
|||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import sh.okx.rankup.RankList;
|
import sh.okx.rankup.RankList;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
public class Rankups extends RankList<Rank> {
|
public class Rankups extends RankList<Rank> {
|
||||||
public Rankups(Rankup plugin, FileConfiguration config) {
|
public Rankups(RankupPlugin plugin, FileConfiguration config) {
|
||||||
super(config, section -> Rank.deserialize(plugin, section));
|
super(config, section -> Rank.deserialize(plugin, section));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package sh.okx.rankup.requirements;
|
package sh.okx.rankup.requirements;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
|
||||||
|
|
||||||
public interface DeductibleRequirement {
|
public interface DeductibleRequirement {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,15 +1,14 @@
|
|||||||
package sh.okx.rankup.requirements;
|
package sh.okx.rankup.requirements;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
|
||||||
|
|
||||||
public abstract class ProgressiveRequirement extends Requirement {
|
public abstract class ProgressiveRequirement extends Requirement {
|
||||||
public ProgressiveRequirement(Rankup plugin, String name) {
|
public ProgressiveRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name);
|
super(plugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProgressiveRequirement(Rankup plugin, String name, boolean subRequirement) {
|
public ProgressiveRequirement(RankupPlugin plugin, String name, boolean subRequirement) {
|
||||||
super(plugin, name, subRequirement);
|
super(plugin, name, subRequirement);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,10 +2,10 @@ package sh.okx.rankup.requirements;
|
|||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
|
|
||||||
public abstract class Requirement implements Cloneable {
|
public abstract class Requirement implements Cloneable {
|
||||||
protected final Rankup plugin;
|
protected final RankupPlugin plugin;
|
||||||
@Getter
|
@Getter
|
||||||
protected final String name;
|
protected final String name;
|
||||||
private String value;
|
private String value;
|
||||||
@@ -13,11 +13,11 @@ public abstract class Requirement implements Cloneable {
|
|||||||
private String sub;
|
private String sub;
|
||||||
private boolean subRequirement;
|
private boolean subRequirement;
|
||||||
|
|
||||||
public Requirement(Rankup plugin, String name) {
|
public Requirement(RankupPlugin plugin, String name) {
|
||||||
this(plugin, name, false);
|
this(plugin, name, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Requirement(Rankup plugin, String name, boolean subRequirement) {
|
public Requirement(RankupPlugin plugin, String name, boolean subRequirement) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.subRequirement = subRequirement;
|
this.subRequirement = subRequirement;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package sh.okx.rankup.requirements;
|
|||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@@ -28,11 +27,17 @@ public class RequirementRegistry {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Requirement> getRequirements(List<String> list) {
|
public Set<Requirement> getRequirements(Iterable<String> list) {
|
||||||
Set<Requirement> requirements = new HashSet<>();
|
Set<Requirement> requirements = new HashSet<>();
|
||||||
|
|
||||||
for (String req : list) {
|
for (String req : list) {
|
||||||
String[] parts = req.split(" ", 2);
|
String[] parts = req.split(" ", 2);
|
||||||
|
if (parts.length < 2) {
|
||||||
|
throw new IllegalArgumentException("For requirement: '" + req + "'. Requirements must contain a space between" +
|
||||||
|
" the name of the requirement and the value of the requirement. If it already looks like it has a space, " +
|
||||||
|
"make sure it is not a tab or has an invisible character.");
|
||||||
|
}
|
||||||
|
|
||||||
String name = parts[0];
|
String name = parts[0];
|
||||||
String value = parts[1];
|
String value = parts[1];
|
||||||
Requirement requirement = newRequirement(name, value);
|
Requirement requirement = newRequirement(name, value);
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package sh.okx.rankup.requirements;
|
package sh.okx.rankup.requirements;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.requirement.XpLevelRequirement;
|
import sh.okx.rankup.requirements.requirement.XpLevelRequirement;
|
||||||
|
|
||||||
public class XpLevelDeductibleRequirement extends XpLevelRequirement implements DeductibleRequirement {
|
public class XpLevelDeductibleRequirement extends XpLevelRequirement implements DeductibleRequirement {
|
||||||
|
|
||||||
public XpLevelDeductibleRequirement(Rankup plugin, String name) {
|
public XpLevelDeductibleRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name);
|
super(plugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class BlockBreakRequirement extends ProgressiveRequirement {
|
public class BlockBreakRequirement extends ProgressiveRequirement {
|
||||||
public BlockBreakRequirement(Rankup plugin) {
|
public BlockBreakRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "block-break", true);
|
super(plugin, "block-break", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class CraftItemRequirement extends ProgressiveRequirement {
|
public class CraftItemRequirement extends ProgressiveRequirement {
|
||||||
public CraftItemRequirement(Rankup plugin) {
|
public CraftItemRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "craft-item", true);
|
super(plugin, "craft-item", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package sh.okx.rankup.requirements.requirement;
|
package sh.okx.rankup.requirements.requirement;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class GroupRequirement extends Requirement {
|
public class GroupRequirement extends Requirement {
|
||||||
public GroupRequirement(Rankup plugin) {
|
public GroupRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "group");
|
super(plugin, "group");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
-7
@@ -1,15 +1,14 @@
|
|||||||
package sh.okx.rankup.requirements.requirement;
|
package sh.okx.rankup.requirements.requirement;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.DeductibleRequirement;
|
import sh.okx.rankup.requirements.DeductibleRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class ItemDeductibleRequirement extends ItemRequirement implements DeductibleRequirement {
|
public class ItemDeductibleRequirement extends ItemRequirement implements DeductibleRequirement {
|
||||||
|
|
||||||
public ItemDeductibleRequirement(Rankup plugin, String name) {
|
public ItemDeductibleRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name);
|
super(plugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,11 +18,28 @@ public class ItemDeductibleRequirement extends ItemRequirement implements Deduct
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(Player player, double multiplier) {
|
public void apply(Player player, double multiplier) {
|
||||||
Material type = Material.matchMaterial(getSub());
|
int count = (int) (getTotal(player) * multiplier);
|
||||||
if (type == null) {
|
|
||||||
throw new IllegalArgumentException("Invalid item " + getSub());
|
ItemStack[] contents = player.getInventory().getStorageContents();
|
||||||
|
for (int i = 0; i < contents.length && count > 0; i++) {
|
||||||
|
ItemStack item = contents[i];
|
||||||
|
|
||||||
|
if (matchItem(item)) {
|
||||||
|
if (count < item.getAmount()) {
|
||||||
|
item.setAmount(item.getAmount() - count);
|
||||||
|
count = 0;
|
||||||
|
} else {
|
||||||
|
count -= item.getAmount();
|
||||||
|
contents[i] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().setStorageContents(contents);
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
throw new IllegalStateException("REPORT THIS ERROR TO THE DEV - COULD NOT DEDUCT ALL ITEMS");
|
||||||
}
|
}
|
||||||
player.getInventory().removeItem(new ItemStack(type, (int) (getValueInt() * multiplier)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -3,15 +3,14 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.DeductibleRequirement;
|
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class ItemRequirement extends ProgressiveRequirement {
|
public class ItemRequirement extends ProgressiveRequirement {
|
||||||
public ItemRequirement(Rankup plugin, String name) {
|
public ItemRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name, true);
|
super(plugin, name, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,9 +25,37 @@ public class ItemRequirement extends ProgressiveRequirement {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getProgress(Player player) {
|
public double getProgress(Player player) {
|
||||||
Material material = Material.matchMaterial(getSub());
|
return Arrays.stream(player.getInventory().getStorageContents())
|
||||||
return Arrays.stream(player.getInventory().getContents())
|
.filter(this::matchItem)
|
||||||
.filter(item -> item != null && item.getType() == material)
|
|
||||||
.mapToInt(ItemStack::getAmount).sum();
|
.mapToInt(ItemStack::getAmount).sum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean matchItem(ItemStack item) {
|
||||||
|
if (item == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String sub = getSub();
|
||||||
|
String[] parts = sub.split(":");
|
||||||
|
|
||||||
|
Material material = Material.matchMaterial(parts[0]);
|
||||||
|
if (material == null) {
|
||||||
|
throw new IllegalArgumentException("[item requirement] could not find material name: " + parts[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parts.length > 1) {
|
||||||
|
int durability;
|
||||||
|
try {
|
||||||
|
durability = Integer.parseInt(parts[1]);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
throw new IllegalArgumentException("[item requirement] durability '" + parts[1] + "' must be a number in item: '" + sub + "'");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (durability != item.getDurability()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return material == item.getType();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class MobKillsRequirement extends ProgressiveRequirement {
|
public class MobKillsRequirement extends ProgressiveRequirement {
|
||||||
public MobKillsRequirement(Rankup plugin) {
|
public MobKillsRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "mob-kills", true);
|
super(plugin, "mob-kills", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,13 +2,13 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
|
|
||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.DeductibleRequirement;
|
import sh.okx.rankup.requirements.DeductibleRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class MoneyDeductibleRequirement extends MoneyRequirement implements DeductibleRequirement {
|
public class MoneyDeductibleRequirement extends MoneyRequirement implements DeductibleRequirement {
|
||||||
|
|
||||||
public MoneyDeductibleRequirement(Rankup plugin, String name) {
|
public MoneyDeductibleRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name);
|
super(plugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package sh.okx.rankup.requirements.requirement;
|
package sh.okx.rankup.requirements.requirement;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class MoneyRequirement extends ProgressiveRequirement {
|
public class MoneyRequirement extends ProgressiveRequirement {
|
||||||
public MoneyRequirement(Rankup plugin, String name) {
|
public MoneyRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name);
|
super(plugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package sh.okx.rankup.requirements.requirement;
|
package sh.okx.rankup.requirements.requirement;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class PermissionRequirement extends Requirement {
|
public class PermissionRequirement extends Requirement {
|
||||||
public PermissionRequirement(Rankup plugin) {
|
public PermissionRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "permission");
|
super(plugin, "permission");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI;
|
import me.clip.placeholderapi.PlaceholderAPI;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ public class PlaceholderRequirement extends ProgressiveRequirement {
|
|||||||
|
|
||||||
public static final double DELTA = 0.00001D;
|
public static final double DELTA = 0.00001D;
|
||||||
|
|
||||||
public PlaceholderRequirement(Rankup plugin) {
|
public PlaceholderRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "placeholder");
|
super(plugin, "placeholder");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
|
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class PlayerKillsRequirement extends ProgressiveRequirement {
|
public class PlayerKillsRequirement extends ProgressiveRequirement {
|
||||||
public PlayerKillsRequirement(Rankup plugin) {
|
public PlayerKillsRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "player-kills");
|
super(plugin, "player-kills");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,7 +2,7 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
|
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
@@ -10,7 +10,7 @@ public class PlaytimeMinutesRequirement extends ProgressiveRequirement {
|
|||||||
private static final int TICKS_PER_MINUTE = 20 * 60;
|
private static final int TICKS_PER_MINUTE = 20 * 60;
|
||||||
private Statistic playOneTick;
|
private Statistic playOneTick;
|
||||||
|
|
||||||
public PlaytimeMinutesRequirement(Rankup plugin) {
|
public PlaytimeMinutesRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "playtime-minutes");
|
super(plugin, "playtime-minutes");
|
||||||
try {
|
try {
|
||||||
playOneTick = Statistic.valueOf("PLAY_ONE_MINUTE");
|
playOneTick = Statistic.valueOf("PLAY_ONE_MINUTE");
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
package sh.okx.rankup.requirements.requirement;
|
package sh.okx.rankup.requirements.requirement;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.DeductibleRequirement;
|
import sh.okx.rankup.requirements.DeductibleRequirement;
|
||||||
import sh.okx.rankup.requirements.requirement.tokenmanager.TokensRequirement;
|
import sh.okx.rankup.requirements.requirement.tokenmanager.TokensRequirement;
|
||||||
|
|
||||||
public class TokensDeductibleRequirement extends TokensRequirement implements DeductibleRequirement {
|
public class TokensDeductibleRequirement extends TokensRequirement implements DeductibleRequirement {
|
||||||
public TokensDeductibleRequirement(Rankup plugin, String name) {
|
public TokensDeductibleRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name);
|
super(plugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,12 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
|
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class TotalMobKillsRequirement extends ProgressiveRequirement {
|
public class TotalMobKillsRequirement extends ProgressiveRequirement {
|
||||||
public TotalMobKillsRequirement(Rankup plugin) {
|
public TotalMobKillsRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "total-mob-kills");
|
super(plugin, "total-mob-kills");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,12 +3,12 @@ package sh.okx.rankup.requirements.requirement;
|
|||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class UseItemRequirement extends ProgressiveRequirement {
|
public class UseItemRequirement extends ProgressiveRequirement {
|
||||||
public UseItemRequirement(Rankup plugin) {
|
public UseItemRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "use-item", true);
|
super(plugin, "use-item", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
package sh.okx.rankup.requirements.requirement;
|
package sh.okx.rankup.requirements.requirement;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class WorldRequirement extends Requirement {
|
public class WorldRequirement extends Requirement {
|
||||||
public WorldRequirement(Rankup plugin) {
|
public WorldRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "world");
|
super(plugin, "world");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package sh.okx.rankup.requirements.requirement;
|
package sh.okx.rankup.requirements.requirement;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class XpLevelRequirement extends ProgressiveRequirement {
|
public class XpLevelRequirement extends ProgressiveRequirement {
|
||||||
public XpLevelRequirement(Rankup plugin, String name) {
|
public XpLevelRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name);
|
super(plugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -3,11 +3,11 @@ package sh.okx.rankup.requirements.requirement.advancedachievements;
|
|||||||
import com.hm.achievement.api.AdvancedAchievementsAPI;
|
import com.hm.achievement.api.AdvancedAchievementsAPI;
|
||||||
import com.hm.achievement.api.AdvancedAchievementsAPIFetcher;
|
import com.hm.achievement.api.AdvancedAchievementsAPIFetcher;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class AdvancedAchievementsAchievementRequirement extends Requirement {
|
public class AdvancedAchievementsAchievementRequirement extends Requirement {
|
||||||
public AdvancedAchievementsAchievementRequirement(Rankup plugin) {
|
public AdvancedAchievementsAchievementRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "advancedachievements-achievement");
|
super(plugin, "advancedachievements-achievement");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,12 +2,12 @@ package sh.okx.rankup.requirements.requirement.advancedachievements;
|
|||||||
|
|
||||||
import com.hm.achievement.api.AdvancedAchievementsAPIFetcher;
|
import com.hm.achievement.api.AdvancedAchievementsAPIFetcher;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
|
|
||||||
public class AdvancedAchievementsTotalRequirement extends ProgressiveRequirement {
|
public class AdvancedAchievementsTotalRequirement extends ProgressiveRequirement {
|
||||||
public AdvancedAchievementsTotalRequirement(Rankup plugin) {
|
public AdvancedAchievementsTotalRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "advancedachievements-total");
|
super(plugin, "advancedachievements-total");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,12 +2,12 @@ package sh.okx.rankup.requirements.requirement.mcmmo;
|
|||||||
|
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
|
|
||||||
public class McMMOPowerLevelRequirement extends ProgressiveRequirement {
|
public class McMMOPowerLevelRequirement extends ProgressiveRequirement {
|
||||||
public McMMOPowerLevelRequirement(Rankup plugin) {
|
public McMMOPowerLevelRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "mcmmo-power-level");
|
super(plugin, "mcmmo-power-level");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
package sh.okx.rankup.requirements.requirement.mcmmo;
|
package sh.okx.rankup.requirements.requirement.mcmmo;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
|
|
||||||
public class McMMOSkillRequirement extends ProgressiveRequirement {
|
public class McMMOSkillRequirement extends ProgressiveRequirement {
|
||||||
public McMMOSkillRequirement(Rankup plugin) {
|
public McMMOSkillRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "mcmmo", true);
|
super(plugin, "mcmmo", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -4,13 +4,13 @@ import java.util.Objects;
|
|||||||
import me.realized.tokenmanager.api.TokenManager;
|
import me.realized.tokenmanager.api.TokenManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
|
|
||||||
public class TokensRequirement extends ProgressiveRequirement {
|
public class TokensRequirement extends ProgressiveRequirement {
|
||||||
protected final TokenManager manager = (TokenManager) Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("TokenManager"));
|
protected final TokenManager manager = (TokenManager) Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("TokenManager"));
|
||||||
|
|
||||||
public TokensRequirement(Rankup plugin, String name) {
|
public TokensRequirement(RankupPlugin plugin, String name) {
|
||||||
super(plugin, name);
|
super(plugin, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
package sh.okx.rankup.requirements.requirement.towny;
|
package sh.okx.rankup.requirements.requirement.towny;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class TownyKingNumberResidentsRequirement extends ProgressiveRequirement {
|
public class TownyKingNumberResidentsRequirement extends ProgressiveRequirement {
|
||||||
public TownyKingNumberResidentsRequirement(Rankup plugin) {
|
public TownyKingNumberResidentsRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "towny-king-residents");
|
super(plugin, "towny-king-residents");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
package sh.okx.rankup.requirements.requirement.towny;
|
package sh.okx.rankup.requirements.requirement.towny;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class TownyKingNumberTownsRequirement extends ProgressiveRequirement {
|
public class TownyKingNumberTownsRequirement extends ProgressiveRequirement {
|
||||||
public TownyKingNumberTownsRequirement(Rankup plugin) {
|
public TownyKingNumberTownsRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "towny-king-towns");
|
super(plugin, "towny-king-towns");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
package sh.okx.rankup.requirements.requirement.towny;
|
package sh.okx.rankup.requirements.requirement.towny;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class TownyKingRequirement extends Requirement {
|
public class TownyKingRequirement extends Requirement {
|
||||||
public TownyKingRequirement(Rankup plugin) {
|
public TownyKingRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "towny-king");
|
super(plugin, "towny-king");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
package sh.okx.rankup.requirements.requirement.towny;
|
package sh.okx.rankup.requirements.requirement.towny;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class TownyMayorNumberResidentsRequirement extends ProgressiveRequirement {
|
public class TownyMayorNumberResidentsRequirement extends ProgressiveRequirement {
|
||||||
public TownyMayorNumberResidentsRequirement(Rankup plugin) {
|
public TownyMayorNumberResidentsRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "towny-mayor-residents");
|
super(plugin, "towny-mayor-residents");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
package sh.okx.rankup.requirements.requirement.towny;
|
package sh.okx.rankup.requirements.requirement.towny;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class TownyMayorRequirement extends Requirement {
|
public class TownyMayorRequirement extends Requirement {
|
||||||
public TownyMayorRequirement(Rankup plugin) {
|
public TownyMayorRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "towny-mayor");
|
super(plugin, "towny-mayor");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,11 +1,11 @@
|
|||||||
package sh.okx.rankup.requirements.requirement.towny;
|
package sh.okx.rankup.requirements.requirement.towny;
|
||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
|
|
||||||
public class TownyResidentRequirement extends Requirement {
|
public class TownyResidentRequirement extends Requirement {
|
||||||
public TownyResidentRequirement(Rankup plugin) {
|
public TownyResidentRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "towny-resident");
|
super(plugin, "towny-resident");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,12 +2,12 @@ package sh.okx.rankup.requirements.requirement.votingplugin;
|
|||||||
|
|
||||||
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
import com.Ben12345rocks.VotingPlugin.UserManager.UserManager;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import sh.okx.rankup.Rankup;
|
import sh.okx.rankup.RankupPlugin;
|
||||||
import sh.okx.rankup.requirements.Requirement;
|
import sh.okx.rankup.requirements.Requirement;
|
||||||
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
import sh.okx.rankup.requirements.ProgressiveRequirement;
|
||||||
|
|
||||||
public class VotingPluginVotesRequirement extends ProgressiveRequirement {
|
public class VotingPluginVotesRequirement extends ProgressiveRequirement {
|
||||||
public VotingPluginVotesRequirement(Rankup plugin) {
|
public VotingPluginVotesRequirement(RankupPlugin plugin) {
|
||||||
super(plugin, "votingplugin-votes");
|
super(plugin, "votingplugin-votes");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,24 +1,22 @@
|
|||||||
package sh.okx.rankup.util;
|
package sh.okx.rankup.util;
|
||||||
|
|
||||||
import com.google.common.base.Suppliers;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
public class ItemUtil {
|
public class ItemUtil {
|
||||||
private static Supplier<Boolean> flattenedSupplier = Suppliers.memoize(ItemUtil::isServerFlattenedPrivate);
|
private static boolean flattened;
|
||||||
|
|
||||||
private static boolean isServerFlattenedPrivate() {
|
static {
|
||||||
try {
|
try {
|
||||||
Material.valueOf("BLACK_STAINED_GLASS_PANE");
|
Material.valueOf("BLACK_STAINED_GLASS_PANE");
|
||||||
return true;
|
flattened = true;
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
return false;
|
flattened = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines if a server is post-flattening or pre-flattening.
|
* Determines if a server is post-flattening or pre-flattening.
|
||||||
* The flattening is the name for a process where, instead of using durability to represent
|
* The flattening is the name for the event where, instead of using durability to represent
|
||||||
* similar items, Mojang decided to use distinct item types for each item.
|
* similar items, Mojang decided to use distinct item types for each item.
|
||||||
* This caused many {@link Material} names to change, making some things incompatible.
|
* This caused many {@link Material} names to change, making some things incompatible.
|
||||||
* The flattening happened in 1.13.
|
* The flattening happened in 1.13.
|
||||||
@@ -26,6 +24,6 @@ public class ItemUtil {
|
|||||||
* @return true if the server is post-flattening (server versions 1.13, 1.14, 1.15) or false if it is pre-flattening (1.12, 1.11, 1.10 etc)
|
* @return true if the server is post-flattening (server versions 1.13, 1.14, 1.15) or false if it is pre-flattening (1.12, 1.11, 1.10 etc)
|
||||||
*/
|
*/
|
||||||
public static boolean isServerFlattened() {
|
public static boolean isServerFlattened() {
|
||||||
return flattenedSupplier.get();
|
return flattened;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,11 +5,12 @@ import org.bukkit.command.CommandSender;
|
|||||||
import sh.okx.rankup.util.VersionChecker.VersionCheckerCallback;
|
import sh.okx.rankup.util.VersionChecker.VersionCheckerCallback;
|
||||||
|
|
||||||
public class UpdateNotifier {
|
public class UpdateNotifier {
|
||||||
private static final String PREFIX = ChatColor.GREEN + "" + ChatColor.BOLD + "Rankup " + ChatColor.RESET;
|
private final String prefix;
|
||||||
|
|
||||||
private final VersionChecker checker;
|
private final VersionChecker checker;
|
||||||
|
|
||||||
public UpdateNotifier(VersionChecker checker) {
|
public UpdateNotifier(VersionChecker checker) {
|
||||||
|
this.prefix = ChatColor.GREEN + "" + ChatColor.BOLD + checker.getPlugin().getName() + ChatColor.RESET + " ";
|
||||||
this.checker = checker;
|
this.checker = checker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,7 +30,7 @@ public class UpdateNotifier {
|
|||||||
public void onOutdatedVersion(String currentVersion, String latestVersion) {
|
public void onOutdatedVersion(String currentVersion, String latestVersion) {
|
||||||
send(sender, join, ChatColor.YELLOW + "A new version is available: " + ChatColor.GOLD + latestVersion
|
send(sender, join, ChatColor.YELLOW + "A new version is available: " + ChatColor.GOLD + latestVersion
|
||||||
+ ChatColor.YELLOW + ". You are on: " + ChatColor.GOLD + currentVersion
|
+ ChatColor.YELLOW + ". You are on: " + ChatColor.GOLD + currentVersion
|
||||||
+ ChatColor.GOLD + "\nhttps://www.spigotmc.org/resources/rankup.17933/");
|
+ ChatColor.GOLD + "\nhttps://www.spigotmc.org/resources/" + VersionChecker.RESOURCE_ID + "/");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -48,7 +49,7 @@ public class UpdateNotifier {
|
|||||||
|
|
||||||
private void send(CommandSender sender, boolean prefix, String message) {
|
private void send(CommandSender sender, boolean prefix, String message) {
|
||||||
if (prefix) {
|
if (prefix) {
|
||||||
sender.sendMessage(PREFIX + message);
|
sender.sendMessage(this.prefix + message);
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,10 +9,9 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class VersionChecker {
|
public class VersionChecker {
|
||||||
|
public static final int RESOURCE_ID = 76964;
|
||||||
|
|
||||||
private static final int RESOURCE_ID = 17933;
|
private final Plugin plugin;
|
||||||
|
|
||||||
private final Plugin plugin; // used exclusively for scheduling
|
|
||||||
private final String currentVersion;
|
private final String currentVersion;
|
||||||
private String latestVersion;
|
private String latestVersion;
|
||||||
private boolean checked = false;
|
private boolean checked = false;
|
||||||
@@ -22,6 +21,10 @@ public class VersionChecker {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Plugin getPlugin() {
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if the version checker has already made an asynchronous call to the web server to check
|
* Checks if the version checker has already made an asynchronous call to the web server to check
|
||||||
* the version, so future checks will run instantly.
|
* the version, so future checks will run instantly.
|
||||||
@@ -45,13 +48,11 @@ public class VersionChecker {
|
|||||||
checked = true;
|
checked = true;
|
||||||
callback.onPreReleaseVersion(currentVersion);
|
callback.onPreReleaseVersion(currentVersion);
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(plugin,
|
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> checkVersionAsync(callback));
|
||||||
// () -> checkVersionSync(new SyncVersionCheckerCallback(plugin, callback)));
|
|
||||||
() -> checkVersionSync(callback));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkVersionSync(VersionCheckerCallback callback) {
|
private void checkVersionAsync(VersionCheckerCallback callback) {
|
||||||
try {
|
try {
|
||||||
latestVersion = getLatestVersion();
|
latestVersion = getLatestVersion();
|
||||||
checked = true;
|
checked = true;
|
||||||
@@ -78,6 +79,7 @@ public class VersionChecker {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the plugin is already on the latest version
|
* Called when the plugin is already on the latest version
|
||||||
|
* May be called asynchronously
|
||||||
*
|
*
|
||||||
* @param version the current, and latest, version of the plugin
|
* @param version the current, and latest, version of the plugin
|
||||||
*/
|
*/
|
||||||
@@ -85,6 +87,7 @@ public class VersionChecker {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the plugin is on a version other than the latest on the SpigotMC plugin page.
|
* Called when the plugin is on a version other than the latest on the SpigotMC plugin page.
|
||||||
|
* May be called asynchronously.
|
||||||
*
|
*
|
||||||
* @param currentVersion the current version of the plugin specified in plugin.yml
|
* @param currentVersion the current version of the plugin specified in plugin.yml
|
||||||
* @param latestVersion the latest version of the plugin specified on SpigotMC.
|
* @param latestVersion the latest version of the plugin specified on SpigotMC.
|
||||||
@@ -99,7 +102,8 @@ public class VersionChecker {
|
|||||||
void onPreReleaseVersion(String version);
|
void onPreReleaseVersion(String version);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the version checker was unable to retrieve the latest version
|
* Called when the version checker was unable to retrieve the latest version.
|
||||||
|
* May be called asynchronously.
|
||||||
*/
|
*/
|
||||||
void onFailure();
|
void onFailure();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# 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: 5
|
version: 6
|
||||||
|
|
||||||
# the locale to use for messages
|
# the locale to use for messages
|
||||||
# all messages can be customised but this allows you to
|
# all messages can be customised but this allows you to
|
||||||
@@ -31,7 +31,7 @@ prestiges: true
|
|||||||
prestige: false
|
prestige: false
|
||||||
|
|
||||||
# if true, players with the permission rankup.notify will receive notifications when they join
|
# if true, players with the permission rankup.notify will receive notifications when they join
|
||||||
# to update if they are on an older version of Rankup.
|
# to update if the server is on an older version of Rankup.
|
||||||
notify-update: true
|
notify-update: true
|
||||||
|
|
||||||
# how people should confirm ranking up
|
# how people should confirm ranking up
|
||||||
@@ -55,28 +55,6 @@ max-rankup:
|
|||||||
# /maxrankup and ranks up to B and then C, it will just say "player has ranked up to C")
|
# /maxrankup and ranks up to B and then C, it will just say "player has ranked up to C")
|
||||||
individual-messages: true
|
individual-messages: true
|
||||||
|
|
||||||
gui:
|
|
||||||
rows: 1
|
|
||||||
rankup:
|
|
||||||
material: EMERALD_BLOCK
|
|
||||||
# index can be separated by spaces to show in multiple groups
|
|
||||||
# for example: 0-3 9-12 18-21
|
|
||||||
# you can also just use a single number instead of a range.
|
|
||||||
index: 0-3
|
|
||||||
name: '&a&lConfirm'
|
|
||||||
# lore is optional
|
|
||||||
lore: '&6Rankup to &b{RANK}'
|
|
||||||
cancel:
|
|
||||||
material: REDSTONE_BLOCK
|
|
||||||
index: 5-8
|
|
||||||
name: '&c&lCancel'
|
|
||||||
fill:
|
|
||||||
name: ' '
|
|
||||||
# if you are using a 1.8-1.12 and you want to change this
|
|
||||||
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
|
||||||
# this works for both the rankup and cancel blocks as well
|
|
||||||
material: BLACK_STAINED_GLASS_PANE
|
|
||||||
|
|
||||||
# options when using the text rankup confirmation
|
# options when using the text rankup confirmation
|
||||||
text:
|
text:
|
||||||
# the time in seconds for a player to
|
# the time in seconds for a player to
|
||||||
|
|||||||
@@ -15,6 +15,28 @@ rankup:
|
|||||||
|
|
||||||
must-prestige: "&cYou must prestige to /rankup further!"
|
must-prestige: "&cYou must prestige to /rankup further!"
|
||||||
|
|
||||||
|
gui:
|
||||||
|
title: "Rankup to {RANK}"
|
||||||
|
rankup:
|
||||||
|
material: EMERALD_BLOCK
|
||||||
|
# index can be separated by spaces to show in multiple groups
|
||||||
|
# for example: 0-3 9-12 18-21
|
||||||
|
# you can also just use a single number instead of a range.
|
||||||
|
index: 0-3
|
||||||
|
name: '&a&lConfirm'
|
||||||
|
# lore is optional
|
||||||
|
lore: '&6Rankup to &b{RANK}'
|
||||||
|
cancel:
|
||||||
|
material: REDSTONE_BLOCK
|
||||||
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
# you can (and probably should) you override these in rankups.yml
|
# you can (and probably should) you override these in rankups.yml
|
||||||
# to show the specific requirements for each rank.
|
# to show the specific requirements for each rank.
|
||||||
# however if you are just using money or don't need to change the message per rank, you can use any combination of:
|
# however if you are just using money or don't need to change the message per rank, you can use any combination of:
|
||||||
@@ -47,7 +69,24 @@ prestige:
|
|||||||
confirmation: |-
|
confirmation: |-
|
||||||
&eAre you sure you want to prestige to &a{RANK}&e?
|
&eAre you sure you want to prestige to &a{RANK}&e?
|
||||||
&eType &c/prestige &eagain to confirm.
|
&eType &c/prestige &eagain to confirm.
|
||||||
title: "Prestige to {RANK}"
|
|
||||||
|
gui:
|
||||||
|
title: "Prestige to {RANK}"
|
||||||
|
rankup:
|
||||||
|
material: GOLD_BLOCK
|
||||||
|
index: 0-3
|
||||||
|
name: '&a&lConfirm'
|
||||||
|
lore: '&6Prestige to &b{RANK}'
|
||||||
|
cancel:
|
||||||
|
material: REDSTONE_BLOCK
|
||||||
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
list:
|
list:
|
||||||
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
complete: "&7{OLD_RANK} &8\xbb &7{RANK}"
|
||||||
|
|||||||
@@ -10,8 +10,29 @@ rankup:
|
|||||||
confirmation: |-
|
confirmation: |-
|
||||||
&eÊtes-vous sûr(e) de vouloir passer au rang &a{RANK}&e?
|
&eÊtes-vous sûr(e) de vouloir passer au rang &a{RANK}&e?
|
||||||
&eTapez &c/rankup &eà nouveau pour confirmer.
|
&eTapez &c/rankup &eà nouveau pour confirmer.
|
||||||
# used for the GUI confirmation
|
|
||||||
title: "Passer au rang {RANK}"
|
gui:
|
||||||
|
rows: 1
|
||||||
|
title: "Passer au rang {RANK}"
|
||||||
|
rankup:
|
||||||
|
material: EMERALD_BLOCK
|
||||||
|
# index can be separated by spaces to show in multiple groups
|
||||||
|
# for example: 0-3 9-12 18-21
|
||||||
|
# you can also just use a single number instead of a range.
|
||||||
|
index: 0-3
|
||||||
|
name: '&a&lConfirm'
|
||||||
|
# lore is optional
|
||||||
|
lore: '&6Rankup to &b{RANK}'
|
||||||
|
cancel:
|
||||||
|
material: REDSTONE_BLOCK
|
||||||
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
must-prestige: "&cVous devez passer un prestige pour continuer à monter de rang!"
|
must-prestige: "&cVous devez passer un prestige pour continuer à monter de rang!"
|
||||||
|
|
||||||
@@ -49,6 +70,25 @@ prestige:
|
|||||||
&eTapez &c/prestige &eà nouveau pour confirmer.
|
&eTapez &c/prestige &eà nouveau pour confirmer.
|
||||||
title: "Passer au prestige {RANK}"
|
title: "Passer au prestige {RANK}"
|
||||||
|
|
||||||
|
gui:
|
||||||
|
rows: 1
|
||||||
|
title: "Prestige to {RANK}"
|
||||||
|
rankup:
|
||||||
|
material: GOLD_BLOCK
|
||||||
|
index: 0-3
|
||||||
|
name: '&a&lConfirm'
|
||||||
|
lore: '&6Prestige to &b{RANK}'
|
||||||
|
cancel:
|
||||||
|
material: REDSTONE_BLOCK
|
||||||
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
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}"
|
||||||
|
|||||||
@@ -10,11 +10,32 @@ rankup:
|
|||||||
confirmation: |-
|
confirmation: |-
|
||||||
&eVocê tem certeza que deseja subir para &a{RANK}&e?
|
&eVocê tem certeza que deseja subir para &a{RANK}&e?
|
||||||
&eDigite &c/rankup &enovamente para confirmar.
|
&eDigite &c/rankup &enovamente para confirmar.
|
||||||
# Utilizado para confirmação em GUI.
|
|
||||||
title: "Rankup to {RANK}"
|
|
||||||
|
|
||||||
must-prestige: "&cVocê deve subir de prestígio para dar /rankup a frente!"
|
must-prestige: "&cVocê deve subir de prestígio para dar /rankup a frente!"
|
||||||
|
|
||||||
|
gui:
|
||||||
|
rows: 1
|
||||||
|
title: "Rankup to {RANK}"
|
||||||
|
rankup:
|
||||||
|
material: EMERALD_BLOCK
|
||||||
|
# index can be separated by spaces to show in multiple groups
|
||||||
|
# for example: 0-3 9-12 18-21
|
||||||
|
# you can also just use a single number instead of a range.
|
||||||
|
index: 0-3
|
||||||
|
name: '&a&lConfirm'
|
||||||
|
# lore is optional
|
||||||
|
lore: '&6Rankup to &b{RANK}'
|
||||||
|
cancel:
|
||||||
|
material: REDSTONE_BLOCK
|
||||||
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
# Você pode (e deveria) substituir isto em rankups.yml
|
# Você pode (e deveria) substituir isto em rankups.yml
|
||||||
# para mostrar os requerimentos específicos para cada rank.
|
# para mostrar os requerimentos específicos para cada rank.
|
||||||
# contudo, se você está apenas usando dinheiro ou não precisa mudar as mensagens por rank, você pode usar qualquer combinação de:
|
# contudo, se você está apenas usando dinheiro ou não precisa mudar as mensagens por rank, você pode usar qualquer combinação de:
|
||||||
@@ -52,6 +73,25 @@ prestige:
|
|||||||
&eDigite &c/prestige &enovamente para confimar.
|
&eDigite &c/prestige &enovamente para confimar.
|
||||||
title: "Subiu de prestígio para {RANK}"
|
title: "Subiu de prestígio para {RANK}"
|
||||||
|
|
||||||
|
gui:
|
||||||
|
rows: 1
|
||||||
|
title: "Prestige to {RANK}"
|
||||||
|
rankup:
|
||||||
|
material: GOLD_BLOCK
|
||||||
|
index: 0-3
|
||||||
|
name: '&a&lConfirm'
|
||||||
|
lore: '&6Prestige to &b{RANK}'
|
||||||
|
cancel:
|
||||||
|
material: REDSTONE_BLOCK
|
||||||
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
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}"
|
||||||
@@ -9,8 +9,29 @@ rankup:
|
|||||||
confirmation: |-
|
confirmation: |-
|
||||||
&eВы уверены, что хотите ранг до &a{RANK}&e?
|
&eВы уверены, что хотите ранг до &a{RANK}&e?
|
||||||
&eВведите &c/rankup &eещё раз, чтобы подтвердить.
|
&eВведите &c/rankup &eещё раз, чтобы подтвердить.
|
||||||
# Используется для подтверждения в GUI
|
|
||||||
title: "Повысить до {RANK}"
|
gui:
|
||||||
|
rows: 1
|
||||||
|
title: "Повысить до {RANK}"
|
||||||
|
rankup:
|
||||||
|
material: EMERALD_BLOCK
|
||||||
|
# index can be separated by spaces to show in multiple groups
|
||||||
|
# for example: 0-3 9-12 18-21
|
||||||
|
# you can also just use a single number instead of a range.
|
||||||
|
index: 0-3
|
||||||
|
name: '&a&lConfirm'
|
||||||
|
# lore is optional
|
||||||
|
lore: '&6Rankup to &b{RANK}'
|
||||||
|
cancel:
|
||||||
|
material: REDSTONE_BLOCK
|
||||||
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
must-prestige: "&cВам нужно будет больше престижа для /rankup в будущем!"
|
must-prestige: "&cВам нужно будет больше престижа для /rankup в будущем!"
|
||||||
|
|
||||||
@@ -49,6 +70,25 @@ prestige:
|
|||||||
&eВведите &c/prestige &eснова для подтверждения.
|
&eВведите &c/prestige &eснова для подтверждения.
|
||||||
title: "Повысить престиж в {RANK}"
|
title: "Повысить престиж в {RANK}"
|
||||||
|
|
||||||
|
gui:
|
||||||
|
rows: 1
|
||||||
|
title: "Prestige to {RANK}"
|
||||||
|
rankup:
|
||||||
|
material: GOLD_BLOCK
|
||||||
|
index: 0-3
|
||||||
|
name: '&a&lConfirm'
|
||||||
|
lore: '&6Prestige to &b{RANK}'
|
||||||
|
cancel:
|
||||||
|
material: REDSTONE_BLOCK
|
||||||
|
index: 5-8
|
||||||
|
name: '&c&lCancel'
|
||||||
|
fill:
|
||||||
|
name: ' '
|
||||||
|
# if you are using a 1.8-1.12 and you want to change this
|
||||||
|
# you can use MATERIAL:data, for example STAINED_GLASS_PANE:8
|
||||||
|
# this works for both the rankup and cancel blocks as well
|
||||||
|
material: BLACK_STAINED_GLASS_PANE
|
||||||
|
|
||||||
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,6 +1,6 @@
|
|||||||
name: Rankup
|
name: Rankup
|
||||||
version: ${version}
|
version: ${version}
|
||||||
main: sh.okx.rankup.Rankup
|
main: sh.okx.rankup.RankupPlugin
|
||||||
author: Okx
|
author: Okx
|
||||||
depend: [Vault]
|
depend: [Vault]
|
||||||
softdepend: [PlaceholderAPI, mcMMO, AdvancedAchievements, Towny]
|
softdepend: [PlaceholderAPI, mcMMO, AdvancedAchievements, Towny]
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
# !!! To use prestiges, you must first enable it in config.yml
|
|
||||||
|
|
||||||
first:
|
first:
|
||||||
# the rank people must be to use this prestige
|
# the rank people must be to use this prestige
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
# see https://github.com/okx-code/Rankup3/wiki/Rank-format
|
#
|
||||||
|
# If you are adding your own ranks, make sure to delete the example ranks!
|
||||||
|
# Need help setting the plugin up?
|
||||||
|
# Read an example: https://github.com/okx-code/Rankup3/wiki/Configuration-Example
|
||||||
|
# Join the discord server for live support: https://discord.gg/maB4382 (buyers only)
|
||||||
|
#
|
||||||
|
|
||||||
# this name doesn't matter
|
# this name doesn't matter
|
||||||
Aexample:
|
Aexample:
|
||||||
|
|||||||
Reference in New Issue
Block a user