Add support for PlayerPoints prices

This commit is contained in:
Jakub Kolář 2016-12-11 20:54:08 +01:00
parent 70a6f3ea04
commit cace3a4a2d
21 changed files with 222 additions and 85 deletions

View File

@ -9,6 +9,7 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.black_ixx.playerpoints.PlayerPoints;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -40,13 +41,14 @@ import cz.boosik.boosCooldown.Runnables.BoosGlobalLimitResetRunnable;
import net.milkbowl.vault.Vault; import net.milkbowl.vault.Vault;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import nms.NMSSetupResponse; import nms.NMSSetupResponse;
import util.boosChat; import util.BoosChat;
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;
private static PlayerPoints playerPoints = null;
private static boolean usingVault = false; private static boolean usingVault = false;
private PluginManager pm; private PluginManager pm;
@ -58,6 +60,10 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
return economy; return economy;
} }
public static PlayerPoints getPlayerPoints() {
return playerPoints;
}
public static Logger getLog() { public static Logger getLog() {
return log; return log;
} }
@ -183,7 +189,7 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
if (args.length == 1) { if (args.length == 1) {
if (sender.hasPermission("booscooldowns.reload") && args[0].equalsIgnoreCase("reload")) { if (sender.hasPermission("booscooldowns.reload") && args[0].equalsIgnoreCase("reload")) {
reload(); reload();
boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " config reloaded"); BoosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " config reloaded");
return true; return true;
} else if (sender.hasPermission("booscooldowns.list.limits") && args[0].equalsIgnoreCase("limits")) { } else if (sender.hasPermission("booscooldowns.list.limits") && args[0].equalsIgnoreCase("limits")) {
try { try {
@ -214,20 +220,20 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
} else if (sender.hasPermission("booscooldowns.clearcooldowns") && args[0].equalsIgnoreCase("clearcooldowns")) { } else if (sender.hasPermission("booscooldowns.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") && command.equalsIgnoreCase("booscooldowns") && args[0].equalsIgnoreCase( } else if (sender.hasPermission("booscooldowns.clearuses") && command.equalsIgnoreCase("booscooldowns") && args[0].equalsIgnoreCase(
"clearuses")) { "clearuses")) {
String co = "uses"; String co = "uses";
BoosConfigManager.clearSomething(co, uuid); BoosConfigManager.clearSomething(co, uuid);
boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " uses of player " + jmeno + " cleared"); BoosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " uses of player " + jmeno + " cleared");
return true; return true;
} else if (sender.hasPermission("booscooldowns.clearwarmups") && command.equalsIgnoreCase("booscooldowns") } else if (sender.hasPermission("booscooldowns.clearwarmups") && 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, "&6[" + pdfFile.getName() + "]&e" + " warmups of player " + jmeno + " cleared"); BoosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " warmups of player " + jmeno + " cleared");
return true; return true;
} }
} else if (args.length == 3) { } else if (args.length == 3) {
@ -238,19 +244,19 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
if (sender.hasPermission("booscooldowns.clearcooldowns") && args[0].equalsIgnoreCase("clearcooldowns")) { if (sender.hasPermission("booscooldowns.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" + " cooldown for command " + command2 + " of player " + uuid + " cleared"); "&6[" + pdfFile.getName() + "]&e" + " cooldown for command " + command2 + " of player " + uuid + " cleared");
return true; return true;
} else if (sender.hasPermission("booscooldowns.clearuses") && args[0].equalsIgnoreCase("clearuses")) { } else if (sender.hasPermission("booscooldowns.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" + " uses for command " + command2 + " of player " + jmeno + " cleared"); "&6[" + pdfFile.getName() + "]&e" + " uses for command " + command2 + " of player " + jmeno + " cleared");
return true; return true;
} else if (sender.hasPermission("booscooldowns.clearwarmups") && args[0].equalsIgnoreCase("clearwarmups")) { } else if (sender.hasPermission("booscooldowns.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" + " warmups for command " + command2 + " of player " + jmeno + " cleared"); "&6[" + pdfFile.getName() + "]&e" + " warmups for command " + command2 + " of player " + jmeno + " cleared");
return true; return true;
@ -266,11 +272,11 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
comm = comm.replace("_", " "); comm = comm.replace("_", " ");
} }
BoosConfigManager.setAddToConfigFile(group, comm, what, value); BoosConfigManager.setAddToConfigFile(group, comm, what, value);
boosChat.sendMessageToCommandSender(sender, BoosChat.sendMessageToCommandSender(sender,
"&6[" + pdfFile.getName() + "]&e " + what + " for command" + comm + " in group " + group + " is now set to " + value); "&6[" + 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[" + pdfFile.getName() + "]&e" + " Command has to start with \"/\"."); BoosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]&e" + " Command has to start with \"/\".");
return true; return true;
} }
} }
@ -286,17 +292,17 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
comm = comm.replace("_", " "); comm = comm.replace("_", " ");
} }
BoosConfigManager.setAddToConfigFile(group, comm, what, value); BoosConfigManager.setAddToConfigFile(group, comm, what, value);
boosChat.sendMessageToCommandSender(sender, BoosChat.sendMessageToCommandSender(sender,
"&6[" + pdfFile.getName() + "]&e " + what + " for command" + comm + " in group " + group + " is now set to " + value); "&6[" + 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[" + pdfFile.getName() + "]&e" + " Command has to start with \"/\"."); BoosChat.sendMessageToCommandSender(sender, "&6[" + 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;
@ -330,6 +336,7 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
pm = getServer().getPluginManager(); pm = getServer().getPluginManager();
registerListeners(); registerListeners();
initializeVault(); initializeVault();
hookPlayerPoints();
BukkitScheduler scheduler = this.getServer().getScheduler(); BukkitScheduler scheduler = this.getServer().getScheduler();
startLimitResetTimersGlobal(); startLimitResetTimersGlobal();
if (BoosConfigManager.getAutoSave()) { if (BoosConfigManager.getAutoSave()) {
@ -361,6 +368,15 @@ public class BoosCoolDown extends JavaPlugin implements Runnable {
} }
private boolean hookPlayerPoints() {
final Plugin plugin = this.getServer().getPluginManager().getPlugin("PlayerPoints");
playerPoints = PlayerPoints.class.cast(plugin);
if (playerPoints != null) {
log.info("[" + pdfFile.getName() + "]" + " found [PlayerPoints], enabling support.");
}
return playerPoints != null;
}
private void registerListeners() { private void registerListeners() {
HandlerList.unregisterAll(this); HandlerList.unregisterAll(this);
pm.registerEvents(new BoosCoolDownListener(this), this); pm.registerEvents(new BoosCoolDownListener(this), this);

View File

@ -29,10 +29,11 @@ import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import cz.boosik.boosCooldown.Managers.BoosCoolDownManager; import cz.boosik.boosCooldown.Managers.BoosCoolDownManager;
import cz.boosik.boosCooldown.Managers.BoosItemCostManager; import cz.boosik.boosCooldown.Managers.BoosItemCostManager;
import cz.boosik.boosCooldown.Managers.BoosLimitManager; import cz.boosik.boosCooldown.Managers.BoosLimitManager;
import cz.boosik.boosCooldown.Managers.BoosPlayerPointsManager;
import cz.boosik.boosCooldown.Managers.BoosPriceManager; import cz.boosik.boosCooldown.Managers.BoosPriceManager;
import cz.boosik.boosCooldown.Managers.BoosWarmUpManager; import cz.boosik.boosCooldown.Managers.BoosWarmUpManager;
import cz.boosik.boosCooldown.Managers.BoosXpCostManager; import cz.boosik.boosCooldown.Managers.BoosXpCostManager;
import util.boosChat; import util.BoosChat;
public class BoosCoolDownListener implements Listener { public class BoosCoolDownListener implements Listener {
public static Map<String, Boolean> commandQueue = new ConcurrentHashMap<>(); public static Map<String, Boolean> commandQueue = new ConcurrentHashMap<>();
@ -45,14 +46,15 @@ public class BoosCoolDownListener implements Listener {
private void checkRestrictions(PlayerCommandPreprocessEvent event, private void checkRestrictions(PlayerCommandPreprocessEvent event,
Player player, String regexCommad, String originalCommand, Player player, String regexCommad, String originalCommand,
int warmupTime, int cooldownTime, double price, String item, int warmupTime, int cooldownTime, double price, String item,
int count, String name, List<String> lore, List<String> enchants, int limit, int xpPrice, int xpRequirement) { int count, String name, List<String> lore, List<String> enchants, int limit, int xpPrice,
int xpRequirement, int playerPoints) {
boolean blocked = false; boolean blocked = false;
String perm = BoosConfigManager.getPermission(player, regexCommad); String perm = BoosConfigManager.getPermission(player, regexCommad);
if (!(perm == null)) { if (!(perm == null)) {
if (!player.hasPermission(perm)) { if (!player.hasPermission(perm)) {
String msg = BoosConfigManager.getPermissionMessage(player, regexCommad); String msg = BoosConfigManager.getPermissionMessage(player, regexCommad);
if (!(msg == null)) { if (!(msg == null)) {
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
} }
event.setCancelled(true); event.setCancelled(true);
} }
@ -72,7 +74,8 @@ public class BoosCoolDownListener implements Listener {
} else if (BoosPriceManager.has(player, price) } else if (BoosPriceManager.has(player, price)
& BoosItemCostManager.has(player, item, count, name, lore, enchants) & BoosItemCostManager.has(player, item, count, name, lore, enchants)
& BoosXpCostManager.has(player, xpPrice) & BoosXpCostManager.has(player, xpPrice)
& BoosXpCostManager.has(player, xpRequirement)) { & BoosXpCostManager.has(player, xpRequirement)
& BoosPlayerPointsManager.has(player, playerPoints)) {
if (BoosCoolDownManager.coolDown(player, regexCommad, if (BoosCoolDownManager.coolDown(player, regexCommad,
originalCommand, cooldownTime)) { originalCommand, cooldownTime)) {
event.setCancelled(true); event.setCancelled(true);
@ -81,7 +84,8 @@ public class BoosCoolDownListener implements Listener {
if (BoosPriceManager.has(player, price) if (BoosPriceManager.has(player, price)
& BoosItemCostManager.has(player, item, count, name, lore, enchants) & BoosItemCostManager.has(player, item, count, name, lore, enchants)
& BoosXpCostManager.has(player, xpPrice) & BoosXpCostManager.has(player, xpPrice)
& BoosXpCostManager.has(player, xpRequirement)) { & BoosXpCostManager.has(player, xpRequirement)
& BoosPlayerPointsManager.has(player, playerPoints)) {
if (!event.isCancelled()) { if (!event.isCancelled()) {
BoosPriceManager.payForCommand(event, player, regexCommad, BoosPriceManager.payForCommand(event, player, regexCommad,
originalCommand, price); originalCommand, price);
@ -94,6 +98,10 @@ public class BoosCoolDownListener implements Listener {
BoosXpCostManager.payXPForCommand(event, player, BoosXpCostManager.payXPForCommand(event, player,
regexCommad, originalCommand, xpPrice); regexCommad, originalCommand, xpPrice);
} }
if (!event.isCancelled()) {
BoosPlayerPointsManager.payForCommand(event, player,
regexCommad, originalCommand, playerPoints);
}
} else { } else {
boolean warmupInProgress = BoosWarmUpManager.isWarmUpProcess(player, regexCommad); boolean warmupInProgress = BoosWarmUpManager.isWarmUpProcess(player, regexCommad);
boolean cooldownInProgress = BoosCoolDownManager.isCoolingdown(player, regexCommad, cooldownTime); boolean cooldownInProgress = BoosCoolDownManager.isCoolingdown(player, regexCommad, cooldownTime);
@ -107,16 +115,15 @@ public class BoosCoolDownListener implements Listener {
BoosCoolDown.getEconomy() BoosCoolDown.getEconomy()
.getBalance(player))); .getBalance(player)));
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
} }
if (!BoosItemCostManager.has(player, item, count, name, lore, enchants) if (!BoosItemCostManager.has(player, item, count, name, lore, enchants)
&& !warmupInProgress && !cooldownInProgress) { && !warmupInProgress && !cooldownInProgress) {
String msg; String msg;
msg = String.format( msg = BoosConfigManager.getInsufficientItemsMessage();
BoosConfigManager.getInsufficientItemsMessage(), "");
JSON json = getItemStackJson(1, item, count, name, lore, enchants); JSON json = getItemStackJson(1, item, count, name, lore, enchants);
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
json.send(player); json.send(player);
} }
if (!BoosXpCostManager.has(player, xpRequirement) if (!BoosXpCostManager.has(player, xpRequirement)
@ -124,18 +131,27 @@ public class BoosCoolDownListener implements Listener {
String msg; String msg;
msg = String.format( msg = String.format(
BoosConfigManager.getInsufficientXpRequirementMessage(), BoosConfigManager.getInsufficientXpRequirementMessage(),
(xpRequirement)); xpRequirement);
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
} }
if (!BoosXpCostManager.has(player, xpPrice) if (!BoosXpCostManager.has(player, xpPrice)
&& !warmupInProgress && !cooldownInProgress) { && !warmupInProgress && !cooldownInProgress) {
String msg; String msg;
msg = String.format( msg = String.format(
BoosConfigManager.getInsufficientXpMessage(), BoosConfigManager.getInsufficientXpMessage(),
(xpPrice)); xpPrice);
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
}
if (!BoosPlayerPointsManager.has(player, playerPoints)
&& !warmupInProgress && !cooldownInProgress) {
String msg;
msg = String.format(
BoosConfigManager.getInsufficientPlayerPointsMessage(),
playerPoints, BoosCoolDown.getPlayerPoints().getAPI().look(player.getUniqueId()));
msg = msg.replaceAll("&command&", originalCommand);
BoosChat.sendMessageToPlayer(player, msg);
} }
event.setCancelled(true); event.setCancelled(true);
} }
@ -143,7 +159,7 @@ public class BoosCoolDownListener implements Listener {
String msg = BoosConfigManager.getMessage( String msg = BoosConfigManager.getMessage(
regexCommad, player); regexCommad, player);
if (!msg.equals("")) { if (!msg.equals("")) {
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
} }
} }
} else { } else {
@ -181,7 +197,7 @@ public class BoosCoolDownListener implements Listener {
Matcher m = p.matcher(event.getMessage()); Matcher m = p.matcher(event.getMessage());
if (m.find()) { if (m.find()) {
{ {
boosChat.sendMessageToPlayer(player, BoosConfigManager BoosChat.sendMessageToPlayer(player, BoosConfigManager
.getInvalidCommandSyntaxMessage()); .getInvalidCommandSyntaxMessage());
event.setCancelled(true); event.setCancelled(true);
return; return;
@ -197,7 +213,7 @@ public class BoosCoolDownListener implements Listener {
commandQueue.remove(key); commandQueue.remove(key);
String commandCancelMessage = BoosConfigManager.getCommandCanceledMessage(); String commandCancelMessage = BoosConfigManager.getCommandCanceledMessage();
commandCancelMessage = commandCancelMessage.replace("&command&", keyList[1]); commandCancelMessage = commandCancelMessage.replace("&command&", keyList[1]);
boosChat.sendMessageToPlayer(player, commandCancelMessage); BoosChat.sendMessageToPlayer(player, commandCancelMessage);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
@ -223,6 +239,7 @@ public class BoosCoolDownListener implements Listener {
int cooldownTime = 0; int cooldownTime = 0;
int xpPrice = 0; int xpPrice = 0;
int xpRequirement = 0; int xpRequirement = 0;
int playerPoints = 0;
on = BoosCoolDown.isPluginOnForPlayer(player); on = BoosCoolDown.isPluginOnForPlayer(player);
if (aliases != null) { if (aliases != null) {
originalCommand = BoosAliasManager.checkCommandAlias( originalCommand = BoosAliasManager.checkCommandAlias(
@ -250,6 +267,10 @@ public class BoosCoolDownListener implements Listener {
player); player);
xpRequirement = BoosConfigManager.getXpRequirement(regexCommad, player); xpRequirement = BoosConfigManager.getXpRequirement(regexCommad, player);
} }
if (BoosConfigManager.getPlayerPointsEnabled()) {
playerPoints = BoosConfigManager.getPlayerPointsPrice(regexCommad,
player);
}
if (BoosConfigManager.getItemCostEnabled()) { if (BoosConfigManager.getItemCostEnabled()) {
item = BoosConfigManager.getItemCostItem(regexCommad, item = BoosConfigManager.getItemCostItem(regexCommad,
player); player);
@ -273,15 +294,15 @@ public class BoosCoolDownListener implements Listener {
.contains(uuid + "@" + originalCommand) && commandQueue.get(uuid + "@" + originalCommand))) { .contains(uuid + "@" + originalCommand) && commandQueue.get(uuid + "@" + originalCommand))) {
this.checkRestrictions(event, player, regexCommad, originalCommand, this.checkRestrictions(event, player, regexCommad, originalCommand,
warmupTime, cooldownTime, price, item, count, name, lore, enchants, limit, warmupTime, cooldownTime, price, item, count, name, lore, enchants, limit,
xpPrice, xpRequirement); xpPrice, xpRequirement, playerPoints);
} else { } else {
if ((price > 0 || xpPrice > 0 || count > 0 || limit > 0) && !BoosWarmUpManager.isWarmUpProcess(player, if ((price > 0 || xpPrice > 0 || count > 0 || limit > 0 || playerPoints > 0) && !BoosWarmUpManager.isWarmUpProcess(player,
regexCommad) && !BoosCoolDownManager.isCoolingdown(player, regexCommad, cooldownTime)) { regexCommad) && !BoosCoolDownManager.isCoolingdown(player, regexCommad, cooldownTime)) {
if (BoosConfigManager.getConfirmCommandEnabled(player)) { 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);
boosChat.sendMessageToPlayer(player, questionMessage); BoosChat.sendMessageToPlayer(player, questionMessage);
} }
if (BoosCoolDown.getEconomy() != null) { if (BoosCoolDown.getEconomy() != null) {
if (BoosConfigManager.getPriceEnabled()) { if (BoosConfigManager.getPriceEnabled()) {
@ -289,20 +310,31 @@ public class BoosCoolDownListener implements Listener {
String priceMessage = BoosConfigManager.getItsPriceMessage(); String priceMessage = BoosConfigManager.getItsPriceMessage();
priceMessage = priceMessage.replace("&price&", BoosCoolDown.getEconomy().format(price)) priceMessage = priceMessage.replace("&price&", BoosCoolDown.getEconomy().format(price))
.replace("&balance&", BoosCoolDown.getEconomy().format(BoosCoolDown.getEconomy().getBalance(player))); .replace("&balance&", BoosCoolDown.getEconomy().format(BoosCoolDown.getEconomy().getBalance(player)));
boosChat.sendMessageToPlayer(player, " " + priceMessage); BoosChat.sendMessageToPlayer(player, " " + priceMessage);
}
}
}
if (BoosCoolDown.getPlayerPoints() != null) {
if (BoosConfigManager.getPlayerPointsEnabled()) {
if (playerPoints > 0) {
String playerPointsMessage = BoosConfigManager.getItsPlayerPointsPriceMessage();
playerPointsMessage = playerPointsMessage.replace("&ppprice&", String.valueOf(playerPoints))
.replace("&ppbalance&",
String.valueOf(BoosCoolDown.getPlayerPoints().getAPI().look(player.getUniqueId())));
BoosChat.sendMessageToPlayer(player, " " + playerPointsMessage);
} }
} }
} }
if (xpPrice > 0) { if (xpPrice > 0) {
String xpMessage = BoosConfigManager.getItsXpPriceMessage(); String xpMessage = BoosConfigManager.getItsXpPriceMessage();
xpMessage = xpMessage.replace("&xpprice&", String.valueOf(xpPrice)); xpMessage = xpMessage.replace("&xpprice&", String.valueOf(xpPrice));
boosChat.sendMessageToPlayer(player, " " + xpMessage); BoosChat.sendMessageToPlayer(player, " " + xpMessage);
} }
if (count > 0) { if (count > 0) {
String itemMessage = BoosConfigManager.getItsItemCostMessage(); String itemMessage = BoosConfigManager.getItsItemCostMessage();
itemMessage = itemMessage.replace("&itemprice&", "").replace("&itemname&", ""); itemMessage = itemMessage.replace("&itemprice&", "").replace("&itemname&", "");
JSON json = getItemStackJson(2, item, count, name, lore, enchants); JSON json = getItemStackJson(2, item, count, name, lore, enchants);
boosChat.sendMessageToPlayer(player, " " + itemMessage); BoosChat.sendMessageToPlayer(player, " " + itemMessage);
json.send(player); json.send(player);
} }
if (limit > 0) { if (limit > 0) {
@ -310,7 +342,7 @@ public class BoosCoolDownListener implements Listener {
String limitMessage = BoosConfigManager.getItsLimitMessage(); String limitMessage = BoosConfigManager.getItsLimitMessage();
limitMessage = limitMessage.replace("&limit&", String.valueOf(limit)) limitMessage = limitMessage.replace("&limit&", String.valueOf(limit))
.replace("&uses&", String.valueOf(limit - uses)); .replace("&uses&", String.valueOf(limit - uses));
boosChat.sendMessageToPlayer(player, " " + limitMessage); BoosChat.sendMessageToPlayer(player, " " + limitMessage);
} }
String yesString = BoosConfigManager.getConfirmCommandMessage(); String yesString = BoosConfigManager.getConfirmCommandMessage();
JSONClickAction yesClick = new JSONClickAction.RunCommand(yesString); JSONClickAction yesClick = new JSONClickAction.RunCommand(yesString);
@ -335,7 +367,7 @@ public class BoosCoolDownListener implements Listener {
} else { } else {
this.checkRestrictions(event, player, regexCommad, originalCommand, this.checkRestrictions(event, player, regexCommad, originalCommand,
warmupTime, cooldownTime, price, item, count, name, lore, enchants, limit, warmupTime, cooldownTime, price, item, count, name, lore, enchants, limit,
xpPrice, xpRequirement); xpPrice, xpRequirement, playerPoints);
} }
} }
} }
@ -364,7 +396,7 @@ public class BoosCoolDownListener implements Listener {
commandQueue.remove(key); commandQueue.remove(key);
String commandCancelMessage = BoosConfigManager.getCommandCanceledMessage(); String commandCancelMessage = BoosConfigManager.getCommandCanceledMessage();
commandCancelMessage = commandCancelMessage.replace("&command&", keyList[1]); commandCancelMessage = commandCancelMessage.replace("&command&", keyList[1]);
boosChat.sendMessageToPlayer(player, commandCancelMessage); BoosChat.sendMessageToPlayer(player, commandCancelMessage);
event.setCancelled(true); event.setCancelled(true);
} }
} }

View File

@ -9,7 +9,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import cz.boosik.boosCooldown.Managers.BoosConfigManager; import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import cz.boosik.boosCooldown.Managers.BoosWarmUpManager; import cz.boosik.boosCooldown.Managers.BoosWarmUpManager;
import util.boosChat; import util.BoosChat;
public class BoosEntityDamageListener implements Listener { public class BoosEntityDamageListener implements Listener {
@ -20,7 +20,7 @@ public class BoosEntityDamageListener implements Listener {
Player player = (Player) entity; Player player = (Player) entity;
if (!player.hasPermission("booscooldowns.nocancel.damage")) { if (!player.hasPermission("booscooldowns.nocancel.damage")) {
if (BoosWarmUpManager.hasWarmUps(player)) { if (BoosWarmUpManager.hasWarmUps(player)) {
boosChat.sendMessageToPlayer(player, BoosConfigManager BoosChat.sendMessageToPlayer(player, BoosConfigManager
.getWarmUpCancelledByDamageMessage()); .getWarmUpCancelledByDamageMessage());
BoosWarmUpManager.cancelWarmUps(player); BoosWarmUpManager.cancelWarmUps(player);
} }

View File

@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerGameModeChangeEvent;
import cz.boosik.boosCooldown.Managers.BoosConfigManager; import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import cz.boosik.boosCooldown.Managers.BoosWarmUpManager; import cz.boosik.boosCooldown.Managers.BoosWarmUpManager;
import util.boosChat; import util.BoosChat;
public class BoosPlayerGameModeChangeListener implements Listener { public class BoosPlayerGameModeChangeListener implements Listener {
@ -21,7 +21,7 @@ public class BoosPlayerGameModeChangeListener implements Listener {
if (!player if (!player
.hasPermission("booscooldowns.nocancel.gamemodechange")) { .hasPermission("booscooldowns.nocancel.gamemodechange")) {
if (BoosWarmUpManager.hasWarmUps(player)) { if (BoosWarmUpManager.hasWarmUps(player)) {
boosChat.sendMessageToPlayer(player, BoosConfigManager BoosChat.sendMessageToPlayer(player, BoosConfigManager
.getCancelWarmupByGameModeChangeMessage()); .getCancelWarmupByGameModeChangeMessage());
BoosWarmUpManager.cancelWarmUps(player); BoosWarmUpManager.cancelWarmUps(player);
} }

View File

@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import cz.boosik.boosCooldown.Managers.BoosConfigManager; import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import cz.boosik.boosCooldown.Managers.BoosWarmUpManager; import cz.boosik.boosCooldown.Managers.BoosWarmUpManager;
import util.boosChat; import util.BoosChat;
public class BoosPlayerInteractListener implements Listener { public class BoosPlayerInteractListener implements Listener {
@ -50,7 +50,7 @@ public class BoosPlayerInteractListener implements Listener {
|| event.getClickedBlock().getType().name() || event.getClickedBlock().getType().name()
.equals("HOPPER")) { .equals("HOPPER")) {
event.setCancelled(true); event.setCancelled(true);
boosChat.sendMessageToPlayer(player, BoosChat.sendMessageToPlayer(player,
BoosConfigManager.getInteractBlockedMessage()); BoosConfigManager.getInteractBlockedMessage());
} }
} }

View File

@ -8,7 +8,7 @@ import org.bukkit.event.player.PlayerMoveEvent;
import cz.boosik.boosCooldown.Managers.BoosConfigManager; import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import cz.boosik.boosCooldown.Managers.BoosWarmUpManager; import cz.boosik.boosCooldown.Managers.BoosWarmUpManager;
import util.boosChat; import util.BoosChat;
public class BoosPlayerMoveListener implements Listener { public class BoosPlayerMoveListener implements Listener {
private int tempTimer = 0; private int tempTimer = 0;
@ -25,7 +25,7 @@ public class BoosPlayerMoveListener implements Listener {
if (BoosWarmUpManager.hasWarmUps(player) && (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event if (BoosWarmUpManager.hasWarmUps(player) && (event.getFrom().getX() != event.getTo().getX() || event.getFrom().getZ() != event
.getTo() .getTo()
.getZ() || event.getFrom().getY() != event.getTo().getY())) { .getZ() || event.getFrom().getY() != event.getTo().getY())) {
boosChat.sendMessageToPlayer(player, BoosChat.sendMessageToPlayer(player,
BoosConfigManager.getWarmUpCancelledByMoveMessage()); BoosConfigManager.getWarmUpCancelledByMoveMessage());
BoosWarmUpManager.cancelWarmUps(player); BoosWarmUpManager.cancelWarmUps(player);
} }

View File

@ -8,7 +8,7 @@ import org.bukkit.event.player.PlayerToggleSneakEvent;
import cz.boosik.boosCooldown.Managers.BoosConfigManager; import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import cz.boosik.boosCooldown.Managers.BoosWarmUpManager; import cz.boosik.boosCooldown.Managers.BoosWarmUpManager;
import util.boosChat; import util.BoosChat;
public class BoosPlayerToggleSneakListener implements Listener { public class BoosPlayerToggleSneakListener implements Listener {
@ -18,7 +18,7 @@ public class BoosPlayerToggleSneakListener implements Listener {
if (player != null if (player != null
&& !player.hasPermission("booscooldowns.nocancel.sneak")) { && !player.hasPermission("booscooldowns.nocancel.sneak")) {
if (BoosWarmUpManager.hasWarmUps(player)) { if (BoosWarmUpManager.hasWarmUps(player)) {
boosChat.sendMessageToPlayer(player, BoosChat.sendMessageToPlayer(player,
BoosConfigManager.getCancelWarmupOnSneakMessage()); BoosConfigManager.getCancelWarmupOnSneakMessage());
BoosWarmUpManager.cancelWarmUps(player); BoosWarmUpManager.cancelWarmUps(player);
} }

View File

@ -8,7 +8,7 @@ import org.bukkit.event.player.PlayerToggleSprintEvent;
import cz.boosik.boosCooldown.Managers.BoosConfigManager; import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import cz.boosik.boosCooldown.Managers.BoosWarmUpManager; import cz.boosik.boosCooldown.Managers.BoosWarmUpManager;
import util.boosChat; import util.BoosChat;
public class BoosPlayerToggleSprintListener implements Listener { public class BoosPlayerToggleSprintListener implements Listener {
@ -18,7 +18,7 @@ public class BoosPlayerToggleSprintListener implements Listener {
if (player != null if (player != null
&& !player.hasPermission("booscooldowns.nocancel.sprint")) { && !player.hasPermission("booscooldowns.nocancel.sprint")) {
if (BoosWarmUpManager.hasWarmUps(player)) { if (BoosWarmUpManager.hasWarmUps(player)) {
boosChat.sendMessageToPlayer(player, BoosChat.sendMessageToPlayer(player,
BoosConfigManager.getCancelWarmupOnSprintMessage()); BoosConfigManager.getCancelWarmupOnSprintMessage());
BoosWarmUpManager.cancelWarmUps(player); BoosWarmUpManager.cancelWarmUps(player);
} }

View File

@ -7,7 +7,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.SignChangeEvent; import org.bukkit.event.block.SignChangeEvent;
import cz.boosik.boosCooldown.Managers.BoosConfigManager; import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import util.boosChat; import util.BoosChat;
public class BoosSignChangeListener implements Listener { public class BoosSignChangeListener implements Listener {
@ -20,7 +20,7 @@ public class BoosSignChangeListener implements Listener {
if (line2.equals("player") if (line2.equals("player")
&& !player && !player
.hasPermission("booscooldowns.signs.player.place")) { .hasPermission("booscooldowns.signs.player.place")) {
boosChat.sendMessageToPlayer(player, BoosChat.sendMessageToPlayer(player,
BoosConfigManager.getCannotCreateSignMessage()); BoosConfigManager.getCannotCreateSignMessage());
event.getBlock().breakNaturally(); event.getBlock().breakNaturally();
event.setCancelled(true); event.setCancelled(true);
@ -28,7 +28,7 @@ public class BoosSignChangeListener implements Listener {
if (line2.equals("server") if (line2.equals("server")
&& !player && !player
.hasPermission("booscooldowns.signs.server.place")) { .hasPermission("booscooldowns.signs.server.place")) {
boosChat.sendMessageToPlayer(player, BoosChat.sendMessageToPlayer(player,
BoosConfigManager.getCannotCreateSignMessage()); BoosConfigManager.getCannotCreateSignMessage());
event.getBlock().breakNaturally(); event.getBlock().breakNaturally();
event.setCancelled(true); event.setCancelled(true);

View File

@ -11,7 +11,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import cz.boosik.boosCooldown.BoosCoolDown; import cz.boosik.boosCooldown.BoosCoolDown;
import cz.boosik.boosCooldown.Managers.BoosConfigManager; import cz.boosik.boosCooldown.Managers.BoosConfigManager;
import util.boosChat; import util.BoosChat;
public class BoosSignInteractListener implements Listener { public class BoosSignInteractListener implements Listener {
private final BoosCoolDown plugin; private final BoosCoolDown plugin;
@ -57,7 +57,7 @@ public class BoosSignInteractListener implements Listener {
plugin.getServer().dispatchCommand( plugin.getServer().dispatchCommand(
plugin.getServer().getConsoleSender(), msg); plugin.getServer().getConsoleSender(), msg);
} else { } else {
boosChat.sendMessageToPlayer(player, BoosChat.sendMessageToPlayer(player,
BoosConfigManager.getCannotUseSignMessage()); BoosConfigManager.getCannotUseSignMessage());
} }
} }

View File

@ -13,7 +13,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import cz.boosik.boosCooldown.BoosCoolDown; import cz.boosik.boosCooldown.BoosCoolDown;
import util.boosChat; import util.BoosChat;
public class BoosConfigManager { public class BoosConfigManager {
@ -473,9 +473,9 @@ public class BoosConfigManager {
Boolean def = confusers.getBoolean("users." + player.getUniqueId() + ".confirmations", getConfirmCommandEnabled(player)); Boolean def = confusers.getBoolean("users." + player.getUniqueId() + ".confirmations", getConfirmCommandEnabled(player));
confusers.set("users." + player.getUniqueId() + ".confirmations", !def); confusers.set("users." + player.getUniqueId() + ".confirmations", !def);
if (def) { if (def) {
boosChat.sendMessageToPlayer(player, "&6[boosCooldowns]&e " + getConfirmToggleMessageFalse()); BoosChat.sendMessageToPlayer(player, "&6[boosCooldowns]&e " + getConfirmToggleMessageFalse());
} else { } else {
boosChat.sendMessageToPlayer(player, "&6[boosCooldowns]&e " + getConfirmToggleMessageTrue()); BoosChat.sendMessageToPlayer(player, "&6[boosCooldowns]&e " + getConfirmToggleMessageTrue());
} }
saveConfusers(); saveConfusers();
loadConfusers(); loadConfusers();
@ -501,6 +501,17 @@ public class BoosConfigManager {
return conf.getBoolean("options.options.item_cost_enabled", true); return conf.getBoolean("options.options.item_cost_enabled", true);
} }
public static boolean getPlayerPointsEnabled() {
return conf.getBoolean("options.options.player_points_prices_enabled", true);
}
public static int getPlayerPointsPrice(String regexCommand, Player player) {
int price;
String group = getCommandGroup(player);
price = conf.getInt("commands.groups." + group + "." + regexCommand + ".playerpoints", 0);
return price;
}
static String getPaidXPForCommandMessage() { static String getPaidXPForCommandMessage() {
return conf.getString("options.messages.paid_xp_for_command", "&6Price of&e &command& &6was &e%s"); return conf.getString("options.messages.paid_xp_for_command", "&6Price of&e &command& &6was &e%s");
} }
@ -531,6 +542,10 @@ public class BoosConfigManager {
return conf.getString("options.messages.insufficient_xp_requirement", "&6Your level is too low to use this!&e &command& &6needs &e%s"); return conf.getString("options.messages.insufficient_xp_requirement", "&6Your level is too low to use this!&e &command& &6needs &e%s");
} }
public static String getInsufficientPlayerPointsMessage() {
return conf.getString("options.messages.insufficient_player_points", "'&6You have not enough PlayerPoints!&e &command& &6needs &e%s'");
}
public static String getInvalidCommandSyntaxMessage() { public static String getInvalidCommandSyntaxMessage() {
return conf.getString("options.messages.invalid_command_syntax", "&6You are not allowed to use command syntax /<pluginname>:<command>!"); return conf.getString("options.messages.invalid_command_syntax", "&6You are not allowed to use command syntax /<pluginname>:<command>!");
} }
@ -662,6 +677,10 @@ public class BoosConfigManager {
return conf.getString("options.messages.confirmation_xp_price_of_command", "&6its price is&e &xpprice& experience levels"); return conf.getString("options.messages.confirmation_xp_price_of_command", "&6its price is&e &xpprice& experience levels");
} }
public static String getItsPlayerPointsPriceMessage() {
return conf.getString("options.messages.confirmation_player_points_price_of_command", "&6its price is&e &ppprice& PlayerPoints &6and you now have &e&ppbalance& PlayerPoints");
}
public static String getCommandCanceledMessage() { public static String getCommandCanceledMessage() {
return conf.getString("options.messages.confirmation_command_cancelled", "&6Execution of command&e &command& &6was cancelled"); return conf.getString("options.messages.confirmation_command_cancelled", "&6Execution of command&e &command& &6was cancelled");
} }
@ -678,4 +697,9 @@ public class BoosConfigManager {
return conf.getBoolean("options.options.command_confirmation", true); return conf.getBoolean("options.options.command_confirmation", true);
} }
} }
public static String getPlayerPointsForCommandMessage() {
return conf.getString("options.messages.paid_player_points_for_command", "Price of &command& was %s PlayerPoints and you now have %s" +
" PlayerPoints");
}
} }

View File

@ -8,7 +8,7 @@ import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import util.boosChat; import util.BoosChat;
public class BoosCoolDownManager { public class BoosCoolDownManager {
@ -99,7 +99,7 @@ public class BoosCoolDownManager {
msg = msg.replaceAll("&unit&", ""); msg = msg.replaceAll("&unit&", "");
msg = msg.replaceAll(" +", " "); msg = msg.replaceAll(" +", " ");
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
return true; return true;
} }
} }
@ -199,7 +199,7 @@ public class BoosCoolDownManager {
msg = msg.replaceAll("&unit&", ""); msg = msg.replaceAll("&unit&", "");
msg = msg.replaceAll(" +", " "); msg = msg.replaceAll(" +", " ");
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
return false; return false;
} }
} }

View File

@ -14,7 +14,7 @@ import com.coloredcarrot.mcapi.json.JSON;
import com.coloredcarrot.mcapi.json.JSONColor; import com.coloredcarrot.mcapi.json.JSONColor;
import com.coloredcarrot.mcapi.json.JSONComponent; import com.coloredcarrot.mcapi.json.JSONComponent;
import com.coloredcarrot.mcapi.json.JSONHoverAction; import com.coloredcarrot.mcapi.json.JSONHoverAction;
import util.boosChat; import util.BoosChat;
public class BoosItemCostManager { public class BoosItemCostManager {
@ -35,7 +35,7 @@ public class BoosItemCostManager {
BoosConfigManager.getPaidItemsForCommandMessage(), ""); BoosConfigManager.getPaidItemsForCommandMessage(), "");
JSON json = getItemStackJson(1, item, count, name, lore, enchants); JSON json = getItemStackJson(1, item, count, name, lore, enchants);
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
json.send(player); json.send(player);
return true; return true;
} else { } else {

View File

@ -9,7 +9,7 @@ import java.util.Set;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import cz.boosik.boosCooldown.BoosCoolDown; import cz.boosik.boosCooldown.BoosCoolDown;
import util.boosChat; import util.BoosChat;
public class BoosLimitManager { public class BoosLimitManager {
@ -75,7 +75,7 @@ public class BoosLimitManager {
msg = msg.replaceAll("&unit&", msg = msg.replaceAll("&unit&",
BoosConfigManager.getUnitSecondsMessage()); BoosConfigManager.getUnitSecondsMessage());
} }
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
} else if (limitResetDelayGlobal > 0) { } else if (limitResetDelayGlobal > 0) {
if (confTime != null) { if (confTime != null) {
callastTimeGlobal.setTime(confTime); callastTimeGlobal.setTime(confTime);
@ -101,12 +101,12 @@ public class BoosLimitManager {
msg = msg.replaceAll("&unit&", msg = msg.replaceAll("&unit&",
BoosConfigManager.getUnitSecondsMessage()); BoosConfigManager.getUnitSecondsMessage());
} }
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
} }
} else { } else {
String msg = String.format(BoosConfigManager String msg = String.format(BoosConfigManager
.getCommandBlockedMessage()); .getCommandBlockedMessage());
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
} }
return true; return true;
} }
@ -157,7 +157,7 @@ public class BoosLimitManager {
message = message.replaceAll("&command&", comm); message = message.replaceAll("&command&", comm);
message = message.replaceAll("&limit&", String.valueOf(lim)); message = message.replaceAll("&limit&", String.valueOf(lim));
message = message.replaceAll("&times&", String.valueOf(num)); message = message.replaceAll("&times&", String.valueOf(num));
boosChat.sendMessageToPlayer(send, message); BoosChat.sendMessageToPlayer(send, message);
} }
} }

View File

@ -0,0 +1,51 @@
package cz.boosik.boosCooldown.Managers;
import org.black_ixx.playerpoints.PlayerPoints;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import cz.boosik.boosCooldown.BoosCoolDown;
import util.BoosChat;
public class BoosPlayerPointsManager {
private static final PlayerPoints playerPoints = BoosCoolDown.getPlayerPoints();
private static boolean payForCommand(Player player,
String originalCommand, int price) {
if (playerPoints == null) {
return true;
}
String msg = "";
if(playerPoints.getAPI().take(player.getUniqueId(), price)) {
msg = String.format(BoosConfigManager.getPlayerPointsForCommandMessage(),
price, playerPoints.getAPI().look(player.getUniqueId()));
msg = msg.replaceAll("&command&", originalCommand);
BoosChat.sendMessageToPlayer(player, msg);
return true;
} else {
msg = String.format(BoosConfigManager.getInsufficientPlayerPointsMessage(),
price, playerPoints.getAPI().look(player.getUniqueId()));
BoosChat.sendMessageToPlayer(player, msg);
return false;
}
}
public static void payForCommand(PlayerCommandPreprocessEvent event,
Player player, String regexCommand, String originalCommand,
int price) {
if (price > 0) {
if (!player.hasPermission("booscooldowns.noplayerpoints")
&& !player.hasPermission("booscooldowns.noplayerpoints."
+ originalCommand)) {
if (!payForCommand(player, originalCommand, price)) {
BoosCoolDownManager.cancelCooldown(player, regexCommand);
event.setCancelled(true);
}
}
}
}
public static boolean has(Player player, int price) {
return playerPoints == null || price <= 0 || playerPoints.getAPI().look(player.getUniqueId()) >= price;
}
}

View File

@ -6,7 +6,7 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import cz.boosik.boosCooldown.BoosCoolDown; import cz.boosik.boosCooldown.BoosCoolDown;
import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.economy.EconomyResponse; import net.milkbowl.vault.economy.EconomyResponse;
import util.boosChat; import util.BoosChat;
public class BoosPriceManager { public class BoosPriceManager {
private static final Economy economy = BoosCoolDown.getEconomy(); private static final Economy economy = BoosCoolDown.getEconomy();
@ -22,12 +22,12 @@ public class BoosPriceManager {
msg = String.format(BoosConfigManager.getPaidForCommandMessage(), msg = String.format(BoosConfigManager.getPaidForCommandMessage(),
economy.format(r.amount), economy.format(r.balance)); economy.format(r.amount), economy.format(r.balance));
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
return true; return true;
} else { } else {
msg = String.format(BoosConfigManager.getPaidErrorMessage(), msg = String.format(BoosConfigManager.getPaidErrorMessage(),
r.errorMessage); r.errorMessage);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
return false; return false;
} }
} }

View File

@ -10,7 +10,7 @@ import org.bukkit.potion.PotionEffectType;
import cz.boosik.boosCooldown.BoosCoolDown; import cz.boosik.boosCooldown.BoosCoolDown;
import cz.boosik.boosCooldown.Runnables.BoosWarmUpTimer; import cz.boosik.boosCooldown.Runnables.BoosWarmUpTimer;
import util.boosChat; import util.BoosChat;
public class BoosWarmUpManager { public class BoosWarmUpManager {
@ -134,7 +134,7 @@ public class BoosWarmUpManager {
msg = msg.replaceAll("&unit&", ""); msg = msg.replaceAll("&unit&", "");
msg = msg.replaceAll(" +", " "); msg = msg.replaceAll(" +", " ");
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
Timer scheduler = new Timer(); Timer scheduler = new Timer();
BoosWarmUpTimer scheduleMe = new BoosWarmUpTimer(bCoolDown, player, regexCommand, originalCommand); BoosWarmUpTimer scheduleMe = new BoosWarmUpTimer(bCoolDown, player, regexCommand, originalCommand);
@ -145,7 +145,7 @@ public class BoosWarmUpManager {
} else { } else {
String msg = BoosConfigManager.getWarmUpAlreadyStartedMessage(); String msg = BoosConfigManager.getWarmUpAlreadyStartedMessage();
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
} }
} }
} }

View File

@ -3,7 +3,7 @@ package cz.boosik.boosCooldown.Managers;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import util.boosChat; import util.BoosChat;
public class BoosXpCostManager { public class BoosXpCostManager {
@ -19,7 +19,7 @@ public class BoosXpCostManager {
String msg = String.format(BoosConfigManager.getPaidXPForCommandMessage(), String msg = String.format(BoosConfigManager.getPaidXPForCommandMessage(),
xpPrice); xpPrice);
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
boosChat.sendMessageToPlayer(player, msg); BoosChat.sendMessageToPlayer(player, msg);
return true; return true;
} else { } else {
return false; return false;

View File

@ -9,13 +9,13 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@SuppressWarnings("ALL") @SuppressWarnings("ALL")
public class boosChat { public class BoosChat {
private static final Logger log = Logger.getLogger("Minecraft"); private static final Logger log = Logger.getLogger("Minecraft");
private static final List<String> Colors = new LinkedList<>(); private static final List<String> Colors = new LinkedList<>();
private static Server server; private static Server server;
public boosChat(Server server) { public BoosChat(Server server) {
Colors.add("&black&"); Colors.add("&black&");
Colors.add("&darkblue&"); Colors.add("&darkblue&");
Colors.add("&darkgreen&"); Colors.add("&darkgreen&");
@ -48,11 +48,11 @@ public class boosChat {
Colors.add("&d"); Colors.add("&d");
Colors.add("&e"); Colors.add("&e");
Colors.add("&f"); Colors.add("&f");
boosChat.server = server; BoosChat.server = server;
} }
public static void broadcastMessage(String message) { public static void broadcastMessage(String message) {
message = boosChat.replaceColorCodes(message); message = BoosChat.replaceColorCodes(message);
log.info("[bColoredChat] " + message); log.info("[bColoredChat] " + message);
server.broadcastMessage(message); server.broadcastMessage(message);
} }
@ -86,19 +86,19 @@ public class boosChat {
public static void sendMessageToCommandSender(CommandSender sender, public static void sendMessageToCommandSender(CommandSender sender,
String message) { String message) {
if (sender instanceof Player) { if (sender instanceof Player) {
boosChat.sendMessageToPlayer((Player) sender, message); BoosChat.sendMessageToPlayer((Player) sender, message);
} else { } else {
boosChat.sendMessageToServer(message); BoosChat.sendMessageToServer(message);
} }
} }
public static void sendMessageToPlayer(Player player, String message) { public static void sendMessageToPlayer(Player player, String message) {
message = boosChat.replaceColorCodes(message); message = BoosChat.replaceColorCodes(message);
player.sendMessage(message); player.sendMessage(message);
} }
private static void sendMessageToServer(String message) { private static void sendMessageToServer(String message) {
message = boosChat.replaceColorCodes(message); message = BoosChat.replaceColorCodes(message);
log.info(message); log.info(message);
} }
} }

View File

@ -10,6 +10,8 @@ options:
item_cost_enabled: true item_cost_enabled: true
#should xp costs be enabled? #should xp costs be enabled?
xp_cost_enabled: true xp_cost_enabled: true
#should player points prices be enabled?
player_points_prices_enabled: true
#should limits be enabled? #should limits be enabled?
limits_enabled: true limits_enabled: true
#do not ever use this if you like your server #do not ever use this if you like your server
@ -69,9 +71,11 @@ options:
paid_for_command: '&6Price of&e &command& &6was&e %s &6and you now have&e %s' paid_for_command: '&6Price of&e &command& &6was&e %s &6and you now have&e %s'
paid_items_for_command: '&6Price of&e &command& &6was &e%s' paid_items_for_command: '&6Price of&e &command& &6was &e%s'
paid_xp_for_command: '&6Price of&e &command& &6was &e%s levels' paid_xp_for_command: '&6Price of&e &command& &6was &e%s levels'
paid_player_points_for_command: '&6Price of&e &command& &6was &e%s PlayerPoints &6and you now have&e %s PlayerPoints'
insufficient_items: '&6You have not enough items!&e &command& &6needs &e%s' insufficient_items: '&6You have not enough items!&e &command& &6needs &e%s'
insufficient_xp: '&6You have not enough XP!&e &command& &6needs &e%s' insufficient_xp: '&6You have not enough XP!&e &command& &6needs &e%s'
insufficient_xp_requirement: '&6Your level is too low to use this!&e &command& &6needs &e%s' insufficient_xp_requirement: '&6Your level is too low to use this!&e &command& &6needs &e%s'
insufficient_player_points: '&6You have not enough PlayerPoints!&e &command& &6needs &e%s'
limit_achieved: '&6You cannot use this command anymore!&f' limit_achieved: '&6You cannot use this command anymore!&f'
limit_reset: '&6Wait&e &seconds& &unit&&6 before your limit for command&e &command& limit_reset: '&6Wait&e &seconds& &unit&&6 before your limit for command&e &command&
&6is reset.&f' &6is reset.&f'
@ -87,6 +91,7 @@ options:
confirmation_item_price_of_command: '&6its price is&e &itemprice& &itemname&' confirmation_item_price_of_command: '&6its price is&e &itemprice& &itemname&'
confirmation_limit_of_command: '&6it is limited to&e &limit& &6uses and you can still use it&e &uses& &6times' confirmation_limit_of_command: '&6it is limited to&e &limit& &6uses and you can still use it&e &uses& &6times'
confirmation_xp_price_of_command: '&6its price is&e &xpprice& experience levels' confirmation_xp_price_of_command: '&6its price is&e &xpprice& experience levels'
confirmation_price_of_command: '&6its price is&e &ppprice& PlayerPoints &6and you now have &e&ppbalance& PlayerPoints'
confirmation_confirm_command_execution: 'Yes' confirmation_confirm_command_execution: 'Yes'
confirmation_confirm_command_execution_hint: 'Click to confirm' confirmation_confirm_command_execution_hint: 'Click to confirm'
confirmation_cancel_command_execution: 'No' confirmation_cancel_command_execution: 'No'
@ -99,6 +104,9 @@ commands:
groups: groups:
#this group will work for all players without any booscooldowns permission #this group will work for all players without any booscooldowns permission
default: default:
/playerpointstest:
#PlayerPoints required to use this command
playerpoints: 5
/permissionstest: /permissionstest:
#permission required to use this command #permission required to use this command
permission: "nice.permission" permission: "nice.permission"

View File

@ -2,7 +2,7 @@ name: boosCooldowns
main: cz.boosik.boosCooldown.BoosCoolDown main: cz.boosik.boosCooldown.BoosCoolDown
version: 3.13.0 version: 3.13.0
authors: [LordBoos (boosik)] authors: [LordBoos (boosik)]
softdepend: [Vault] softdepend: [Vault, PlayerPoints]
description: > description: >
Shortcuts Shortcuts
commands: commands:
@ -60,6 +60,12 @@ permissions:
booscooldowns.noxpcost./command: booscooldowns.noxpcost./command:
description: Command "/command" will not be affected by xp cost for users with this permission. description: Command "/command" will not be affected by xp cost for users with this permission.
default: false default: false
booscooldowns.noplayerpoints:
description: Players commands will always be free of charge (PlayerPoints).
default: false
booscooldowns.noplayerpoints./command:
description: Command "/command" will not be affected by price for users with this permission (PlayerPoints).
default: false
booscooldowns.nocooldown: booscooldowns.nocooldown:
description: Player wont be affected by cooldowns. description: Player wont be affected by cooldowns.
default: false default: false