Add option to disable command confirmations per player

This commit is contained in:
Jakub Kolář 2016-03-12 15:16:05 +01:00
parent 6779923320
commit 498f2441ce
4 changed files with 182 additions and 304 deletions

View File

@ -32,6 +32,7 @@ import java.util.UUID;
import java.util.logging.Logger; import java.util.logging.Logger;
public class BoosCoolDown extends JavaPlugin implements Runnable { public class BoosCoolDown extends JavaPlugin implements Runnable {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private static PluginDescriptionFile pdfFile; private static PluginDescriptionFile pdfFile;
private static Economy economy = null; private static Economy economy = null;
@ -39,8 +40,7 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
private PluginManager pm; private PluginManager pm;
public static void commandLogger(String player, String command) { public static void commandLogger(String player, String command) {
log.info("[" + "boosLogger" + "] " + player + " used command " log.info("[" + "boosLogger" + "] " + player + " used command " + command);
+ command);
} }
public static Economy getEconomy() { public static Economy getEconomy() {
@ -59,39 +59,29 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
private static void startLimitResetTimersGlobal() { private static void startLimitResetTimersGlobal() {
YamlConfiguration confusers = BoosConfigManager.getConfusers(); YamlConfiguration confusers = BoosConfigManager.getConfusers();
ConfigurationSection global = confusers ConfigurationSection global = confusers.getConfigurationSection("global");
.getConfigurationSection("global");
if (global != null) { if (global != null) {
Set<String> globalKeys = global.getKeys(false); Set<String> globalKeys = global.getKeys(false);
BukkitScheduler scheduler = Bukkit.getScheduler(); BukkitScheduler scheduler = Bukkit.getScheduler();
for (String key : globalKeys) { for (String key : globalKeys) {
String confTime = confusers.getString("global." + key String confTime = confusers.getString("global." + key + ".reset");
+ ".reset"); long limitResetDelay = BoosConfigManager.getLimitResetDelayGlobal(key);
long limitResetDelay = BoosConfigManager
.getLimitResetDelayGlobal(key);
Date endDate = getTime(confTime); Date endDate = getTime(confTime);
Date startDate = getCurrTime(); Date startDate = getCurrTime();
Calendar calcurrTime = Calendar.getInstance(); Calendar calcurrTime = Calendar.getInstance();
calcurrTime.setTime(startDate); calcurrTime.setTime(startDate);
Calendar callastTime = Calendar.getInstance(); Calendar callastTime = Calendar.getInstance();
callastTime.setTime(endDate); callastTime.setTime(endDate);
long time = secondsBetween(calcurrTime, callastTime, long time = secondsBetween(calcurrTime, callastTime, limitResetDelay);
limitResetDelay);
if (limitResetDelay != -65535) { if (limitResetDelay != -65535) {
if (time <= 0) { if (time <= 0) {
time = 1; time = 1;
} }
BoosCoolDown.getLog().info( BoosCoolDown.getLog().info("[boosCooldowns] Starting timer for " + time + " seconds to reset limits for command " + key);
"[boosCooldowns] Starting timer for " + time scheduler.scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("boosCooldowns"), new BoosGlobalLimitResetRunnable(key),
+ " seconds to reset limits for command " time * 20);
+ key);
scheduler.scheduleSyncDelayedTask(Bukkit.getPluginManager()
.getPlugin("boosCooldowns"),
new BoosGlobalLimitResetRunnable(key), time * 20);
} else { } else {
BoosCoolDown.getLog().info( BoosCoolDown.getLog().info("[boosCooldowns] Stoping timer to reset limits for command " + key);
"[boosCooldowns] Stoping timer to reset limits for command "
+ key);
} }
} }
} }
@ -113,24 +103,16 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
if (time <= 0) { if (time <= 0) {
time = 1; time = 1;
} }
BoosCoolDown.getLog().info( BoosCoolDown.getLog().info("[boosCooldowns] Starting timer for " + time + " seconds to reset limits for command " + key);
"[boosCooldowns] Starting timer for " + time scheduler.scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("boosCooldowns"), new BoosGlobalLimitResetRunnable(key), time * 20);
+ " seconds to reset limits for command " + key);
scheduler.scheduleSyncDelayedTask(Bukkit.getPluginManager()
.getPlugin("boosCooldowns"),
new BoosGlobalLimitResetRunnable(key), time * 20);
} else { } else {
BoosCoolDown.getLog().info( BoosCoolDown.getLog().info("[boosCooldowns] Stoping timer to reset limits for command " + key);
"[boosCooldowns] Stoping timer to reset limits for command "
+ key);
} }
} }
private static long secondsBetween(Calendar startDate, Calendar endDate, private static long secondsBetween(Calendar startDate, Calendar endDate, long limitResetDelay) {
long limitResetDelay) {
long secondsBetween = 0; long secondsBetween = 0;
secondsBetween = ((endDate.getTimeInMillis() - startDate secondsBetween = ((endDate.getTimeInMillis() - startDate.getTimeInMillis()) / 1000) + limitResetDelay;
.getTimeInMillis()) / 1000) + limitResetDelay;
return secondsBetween; return secondsBetween;
} }
@ -166,93 +148,69 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
private void initializeVault() { private void initializeVault() {
Plugin x = pm.getPlugin("Vault"); Plugin x = pm.getPlugin("Vault");
if (x != null & x instanceof Vault) { if (x != null & x instanceof Vault) {
log.info("[" + pdfFile.getName() + "]" log.info("[" + pdfFile.getName() + "]" + " found [Vault] searching for economy plugin.");
+ " found [Vault] searching for economy plugin.");
usingVault = true; usingVault = true;
if (setupEconomy()) { if (setupEconomy()) {
log.info("[" + pdfFile.getName() + "]" + " found [" log.info("[" + pdfFile.getName() + "]" + " found [" + economy.getName() + "] plugin, enabling prices support.");
+ economy.getName()
+ "] plugin, enabling prices support.");
} else { } else {
log.info("[" log.info("[" + pdfFile.getName() + "]" + " economy plugin not found, disabling prices support.");
+ pdfFile.getName()
+ "]"
+ " economy plugin not found, disabling prices support.");
} }
} else { } else {
log.info("[" + pdfFile.getName() + "]" log.info("[" + pdfFile.getName() + "]" + " [Vault] not found disabling economy support.");
+ " [Vault] not found disabling economy support.");
usingVault = false; usingVault = false;
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public boolean onCommand(CommandSender sender, Command c, public boolean onCommand(CommandSender sender, Command c, String commandLabel, String[] args) {
String commandLabel, String[] args) {
String command = c.getName().toLowerCase(); String command = c.getName().toLowerCase();
if (command.equalsIgnoreCase("booscooldowns")) { if (command.equalsIgnoreCase("booscooldowns")) {
if (args.length == 1) { if (args.length == 1) {
if (sender.hasPermission("booscooldowns.reload") if (sender.hasPermission("booscooldowns.reload") && args[0].equalsIgnoreCase("reload")) {
&& args[0].equalsIgnoreCase("reload")) {
reload(); reload();
boosChat.sendMessageToCommandSender(sender, boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " config reloaded");
"&6[" + pdfFile.getName() + "]&e"
+ " config reloaded");
return true; return true;
} } else if (sender.hasPermission("booscooldowns.list.limits") && args[0].equalsIgnoreCase("limits")) {
if (sender.hasPermission("booscooldowns.list.limits")
&& args[0].equalsIgnoreCase("limits")) {
try { try {
Player send = (Player) sender; Player send = (Player) sender;
Set<String> commands = BoosConfigManager Set<String> commands = BoosConfigManager.getCommands(send);
.getCommands(send);
for (String comm : commands) { for (String comm : commands) {
int lim = BoosConfigManager.getLimit(comm, send); int lim = BoosConfigManager.getLimit(comm, send);
BoosLimitManager.getLimitListMessages(send, comm, BoosLimitManager.getLimitListMessages(send, comm, lim);
lim);
} }
} catch (ClassCastException e) { } catch (ClassCastException e) {
log.warning("You cannot use this command from console!"); log.warning("You cannot use this command from console!");
} }
return true; return true;
} else if (sender.hasPermission("booscooldowns.globalreset") } else if (sender.hasPermission("booscooldowns.globalreset") && args[0].equalsIgnoreCase("startglobalreset")) {
&& args[0].equalsIgnoreCase("startglobalreset")) {
BoosLimitManager.setGlobalLimitResetDate(); BoosLimitManager.setGlobalLimitResetDate();
startLimitResetTimersGlobal(); startLimitResetTimersGlobal();
return true; return true;
} else if (args[0].equalsIgnoreCase("confirmations")) {
BoosConfigManager.toggleConfirmations((Player)sender);
return true;
} }
} else if (args.length == 2) { } else if (args.length == 2) {
String jmeno = args[1]; String jmeno = args[1];
Player player = Bukkit.getPlayerExact(jmeno); Player player = Bukkit.getPlayerExact(jmeno);
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (sender.hasPermission("booscooldowns.clearcooldowns") if (sender.hasPermission("booscooldowns.clearcooldowns") && args[0].equalsIgnoreCase("clearcooldowns")) {
&& args[0].equalsIgnoreCase("clearcooldowns")) {
String co = "cooldown"; String co = "cooldown";
BoosConfigManager.clearSomething(co, uuid); BoosConfigManager.clearSomething(co, uuid);
boosChat.sendMessageToCommandSender(sender, boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " cooldowns of player " + jmeno + " cleared");
"&6[" + pdfFile.getName() + "]&e"
+ " cooldowns of player " + jmeno
+ " cleared");
return true; return true;
} else if (sender.hasPermission("booscooldowns.clearuses") } else if (sender.hasPermission("booscooldowns.clearuses") && command.equalsIgnoreCase("booscooldowns") && args[0].equalsIgnoreCase(
&& command.equalsIgnoreCase("booscooldowns") "clearuses")) {
&& args[0].equalsIgnoreCase("clearuses")) {
String co = "uses"; String co = "uses";
BoosConfigManager.clearSomething(co, uuid); BoosConfigManager.clearSomething(co, uuid);
boosChat.sendMessageToCommandSender(sender, boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " uses of player " + jmeno + " cleared");
"&6[" + pdfFile.getName() + "]&e"
+ " uses of player " + jmeno + " cleared");
return true; return true;
} else if (sender.hasPermission("booscooldowns.clearwarmups") } else if (sender.hasPermission("booscooldowns.clearwarmups") && command.equalsIgnoreCase("booscooldowns")
&& command.equalsIgnoreCase("booscooldowns")
&& args[0].equalsIgnoreCase("clearwarmups")) { && args[0].equalsIgnoreCase("clearwarmups")) {
String co = "warmup"; String co = "warmup";
BoosConfigManager.clearSomething(co, uuid); BoosConfigManager.clearSomething(co, uuid);
boosChat.sendMessageToCommandSender(sender, boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " warmups of player " + jmeno + " cleared");
"&6[" + pdfFile.getName() + "]&e"
+ " warmups of player " + jmeno
+ " cleared");
return true; return true;
} }
} else if (args.length == 3) { } else if (args.length == 3) {
@ -260,38 +218,28 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
Player player = Bukkit.getPlayerExact(jmeno); Player player = Bukkit.getPlayerExact(jmeno);
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
String command2 = args[2].trim(); String command2 = args[2].trim();
if (sender.hasPermission("booscooldowns.clearcooldowns") if (sender.hasPermission("booscooldowns.clearcooldowns") && args[0].equalsIgnoreCase("clearcooldowns")) {
&& args[0].equalsIgnoreCase("clearcooldowns")) {
String co = "cooldown"; String co = "cooldown";
BoosConfigManager.clearSomething(co, uuid, command2); BoosConfigManager.clearSomething(co, uuid, command2);
boosChat.sendMessageToCommandSender(sender, boosChat.sendMessageToCommandSender(sender,
"&6[" + pdfFile.getName() + "]&e" "&6[" + pdfFile.getName() + "]&e" + " cooldown for command " + command2 + " of player " + uuid + " cleared");
+ " cooldown for command " + command2
+ " of player " + uuid + " cleared");
return true; return true;
} else if (sender.hasPermission("booscooldowns.clearuses") } else if (sender.hasPermission("booscooldowns.clearuses") && args[0].equalsIgnoreCase("clearuses")) {
&& args[0].equalsIgnoreCase("clearuses")) {
String co = "uses"; String co = "uses";
BoosConfigManager.clearSomething(co, uuid, command2); BoosConfigManager.clearSomething(co, uuid, command2);
boosChat.sendMessageToCommandSender(sender, boosChat.sendMessageToCommandSender(sender,
"&6[" + pdfFile.getName() + "]&e" "&6[" + pdfFile.getName() + "]&e" + " uses for command " + command2 + " of player " + jmeno + " cleared");
+ " uses for command " + command2
+ " of player " + jmeno + " cleared");
return true; return true;
} else if (sender.hasPermission("booscooldowns.clearwarmups") } else if (sender.hasPermission("booscooldowns.clearwarmups") && args[0].equalsIgnoreCase("clearwarmups")) {
&& args[0].equalsIgnoreCase("clearwarmups")) {
String co = "warmup"; String co = "warmup";
BoosConfigManager.clearSomething(co, uuid, command2); BoosConfigManager.clearSomething(co, uuid, command2);
boosChat.sendMessageToCommandSender(sender, boosChat.sendMessageToCommandSender(sender,
"&6[" + pdfFile.getName() + "]&e" "&6[" + pdfFile.getName() + "]&e" + " warmups for command " + command2 + " of player " + jmeno + " cleared");
+ " warmups for command " + command2
+ " of player " + jmeno + " cleared");
return true; return true;
} }
} else if (args.length == 4) { } else if (args.length == 4) {
if (sender.hasPermission("booscooldowns.set") if (sender.hasPermission("booscooldowns.set") && args[0].equalsIgnoreCase("set")) {
&& args[0].equalsIgnoreCase("set")) {
String what = args[1]; String what = args[1];
String comm = args[2]; String comm = args[2];
String value = args[3]; String value = args[3];
@ -300,24 +248,18 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
if (comm.contains("_")) { if (comm.contains("_")) {
comm = comm.replace("_", " "); comm = comm.replace("_", " ");
} }
BoosConfigManager.setAddToConfigFile(group, comm, what, BoosConfigManager.setAddToConfigFile(group, comm, what, value);
value); boosChat.sendMessageToCommandSender(sender,
boosChat.sendMessageToCommandSender(sender, "&6[" "&6[" + pdfFile.getName() + "]&e " + what + " for command" + comm + " in group " + group + " is now set to " + value);
+ pdfFile.getName() + "]&e " + what
+ " for command" + comm + " in group " + group
+ " is now set to " + value);
return true; return true;
} else { } else {
boosChat.sendMessageToCommandSender(sender, "&6[" boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " Command has to start with \"/\".");
+ pdfFile.getName() + "]&e"
+ " Command has to start with \"/\".");
return true; return true;
} }
} }
} else if (args.length == 5) { } else if (args.length == 5) {
if (sender.hasPermission("booscooldowns.set") if (sender.hasPermission("booscooldowns.set") && args[0].equalsIgnoreCase("set")) {
&& args[0].equalsIgnoreCase("set")) {
String what = args[1]; String what = args[1];
String comm = args[2]; String comm = args[2];
String value = args[3]; String value = args[3];
@ -326,29 +268,23 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
if (comm.contains("_")) { if (comm.contains("_")) {
comm = comm.replace("_", " "); comm = comm.replace("_", " ");
} }
BoosConfigManager.setAddToConfigFile(group, comm, what, BoosConfigManager.setAddToConfigFile(group, comm, what, value);
value); boosChat.sendMessageToCommandSender(sender,
boosChat.sendMessageToCommandSender(sender, "&6[" "&6[" + pdfFile.getName() + "]&e " + what + " for command" + comm + " in group " + group + " is now set to " + value);
+ pdfFile.getName() + "]&e " + what
+ " for command" + comm + " in group " + group
+ " is now set to " + value);
return true; return true;
} else { } else {
boosChat.sendMessageToCommandSender(sender, "&6[" boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " Command has to start with \"/\".");
+ pdfFile.getName() + "]&e"
+ " Command has to start with \"/\".");
return true; return true;
} }
} }
} else { } else {
// boosChat.sendMessageToCommandSender(sender, // boosChat.sendMessageToCommandSender(sender,
// "&6[" + pdfFile.getName() + "]&e" // "&6[" + pdfFile.getName() + "]&e"
// + " Invalid command or access denied!"); // + " Invalid command or access denied!");
return false; return false;
} }
} } return false;
return false;
} }
@ -361,17 +297,14 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
BoosConfigManager.saveConfusers(); BoosConfigManager.saveConfusers();
log.info("[" + pdfFile.getName() + "]" + " cooldowns saved!"); log.info("[" + pdfFile.getName() + "]" + " cooldowns saved!");
} }
log.info("[" + pdfFile.getName() + "]" + " version " log.info("[" + pdfFile.getName() + "]" + " version " + pdfFile.getVersion() + " disabled!");
+ pdfFile.getVersion() + " disabled!");
} }
@Override @Override
public void onEnable() { public void onEnable() {
pdfFile = this.getDescription(); pdfFile = this.getDescription();
PluginDescriptionFile pdfFile = this.getDescription(); PluginDescriptionFile pdfFile = this.getDescription();
log.info("[" + pdfFile.getName() + "]" + " version " log.info("[" + pdfFile.getName() + "]" + " version " + pdfFile.getVersion() + " by " + pdfFile.getAuthors() + " is enabled!");
+ pdfFile.getVersion() + " by " + pdfFile.getAuthors()
+ " is enabled!");
this.saveDefaultConfig(); this.saveDefaultConfig();
new BoosConfigManager(this); new BoosConfigManager(this);
BoosConfigManager.load(); BoosConfigManager.load();
@ -382,9 +315,7 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
BukkitScheduler scheduler = this.getServer().getScheduler(); BukkitScheduler scheduler = this.getServer().getScheduler();
startLimitResetTimersGlobal(); startLimitResetTimersGlobal();
if (BoosConfigManager.getAutoSave()) { if (BoosConfigManager.getAutoSave()) {
scheduler.scheduleSyncRepeatingTask(this, this, scheduler.scheduleSyncRepeatingTask(this, this, BoosConfigManager.getSaveInterval() * 1200, BoosConfigManager.getSaveInterval() * 1200);
BoosConfigManager.getSaveInterval() * 1200,
BoosConfigManager.getSaveInterval() * 1200);
} }
if (BoosConfigManager.getClearOnRestart()) { if (BoosConfigManager.getClearOnRestart()) {
@ -405,9 +336,7 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
if (BoosConfigManager.getCancelWarmUpOnDamage()) { if (BoosConfigManager.getCancelWarmUpOnDamage()) {
pm.registerEvents(new BoosEntityDamageListener(), this); pm.registerEvents(new BoosEntityDamageListener(), this);
} }
if (BoosConfigManager.getCleanCooldownsOnDeath() if (BoosConfigManager.getCleanCooldownsOnDeath() || BoosConfigManager.getCleanUsesOnDeath() || BoosConfigManager.getStartCooldownsOnDeath()) {
|| BoosConfigManager.getCleanUsesOnDeath()
|| BoosConfigManager.getStartCooldownsOnDeath()) {
pm.registerEvents(new BoosPlayerDeathListener(), this); pm.registerEvents(new BoosPlayerDeathListener(), this);
} }
if (BoosConfigManager.getCancelWarmUpOnGameModeChange()) { if (BoosConfigManager.getCancelWarmUpOnGameModeChange()) {
@ -446,8 +375,8 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
private boolean setupEconomy() { private boolean setupEconomy() {
if (usingVault) { if (usingVault) {
RegisteredServiceProvider<Economy> economyProvider = getServer() RegisteredServiceProvider<Economy> economyProvider = getServer()
.getServicesManager().getRegistration( .getServicesManager()
net.milkbowl.vault.economy.Economy.class); .getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) { if (economyProvider != null) {
economy = economyProvider.getProvider(); economy = economyProvider.getProvider();
} }

View File

@ -161,7 +161,7 @@ public class BoosCoolDownListener implements Listener {
} }
} }
} }
if (BoosConfigManager.getConfirmCommandEnabled()) { if (BoosConfigManager.getConfirmCommandEnabled(player)) {
for (String key : commandQueue.keySet()) { for (String key : commandQueue.keySet()) {
String[] keyList = key.split("@"); String[] keyList = key.split("@");
if (keyList[0].equals(String.valueOf(uuid))) { if (keyList[0].equals(String.valueOf(uuid))) {
@ -229,13 +229,13 @@ public class BoosCoolDownListener implements Listener {
break; break;
} }
} }
if (!BoosConfigManager.getConfirmCommandEnabled() || (commandQueue.keySet().contains(uuid + "@" + originalCommand) && commandQueue.get(uuid + "@" + originalCommand))) { if (!BoosConfigManager.getConfirmCommandEnabled(player) || (commandQueue.keySet().contains(uuid + "@" + originalCommand) && commandQueue.get(uuid + "@" + originalCommand))) {
this.checkRestrictions(event, player, regexCommad, originalCommand, this.checkRestrictions(event, player, regexCommad, originalCommand,
warmupTime, cooldownTime, price, item, count, limit, warmupTime, cooldownTime, price, item, count, limit,
xpPrice); xpPrice);
} else { } else {
if ((price > 0 || xpPrice > 0 || count > 0 || limit > 0) && !BoosWarmUpManager.isWarmUpProcess(player, regexCommad) && !BoosCoolDownManager.isCoolingdown(player,regexCommad,cooldownTime)) { if ((price > 0 || xpPrice > 0 || count > 0 || limit > 0) && !BoosWarmUpManager.isWarmUpProcess(player, regexCommad) && !BoosCoolDownManager.isCoolingdown(player,regexCommad,cooldownTime)) {
if (BoosConfigManager.getConfirmCommandEnabled()) { if (BoosConfigManager.getConfirmCommandEnabled(player)) {
commandQueue.put(uuid + "@" + originalCommand, false); commandQueue.put(uuid + "@" + originalCommand, false);
String questionMessage = BoosConfigManager.getQuestionMessage(); String questionMessage = BoosConfigManager.getQuestionMessage();
questionMessage = questionMessage.replace("&command&", originalCommand); questionMessage = questionMessage.replace("&command&", originalCommand);
@ -287,7 +287,7 @@ public class BoosCoolDownListener implements Listener {
private void onPlayerChatEvent(AsyncPlayerChatEvent event){ private void onPlayerChatEvent(AsyncPlayerChatEvent event){
Player player = event.getPlayer(); Player player = event.getPlayer();
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (BoosConfigManager.getConfirmCommandEnabled()) { if (BoosConfigManager.getConfirmCommandEnabled(player)) {
for (String key : commandQueue.keySet()) { for (String key : commandQueue.keySet()) {
String[] keyList = key.split("@"); String[] keyList = key.split("@");
if (keyList[0].equals(String.valueOf(uuid))) { if (keyList[0].equals(String.valueOf(uuid))) {

View File

@ -5,6 +5,7 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import util.boosChat;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -42,20 +43,18 @@ public class BoosConfigManager {
confusersFile.createNewFile(); confusersFile.createNewFile();
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Could not save storage file!");
"[boosCooldowns] Could not save storage file!");
} }
} }
} }
public static void clear() { public static void clear() {
ConfigurationSection userSection = confusers ConfigurationSection userSection = confusers.getConfigurationSection("users");
.getConfigurationSection("users"); if (userSection == null) {
if (userSection == null)
return; return;
}
for (String user : userSection.getKeys(false)) { for (String user : userSection.getKeys(false)) {
ConfigurationSection cooldown = confusers ConfigurationSection cooldown = confusers.getConfigurationSection("users." + user + ".cooldown");
.getConfigurationSection("users." + user + ".cooldown");
if (cooldown != null) { if (cooldown != null) {
for (String key : cooldown.getKeys(false)) { for (String key : cooldown.getKeys(false)) {
confusers.set("users." + user + ".cooldown." + key, null); confusers.set("users." + user + ".cooldown." + key, null);
@ -63,8 +62,7 @@ public class BoosConfigManager {
} }
confusers.set("users." + user + ".cooldown", null); confusers.set("users." + user + ".cooldown", null);
ConfigurationSection warmup = confusers ConfigurationSection warmup = confusers.getConfigurationSection("users." + user + ".warmup");
.getConfigurationSection("users." + user + ".warmup");
if (warmup != null) { if (warmup != null) {
for (String key : warmup.getKeys(false)) { for (String key : warmup.getKeys(false)) {
confusers.set("users." + user + ".warmup." + key, null); confusers.set("users." + user + ".warmup." + key, null);
@ -79,10 +77,10 @@ public class BoosConfigManager {
} }
public static void clearSomething(String co, UUID uuid) { public static void clearSomething(String co, UUID uuid) {
ConfigurationSection userSection = confusers ConfigurationSection userSection = confusers.getConfigurationSection("users." + uuid + "." + co);
.getConfigurationSection("users." + uuid + "." + co); if (userSection == null) {
if (userSection == null)
return; return;
}
confusers.set("users." + uuid + "." + co, null); confusers.set("users." + uuid + "." + co, null);
saveConfusers(); saveConfusers();
loadConfusers(); loadConfusers();
@ -101,34 +99,27 @@ public class BoosConfigManager {
public static Set<String> getAliases() { public static Set<String> getAliases() {
Set<String> aliases = null; Set<String> aliases = null;
ConfigurationSection aliasesSection = conf ConfigurationSection aliasesSection = conf.getConfigurationSection("commands.aliases");
.getConfigurationSection("commands.aliases");
if (aliasesSection != null) { if (aliasesSection != null) {
aliases = conf.getConfigurationSection("commands.aliases").getKeys( aliases = conf.getConfigurationSection("commands.aliases").getKeys(false);
false);
} }
return aliases; return aliases;
} }
public static boolean getBlockInteractDuringWarmup() { public static boolean getBlockInteractDuringWarmup() {
return conf.getBoolean("options.options.block_interact_during_warmup", return conf.getBoolean("options.options.block_interact_during_warmup", false);
false);
} }
public static String getCancelWarmupByGameModeChangeMessage() { public static String getCancelWarmupByGameModeChangeMessage() {
return conf.getString( return conf.getString("options.messages.warmup_cancelled_by_gamemode_change", "&6Warm-ups have been cancelled due to changing gamemode.&f");
"options.messages.warmup_cancelled_by_gamemode_change",
"&6Warm-ups have been cancelled due to changing gamemode.&f");
} }
public static boolean getCancelWarmUpOnDamage() { public static boolean getCancelWarmUpOnDamage() {
return conf return conf.getBoolean("options.options.cancel_warmup_on_damage", false);
.getBoolean("options.options.cancel_warmup_on_damage", false);
} }
public static boolean getCancelWarmUpOnGameModeChange() { public static boolean getCancelWarmUpOnGameModeChange() {
return conf.getBoolean( return conf.getBoolean("options.options.cancel_warmup_on_gamemode_change", false);
"options.options.cancel_warmup_on_gamemode_change", false);
} }
public static boolean getCancelWarmupOnMove() { public static boolean getCancelWarmupOnMove() {
@ -140,33 +131,27 @@ public class BoosConfigManager {
} }
public static String getCancelWarmupOnSneakMessage() { public static String getCancelWarmupOnSneakMessage() {
return conf.getString("options.messages.warmup_cancelled_by_sneak", return conf.getString("options.messages.warmup_cancelled_by_sneak", "&6Warm-ups have been cancelled due to sneaking.&f");
"&6Warm-ups have been cancelled due to sneaking.&f");
} }
public static boolean getCancelWarmupOnSprint() { public static boolean getCancelWarmupOnSprint() {
return conf return conf.getBoolean("options.options.cancel_warmup_on_sprint", false);
.getBoolean("options.options.cancel_warmup_on_sprint", false);
} }
public static String getCancelWarmupOnSprintMessage() { public static String getCancelWarmupOnSprintMessage() {
return conf.getString("options.messages.warmup_cancelled_by_sprint", return conf.getString("options.messages.warmup_cancelled_by_sprint", "&6Warm-ups have been cancelled due to sprinting.&f");
"&6Warm-ups have been cancelled due to sprinting.&f");
} }
public static String getCannotCreateSignMessage() { public static String getCannotCreateSignMessage() {
return conf.getString("options.messages.cannot_create_sign", return conf.getString("options.messages.cannot_create_sign", "&6You are not allowed to create this kind of signs!&f");
"&6You are not allowed to create this kind of signs!&f");
} }
public static String getCannotUseSignMessage() { public static String getCannotUseSignMessage() {
return conf.getString("options.messages.cannot_use_sign", return conf.getString("options.messages.cannot_use_sign", "&6You are not allowed to use this sign!&f");
"&6You are not allowed to use this sign!&f");
} }
public static boolean getCleanCooldownsOnDeath() { public static boolean getCleanCooldownsOnDeath() {
return conf.getBoolean("options.options.clear_cooldowns_on_death", return conf.getBoolean("options.options.clear_cooldowns_on_death", false);
false);
} }
public static boolean getCleanUsesOnDeath() { public static boolean getCleanUsesOnDeath() {
@ -178,8 +163,7 @@ public class BoosConfigManager {
} }
static String getCommandBlockedMessage() { static String getCommandBlockedMessage() {
return conf.getString("options.messages.limit_achieved", return conf.getString("options.messages.limit_achieved", "&6You cannot use this command anymore!&f");
"&6You cannot use this command anymore!&f");
} }
private static String getCommandGroup(Player player) { private static String getCommandGroup(Player player) {
@ -196,8 +180,7 @@ public class BoosConfigManager {
} }
private static Set<String> getCommandGroups() { private static Set<String> getCommandGroups() {
ConfigurationSection groupsSection = conf ConfigurationSection groupsSection = conf.getConfigurationSection("commands.groups");
.getConfigurationSection("commands.groups");
Set<String> groups = null; Set<String> groups = null;
if (groupsSection != null) { if (groupsSection != null) {
groups = groupsSection.getKeys(false); groups = groupsSection.getKeys(false);
@ -212,8 +195,7 @@ public class BoosConfigManager {
public static Set<String> getCommands(Player player) { public static Set<String> getCommands(Player player) {
String group = getCommandGroup(player); String group = getCommandGroup(player);
Set<String> commands = null; Set<String> commands = null;
ConfigurationSection commandsSection = conf ConfigurationSection commandsSection = conf.getConfigurationSection("commands.groups." + group);
.getConfigurationSection("commands.groups." + group);
if (commandsSection != null) { if (commandsSection != null) {
commands = commandsSection.getKeys(false); commands = commandsSection.getKeys(false);
} }
@ -228,8 +210,7 @@ public class BoosConfigManager {
int coolDown; int coolDown;
String coolDownString = ""; String coolDownString = "";
String group = getCommandGroup(player); String group = getCommandGroup(player);
coolDownString = conf.getString("commands.groups." + group + "." coolDownString = conf.getString("commands.groups." + group + "." + regexCommand + ".cooldown", "0");
+ regexCommand + ".cooldown", "0");
coolDown = parseTime(coolDownString); coolDown = parseTime(coolDownString);
return coolDown; return coolDown;
} }
@ -239,29 +220,21 @@ public class BoosConfigManager {
} }
static String getCoolDownMessage() { static String getCoolDownMessage() {
return conf return conf.getString("options.messages.cooling_down", "&6Wait&e &seconds& seconds&6 before you can use command&e &command& &6again.&f");
.getString(
"options.messages.cooling_down",
"&6Wait&e &seconds& seconds&6 before you can use command&e &command& &6again.&f");
} }
static Set<String> getCooldowns(Player player) { static Set<String> getCooldowns(Player player) {
String cool = getCommandGroup(player); String cool = getCommandGroup(player);
return conf.getConfigurationSection( return conf.getConfigurationSection("commands.groups." + cool).getKeys(false);
"commands.groups." + cool).getKeys(false);
} }
public static String getInsufficientFundsMessage() { public static String getInsufficientFundsMessage() {
return conf return conf.getString("options.messages.insufficient_funds",
.getString( "&6You have insufficient funds!&e &command& &6costs &e%s &6but you only have &e%s");
"options.messages.insufficient_funds",
"&6You have insufficient funds!&e &command& &6costs &e%s &6but you only have &e%s");
} }
public static String getInteractBlockedMessage() { public static String getInteractBlockedMessage() {
return conf.getString( return conf.getString("options.messages.interact_blocked_during_warmup", "&6You can't do this when command is warming-up!&f");
"options.messages.interact_blocked_during_warmup",
"&6You can't do this when command is warming-up!&f");
} }
public static String getItemCostItem(String regexCommand, Player player) { public static String getItemCostItem(String regexCommand, Player player) {
@ -269,8 +242,7 @@ public class BoosConfigManager {
String temp; String temp;
String[] command; String[] command;
String group = getCommandGroup(player); String group = getCommandGroup(player);
temp = conf.getString("commands.groups." + group + "." + regexCommand temp = conf.getString("commands.groups." + group + "." + regexCommand + ".itemcost", "");
+ ".itemcost", "");
command = temp.split(","); command = temp.split(",");
if (command.length == 2) { if (command.length == 2) {
item = command[0]; item = command[0];
@ -283,8 +255,7 @@ public class BoosConfigManager {
String temp; String temp;
String[] command; String[] command;
String group = getCommandGroup(player); String group = getCommandGroup(player);
temp = conf.getString("commands.groups." + group + "." + regexCommand temp = conf.getString("commands.groups." + group + "." + regexCommand + ".itemcost", "");
+ ".itemcost", "");
command = temp.split(","); command = temp.split(",");
if (command.length == 2) { if (command.length == 2) {
count = Integer.valueOf(command[1]); count = Integer.valueOf(command[1]);
@ -295,8 +266,7 @@ public class BoosConfigManager {
public static int getLimit(String regexCommand, Player player) { public static int getLimit(String regexCommand, Player player) {
int limit; int limit;
String group = getCommandGroup(player); String group = getCommandGroup(player);
limit = conf.getInt("commands.groups." + group + "." + regexCommand limit = conf.getInt("commands.groups." + group + "." + regexCommand + ".limit", -1);
+ ".limit", -1);
return limit; return limit;
} }
@ -305,10 +275,8 @@ public class BoosConfigManager {
} }
static String getLimitListMessage() { static String getLimitListMessage() {
return conf return conf.getString("options.messages.limit_list",
.getString( "&6Limit for command &e&command&&6 is &e&limit&&6. You can still use it &e&times&&6 times.&f");
"options.messages.limit_list",
"&6Limit for command &e&command&&6 is &e&limit&&6. You can still use it &e&times&&6 times.&f");
} }
static boolean getLimitsEnabled() { static boolean getLimitsEnabled() {
@ -323,35 +291,30 @@ public class BoosConfigManager {
static List<String> getSharedCooldowns(String pre, Player player) { static List<String> getSharedCooldowns(String pre, Player player) {
List<String> sharedCooldowns; List<String> sharedCooldowns;
String group = getCommandGroup(player); String group = getCommandGroup(player);
sharedCooldowns = conf.getStringList("commands.groups." + group + "." sharedCooldowns = conf.getStringList("commands.groups." + group + "." + pre + ".shared_cooldown");
+ pre + ".shared_cooldown");
return sharedCooldowns; return sharedCooldowns;
} }
public static List<String> getSharedLimits(String pre, Player player) { public static List<String> getSharedLimits(String pre, Player player) {
List<String> sharedLimits; List<String> sharedLimits;
String group = getCommandGroup(player); String group = getCommandGroup(player);
sharedLimits = conf.getStringList("commands.groups." + group + "." sharedLimits = conf.getStringList("commands.groups." + group + "." + pre + ".shared_limit");
+ pre + ".shared_limit");
return sharedLimits; return sharedLimits;
} }
public static String getMessage(String regexCommand, Player player) { public static String getMessage(String regexCommand, Player player) {
String message = ""; String message = "";
String group = getCommandGroup(player); String group = getCommandGroup(player);
message = conf.getString("commands.groups." + group + "." message = conf.getString("commands.groups." + group + "." + regexCommand + ".message", "");
+ regexCommand + ".message", "");
return message; return message;
} }
static String getPaidErrorMessage() { static String getPaidErrorMessage() {
return conf.getString("options.messages.paid_error", return conf.getString("options.messages.paid_error", "An error has occured: %s");
"An error has occured: %s");
} }
static String getPaidForCommandMessage() { static String getPaidForCommandMessage() {
return conf.getString("options.messages.paid_for_command", return conf.getString("options.messages.paid_for_command", "Price of &command& was %s and you now have %s");
"Price of &command& was %s and you now have %s");
} }
static String getPotionEffect(String regexCommand, Player player) { static String getPotionEffect(String regexCommand, Player player) {
@ -359,8 +322,7 @@ public class BoosConfigManager {
String temp; String temp;
String[] command; String[] command;
String group = getCommandGroup(player); String group = getCommandGroup(player);
temp = conf.getString("commands.groups." + group + "." + regexCommand temp = conf.getString("commands.groups." + group + "." + regexCommand + ".potion", "");
+ ".potion", "");
command = temp.split(","); command = temp.split(",");
if (command.length == 2) { if (command.length == 2) {
effect = command[0]; effect = command[0];
@ -373,8 +335,7 @@ public class BoosConfigManager {
String temp; String temp;
String[] command; String[] command;
String group = getCommandGroup(player); String group = getCommandGroup(player);
temp = conf.getString("commands.groups." + group + "." + regexCommand temp = conf.getString("commands.groups." + group + "." + regexCommand + ".potion", "");
+ ".potion", "");
command = temp.split(","); command = temp.split(",");
if (command.length == 2) { if (command.length == 2) {
effect = Integer.valueOf(command[1]); effect = Integer.valueOf(command[1]);
@ -385,8 +346,7 @@ public class BoosConfigManager {
public static double getPrice(String regexCommand, Player player) { public static double getPrice(String regexCommand, Player player) {
double price; double price;
String group = getCommandGroup(player); String group = getCommandGroup(player);
price = conf.getDouble("commands.groups." + group + "." + regexCommand price = conf.getDouble("commands.groups." + group + "." + regexCommand + ".price", 0.0);
+ ".price", 0.0);
return price; return price;
} }
@ -403,8 +363,7 @@ public class BoosConfigManager {
} }
public static boolean getStartCooldownsOnDeath() { public static boolean getStartCooldownsOnDeath() {
return conf.getBoolean("options.options.start_cooldowns_on_death", return conf.getBoolean("options.options.start_cooldowns_on_death", false);
false);
} }
static String getUnitHoursMessage() { static String getUnitHoursMessage() {
@ -423,25 +382,21 @@ public class BoosConfigManager {
int warmUp; int warmUp;
String warmUpString = ""; String warmUpString = "";
String group = getCommandGroup(player); String group = getCommandGroup(player);
warmUpString = conf.getString("commands.groups." + group + "." warmUpString = conf.getString("commands.groups." + group + "." + regexCommand + ".warmup", "0");
+ regexCommand + ".warmup", "0");
warmUp = parseTime(warmUpString); warmUp = parseTime(warmUpString);
return warmUp; return warmUp;
} }
static String getWarmUpAlreadyStartedMessage() { static String getWarmUpAlreadyStartedMessage() {
return conf.getString("options.messages.warmup_already_started", return conf.getString("options.messages.warmup_already_started", "&6Warm-Up process for&e &command& &6has already started.&f");
"&6Warm-Up process for&e &command& &6has already started.&f");
} }
public static String getWarmUpCancelledByDamageMessage() { public static String getWarmUpCancelledByDamageMessage() {
return conf.getString("options.messages.warmup_cancelled_by_damage", return conf.getString("options.messages.warmup_cancelled_by_damage", "&6Warm-ups have been cancelled due to receiving damage.&f");
"&6Warm-ups have been cancelled due to receiving damage.&f");
} }
public static String getWarmUpCancelledByMoveMessage() { public static String getWarmUpCancelledByMoveMessage() {
return conf.getString("options.messages.warmup_cancelled_by_move", return conf.getString("options.messages.warmup_cancelled_by_move", "&6Warm-ups have been cancelled due to moving.&f");
"&6Warm-ups have been cancelled due to moving.&f");
} }
public static boolean getWarmupEnabled() { public static boolean getWarmupEnabled() {
@ -449,9 +404,7 @@ public class BoosConfigManager {
} }
static String getWarmUpMessage() { static String getWarmUpMessage() {
return conf return conf.getString("options.messages.warming_up", "&6Wait&e &seconds& seconds&6 before command&e &command& &6has warmed up.&f");
.getString("options.messages.warming_up",
"&6Wait&e &seconds& seconds&6 before command&e &command& &6has warmed up.&f");
} }
public static void load() { public static void load() {
@ -459,16 +412,13 @@ public class BoosConfigManager {
conf.load(confFile); conf.load(confFile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Configuration file not found!");
"[boosCooldowns] Configuration file not found!");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Could not read configuration file!");
"[boosCooldowns] Could not read configuration file!");
} catch (InvalidConfigurationException e) { } catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Configuration file is invalid!");
"[boosCooldowns] Configuration file is invalid!");
} }
} }
@ -477,16 +427,13 @@ public class BoosConfigManager {
confusers.load(confusersFile); confusers.load(confusersFile);
} catch (FileNotFoundException e) { } catch (FileNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Storage file not found!");
"[boosCooldowns] Storage file not found!");
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Could not read storage file!");
"[boosCooldowns] Could not read storage file!");
} catch (InvalidConfigurationException e) { } catch (InvalidConfigurationException e) {
e.printStackTrace(); e.printStackTrace();
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Storage file is invalid!");
"[boosCooldowns] Storage file is invalid!");
} }
} }
@ -501,49 +448,57 @@ public class BoosConfigManager {
confusers.save(confusersFile); confusers.save(confusersFile);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Could not save storage file!");
"[boosCooldowns] Could not save storage file!");
} }
} }
public static void setAddToConfigFile(String group, String command, String what, public static void setAddToConfigFile(String group, String command, String what, String value) {
String value) {
group = group.toLowerCase(); group = group.toLowerCase();
command = command.toLowerCase(); command = command.toLowerCase();
int value2; int value2;
try { try {
value2 = Integer.parseInt(value); value2 = Integer.parseInt(value);
reload(); reload();
conf.set("commands.groups." + group + "." + command + "." + what, conf.set("commands.groups." + group + "." + command + "." + what, value2);
value2);
} catch (NumberFormatException e1) { } catch (NumberFormatException e1) {
reload(); reload();
conf.set("commands.groups." + group + "." + command + "." + what, conf.set("commands.groups." + group + "." + command + "." + what, value);
value);
} }
try { try {
conf.save(confFile); conf.save(confFile);
} catch (IOException e) { } catch (IOException e) {
BoosCoolDown.getLog().severe( BoosCoolDown.getLog().severe("[boosCooldowns] Could not save configuration file!");
"[boosCooldowns] Could not save configuration file!");
} }
reload(); reload();
} }
public static void toggleConfirmations(Player player) {
Boolean def = confusers.getBoolean("users." + player.getUniqueId() + ".confirmations", getConfirmCommandEnabled(player));
confusers.set("users." + player.getUniqueId() + ".confirmations", !def);
if (def) {
boosChat.sendMessageToPlayer(player, "&6[boosCooldowns]&e " + getConfirmToggleMessageFalse());
} else {
boosChat.sendMessageToPlayer(player, "&6[boosCooldowns]&e " + getConfirmToggleMessageTrue());
}
saveConfusers();
loadConfusers();
}
public static Boolean getConfirmationsPlayer(Player player) {
return (Boolean)confusers.get("users." + player.getUniqueId() + ".confirmations", null);
}
public static boolean getAutoSave() { public static boolean getAutoSave() {
return conf.getBoolean( return conf.getBoolean("options.options.auto_save_enabled_CAN_CAUSE_BIG_LAGS", false);
"options.options.auto_save_enabled_CAN_CAUSE_BIG_LAGS", false);
} }
static String getPaidItemsForCommandMessage() { static String getPaidItemsForCommandMessage() {
return conf.getString("options.messages.paid_items_for_command", return conf.getString("options.messages.paid_items_for_command", "&6Price of&e &command& &6was &e%s");
"&6Price of&e &command& &6was &e%s");
} }
public static String getInsufficientItemsMessage() { public static String getInsufficientItemsMessage() {
return conf.getString("options.messages.insufficient_items", return conf.getString("options.messages.insufficient_items", "&6You have not enough items!&e &command& &6needs &e%s");
"&6You have not enough items!&e &command& &6needs &e%s");
} }
public static boolean getItemCostEnabled() { public static boolean getItemCostEnabled() {
@ -551,15 +506,13 @@ public class BoosConfigManager {
} }
static String getPaidXPForCommandMessage() { static String getPaidXPForCommandMessage() {
return conf.getString("options.messages.paid_xp_for_command", return conf.getString("options.messages.paid_xp_for_command", "&6Price of&e &command& &6was &e%s");
"&6Price of&e &command& &6was &e%s");
} }
public static int getXpPrice(String regexCommand, Player player) { public static int getXpPrice(String regexCommand, Player player) {
int price; int price;
String group = getCommandGroup(player); String group = getCommandGroup(player);
price = conf.getInt("commands.groups." + group + "." + regexCommand price = conf.getInt("commands.groups." + group + "." + regexCommand + ".xpcost", 0);
+ ".xpcost", 0);
return price; return price;
} }
@ -568,31 +521,24 @@ public class BoosConfigManager {
} }
public static String getInsufficientXpMessage() { public static String getInsufficientXpMessage() {
return conf.getString("options.messages.insufficient_xp", return conf.getString("options.messages.insufficient_xp", "&6You have not enough XP!&e &command& &6needs &e%s");
"&6You have not enough XP!&e &command& &6needs &e%s");
} }
public static String getInvalidCommandSyntaxMessage() { public static String getInvalidCommandSyntaxMessage() {
return conf return conf.getString("options.messages.invalid_command_syntax", "&6You are not allowed to use command syntax /<pluginname>:<command>!");
.getString("options.messages.invalid_command_syntax",
"&6You are not allowed to use command syntax /<pluginname>:<command>!");
} }
static long getLimitResetDelay(String regexCommand, Player player) { static long getLimitResetDelay(String regexCommand, Player player) {
long limitreset; long limitreset;
String limitResetString = ""; String limitResetString = "";
String group = getCommandGroup(player); String group = getCommandGroup(player);
limitResetString = conf.getString("commands.groups." + group + "." limitResetString = conf.getString("commands.groups." + group + "." + regexCommand + ".limit_reset_delay", "0");
+ regexCommand + ".limit_reset_delay", "0");
limitreset = parseTime(limitResetString); limitreset = parseTime(limitResetString);
return limitreset; return limitreset;
} }
static String getLimitResetMessage() { static String getLimitResetMessage() {
return conf return conf.getString("options.messages.limit_reset", "&6Wait&e &seconds& &unit&&6 before your limit for command&e &command& &6is reset.&f");
.getString(
"options.messages.limit_reset",
"&6Wait&e &seconds& &unit&&6 before your limit for command&e &command& &6is reset.&f");
} }
static void clearSomething2(String co, String uuid, int hashedCommand) { static void clearSomething2(String co, String uuid, int hashedCommand) {
@ -602,8 +548,7 @@ public class BoosConfigManager {
public static long getLimitResetDelayGlobal(String command) { public static long getLimitResetDelayGlobal(String command) {
long delay = 0; long delay = 0;
String delayString = ""; String delayString = "";
delayString = conf.getString( delayString = conf.getString("global." + command + ".limit_reset_delay", "0");
"global." + command + ".limit_reset_delay", "0");
delay = parseTime(delayString); delay = parseTime(delayString);
return delay; return delay;
} }
@ -651,45 +596,45 @@ public class BoosConfigManager {
} }
public static String getLimitResetNowMessage() { public static String getLimitResetNowMessage() {
return conf.getString("options.messages.limit_reset_now", return conf.getString("options.messages.limit_reset_now", "&6Reseting limits for command&e &command& &6now.&f");
"&6Reseting limits for command&e &command& &6now.&f");
} }
public static String getPermission(Player player, String regexCommad) { public static String getPermission(Player player, String regexCommad) {
String group = getCommandGroup(player); String group = getCommandGroup(player);
return conf.getString("commands.groups." + group + "." return conf.getString("commands.groups." + group + "." + regexCommad + ".permission");
+ regexCommad + ".permission");
} }
public static String getPermissionMessage(Player player, String regexCommad) { public static String getPermissionMessage(Player player, String regexCommad) {
String group = getCommandGroup(player); String group = getCommandGroup(player);
return conf.getString("commands.groups." + group + "." return conf.getString("commands.groups." + group + "." + regexCommad + ".denied_message");
+ regexCommad + ".denied_message");
} }
public static String getCancelCommandMessage() { public static String getCancelCommandMessage() {
return conf.getString("options.messages.confirmation_cancel_command_execution", return conf.getString("options.messages.confirmation_cancel_command_execution", "No");
"No");
} }
public static String getConfirmCommandMessage() { public static String getConfirmCommandMessage() {
return conf.getString("options.messages.confirmation_confirm_command_execution", return conf.getString("options.messages.confirmation_confirm_command_execution", "Yes");
"Yes"); }
public static String getConfirmToggleMessageTrue() {
return conf.getString("options.messages.confirmation_toggle_enable", "Confirmation messages are now enabled for you!");
}
public static String getConfirmToggleMessageFalse() {
return conf.getString("options.messages.confirmation_toggle_disable", "Confirmation messages are now disabled for you!");
} }
public static String getItsPriceMessage() { public static String getItsPriceMessage() {
return conf.getString("options.messages.confirmation_price_of_command", return conf.getString("options.messages.confirmation_price_of_command", "&6its price is&e &price& &6and you now have &e&balance&");
"&6its price is&e &price& &6and you now have &e&balance&");
} }
public static String getQuestionMessage() { public static String getQuestionMessage() {
return conf.getString("options.messages.confirmation_message", return conf.getString("options.messages.confirmation_message", "&6Would you like to use command&e &command& &6?");
"&6Would you like to use command&e &command& &6?");
} }
public static String getItsItemCostMessage() { public static String getItsItemCostMessage() {
return conf.getString("options.messages.confirmation_item_price_of_command", return conf.getString("options.messages.confirmation_item_price_of_command", "&6its price is&e &itemprice& &itemname&");
"&6its price is&e &itemprice& &itemname&");
} }
public static String getItsLimitMessage() { public static String getItsLimitMessage() {
@ -698,22 +643,23 @@ public class BoosConfigManager {
} }
public static String getItsXpPriceMessage() { public static String getItsXpPriceMessage() {
return conf.getString("options.messages.confirmation_xp_price_of_command", return conf.getString("options.messages.confirmation_xp_price_of_command", "&6its price is&e &xpprice& experience levels");
"&6its price is&e &xpprice& experience levels");
} }
public static String getCommandCanceledMessage() { public static String getCommandCanceledMessage() {
return conf.getString("options.messages.confirmation_command_cancelled", return conf.getString("options.messages.confirmation_command_cancelled", "&6Execution of command&e &command& &6was cancelled");
"&6Execution of command&e &command& &6was cancelled");
} }
public static boolean getSyntaxBlocker() { public static boolean getSyntaxBlocker() {
return conf.getBoolean("options.options.syntax_blocker_enabled", return conf.getBoolean("options.options.syntax_blocker_enabled", true);
true);
} }
public static boolean getConfirmCommandEnabled() { public static boolean getConfirmCommandEnabled(Player player) {
return conf.getBoolean("options.options.command_confirmation", Boolean playersChoice = getConfirmationsPlayer(player);
true); if (playersChoice != null) {
return playersChoice;
} else {
return conf.getBoolean("options.options.command_confirmation", true);
}
} }
} }

View File

@ -21,6 +21,7 @@ options:
command_logging: false command_logging: false
command_signs: false command_signs: false
syntax_blocker_enabled: true syntax_blocker_enabled: true
command_confirmation: true
units: units:
seconds: seconds seconds: seconds
minutes: minutes minutes: minutes
@ -63,6 +64,8 @@ options:
confirmation_confirm_command_execution: 'Yes' confirmation_confirm_command_execution: 'Yes'
confirmation_cancel_command_execution: 'No' confirmation_cancel_command_execution: 'No'
confirmation_command_cancelled: '&6Execution of command&e &command& &6was cancelled' confirmation_command_cancelled: '&6Execution of command&e &command& &6was cancelled'
confirmation_toggle_disable: 'Confirmation messages are now disabled for you!'
confirmation_toggle_enable: 'Confirmation messages are now enabled for you!'
commands: commands:
groups: groups:
default: default: