Fixed /bcd limits command
This commit is contained in:
parent
46e72399f4
commit
021e507bb4
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,6 @@
|
|||
name: boosCooldowns
|
||||
main: cz.boosik.boosCooldown.boosCoolDown
|
||||
version: 3.6.2
|
||||
version: 3.6.3
|
||||
authors: [LordBoos (ingame name boosik)]
|
||||
softdepend: [Vault]
|
||||
description: >
|
||||
|
|
|
@ -11,7 +11,14 @@ import util.boosChat;
|
|||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
import cz.boosik.boosCooldown.boosWarmUpManager;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosEntityDamageListener implements Listener {
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.isCancelled())
|
||||
|
|
|
@ -10,7 +10,14 @@ import org.bukkit.event.entity.PlayerDeathEvent;
|
|||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
import cz.boosik.boosCooldown.boosCoolDownManager;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosPlayerDeathListener implements Listener {
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onPlayerDeath(PlayerDeathEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
|
|
|
@ -11,7 +11,14 @@ import util.boosChat;
|
|||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
import cz.boosik.boosCooldown.boosWarmUpManager;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosPlayerGameModeChangeListener implements Listener {
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onPlayerGameModeChange(PlayerGameModeChangeEvent event) {
|
||||
if (event.isCancelled())
|
||||
|
|
|
@ -11,7 +11,14 @@ import util.boosChat;
|
|||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
import cz.boosik.boosCooldown.boosWarmUpManager;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosPlayerInteractListener implements Listener {
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onPlayerInteract(PlayerInteractEvent event) {
|
||||
if (event.isCancelled())
|
||||
|
|
|
@ -6,16 +6,25 @@ import org.bukkit.event.EventHandler;
|
|||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
|
||||
import util.boosChat;
|
||||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
import cz.boosik.boosCooldown.boosWarmUpManager;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosPlayerMoveListener implements Listener {
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
private static boolean hasMoved(Player player) {
|
||||
String curworld = player.getWorld().getName();
|
||||
String cmdworld = boosWarmUpManager.playerworld.get(player);
|
||||
String cmdworld = boosWarmUpManager.getPlayerworld().get(player);
|
||||
Location curloc = player.getLocation();
|
||||
Location cmdloc = boosWarmUpManager.playerloc.get(player);
|
||||
Location cmdloc = boosWarmUpManager.getPlayerloc().get(player);
|
||||
if (!curworld.equals(cmdworld)) {
|
||||
return true;
|
||||
} else if (cmdloc.distanceSquared(curloc) > 2) {
|
||||
|
@ -25,8 +34,11 @@ public class boosPlayerMoveListener implements Listener {
|
|||
return false;
|
||||
}
|
||||
|
||||
int tempTimer = 0;
|
||||
private int tempTimer = 0;
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onPlayerMove(PlayerMoveEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
|
|
|
@ -10,7 +10,14 @@ import util.boosChat;
|
|||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
import cz.boosik.boosCooldown.boosWarmUpManager;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosPlayerToggleSneakListener implements Listener {
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onPlayerToggleSneak(PlayerToggleSneakEvent event) {
|
||||
if (event.isCancelled())
|
||||
|
|
|
@ -10,7 +10,14 @@ import util.boosChat;
|
|||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
import cz.boosik.boosCooldown.boosWarmUpManager;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosPlayerToggleSprintListener implements Listener {
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
|
||||
if (event.isCancelled())
|
||||
|
|
|
@ -9,9 +9,16 @@ import org.bukkit.event.block.SignChangeEvent;
|
|||
import util.boosChat;
|
||||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosSignChangeListener implements Listener {
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onSignChange(SignChangeEvent event) {
|
||||
private void onSignChange(SignChangeEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
|
|
|
@ -13,13 +13,23 @@ import util.boosChat;
|
|||
import cz.boosik.boosCooldown.boosConfigManager;
|
||||
import cz.boosik.boosCooldown.boosCoolDown;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosSignInteractListener implements Listener {
|
||||
private final boosCoolDown plugin;
|
||||
|
||||
/**
|
||||
* @param instance
|
||||
*/
|
||||
public boosSignInteractListener(boosCoolDown instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
private void onSignInteract(PlayerInteractEvent event) {
|
||||
String msg;
|
||||
|
|
|
@ -4,7 +4,6 @@ import java.io.File;
|
|||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -13,14 +12,20 @@ import org.bukkit.configuration.InvalidConfigurationException;
|
|||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosConfigManager {
|
||||
|
||||
private static YamlConfiguration conf;
|
||||
private static YamlConfiguration confusers;
|
||||
private static File confFile;
|
||||
private static File confusersFile;
|
||||
static List<String> players = new LinkedList<String>();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void clear() {
|
||||
ConfigurationSection userSection = confusers
|
||||
.getConfigurationSection("users");
|
||||
|
@ -53,6 +58,10 @@ public class boosConfigManager {
|
|||
loadConfusers();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param co
|
||||
* @param player
|
||||
*/
|
||||
public static void clearSomething(String co, String player) {
|
||||
ConfigurationSection userSection = confusers
|
||||
.getConfigurationSection("users."
|
||||
|
@ -65,6 +74,11 @@ public class boosConfigManager {
|
|||
loadConfusers();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param co
|
||||
* @param player
|
||||
* @param command
|
||||
*/
|
||||
static void clearSomething(String co, String player, String command) {
|
||||
int pre2 = command.toLowerCase().hashCode();
|
||||
confusers.set("users." + player.toLowerCase().hashCode() + "." + co
|
||||
|
@ -73,106 +87,224 @@ public class boosConfigManager {
|
|||
loadConfusers();
|
||||
}
|
||||
|
||||
public static String getAlias(String message) {
|
||||
/**
|
||||
* @param message
|
||||
* @return
|
||||
*/
|
||||
static String getAlias(String message) {
|
||||
return conf.getString("commands.aliases." + message);
|
||||
}
|
||||
|
||||
public static Set<String> getAliases() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static Set<String> getAliases() {
|
||||
Set<String> aliases = conf.getConfigurationSection("commands.aliases")
|
||||
.getKeys(false);
|
||||
return aliases;
|
||||
}
|
||||
|
||||
public static boolean getBlockInteractDuringWarmup() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getBlockInteractDuringWarmup() {
|
||||
return conf.getBoolean("options.options.block_interact_during_warmup",
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static String getCancelWarmupByGameModeChangeMessage() {
|
||||
return conf.getString(
|
||||
"options.messages.warmup_cancelled_by_gamemode_change",
|
||||
"&6Warm-ups have been cancelled due to changing gamemode.&f");
|
||||
}
|
||||
|
||||
public static boolean getCancelWarmUpOnDamage() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getCancelWarmUpOnDamage() {
|
||||
return conf
|
||||
.getBoolean("options.options.cancel_warmup_on_damage", false);
|
||||
}
|
||||
|
||||
public static boolean getCancelWarmUpOnGameModeChange() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getCancelWarmUpOnGameModeChange() {
|
||||
return conf.getBoolean(
|
||||
"options.options.cancel_warmup_on_gamemode_change", false);
|
||||
}
|
||||
|
||||
public static boolean getCancelWarmupOnMove() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getCancelWarmupOnMove() {
|
||||
return conf.getBoolean("options.options.cancel_warmup_on_move", false);
|
||||
}
|
||||
|
||||
public static boolean getCancelWarmupOnSneak() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getCancelWarmupOnSneak() {
|
||||
return conf.getBoolean("options.options.cancel_warmup_on_sneak", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static String getCancelWarmupOnSneakMessage() {
|
||||
return conf.getString("options.messages.warmup_cancelled_by_sneak",
|
||||
"&6Warm-ups have been cancelled due to sneaking.&f");
|
||||
}
|
||||
|
||||
public static boolean getCancelWarmupOnSprint() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getCancelWarmupOnSprint() {
|
||||
return conf
|
||||
.getBoolean("options.options.cancel_warmup_on_sprint", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static String getCancelWarmupOnSprintMessage() {
|
||||
return conf.getString("options.messages.warmup_cancelled_by_sprint",
|
||||
"&6Warm-ups have been cancelled due to sprinting.&f");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static String getCannotCreateSignMessage() {
|
||||
return conf.getString("options.messages.cannot_create_sign",
|
||||
"&6You are not allowed to create this kind of signs!&f");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static String getCannotUseSignMessage() {
|
||||
return conf.getString("options.messages.cannot_use_sign",
|
||||
"&6You are not allowed to use this sign!&f");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static boolean getCleanCooldownsOnDeath() {
|
||||
return conf.getBoolean("options.options.clear_cooldowns_on_death",
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static boolean getCleanUsesOnDeath() {
|
||||
return conf.getBoolean("options.options.clear_uses_on_death", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getClearOnRestart() {
|
||||
return conf.getBoolean("options.options.clear_on_restart", false);
|
||||
}
|
||||
|
||||
public static String getCommandBlockedMessage() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getCommandBlockedMessage() {
|
||||
return conf.getString("options.messages.limit_achieved",
|
||||
"&6You cannot use this command anymore!&f");
|
||||
}
|
||||
|
||||
public static boolean getCommandLogging() {
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static String getCommandGroup(Player player) {
|
||||
String cmdGroup = "default";
|
||||
for (String group : getCommandGroups()) {
|
||||
if (player.hasPermission("booscooldowns." + group)) {
|
||||
cmdGroup = group;
|
||||
}
|
||||
}
|
||||
return cmdGroup;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static Set<String> getCommandGroups() {
|
||||
Set<String> groups = conf.getConfigurationSection("commands.groups")
|
||||
.getKeys(false);
|
||||
return groups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getCommandLogging() {
|
||||
return conf.getBoolean("options.options.command_logging", false);
|
||||
}
|
||||
|
||||
public static YamlConfiguration getConfusers() {
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static Set<String> getCommands(Player player) {
|
||||
String group = getCommandGroup(player);
|
||||
Set<String> commands = conf.getConfigurationSection(
|
||||
"commands.groups." + group).getKeys(false);
|
||||
return commands;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param regexCommand
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static String[] getCommandValues(String regexCommand, Player player) {
|
||||
String[] values;
|
||||
String line = "";
|
||||
String group = getCommandGroup(player);
|
||||
line = conf.getString("commands.groups." + group + "." + regexCommand,
|
||||
line);
|
||||
values = line.split(",");
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static YamlConfiguration getConfusers() {
|
||||
return confusers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pre
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static int getCoolDown(String pre, Player player) {
|
||||
int coolDown = 0;
|
||||
coolDown = Integer.parseInt(getCommandValues(pre, player)[1]);
|
||||
return coolDown;
|
||||
}
|
||||
|
||||
public static boolean getCooldownEnabled() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getCooldownEnabled() {
|
||||
return conf.getBoolean("options.options.cooldowns_enabled", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getCoolDownMessage() {
|
||||
return conf
|
||||
.getString(
|
||||
|
@ -180,78 +312,115 @@ public class boosConfigManager {
|
|||
"&6Wait&e &seconds& seconds&6 before you can use command&e &command& &6again.&f");
|
||||
}
|
||||
|
||||
public static Set<String> getCooldowns(Player player) {
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static Set<String> getCooldowns(Player player) {
|
||||
String cool = getCommandGroup(player);
|
||||
Set<String> cooldowns = conf.getConfigurationSection(
|
||||
"commands.groups." + cool).getKeys(false);
|
||||
return cooldowns;
|
||||
}
|
||||
|
||||
public static String getInsufficientFundsMessage() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getInsufficientFundsMessage() {
|
||||
return conf
|
||||
.getString("options.messages.insufficient_funds",
|
||||
.getString(
|
||||
"options.messages.insufficient_funds",
|
||||
"&6You have insufficient funds!&e &command& &6costs &e%s &6but you only have &e%s");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static String getInteractBlockedMessage() {
|
||||
return conf.getString(
|
||||
"options.messages.interact_blocked_during_warmup",
|
||||
"&6You can't do this when command is warming-up!&f");
|
||||
}
|
||||
|
||||
public static int getLimit(String pre, Player player) {
|
||||
/**
|
||||
* @param pre
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static int getLimit(String pre, Player player) {
|
||||
int limit = -1;
|
||||
limit = Integer.parseInt(getCommandValues(pre, player)[3]);
|
||||
return limit;
|
||||
}
|
||||
|
||||
public static boolean getLimitEnabled() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getLimitEnabled() {
|
||||
return conf.getBoolean("options.options.limits_enabled", true);
|
||||
}
|
||||
|
||||
public static String getLimitListMessage() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getLimitListMessage() {
|
||||
return conf
|
||||
.getString(
|
||||
"options.messages.limit_list",
|
||||
"&6Limit for command &e&command&&6 is &e&limit&&6. You can still use it &e×&&6 times.&f");
|
||||
}
|
||||
|
||||
public static Set<String> getLimits(Player player) {
|
||||
String lim = getCommandGroup(player);
|
||||
Set<String> limits = conf.getConfigurationSection(
|
||||
"commands.groups." + lim).getKeys(false);
|
||||
return limits;
|
||||
}
|
||||
|
||||
public static boolean getLimitsEnabled() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getLimitsEnabled() {
|
||||
return conf.getBoolean("options.options.limits_enabled", true);
|
||||
}
|
||||
|
||||
public static String getLink(String pre) {
|
||||
/**
|
||||
* @param pre
|
||||
* @return
|
||||
*/
|
||||
static String getLink(String pre) {
|
||||
String link = null;
|
||||
pre = pre.toLowerCase();
|
||||
link = conf.getString("commands.links.link." + pre, link);
|
||||
return link;
|
||||
}
|
||||
|
||||
public static List<String> getLinkList(String link) {
|
||||
/**
|
||||
* @param link
|
||||
* @return
|
||||
*/
|
||||
static List<String> getLinkList(String link) {
|
||||
List<String> linkGroup;
|
||||
link = link.toLowerCase();
|
||||
linkGroup = conf.getStringList("commands.links.linkGroups." + link);
|
||||
return linkGroup;
|
||||
}
|
||||
|
||||
public static String getPaidErrorMessage() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getPaidErrorMessage() {
|
||||
return conf.getString("options.messages.paid_error",
|
||||
"An error has occured: %s");
|
||||
}
|
||||
|
||||
public static String getPaidForCommandMessage() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getPaidForCommandMessage() {
|
||||
return conf.getString("options.messages.paid_for_command",
|
||||
"Price of &command& was %s and you now have %s");
|
||||
}
|
||||
|
||||
public static String getPotionEffect(String pre, Player player) {
|
||||
/**
|
||||
* @param pre
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static String getPotionEffect(String pre, Player player) {
|
||||
String effect = "";
|
||||
pre = pre.toLowerCase();
|
||||
String[] command = getCommandValues(pre, player);
|
||||
|
@ -261,7 +430,12 @@ public class boosConfigManager {
|
|||
return effect;
|
||||
}
|
||||
|
||||
public static int getPotionEffectStrength(String pre, Player player) {
|
||||
/**
|
||||
* @param pre
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static int getPotionEffectStrength(String pre, Player player) {
|
||||
int effect = 0;
|
||||
pre = pre.toLowerCase();
|
||||
String[] command = getCommandValues(pre, player);
|
||||
|
@ -271,73 +445,122 @@ public class boosConfigManager {
|
|||
return effect;
|
||||
}
|
||||
|
||||
public static double getPrice(String pre, Player player) {
|
||||
/**
|
||||
* @param pre
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static double getPrice(String pre, Player player) {
|
||||
double price = 0.0;
|
||||
price = Double.parseDouble(getCommandValues(pre, player)[2]);
|
||||
return price;
|
||||
}
|
||||
|
||||
public static boolean getPriceEnabled() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getPriceEnabled() {
|
||||
return conf.getBoolean("options.options.prices_enabled", true);
|
||||
}
|
||||
|
||||
public static int getSaveInterval() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static int getSaveInterval() {
|
||||
return conf.getInt("options.options.save_interval_in_minutes", 15);
|
||||
}
|
||||
|
||||
public static boolean getSignCommands() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getSignCommands() {
|
||||
return conf.getBoolean("options.options.command_signs", false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static boolean getStartCooldownsOnDeath() {
|
||||
return conf.getBoolean("options.options.start_cooldowns_on_death",
|
||||
false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getUnitHoursMessage() {
|
||||
return conf.getString("options.units.hours", "hours");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getUnitMinutesMessage() {
|
||||
return conf.getString("options.units.minutes", "minutes");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getUnitSecondsMessage() {
|
||||
return conf.getString("options.units.seconds", "seconds");
|
||||
}
|
||||
|
||||
public static int getWarmUp(String pre, Player player) {
|
||||
/**
|
||||
* @param pre
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static int getWarmUp(String pre, Player player) {
|
||||
int warmUp = -1;
|
||||
String[] values = getCommandValues(pre, player);
|
||||
warmUp = Integer.parseInt(values[0]);
|
||||
return warmUp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getWarmUpAlreadyStartedMessage() {
|
||||
return conf.getString("options.messages.warmup_already_started",
|
||||
"&6Warm-Up process for&e &command& &6has already started.&f");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static String getWarmUpCancelledByDamageMessage() {
|
||||
return conf.getString("options.messages.warmup_cancelled_by_damage",
|
||||
"&6Warm-ups have been cancelled due to receiving damage.&f");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static String getWarmUpCancelledByMoveMessage() {
|
||||
return conf.getString("options.messages.warmup_cancelled_by_move",
|
||||
"&6Warm-ups have been cancelled due to moving.&f");
|
||||
}
|
||||
|
||||
public static boolean getWarmupEnabled() {
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static boolean getWarmupEnabled() {
|
||||
return conf.getBoolean("options.options.warmups_enabled", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static String getWarmUpMessage() {
|
||||
return conf
|
||||
.getString("options.messages.warming_up",
|
||||
"&6Wait&e &seconds& seconds&6 before command&e &command& &6has warmed up.&f");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void load() {
|
||||
try {
|
||||
conf.load(confFile);
|
||||
|
@ -350,6 +573,9 @@ public class boosConfigManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void loadConfusers() {
|
||||
try {
|
||||
confusers.load(confusersFile);
|
||||
|
@ -362,11 +588,17 @@ public class boosConfigManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void reload() {
|
||||
conf = new YamlConfiguration();
|
||||
load();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void saveConfusers() {
|
||||
try {
|
||||
confFile.createNewFile();
|
||||
|
@ -376,6 +608,11 @@ public class boosConfigManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param coSetnout
|
||||
* @param co
|
||||
* @param hodnota
|
||||
*/
|
||||
static void setAddToConfigFile(String coSetnout, String co, String hodnota) {
|
||||
co = co.toLowerCase();
|
||||
coSetnout = coSetnout.toLowerCase();
|
||||
|
@ -389,9 +626,11 @@ public class boosConfigManager {
|
|||
reload();
|
||||
}
|
||||
|
||||
// test
|
||||
/**
|
||||
* @param boosCoolDown
|
||||
*/
|
||||
@SuppressWarnings("static-access")
|
||||
public boosConfigManager(boosCoolDown boosCoolDown) {
|
||||
boosConfigManager(boosCoolDown boosCoolDown) {
|
||||
confFile = new File(boosCoolDown.getDataFolder(), "config.yml");
|
||||
if (confFile.exists()) {
|
||||
conf = new YamlConfiguration();
|
||||
|
@ -471,10 +710,13 @@ public class boosConfigManager {
|
|||
}
|
||||
try {
|
||||
conf.addDefault("commands.groups.default.*", "1,1,0.0,-1");
|
||||
conf.addDefault("commands.groups.default./anothercommand", "0,2,0.0,-1");
|
||||
conf.addDefault("commands.groups.default./yetanothercommand", "5,0,10.0,5,WEAKNESS,3");
|
||||
conf.addDefault("commands.groups.default./anothercommand",
|
||||
"0,2,0.0,-1");
|
||||
conf.addDefault("commands.groups.default./yetanothercommand",
|
||||
"5,0,10.0,5,WEAKNESS,3");
|
||||
conf.addDefault("commands.groups.VIP./command *", "5,30,10.0,0");
|
||||
conf.addDefault("commands.groups.VIP./anothercommand", "2,10,5.0,20");
|
||||
conf.addDefault("commands.groups.VIP./anothercommand",
|
||||
"2,10,5.0,20");
|
||||
conf.addDefault("commands.links.link./lol", "default");
|
||||
conf.addDefault("commands.links.link./example", "default");
|
||||
conf.addDefault("commands.links.link./command", "default");
|
||||
|
@ -506,37 +748,4 @@ public class boosConfigManager {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<String> getCommandGroups() {
|
||||
Set<String> groups = conf.getConfigurationSection("commands.groups")
|
||||
.getKeys(false);
|
||||
return groups;
|
||||
}
|
||||
|
||||
public static String getCommandGroup(Player player) {
|
||||
String cmdGroup = "default";
|
||||
for (String group : getCommandGroups()) {
|
||||
if (player.hasPermission("booscooldowns." + group)) {
|
||||
cmdGroup = group;
|
||||
}
|
||||
}
|
||||
return cmdGroup;
|
||||
}
|
||||
|
||||
public static Set<String> getCommands(Player player) {
|
||||
String group = getCommandGroup(player);
|
||||
Set<String> commands = conf.getConfigurationSection(
|
||||
"commands.groups." + group).getKeys(false);
|
||||
return commands;
|
||||
}
|
||||
|
||||
public static String[] getCommandValues(String regexCommand, Player player) {
|
||||
String[] values;
|
||||
String line = "";
|
||||
String group = getCommandGroup(player);
|
||||
line = conf.getString("commands.groups." + group + "." + regexCommand,
|
||||
line);
|
||||
values = line.split(",");
|
||||
return values;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package cz.boosik.boosCooldown;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import net.milkbowl.vault.Vault;
|
||||
|
@ -29,25 +30,43 @@ import cz.boosik.boosCooldown.Listeners.boosPlayerToggleSprintListener;
|
|||
import cz.boosik.boosCooldown.Listeners.boosSignChangeListener;
|
||||
import cz.boosik.boosCooldown.Listeners.boosSignInteractListener;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosCoolDown extends JavaPlugin implements Runnable {
|
||||
public static final Logger log = Logger.getLogger("Minecraft");
|
||||
public static PluginDescriptionFile pdfFile;
|
||||
private static final Logger log = Logger.getLogger("Minecraft");
|
||||
private static PluginDescriptionFile pdfFile;
|
||||
private static Economy economy = null;
|
||||
private static boolean usingVault = false;
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param command
|
||||
*/
|
||||
public static void commandLogger(String player, String command) {
|
||||
log.info("[" + "boosLogger" + "] " + player + " used command "
|
||||
+ command);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static Economy getEconomy() {
|
||||
return economy;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static Logger getLog() {
|
||||
return log;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
static boolean isPluginOnForPlayer(Player player) {
|
||||
boolean on;
|
||||
if (player.hasPermission("booscooldowns.exception")) {
|
||||
|
@ -60,12 +79,11 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
return on;
|
||||
}
|
||||
|
||||
public static boolean isUsingVault() {
|
||||
return usingVault;
|
||||
}
|
||||
|
||||
private PluginManager pm;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void initializeVault() {
|
||||
Plugin x = this.getServer().getPluginManager().getPlugin("Vault");
|
||||
if (x != null & x instanceof Vault) {
|
||||
|
@ -89,6 +107,9 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command c,
|
||||
String commandLabel, String[] args) {
|
||||
|
@ -107,7 +128,12 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
&& args[0].equalsIgnoreCase("limits")) {
|
||||
try {
|
||||
Player send = (Player) sender;
|
||||
boosConfigManager.getLimits(send);
|
||||
Set<String> commands = boosConfigManager
|
||||
.getCommands(send);
|
||||
for (String comm : commands) {
|
||||
int lim = boosConfigManager.getLimit(comm, send);
|
||||
boosLimitManager.getLimitListMessages(send, comm, lim);
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
log.warning("You cannot use this command from console!");
|
||||
}
|
||||
|
@ -193,7 +219,7 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
return true;
|
||||
}
|
||||
if (co.startsWith("/") || co.equals("*")) {
|
||||
if (co.contains("_")){
|
||||
if (co.contains("_")) {
|
||||
co = co.replace("_", " ");
|
||||
}
|
||||
boosConfigManager.setAddToConfigFile(coSetnout, co,
|
||||
|
@ -224,6 +250,9 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
|
||||
*/
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (boosConfigManager.getClearOnRestart() == true) {
|
||||
|
@ -237,6 +266,9 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
+ pdfFile.getVersion() + " disabled!");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.bukkit.plugin.java.JavaPlugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
pdfFile = this.getDescription();
|
||||
|
@ -266,6 +298,9 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void registerListeners() {
|
||||
HandlerList.unregisterAll(this);
|
||||
pm.registerEvents(new boosCoolDownListener(this), this);
|
||||
|
@ -298,11 +333,17 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void reload() {
|
||||
boosConfigManager.reload();
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
boosConfigManager.saveConfusers();
|
||||
|
@ -310,6 +351,9 @@ public class boosCoolDown extends JavaPlugin implements Runnable {
|
|||
log.info("[boosCooldowns] Config saved!");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
private boolean setupEconomy() {
|
||||
if (usingVault) {
|
||||
RegisteredServiceProvider<Economy> economyProvider = getServer()
|
||||
|
|
|
@ -1,21 +1,40 @@
|
|||
package cz.boosik.boosCooldown;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
|
||||
import util.boosChat;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosCoolDownListener implements Listener {
|
||||
private static boosCoolDown plugin;
|
||||
|
||||
/**
|
||||
* @param instance
|
||||
*/
|
||||
public boosCoolDownListener(boosCoolDown instance) {
|
||||
plugin = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
* @param player
|
||||
* @param regexCommad
|
||||
* @param originalCommand
|
||||
* @param warmupTime
|
||||
* @param cooldownTime
|
||||
* @param price
|
||||
* @param limit
|
||||
*/
|
||||
private void checkRestrictions(PlayerCommandPreprocessEvent event,
|
||||
Player player, String regexCommad, String originalCommand,
|
||||
int warmupTime, int cooldownTime, double price, int limit) {
|
||||
|
@ -53,6 +72,9 @@ public class boosCoolDownListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
private void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
||||
if (event.isCancelled()) {
|
||||
|
@ -86,18 +108,18 @@ public class boosCoolDownListener implements Listener {
|
|||
String group2 = group.replace("*", ".+");
|
||||
if (originalCommand.matches(group2)) {
|
||||
regexCommad = group;
|
||||
if (boosConfigManager.getWarmupEnabled()){
|
||||
if (boosConfigManager.getWarmupEnabled()) {
|
||||
warmupTime = boosConfigManager.getWarmUp(regexCommad,
|
||||
player);
|
||||
}
|
||||
if (boosConfigManager.getCooldownEnabled()){
|
||||
cooldownTime = boosConfigManager.getCoolDown(regexCommad,
|
||||
player);
|
||||
if (boosConfigManager.getCooldownEnabled()) {
|
||||
cooldownTime = boosConfigManager.getCoolDown(
|
||||
regexCommad, player);
|
||||
}
|
||||
if (boosConfigManager.getPriceEnabled()){
|
||||
if (boosConfigManager.getPriceEnabled()) {
|
||||
price = boosConfigManager.getPrice(regexCommad, player);
|
||||
}
|
||||
if (boosConfigManager.getLimitEnabled()){
|
||||
if (boosConfigManager.getLimitEnabled()) {
|
||||
limit = boosConfigManager.getLimit(regexCommad, player);
|
||||
}
|
||||
break;
|
||||
|
@ -108,13 +130,16 @@ public class boosCoolDownListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
private void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||
String chatMessage = event.getMessage();
|
||||
String temp = "globalchat";
|
||||
double price = 0;
|
||||
Player player = event.getPlayer();
|
||||
if (!boosConfigManager.getCommands(player).contains("globalchat")){
|
||||
if (!boosConfigManager.getCommands(player).contains("globalchat")) {
|
||||
return;
|
||||
}
|
||||
int cooldownTime = boosConfigManager.getCoolDown(temp, player);
|
||||
|
@ -135,6 +160,14 @@ public class boosCoolDownListener implements Listener {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
* @param player
|
||||
* @param regexCommad
|
||||
* @param originalCommand
|
||||
* @param warmupTime
|
||||
* @param cooldownTime
|
||||
*/
|
||||
private void start(PlayerCommandPreprocessEvent event, Player player,
|
||||
String regexCommad, String originalCommand, int warmupTime,
|
||||
int cooldownTime) {
|
||||
|
|
|
@ -5,9 +5,15 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import util.boosChat;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosCoolDownManager {
|
||||
static void cancelCooldown(Player player, String regexCommand) {
|
||||
int pre2 = regexCommand.toLowerCase().hashCode();
|
||||
|
@ -16,7 +22,14 @@ public class boosCoolDownManager {
|
|||
+ ".cooldown." + pre2, null);
|
||||
}
|
||||
|
||||
private static boolean cd(Player player, String regexCommand,
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
* @param coolDownSeconds
|
||||
* @return
|
||||
*/
|
||||
static boolean cd(Player player, String regexCommand,
|
||||
String originalCommand, int coolDownSeconds) {
|
||||
Date lastTime = getTime(player, regexCommand);
|
||||
String link = boosConfigManager.getLink(regexCommand);
|
||||
|
@ -77,6 +90,13 @@ public class boosCoolDownManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
static boolean coolDown(Player player, String regexCommand,
|
||||
String originalCommand, int time) {
|
||||
regexCommand = regexCommand.toLowerCase();
|
||||
|
@ -89,6 +109,9 @@ public class boosCoolDownManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
static Date getCurrTime() {
|
||||
String currTime = "";
|
||||
Calendar cal = Calendar.getInstance();
|
||||
|
@ -104,6 +127,11 @@ public class boosCoolDownManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @return
|
||||
*/
|
||||
static Date getTime(Player player, String regexCommand) {
|
||||
int pre2 = regexCommand.toLowerCase().hashCode();
|
||||
String confTime = "";
|
||||
|
@ -125,6 +153,13 @@ public class boosCoolDownManager {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
* @param time
|
||||
* @return
|
||||
*/
|
||||
static boolean checkCoolDownOK(Player player, String regexCommand,
|
||||
String originalCommand, int time) {
|
||||
regexCommand = regexCommand.toLowerCase();
|
||||
|
@ -170,7 +205,12 @@ public class boosCoolDownManager {
|
|||
return true;
|
||||
}
|
||||
|
||||
public static long secondsBetween(Calendar startDate, Calendar endDate) {
|
||||
/**
|
||||
* @param startDate
|
||||
* @param endDate
|
||||
* @return
|
||||
*/
|
||||
static long secondsBetween(Calendar startDate, Calendar endDate) {
|
||||
long secondsBetween = 0;
|
||||
|
||||
while (startDate.before(endDate)) {
|
||||
|
@ -180,6 +220,10 @@ public class boosCoolDownManager {
|
|||
return secondsBetween;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
*/
|
||||
static void setTime(Player player, String regexCommand) {
|
||||
int pre2 = regexCommand.toLowerCase().hashCode();
|
||||
String currTime = "";
|
||||
|
@ -191,6 +235,10 @@ public class boosCoolDownManager {
|
|||
+ ".cooldown." + pre2, currTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param message
|
||||
*/
|
||||
public static void startAllCooldowns(Player player, String message) {
|
||||
for (String a : boosConfigManager.getCooldowns(player)) {
|
||||
int cooldownTime = boosConfigManager.getCoolDown(a, player);
|
||||
|
|
|
@ -6,7 +6,18 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import util.boosChat;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosLimitManager {
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
* @param limit
|
||||
* @return
|
||||
*/
|
||||
static boolean blocked(Player player, String regexCommand,
|
||||
String originalCommand, int limit) {
|
||||
int uses = getUses(player, regexCommand);
|
||||
|
@ -23,12 +34,15 @@ public class boosLimitManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
static void getLimits(Player player) {
|
||||
int usesNum = 0;
|
||||
int limitNum = 0;
|
||||
int num;
|
||||
String message;
|
||||
Set<String> uses = boosConfigManager.getLimits(player);
|
||||
Set<String> uses = boosConfigManager.getCommands(player);
|
||||
if (uses != null) {
|
||||
for (String key : uses) {
|
||||
usesNum = boosConfigManager.getConfusers().getInt(
|
||||
|
@ -49,6 +63,11 @@ public class boosLimitManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @return
|
||||
*/
|
||||
static int getUses(Player player, String regexCommand) {
|
||||
int regexCommand2 = regexCommand.toLowerCase().hashCode();
|
||||
int uses = 0;
|
||||
|
@ -58,15 +77,17 @@ public class boosLimitManager {
|
|||
return uses;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
*/
|
||||
static void setUses(Player player, String regexCommand,
|
||||
String originalCommand) {
|
||||
if (boosConfigManager.getLimitsEnabled()) {
|
||||
if (boosConfigManager.getLimits(player).contains(regexCommand)) {
|
||||
boosCoolDown.log.info("regexCommand: " + regexCommand
|
||||
+ " originalCommand: " + originalCommand);
|
||||
if (boosConfigManager.getCommands(player).contains(regexCommand)) {
|
||||
int regexCommand2 = regexCommand.toLowerCase().hashCode();
|
||||
int uses = getUses(player, regexCommand);
|
||||
boosCoolDown.log.info("Uses: " + uses);
|
||||
uses = uses + 1;
|
||||
try {
|
||||
boosConfigManager.getConfusers().set(
|
||||
|
@ -74,13 +95,40 @@ public class boosLimitManager {
|
|||
+ player.getName().toLowerCase().hashCode()
|
||||
+ ".uses." + regexCommand2, uses);
|
||||
} catch (IllegalArgumentException e) {
|
||||
boosCoolDown.log.warning("Player " + player.getName()
|
||||
+ " used empty command and caused this error!");
|
||||
boosCoolDown
|
||||
.getLog()
|
||||
.warning(
|
||||
"Player "
|
||||
+ player.getName()
|
||||
+ " used empty command and caused this error!");
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param send
|
||||
* @param comm
|
||||
* @param lim
|
||||
*/
|
||||
static void getLimitListMessages(Player send, String comm, int lim) {
|
||||
if (lim != -1) {
|
||||
int uses = getUses(send, comm);
|
||||
String message = boosConfigManager
|
||||
.getLimitListMessage();
|
||||
int num = lim - uses;
|
||||
if (num < 0) {
|
||||
num = 0;
|
||||
}
|
||||
message = boosConfigManager.getLimitListMessage();
|
||||
message = message.replaceAll("&command&", comm);
|
||||
message = message.replaceAll("&limit&",
|
||||
String.valueOf(lim));
|
||||
message = message.replaceAll("×&", String.valueOf(num));
|
||||
boosChat.sendMessageToPlayer(send, message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,11 +9,23 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|||
|
||||
import util.boosChat;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosPriceManager {
|
||||
private static Economy economy = boosCoolDown.getEconomy();
|
||||
static String msg = "";
|
||||
private static String msg = "";
|
||||
|
||||
public static boolean payForCommand(Player player, String regexCommand,
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
* @param price
|
||||
* @param name
|
||||
* @return
|
||||
*/
|
||||
static boolean payForCommand(Player player, String regexCommand,
|
||||
String originalCommand, double price, String name) {
|
||||
if (economy == null) {
|
||||
return true;
|
||||
|
@ -46,6 +58,13 @@ public class boosPriceManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param event
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
* @param price
|
||||
*/
|
||||
static void payForCommand(PlayerCommandPreprocessEvent event,
|
||||
Player player, String regexCommand, String originalCommand,
|
||||
double price) {
|
||||
|
|
|
@ -10,15 +10,28 @@ import org.bukkit.potion.PotionEffectType;
|
|||
|
||||
import util.boosChat;
|
||||
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* @author Jakub
|
||||
*
|
||||
*/
|
||||
public class boosWarmUpManager {
|
||||
|
||||
private static ConcurrentHashMap<String, boosWarmUpTimer> playercommands = new ConcurrentHashMap<String, boosWarmUpTimer>();
|
||||
public static ConcurrentHashMap<Player, Location> playerloc = new ConcurrentHashMap<Player, Location>();
|
||||
public static ConcurrentHashMap<Player, String> playerworld = new ConcurrentHashMap<Player, String>();
|
||||
private static ConcurrentHashMap<Player, Location> playerloc = new ConcurrentHashMap<Player, Location>();
|
||||
private static ConcurrentHashMap<Player, String> playerworld = new ConcurrentHashMap<Player, String>();
|
||||
|
||||
static Timer scheduler;
|
||||
private static Timer scheduler;
|
||||
|
||||
public static void applyPotionEffect(Player player, String regexCommand,
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param warmUpSeconds
|
||||
*/
|
||||
static void applyPotionEffect(Player player, String regexCommand,
|
||||
int warmUpSeconds) {
|
||||
String potion = boosConfigManager.getPotionEffect(regexCommand, player);
|
||||
if (potion.equals("")) {
|
||||
|
@ -35,6 +48,9 @@ public class boosWarmUpManager {
|
|||
true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
public static void cancelWarmUps(Player player) {
|
||||
Iterator<String> iter = playercommands.keySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
|
@ -45,11 +61,18 @@ public class boosWarmUpManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
public static void clearLocWorld(Player player) {
|
||||
boosWarmUpManager.playerloc.remove(player);
|
||||
boosWarmUpManager.playerworld.remove(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasWarmUps(Player player) {
|
||||
for (String key : playercommands.keySet()) {
|
||||
if (key.startsWith(player.getName() + "@")) {
|
||||
|
@ -59,6 +82,11 @@ public class boosWarmUpManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @return
|
||||
*/
|
||||
static boolean checkWarmUpOK(Player player, String regexCommand) {
|
||||
int pre2 = regexCommand.toLowerCase().hashCode();
|
||||
int ok = 0;
|
||||
|
@ -71,7 +99,12 @@ public class boosWarmUpManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static boolean isWarmUpProcess(Player player, String regexCommand) {
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @return
|
||||
*/
|
||||
static boolean isWarmUpProcess(Player player, String regexCommand) {
|
||||
regexCommand = regexCommand.toLowerCase();
|
||||
if (playercommands.containsKey(player.getName() + "@" + regexCommand)) {
|
||||
return true;
|
||||
|
@ -79,7 +112,10 @@ public class boosWarmUpManager {
|
|||
return false;
|
||||
}
|
||||
|
||||
public static void killTimer(Player player) {
|
||||
/**
|
||||
* @param player
|
||||
*/
|
||||
static void killTimer(Player player) {
|
||||
for (String key : playercommands.keySet()) {
|
||||
if (key.startsWith(player.getName() + "@")) {
|
||||
playercommands.get(key).cancel();
|
||||
|
@ -87,6 +123,10 @@ public class boosWarmUpManager {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
*/
|
||||
static void removeWarmUp(Player player, String regexCommand) {
|
||||
int pre2 = regexCommand.toLowerCase().hashCode();
|
||||
boosConfigManager.getConfusers().set(
|
||||
|
@ -94,6 +134,10 @@ public class boosWarmUpManager {
|
|||
+ ".warmup." + pre2, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
*/
|
||||
static void removeWarmUpOK(Player player, String regexCommand) {
|
||||
int pre2 = regexCommand.toLowerCase().hashCode();
|
||||
boosConfigManager.getConfusers().set(
|
||||
|
@ -101,10 +145,17 @@ public class boosWarmUpManager {
|
|||
+ ".warmup." + pre2, null);
|
||||
}
|
||||
|
||||
public static void removeWarmUpProcess(String tag) {
|
||||
/**
|
||||
* @param tag
|
||||
*/
|
||||
static void removeWarmUpProcess(String tag) {
|
||||
boosWarmUpManager.playercommands.remove(tag);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
*/
|
||||
static void setWarmUpOK(Player player, String regexCommand) {
|
||||
int pre2 = regexCommand.toLowerCase().hashCode();
|
||||
boosConfigManager.getConfusers().set(
|
||||
|
@ -112,7 +163,14 @@ public class boosWarmUpManager {
|
|||
+ ".warmup." + pre2, 1);
|
||||
}
|
||||
|
||||
public static void startWarmUp(boosCoolDown bCoolDown, Player player,
|
||||
/**
|
||||
* @param bCoolDown
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
* @param warmUpSeconds
|
||||
*/
|
||||
static void startWarmUp(boosCoolDown bCoolDown, Player player,
|
||||
String regexCommand, String originalCommand, int warmUpSeconds) {
|
||||
regexCommand = regexCommand.toLowerCase();
|
||||
long warmUpMinutes = Math.round(warmUpSeconds / 60);
|
||||
|
@ -149,4 +207,18 @@ public class boosWarmUpManager {
|
|||
boosChat.sendMessageToPlayer(player, msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static ConcurrentHashMap<Player, String> getPlayerworld() {
|
||||
return playerworld;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public static ConcurrentHashMap<Player, Location> getPlayerloc() {
|
||||
return playerloc;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,9 @@ import org.bukkit.entity.Player;
|
|||
public class boosWarmUpTimer extends TimerTask {
|
||||
|
||||
public class boosWarmUpRunnable implements Runnable {
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Runnable#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
if (player.isOnline() && !player.isDead()
|
||||
|
@ -38,9 +41,19 @@ public class boosWarmUpTimer extends TimerTask {
|
|||
private String originalCommand;
|
||||
private String regexCommand;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public boosWarmUpTimer() {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bCoolDown
|
||||
* @param timer
|
||||
* @param player
|
||||
* @param regexCommand
|
||||
* @param originalCommand
|
||||
*/
|
||||
public boosWarmUpTimer(boosCoolDown bCoolDown, Timer timer, Player player,
|
||||
String regexCommand, String originalCommand) {
|
||||
this.bCoolDown = bCoolDown;
|
||||
|
@ -49,6 +62,9 @@ public class boosWarmUpTimer extends TimerTask {
|
|||
this.originalCommand = originalCommand;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.util.TimerTask#run()
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
bCoolDown.getServer().getScheduler()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
name: boosCooldowns
|
||||
main: cz.boosik.boosCooldown.boosCoolDown
|
||||
version: 3.6.2
|
||||
version: 3.6.3
|
||||
authors: [LordBoos (ingame name boosik)]
|
||||
softdepend: [Vault]
|
||||
description: >
|
||||
|
|
Loading…
Reference in New Issue