mirror of
https://github.com/LordBoos/boosCooldowns.git
synced 2024-11-16 15:45:55 +01:00
Now uses SuperPerms, Cleanup, Iterator fix. Thx to V10lator.
This commit is contained in:
parent
c3ad44e645
commit
36eb94ebdd
@ -462,25 +462,21 @@ public class boosConfigManager {
|
||||
|
||||
public static String getLimGrp(Player player){
|
||||
String lim;
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (boosCoolDown.getPermissions().has(player,
|
||||
if (player.hasPermission(
|
||||
"booscooldowns.limit2")) {
|
||||
lim = "limit2";
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit3")) {
|
||||
lim = "limit3";
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit4")) {
|
||||
lim = "limit4";
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit5")) {
|
||||
lim = "limit5";
|
||||
} else {
|
||||
lim = "limit";
|
||||
}
|
||||
} else {
|
||||
lim = "limit";
|
||||
}
|
||||
return lim;
|
||||
}
|
||||
|
||||
|
@ -4,8 +4,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -20,11 +18,8 @@ import util.boosChat;
|
||||
public class boosCoolDown extends JavaPlugin {
|
||||
public static final Logger log = Logger.getLogger("Minecraft");
|
||||
public static PluginDescriptionFile pdfFile;
|
||||
private static Permission permissions = null;
|
||||
private static Economy economy = null;
|
||||
private static boolean usingVault = false;
|
||||
private static boolean usingEconomy = false;
|
||||
private static boolean usingPermissions = false;
|
||||
private PluginManager pm;
|
||||
|
||||
public void onEnable() {
|
||||
@ -63,10 +58,9 @@ public class boosCoolDown extends JavaPlugin {
|
||||
public boolean onCommand(CommandSender sender, Command c,
|
||||
String commandLabel, String[] args) {
|
||||
String command = c.getName().toLowerCase();
|
||||
if (usingPermissions) {
|
||||
if (command.equalsIgnoreCase("booscooldowns")) {
|
||||
if (args.length == 1) {
|
||||
if (permissions.has(sender, "booscooldowns.reload")
|
||||
if (sender.hasPermission("booscooldowns.reload")
|
||||
&& args[0].equalsIgnoreCase("reload")) {
|
||||
boosConfigManager.reload();
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
@ -74,7 +68,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
+ " config reloaded");
|
||||
return true;
|
||||
}
|
||||
if (permissions.has(sender, "booscooldowns.list.limits")
|
||||
if (sender.hasPermission("booscooldowns.list.limits")
|
||||
&& args[0].equalsIgnoreCase("limits")) {
|
||||
try {
|
||||
Player send = (Player) sender;
|
||||
@ -87,7 +81,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
}
|
||||
if (args.length == 2) {
|
||||
String jmeno = args[1];
|
||||
if (permissions.has(sender, "booscooldowns.clearcooldowns")
|
||||
if (sender.hasPermission("booscooldowns.clearcooldowns")
|
||||
&& args[0].equalsIgnoreCase("clearcooldowns")) {
|
||||
String co = "cooldown";
|
||||
boosCoolDownManager.clearSomething(co, jmeno);
|
||||
@ -95,8 +89,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " cooldowns of player " + jmeno + " cleared");
|
||||
return true;
|
||||
} else if (permissions.has(sender,
|
||||
"booscooldowns.clearuses")
|
||||
} else if (sender.hasPermission("booscooldowns.clearuses")
|
||||
&& command.equalsIgnoreCase("booscooldowns")
|
||||
&& args[0].equalsIgnoreCase("clearuses")) {
|
||||
String co = "uses";
|
||||
@ -105,8 +98,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " uses of player " + jmeno + " cleared");
|
||||
return true;
|
||||
} else if (permissions.has(sender,
|
||||
"booscooldowns.clearwarmups")
|
||||
} else if (sender.hasPermission("booscooldowns.clearwarmups")
|
||||
&& command.equalsIgnoreCase("booscooldowns")
|
||||
&& args[0].equalsIgnoreCase("clearwarmups")) {
|
||||
String co = "warmup";
|
||||
@ -120,7 +112,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
if (args.length == 3) {
|
||||
String jmeno = args[1];
|
||||
String command2 = args[2].trim();
|
||||
if (permissions.has(sender, "booscooldowns.clearcooldowns")
|
||||
if (sender.hasPermission("booscooldowns.clearcooldowns")
|
||||
&& args[0].equalsIgnoreCase("clearcooldowns")) {
|
||||
String co = "cooldown";
|
||||
boosCoolDownManager.clearSomething(co, jmeno, command2);
|
||||
@ -129,8 +121,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
+ " cooldown for command " + command2
|
||||
+ " of player " + jmeno + " cleared");
|
||||
return true;
|
||||
} else if (permissions.has(sender,
|
||||
"booscooldowns.clearuses")
|
||||
} else if (sender.hasPermission("booscooldowns.clearuses")
|
||||
&& args[0].equalsIgnoreCase("clearuses")) {
|
||||
String co = "uses";
|
||||
boosCoolDownManager.clearSomething(co, jmeno, command2);
|
||||
@ -139,8 +130,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
+ " uses for command " + command2
|
||||
+ " of player " + jmeno + " cleared");
|
||||
return true;
|
||||
} else if (permissions.has(sender,
|
||||
"booscooldowns.clearwarmups")
|
||||
} else if (sender.hasPermission("booscooldowns.clearwarmups")
|
||||
&& args[0].equalsIgnoreCase("clearwarmups")) {
|
||||
String co = "warmup";
|
||||
boosCoolDownManager.clearSomething(co, jmeno, command2);
|
||||
@ -152,7 +142,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
if (args.length == 4) {
|
||||
if (permissions.has(sender, "booscooldowns.set")
|
||||
if (sender.hasPermission("booscooldowns.set")
|
||||
&& args[0].equalsIgnoreCase("set")) {
|
||||
String coSetnout = args[1];
|
||||
String co = args[2];
|
||||
@ -213,136 +203,7 @@ public class boosCoolDown extends JavaPlugin {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (sender.isOp()) {
|
||||
if (command.equalsIgnoreCase("booscooldowns")) {
|
||||
if (args.length == 1) {
|
||||
if (args[0].equalsIgnoreCase("reload")) {
|
||||
boosConfigManager.reload();
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " config reloaded");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (args.length == 2) {
|
||||
String jmeno = args[1];
|
||||
if (args[0].equalsIgnoreCase("clearcooldowns")) {
|
||||
String co = "cooldown";
|
||||
boosCoolDownManager.clearSomething(co, jmeno);
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " cooldowns of player " + jmeno + " cleared");
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("clearuses")) {
|
||||
String co = "uses";
|
||||
boosCoolDownManager.clearSomething(co, jmeno);
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " uses of player " + jmeno + " cleared");
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("clearwarmups")) {
|
||||
String co = "warmup";
|
||||
boosCoolDownManager.clearSomething(co, jmeno);
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " warmups of player " + jmeno + " cleared");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (args.length == 3) {
|
||||
String jmeno = args[1];
|
||||
String command2 = args[2].trim();
|
||||
if (args[0].equalsIgnoreCase("clearcooldowns")) {
|
||||
String co = "cooldown";
|
||||
boosCoolDownManager.clearSomething(co, jmeno, command2);
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " cooldown for command " + command2
|
||||
+ " of player " + jmeno + " cleared");
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("clearuses")) {
|
||||
String co = "uses";
|
||||
boosCoolDownManager.clearSomething(co, jmeno, command2);
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " uses for command " + command2
|
||||
+ " of player " + jmeno + " cleared");
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("clearwarmups")) {
|
||||
String co = "warmup";
|
||||
boosCoolDownManager.clearSomething(co, jmeno, command2);
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " warmups for command " + command2
|
||||
+ " of player " + jmeno + " cleared");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (args.length == 4) {
|
||||
if (args[0].equalsIgnoreCase("set")) {
|
||||
String coSetnout = args[1];
|
||||
String co = args[2];
|
||||
int hodnota = 0;
|
||||
try {
|
||||
hodnota = Integer.valueOf(args[3]);
|
||||
} catch (Exception e) {
|
||||
boosChat.sendMessageToCommandSender(sender, "&6["
|
||||
+ pdfFile.getName() + "]&e"
|
||||
+ " Added value must be number!");
|
||||
return true;
|
||||
}
|
||||
if (co.startsWith("/")) {
|
||||
if (coSetnout.equals("cooldown")
|
||||
|| coSetnout.equals("cooldown2")
|
||||
|| coSetnout.equals("cooldown3")
|
||||
|| coSetnout.equals("cooldown4")
|
||||
|| coSetnout.equals("cooldown5")
|
||||
|| coSetnout.equals("warmup")
|
||||
|| coSetnout.equals("warmup2")
|
||||
|| coSetnout.equals("warmup3")
|
||||
|| coSetnout.equals("warmup4")
|
||||
|| coSetnout.equals("warmup5")
|
||||
|| coSetnout.equals("limit")
|
||||
|| coSetnout.equals("limit2")
|
||||
|| coSetnout.equals("limit3")
|
||||
|| coSetnout.equals("limit4")
|
||||
|| coSetnout.equals("limit5")
|
||||
|| coSetnout.equals("price")
|
||||
|| coSetnout.equals("price2")
|
||||
|| coSetnout.equals("price3")
|
||||
|| coSetnout.equals("price4")
|
||||
|| coSetnout.equals("price5")) {
|
||||
boosConfigManager.setAddToConfigFile(coSetnout,
|
||||
co, hodnota);
|
||||
boosChat.sendMessageToCommandSender(sender,
|
||||
"&6[" + pdfFile.getName() + "]&e" + " "
|
||||
+ coSetnout + " for command "
|
||||
+ co + " is now set to "
|
||||
+ hodnota);
|
||||
return true;
|
||||
} else {
|
||||
boosChat.sendMessageToCommandSender(
|
||||
sender,
|
||||
"&6["
|
||||
+ pdfFile.getName()
|
||||
+ "]&e"
|
||||
+ " You can only set cooldown, cooldown2, cooldown3, cooldown4, cooldown5, warmup, warmup2, warmup3, warmup4, warmup5, limit, limit2, limit3, limit4, limit5, price, price2, price3, price4, price5.");
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
boosChat.sendMessageToCommandSender(
|
||||
sender,
|
||||
"&6["
|
||||
+ pdfFile.getName()
|
||||
+ "]&e"
|
||||
+ " Added command have to start with \"/\".");
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
boosChat.sendMessageToCommandSender(
|
||||
sender,
|
||||
@ -358,22 +219,10 @@ public class boosCoolDown extends JavaPlugin {
|
||||
return economy;
|
||||
}
|
||||
|
||||
public static Permission getPermissions() {
|
||||
return permissions;
|
||||
}
|
||||
|
||||
public static boolean isUsingVault() {
|
||||
return usingVault;
|
||||
}
|
||||
|
||||
public static boolean isUsingEconomy() {
|
||||
return usingEconomy;
|
||||
}
|
||||
|
||||
public static boolean isUsingPermissions() {
|
||||
return usingPermissions;
|
||||
}
|
||||
|
||||
public static void commandLogger(String player, String command) {
|
||||
log.info("[" + "boosLogger" + "] " + player + " used command "
|
||||
+ command);
|
||||
@ -387,25 +236,8 @@ public class boosCoolDown extends JavaPlugin {
|
||||
if (economyProvider != null) {
|
||||
economy = economyProvider.getProvider();
|
||||
}
|
||||
usingEconomy = true;
|
||||
return (economy != null);
|
||||
}
|
||||
usingEconomy = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean setupPermissions() {
|
||||
if (usingVault) {
|
||||
RegisteredServiceProvider<Permission> permissionsProvider = getServer()
|
||||
.getServicesManager().getRegistration(
|
||||
net.milkbowl.vault.permission.Permission.class);
|
||||
if (permissionsProvider != null) {
|
||||
permissions = permissionsProvider.getProvider();
|
||||
}
|
||||
usingPermissions = true;
|
||||
return (permissions != null);
|
||||
}
|
||||
usingPermissions = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -414,48 +246,22 @@ public class boosCoolDown extends JavaPlugin {
|
||||
if (x != null & x instanceof Vault) {
|
||||
log.info("[" + pdfFile.getName() + "]"
|
||||
+ " found [Vault] searching for economy plugin.");
|
||||
log.info("[" + pdfFile.getName() + "]"
|
||||
+ " found [Vault] searching for permissions plugin.");
|
||||
usingVault = true;
|
||||
if (setupEconomy() && setupPermissions()) {
|
||||
if (setupEconomy()) {
|
||||
log.info("[" + pdfFile.getName() + "]" + " found ["
|
||||
+ economy.getName()
|
||||
+ "] plugin, enabling prices support.");
|
||||
log.info("[" + pdfFile.getName() + "]" + " found ["
|
||||
+ permissions.getName()
|
||||
+ "] plugin, enabling permissions support.");
|
||||
} else if (setupEconomy() && !setupPermissions()) {
|
||||
log.info("[" + pdfFile.getName() + "]" + " found ["
|
||||
+ economy.getName()
|
||||
+ "] plugin, enabling prices support.");
|
||||
log.info("["
|
||||
+ pdfFile.getName()
|
||||
+ "]"
|
||||
+ "] permissions pluging not found, disabling permissions support.");
|
||||
} else if (!setupEconomy() && setupPermissions()) {
|
||||
log.info("["
|
||||
+ pdfFile.getName()
|
||||
+ "]"
|
||||
+ " economy plugin not found, disabling prices support.");
|
||||
usingEconomy = false;
|
||||
log.info("[" + pdfFile.getName() + "]" + " found ["
|
||||
+ permissions.getName()
|
||||
+ "] plugin, enabling permissions support.");
|
||||
} else {
|
||||
log.info("["
|
||||
+ pdfFile.getName()
|
||||
+ "]"
|
||||
+ " economy plugin not found, disabling prices support.");
|
||||
log.info("["
|
||||
+ pdfFile.getName()
|
||||
+ "]"
|
||||
+ "] permissions pluging not found, disabling permissions support.");
|
||||
}
|
||||
} else {
|
||||
log.info("["
|
||||
+ pdfFile.getName()
|
||||
+ "]"
|
||||
+ " [Vault] not found disabling economy and permissions support.");
|
||||
+ " [Vault] not found disabling economy support.");
|
||||
usingVault = false;
|
||||
}
|
||||
}
|
||||
|
@ -173,103 +173,86 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
|
||||
private int preSubCheck(Player player, String preSub) {
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (boosCoolDown.getPermissions().has(player,
|
||||
"booscooldowns.warmup2")) {
|
||||
|
||||
if (player.hasPermission("booscooldowns.warmup2")) {
|
||||
return boosConfigManager.getWarmUp2(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
"booscooldowns.warmup3")) {
|
||||
} else if (player.hasPermission("booscooldowns.warmup3")) {
|
||||
return boosConfigManager.getWarmUp3(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.warmup4")) {
|
||||
return boosConfigManager.getWarmUp4(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.warmup5")) {
|
||||
return boosConfigManager.getWarmUp5(preSub);
|
||||
} else {
|
||||
return boosConfigManager.getWarmUp(preSub);
|
||||
}
|
||||
} else {
|
||||
return boosConfigManager.getWarmUp(preSub);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private int preLimitCheck(Player player, String preSub) {
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (boosCoolDown.getPermissions().has(player,
|
||||
if (player.hasPermission(
|
||||
"booscooldowns.limit2")) {
|
||||
return boosConfigManager.getLimit2(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit3")) {
|
||||
return boosConfigManager.getLimit3(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit4")) {
|
||||
return boosConfigManager.getLimit4(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit5")) {
|
||||
return boosConfigManager.getLimit5(preSub);
|
||||
} else {
|
||||
return boosConfigManager.getLimit(preSub);
|
||||
}
|
||||
} else {
|
||||
return boosConfigManager.getLimit(preSub);
|
||||
}
|
||||
}
|
||||
|
||||
private int preCDCheck(Player player, String preSub) {
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (boosCoolDown.getPermissions().has(player,
|
||||
if (player.hasPermission(
|
||||
"booscooldowns.cooldown2")) {
|
||||
return boosConfigManager.getCoolDown2(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.cooldown3")) {
|
||||
return boosConfigManager.getCoolDown3(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.cooldown4")) {
|
||||
return boosConfigManager.getCoolDown4(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.cooldown5")) {
|
||||
return boosConfigManager.getCoolDown5(preSub);
|
||||
} else {
|
||||
return boosConfigManager.getCoolDown(preSub);
|
||||
}
|
||||
} else {
|
||||
return boosConfigManager.getCoolDown(preSub);
|
||||
}
|
||||
}
|
||||
|
||||
public int prePriceCheck(Player player, String preSub) {
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (boosCoolDown.getPermissions().has(player,
|
||||
if (player.hasPermission(
|
||||
"booscooldowns.cooldown2")) {
|
||||
return boosConfigManager.getPrice2(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.cooldown3")) {
|
||||
return boosConfigManager.getPrice3(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.cooldown4")) {
|
||||
return boosConfigManager.getPrice4(preSub);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.cooldown5")) {
|
||||
return boosConfigManager.getPrice5(preSub);
|
||||
} else {
|
||||
return boosConfigManager.getPrice(preSub);
|
||||
}
|
||||
} else {
|
||||
return boosConfigManager.getPrice(preSub);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean blocked(Player player, String pre, String msg) {
|
||||
int limit = -1;
|
||||
int uses = boosCoolDownManager.getUses(player, pre, msg);
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (boosCoolDown.getPermissions().has(player,
|
||||
if (player.hasPermission(
|
||||
"booscooldowns.nolimit")
|
||||
|| boosCoolDown.getPermissions().has(player,
|
||||
|| player.hasPermission(
|
||||
"booscooldowns.nolimit." + pre)) {
|
||||
} else {
|
||||
if (boosCoolDown.getPermissions().has(player,
|
||||
if (player.hasPermission(
|
||||
"booscooldowns.limit2")) {
|
||||
limit = boosConfigManager.getLimit2(pre);
|
||||
if (limit == -1) {
|
||||
@ -277,7 +260,7 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
} else if (limit <= uses) {
|
||||
return true;
|
||||
}
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit3")) {
|
||||
limit = boosConfigManager.getLimit3(pre);
|
||||
if (limit == -1) {
|
||||
@ -285,7 +268,7 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
} else if (limit <= uses) {
|
||||
return true;
|
||||
}
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit4")) {
|
||||
limit = boosConfigManager.getLimit4(pre);
|
||||
if (limit == -1) {
|
||||
@ -293,7 +276,7 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
} else if (limit <= uses) {
|
||||
return true;
|
||||
}
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
} else if (player.hasPermission(
|
||||
"booscooldowns.limit5")) {
|
||||
limit = boosConfigManager.getLimit5(pre);
|
||||
if (limit == -1) {
|
||||
@ -310,14 +293,6 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
limit = boosConfigManager.getLimit(pre);
|
||||
if (limit == -1) {
|
||||
return false;
|
||||
} else if (limit <= uses) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -326,8 +301,7 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
if (player.isOp()) {
|
||||
on = false;
|
||||
}
|
||||
if (boosCoolDown.isUsingPermissions()
|
||||
&& boosCoolDown.getPermissions().has(player,
|
||||
if (player.hasPermission(
|
||||
"booscooldowns.exception")) {
|
||||
on = false;
|
||||
} else if (player.isOp()) {
|
||||
@ -343,13 +317,10 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
Player player, String pre, String message, int warmUpSeconds,
|
||||
int price) {
|
||||
if (!blocked) {
|
||||
// int warmUpSeconds = 0;
|
||||
// warmUpSeconds = preSubCheck(player, pre);
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (warmUpSeconds > 0) {
|
||||
if (!boosCoolDown.getPermissions().has(player,
|
||||
if (!player.hasPermission(
|
||||
"booscooldowns.nowarmup")
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
&& !player.hasPermission(
|
||||
"booscooldowns.nowarmup." + pre)) {
|
||||
start(event, player, pre, message, warmUpSeconds);
|
||||
}
|
||||
@ -358,16 +329,7 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (warmUpSeconds > 0) {
|
||||
start(event, player, pre, message, warmUpSeconds);
|
||||
} else {
|
||||
if (boosCoolDownManager.coolDown(player, pre)) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!event.isCancelled() && boosCoolDown.isUsingEconomy()) {
|
||||
if (!event.isCancelled()) {
|
||||
payForCommand(event, player, pre, message, price);
|
||||
}
|
||||
} else {
|
||||
@ -388,14 +350,13 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
Player player, String pre, String message, int price) {
|
||||
String name = player.getName();
|
||||
if (price > 0) {
|
||||
if (!boosCoolDown.getPermissions().has(player,
|
||||
if (!player.hasPermission(
|
||||
"booscooldowns.noprice")
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
&& !player.hasPermission(
|
||||
"booscooldowns.noprice." + pre)) {
|
||||
if (boosPriceManager.payForCommand(player, pre, price, name)) {
|
||||
return;
|
||||
} else {
|
||||
// boosPriceManager.payForCommand(player, pre, price, name);
|
||||
boosCoolDownManager.cancelCooldown(player, pre);
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -436,9 +397,8 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (player != null
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
&& !player.hasPermission(
|
||||
"booscooldowns.nocancel.move")) {
|
||||
if (boosWarmUpManager.hasWarmUps(player) && hasMoved(player)) {
|
||||
clearLocWorld(player);
|
||||
@ -448,17 +408,6 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (player != null) {
|
||||
if (boosWarmUpManager.hasWarmUps(player) && hasMoved(player)) {
|
||||
clearLocWorld(player);
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
boosConfigManager.getWarmUpCancelledByMoveMessage());
|
||||
boosWarmUpManager.cancelWarmUps(player);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean hasMoved(Player player) {
|
||||
@ -489,9 +438,8 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (player != null
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
&& !player.hasPermission(
|
||||
"booscooldowns.nocancel.sneak")) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
@ -500,16 +448,6 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (player != null) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
boosConfigManager.getCancelWarmupOnSneakMessage());
|
||||
boosWarmUpManager.cancelWarmUps(player);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -521,9 +459,8 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
return;
|
||||
|
||||
Player player = event.getPlayer();
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (player != null
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
&& !player.hasPermission(
|
||||
"booscooldowns.nocancel.sprint")) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
@ -532,16 +469,6 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (player != null) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
boosConfigManager.getCancelWarmupOnSprintMessage());
|
||||
boosWarmUpManager.cancelWarmUps(player);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@ -555,9 +482,8 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity != null && entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (player != null
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
&& !player.hasPermission(
|
||||
"booscooldowns.nocancel.damage")) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
boosChat.sendMessageToPlayer(player, boosConfigManager
|
||||
@ -566,16 +492,6 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (player != null) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
boosChat.sendMessageToPlayer(player, boosConfigManager
|
||||
.getWarmUpCancelledByDamageMessage());
|
||||
boosWarmUpManager.cancelWarmUps(player);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -590,9 +506,8 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
Entity entity = event.getPlayer();
|
||||
if (entity != null && entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (player != null
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
&& !player.hasPermission(
|
||||
"booscooldowns.dontblock.interact")) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
if (event.getClickedBlock().getType().name()
|
||||
@ -625,40 +540,6 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (player != null) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
if (event.getClickedBlock().getType().name()
|
||||
.equals("CHEST")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("FURNACE")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("BURNING_FURNACE")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("WORKBENCH")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("DISPENSER")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("JUKEBOX")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("LOCKED_CHEST")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("ENCHANTMENT_TABLE")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("BREWING_STAND")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("CAULDRON")
|
||||
|| event.getClickedBlock().getType().name()
|
||||
.equals("STORAGE_MINECART")) {
|
||||
event.setCancelled(true);
|
||||
boosChat.sendMessageToPlayer(player,
|
||||
boosConfigManager
|
||||
.getInteractBlockedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -673,9 +554,8 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
Entity entity = event.getPlayer();
|
||||
if (entity != null && entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (player != null
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
&& !player.hasPermission(
|
||||
"booscooldowns.nocancel.gamemodechange")) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
boosChat.sendMessageToPlayer(player, boosConfigManager
|
||||
@ -684,16 +564,6 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (player != null) {
|
||||
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||
boosChat.sendMessageToPlayer(player, boosConfigManager
|
||||
.getCancelWarmupByGameModeChangeMessage());
|
||||
boosWarmUpManager.cancelWarmUps(player);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -705,9 +575,8 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
Entity entity = event.getEntity();
|
||||
if (entity != null && entity instanceof Player) {
|
||||
Player player = (Player) entity;
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (player != null
|
||||
&& boosCoolDown.getPermissions().has(player,
|
||||
&& player.hasPermission(
|
||||
"booscooldowns.clear.cooldowns.death")) {
|
||||
if (boosConfigManager.getCleanCooldownsOnDeath()) {
|
||||
boosCoolDownManager.clearSomething("cooldown", player
|
||||
@ -715,25 +584,13 @@ public class boosCoolDownListener<a> implements Listener {
|
||||
}
|
||||
}
|
||||
if (player != null
|
||||
&& boosCoolDown.getPermissions().has(player,
|
||||
&& player.hasPermission(
|
||||
"booscooldowns.clear.uses.death")) {
|
||||
if (boosConfigManager.getCleanUsesOnDeath()) {
|
||||
boosCoolDownManager.clearSomething("uses", player
|
||||
.getName().toLowerCase());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (player != null) {
|
||||
if (boosConfigManager.getCleanCooldownsOnDeath()) {
|
||||
boosCoolDownManager.clearSomething("cooldown", player
|
||||
.getName().toLowerCase());
|
||||
}
|
||||
if (boosConfigManager.getCleanUsesOnDeath()) {
|
||||
boosCoolDownManager.clearSomething("uses", player
|
||||
.getName().toLowerCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,19 +156,11 @@ public class boosCoolDownManager {
|
||||
pre = pre.toLowerCase();
|
||||
int coolDownSeconds = 0;
|
||||
coolDownSeconds = getCooldownGroup(player, pre, coolDownSeconds);
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (coolDownSeconds > 0
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
"booscooldowns.nocooldown")
|
||||
&& !boosCoolDown.getPermissions().has(player,
|
||||
"booscooldowns.nocooldown." + pre)) {
|
||||
&& !player.hasPermission("booscooldowns.nocooldown")
|
||||
&& !player.hasPermission("booscooldowns.nocooldown." + pre)) {
|
||||
return cd(player, pre, coolDownSeconds);
|
||||
}
|
||||
} else {
|
||||
if (coolDownSeconds > 0) {
|
||||
return cd(player, pre, coolDownSeconds);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -285,25 +277,17 @@ public class boosCoolDownManager {
|
||||
|
||||
private static int getCooldownGroup(Player player, String pre,
|
||||
int coolDownSeconds) {
|
||||
if (boosCoolDown.isUsingPermissions()) {
|
||||
if (boosCoolDown.getPermissions().has(player,
|
||||
"booscooldowns.cooldown2")) {
|
||||
if (player.hasPermission("booscooldowns.cooldown2")) {
|
||||
coolDownSeconds = boosConfigManager.getCoolDown2(pre);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
"booscooldowns.cooldown3")) {
|
||||
} else if (player.hasPermission("booscooldowns.cooldown3")) {
|
||||
coolDownSeconds = boosConfigManager.getCoolDown3(pre);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
"booscooldowns.cooldown4")) {
|
||||
} else if (player.hasPermission("booscooldowns.cooldown4")) {
|
||||
coolDownSeconds = boosConfigManager.getCoolDown4(pre);
|
||||
} else if (boosCoolDown.getPermissions().has(player,
|
||||
"booscooldowns.cooldown5")) {
|
||||
} else if (player.hasPermission("booscooldowns.cooldown5")) {
|
||||
coolDownSeconds = boosConfigManager.getCoolDown5(pre);
|
||||
} else {
|
||||
coolDownSeconds = boosConfigManager.getCoolDown(pre);
|
||||
}
|
||||
} else {
|
||||
coolDownSeconds = boosConfigManager.getCoolDown(pre);
|
||||
}
|
||||
return coolDownSeconds;
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,8 @@ import net.milkbowl.vault.economy.EconomyResponse;
|
||||
public class boosPriceManager {
|
||||
private static Economy economy = boosCoolDown.getEconomy();
|
||||
public static boolean payForCommand(Player player, String pre, int price, String name) {
|
||||
if (economy == null){
|
||||
return true;}
|
||||
EconomyResponse r = economy.withdrawPlayer(name, price);
|
||||
if (r.transactionSuccess()) {
|
||||
String msg = String.format(
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cz.boosik.boosCooldown;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Timer;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@ -62,10 +63,19 @@ public class boosWarmUpManager {
|
||||
boosWarmUpManager.playercommands.remove(tag);
|
||||
}
|
||||
|
||||
// public static void cancelWarmUps(Player player) {
|
||||
// for (String key : playercommands.keySet()) {
|
||||
// if (key.startsWith(player.getName() + "@")) {
|
||||
// removeWarmUpProcess(key);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
public static void cancelWarmUps(Player player) {
|
||||
for (String key : playercommands.keySet()) {
|
||||
if (key.startsWith(player.getName() + "@")) {
|
||||
removeWarmUpProcess(key);
|
||||
Iterator<String> iter = playercommands.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
if (iter.next().startsWith(player.getName() + "@")) {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,3 +9,76 @@ commands:
|
||||
booscooldowns:
|
||||
description: Reload command.
|
||||
usage: Use /booscooldowns reload, clearcooldowns <player>, clearwarmups <player> or clearuses <player>
|
||||
permissions:
|
||||
booscooldowns.exception:
|
||||
description: Player wont be affected by plugin at all (no warmups, no cooldowns, no prices).
|
||||
default: op
|
||||
booscooldowns.nocancel.move:
|
||||
description: Players warmups will not be canceled by moving, even if it's turned on.
|
||||
default: false
|
||||
booscooldowns.nocancel.damage:
|
||||
description: Players warmups will not be canceled by damage, even if it's turned on.
|
||||
default: false
|
||||
booscooldowns.nocancel.sneak:
|
||||
description: Players warmups will not be canceled by sneaking, even if it's turned on.
|
||||
default: false
|
||||
booscooldowns.nocancel.sprint:
|
||||
description: Players warmups will not be canceled by sprinting, even if it's turned on.
|
||||
default: false
|
||||
booscooldowns.nocancel.gamemodechange:
|
||||
description: Players warmups will not be canceled by changing gamemode, even if it's turned on.
|
||||
default: false
|
||||
booscooldowns.dontblock.interact:
|
||||
description: Players interaction will not be blocked during warmup, even if it's turned on.
|
||||
default: false
|
||||
booscooldowns.noprice:
|
||||
description: Players commands will always be free of charge.
|
||||
default: false
|
||||
booscooldowns.noprice./command:
|
||||
description: Command "/command" will not be affected by price for users with this permission.
|
||||
default: false
|
||||
booscooldowns.nocooldown:
|
||||
description: Player wont be affected by cooldowns.
|
||||
default: false
|
||||
booscooldowns.nocooldown./command:
|
||||
description: Command "/command" will not be affected by cooldown for users with this permission.
|
||||
default: false
|
||||
booscooldowns.nowarmup:
|
||||
description: Player wont be affected by warmups.
|
||||
default: false
|
||||
booscooldowns.nowarmup./command:
|
||||
description: Command "/command" will not be affected by warmup for users with this permission.
|
||||
default: false
|
||||
booscooldowns.nolimit:
|
||||
description: Player wont be affected by limiting.
|
||||
default: false
|
||||
booscooldowns.nolimit./command:
|
||||
description: Command "/command" will not be affected by limits for users with this permission.
|
||||
default: false
|
||||
booscooldowns.warmup2-5:
|
||||
description: (example booscooldowns.warmup4) Player will be affected by given number of warmup group (times from warmup4 in config file will be used for player with booscooldowns.warmup4). Players without this permission, will be affected by default warmups, from warmup in config file.
|
||||
default: false
|
||||
booscooldowns.price2-5:
|
||||
description: (example booscooldowns.price3) Player will be affected by given number of price group (times from price3 in config file will be used for player with booscooldowns.price3). Players without this permission, will be affected by default pricess, from price in config file.
|
||||
default: false
|
||||
booscooldowns.cooldown2-5:
|
||||
description: (example booscooldowns.cooldown5) Player will be affected by given number of cooldown group (times from cooldown5 in config file will be used for player with booscooldowns.cooldown5). Players without this permission, will be affected by default cooldowns, from cooldown in config file.
|
||||
default: false
|
||||
booscooldowns.limit2-5:
|
||||
description: (example booscooldowns.blocked2) Player will be affected by given number of limit group (limited commands from blocked2 in config file will be used for player with booscooldowns.limit2). Players without this permission, will be affected by default blocked commands, from blocked in config file.
|
||||
default: false
|
||||
booscooldowns.reload:
|
||||
description: Player can use "/booscooldowns reload" to reload config file.
|
||||
default: op
|
||||
booscooldowns.clear.uses.death:
|
||||
description: Players uses (limit-uses=how many times playr can still use command) are cleared on death (must be enabled in config file too!).
|
||||
default: false
|
||||
booscooldowns.clear.cooldowns.death:
|
||||
description: Players cooldowns are cleared on death (must be enabled in config file too!).
|
||||
default: false
|
||||
booscooldowns.list.limits:
|
||||
description: Player can use "/booscooldowns limits" to see limits and how many times he can still use commands.
|
||||
default: true
|
||||
booscooldowns.set:
|
||||
description: Users with this can use "/booscooldowns set" command.
|
||||
default: op
|
Loading…
Reference in New Issue
Block a user