many things I've forget to commit

This commit is contained in:
Boosik 2015-01-06 11:33:42 +01:00
parent 3d594f2c03
commit ff5075b0e4
9 changed files with 3444 additions and 3117 deletions

149
pom.xml
View File

@ -1,67 +1,82 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<modelVersion>4.0.0</modelVersion> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>cz.boosik</groupId> <modelVersion>4.0.0</modelVersion>
<artifactId>boosCooldowns</artifactId> <groupId>cz.boosik</groupId>
<version>3.8.5</version> <artifactId>boosCooldowns</artifactId>
<name>boosCooldowns</name> <version>3.9.5</version>
<packaging>jar</packaging> <name>boosCooldowns</name>
<url>http://maven.apache.org</url> <packaging>jar</packaging>
<properties> <url>http://maven.apache.org</url>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <properties>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<pluginRepositories> <minecraft.version>1.8</minecraft.version>
<pluginRepository> <bukkit.version>R0.1</bukkit.version>
<id>maven2-repository.dev.java.net</id> <bukkit.packet>v1_8_R1</bukkit.packet>
<name>Java.net Repository for Maven</name> </properties>
<url>http://download.java.net/maven/2/</url> <pluginRepositories>
<layout>default</layout> <pluginRepository>
</pluginRepository> <id>maven2-repository.dev.java.net</id>
</pluginRepositories> <name>Java.net Repository for Maven</name>
<repositories> <url>http://download.java.net/maven/2/</url>
<repository> <layout>default</layout>
<id>bukkit-repo</id> </pluginRepository>
<url>http://repo.bukkit.org/content/groups/public/</url> <pluginRepository>
</repository> <id>bukkit-plugins</id>
<repository> <url>http://repo.bukkit.org/content/groups/public/</url>
<id>vault-repo</id> </pluginRepository>
<url>http://nexus.theyeticave.net/content/repositories/pub_releases</url> </pluginRepositories>
</repository> <repositories>
</repositories> <repository>
<dependencies> <id>bukkit-repo</id>
<dependency> <url>http://repo.bukkit.org/content/groups/public/</url>
<groupId>org.bukkit</groupId> </repository>
<artifactId>bukkit</artifactId> <repository>
<version>LATEST</version> <id>vault-repo</id>
</dependency> <url>http://nexus.theyeticave.net/content/repositories/pub_releases</url>
<dependency> </repository>
<groupId>net.milkbowl.vault</groupId> <repository>
<artifactId>Vault</artifactId> <id>spigot-repo</id>
<version>LATEST</version> <url>http://repo.md-5.net/content/repositories/snapshots/</url>
</dependency> </repository>
</dependencies> </repositories>
<build> <dependencies>
<finalName>boosCooldowns</finalName> <dependency>
<sourceDirectory>${basedir}/src/main/java/</sourceDirectory> <groupId>org.bukkit</groupId>
<resources> <artifactId>bukkit</artifactId>
<resource> <version>${minecraft.version}-${bukkit.version}-SNAPSHOT</version>
<targetPath>.</targetPath> <scope>provided</scope>
<filtering>true</filtering> <optional>true</optional>
<directory>${basedir}/src/main/resources/</directory> </dependency>
<includes> <dependency>
<include>plugin.yml</include> <groupId>net.milkbowl.vault</groupId>
</includes> <artifactId>Vault</artifactId>
</resource> <version>LATEST</version>
</resources> </dependency>
<plugins> </dependencies>
<plugin> <build>
<artifactId>maven-compiler-plugin</artifactId> <finalName>boosCooldowns</finalName>
<version>3.1</version> <sourceDirectory>${basedir}/src/main/java/</sourceDirectory>
<configuration> <resources>
<source>1.7</source> <resource>
<target>1.7</target> <targetPath>.</targetPath>
</configuration> <filtering>true</filtering>
</plugin> <directory>${basedir}/src/main/resources/</directory>
</plugins> <includes>
</build> <include>plugin.yml</include>
</project> <include>config.yml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

File diff suppressed because it is too large Load Diff

View File

@ -1,430 +1,560 @@
package cz.boosik.boosCooldown; package cz.boosik.boosCooldown;
import java.io.IOException; import java.io.IOException;
import java.util.Set; import java.text.ParseException;
import java.util.UUID; import java.text.SimpleDateFormat;
import java.util.logging.Logger; import java.util.Calendar;
import java.util.Date;
import net.milkbowl.vault.Vault; import java.util.Set;
import net.milkbowl.vault.economy.Economy; import java.util.UUID;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.command.Command; import net.milkbowl.vault.Vault;
import org.bukkit.command.CommandSender; import net.milkbowl.vault.economy.Economy;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin; import org.bukkit.command.Command;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.command.CommandSender;
import org.bukkit.plugin.PluginManager; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitScheduler; import org.bukkit.event.HandlerList;
import org.mcstats.MetricsLite; import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import util.boosChat; import org.bukkit.plugin.PluginManager;
import cz.boosik.boosCooldown.Listeners.BoosEntityDamageListener; import org.bukkit.plugin.RegisteredServiceProvider;
import cz.boosik.boosCooldown.Listeners.BoosPlayerDeathListener; import org.bukkit.plugin.java.JavaPlugin;
import cz.boosik.boosCooldown.Listeners.BoosPlayerGameModeChangeListener; import org.bukkit.scheduler.BukkitScheduler;
import cz.boosik.boosCooldown.Listeners.BoosPlayerInteractListener; import org.mcstats.MetricsLite;
import cz.boosik.boosCooldown.Listeners.BoosPlayerMoveListener;
import cz.boosik.boosCooldown.Listeners.BoosPlayerToggleSneakListener; import util.boosChat;
import cz.boosik.boosCooldown.Listeners.BoosPlayerToggleSprintListener; import cz.boosik.boosCooldown.Listeners.BoosEntityDamageListener;
import cz.boosik.boosCooldown.Listeners.BoosSignChangeListener; import cz.boosik.boosCooldown.Listeners.BoosPlayerDeathListener;
import cz.boosik.boosCooldown.Listeners.BoosSignInteractListener; import cz.boosik.boosCooldown.Listeners.BoosPlayerGameModeChangeListener;
import cz.boosik.boosCooldown.Listeners.BoosPlayerInteractListener;
/** import cz.boosik.boosCooldown.Listeners.BoosPlayerMoveListener;
* Hlavn<EFBFBD> t<EFBFBD><EFBFBD>da pluginu. T<EFBFBD><EFBFBD>da je potomkem JavaPlugin a implementuje Runnable. import cz.boosik.boosCooldown.Listeners.BoosPlayerToggleSneakListener;
* Tato t<EFBFBD><EFBFBD>da se star<EFBFBD> o ve<EFBFBD>ker<EFBFBD> inicializace p<EFBFBD>i spu<EFBFBD>t<EFBFBD>n<EFBFBD> a ukon<EFBFBD>en<EFBFBD> pluginu. import cz.boosik.boosCooldown.Listeners.BoosPlayerToggleSprintListener;
* Toto zahrnuje zji<EFBFBD>t<EFBFBD>n<EFBFBD>, zda je k dispozici plugin Vault a ekonomick<EFBFBD> plugin, import cz.boosik.boosCooldown.Listeners.BoosSignChangeListener;
* registraci poslucha<EFBFBD><EFBFBD> a tak<EFBFBD> se star<EFBFBD> o funkce v<EFBFBD>ech kontroln<EFBFBD>ch a import cz.boosik.boosCooldown.Listeners.BoosSignInteractListener;
* konfigura<EFBFBD>n<EFBFBD>ch p<EFBFBD><EFBFBD>kaz<EFBFBD>. Periodicky tak<EFBFBD> ukl<EFBFBD>d<EFBFBD> soubor datab<EFBFBD>ze v intervalu
* nastaven<EFBFBD>m v konfiguraci. /**
* * Hlavn<EFBFBD> t<EFBFBD><EFBFBD>da pluginu. T<EFBFBD><EFBFBD>da je potomkem JavaPlugin a implementuje Runnable.
* @author Jakub Kol<EFBFBD><EFBFBD> * Tato t<EFBFBD><EFBFBD>da se star<EFBFBD> o ve<EFBFBD>ker<EFBFBD> inicializace p<EFBFBD>i spu<EFBFBD>t<EFBFBD>n<EFBFBD> a ukon<EFBFBD>en<EFBFBD> pluginu.
* * Toto zahrnuje zji<EFBFBD>t<EFBFBD>n<EFBFBD>, zda je k dispozici plugin Vault a ekonomick<EFBFBD> plugin,
*/ * registraci poslucha<EFBFBD><EFBFBD> a tak<EFBFBD> se star<EFBFBD> o funkce v<EFBFBD>ech kontroln<EFBFBD>ch a
public class BoosCoolDown extends JavaPlugin implements Runnable { * konfigura<EFBFBD>n<EFBFBD>ch p<EFBFBD><EFBFBD>kaz<EFBFBD>. Periodicky tak<EFBFBD> ukl<EFBFBD>d<EFBFBD> soubor datab<EFBFBD>ze v intervalu
private static final Logger log = Logger.getLogger("Minecraft"); * nastaven<EFBFBD>m v konfiguraci.
private static PluginDescriptionFile pdfFile; *
private static Economy economy = null; * @author Jakub Kol<EFBFBD><EFBFBD>
private static boolean usingVault = false; *
private PluginManager pm; */
public class BoosCoolDown extends JavaPlugin implements Runnable {
/** private static final Logger log = Logger.getLogger("Minecraft");
* Metoda odes<EFBFBD>l<EFBFBD> zpr<EFBFBD>vy o pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kaz<EFBFBD> do konzole serveru. private static PluginDescriptionFile pdfFile;
* private static Economy economy = null;
* @param player private static boolean usingVault = false;
* jm<EFBFBD>no hr<EFBFBD><EFBFBD>e kter<EFBFBD> vykonal p<EFBFBD><EFBFBD>kaz private PluginManager pm;
* @param command private static BoosCoolDown instance = null;
* vykonan<EFBFBD> p<EFBFBD><EFBFBD>kaz
*/ /**
public static void commandLogger(String player, String command) { * Metoda odes<EFBFBD>l<EFBFBD> zpr<EFBFBD>vy o pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kaz<EFBFBD> do konzole serveru.
log.info("[" + "boosLogger" + "] " + player + " used command " *
+ command); * @param player
} * jm<EFBFBD>no hr<EFBFBD><EFBFBD>e kter<EFBFBD> vykonal p<EFBFBD><EFBFBD>kaz
* @param command
/** * vykonan<EFBFBD> p<EFBFBD><EFBFBD>kaz
* @return */
*/ public static void commandLogger(String player, String command) {
public static Economy getEconomy() { log.info("[" + "boosLogger" + "] " + player + " used command "
return economy; + command);
} }
/** /**
* @return * @return
*/ */
public static Logger getLog() { public static Economy getEconomy() {
return log; return economy;
} }
/** /**
* Metoda zji<EFBFBD><EFBFBD>uje na z<EFBFBD>klad<EFBFBD> opr<EFBFBD>vn<EFBFBD>n<EFBFBD> jestli je plugin aktivn<EFBFBD> pro dan<EFBFBD>ho * @return
* hr<EFBFBD><EFBFBD>e nebo ne. */
* public static Logger getLog() {
* @param player return log;
* specifikovan<EFBFBD> hr<EFBFBD><EFBFBD> }
* @return
*/ /**
static boolean isPluginOnForPlayer(Player player) { * Metoda zji<EFBFBD><EFBFBD>uje na z<EFBFBD>klad<EFBFBD> opr<EFBFBD>vn<EFBFBD>n<EFBFBD> jestli je plugin aktivn<EFBFBD> pro dan<EFBFBD>ho
boolean on; * hr<EFBFBD><EFBFBD>e nebo ne.
if (player.hasPermission("booscooldowns.exception")) { *
on = false; * @param player
} else if (player.isOp()) { * specifikovan<EFBFBD> hr<EFBFBD><EFBFBD>
on = false; * @return
} else { */
on = true; static boolean isPluginOnForPlayer(Player player) {
} boolean on;
return on; if (player.hasPermission("booscooldowns.exception")) {
} on = false;
} else if (player.isOp()) {
/** on = false;
* Metoda zji<EFBFBD><EFBFBD>uje jestli je dostupn<EFBFBD> plugin Vault a na z<EFBFBD>klad<EFBFBD> toho vol<EFBFBD> } else {
* metodu pro nastaven<EFBFBD> ekonomick<EFBFBD>ho pluginu a informuje o tom u<EFBFBD>ivatele on = true;
* pomoc<EFBFBD> konzole serveru. }
*/ return on;
private void initializeVault() { }
Plugin x = pm.getPlugin("Vault");
if (x != null & x instanceof Vault) { /**
log.info("[" + pdfFile.getName() + "]" * Metoda zji<EFBFBD><EFBFBD>uje jestli je dostupn<EFBFBD> plugin Vault a na z<EFBFBD>klad<EFBFBD> toho vol<EFBFBD>
+ " found [Vault] searching for economy plugin."); * metodu pro nastaven<EFBFBD> ekonomick<EFBFBD>ho pluginu a informuje o tom u<EFBFBD>ivatele
usingVault = true; * pomoc<EFBFBD> konzole serveru.
if (setupEconomy()) { */
log.info("[" + pdfFile.getName() + "]" + " found [" private void initializeVault() {
+ economy.getName() Plugin x = pm.getPlugin("Vault");
+ "] plugin, enabling prices support."); if (x != null & x instanceof Vault) {
} else { log.info("[" + pdfFile.getName() + "]"
log.info("[" + " found [Vault] searching for economy plugin.");
+ pdfFile.getName() usingVault = true;
+ "]" if (setupEconomy()) {
+ " economy plugin not found, disabling prices support."); log.info("[" + pdfFile.getName() + "]" + " found ["
} + economy.getName()
} else { + "] plugin, enabling prices support.");
log.info("[" + pdfFile.getName() + "]" } else {
+ " [Vault] not found disabling economy support."); log.info("["
usingVault = false; + pdfFile.getName()
} + "]"
} + " economy plugin not found, disabling prices support.");
}
/* } else {
* (non-Javadoc) log.info("[" + pdfFile.getName() + "]"
* + " [Vault] not found disabling economy support.");
* @see usingVault = false;
* org.bukkit.plugin.java.JavaPlugin#onCommand(org.bukkit.command.CommandSender }
* , org.bukkit.command.Command, java.lang.String, java.lang.String[]) }
*/
@SuppressWarnings("deprecation") /*
@Override * (non-Javadoc)
public boolean onCommand(CommandSender sender, Command c, *
String commandLabel, String[] args) { * @see
String command = c.getName().toLowerCase(); * org.bukkit.plugin.java.JavaPlugin#onCommand(org.bukkit.command.CommandSender
if (command.equalsIgnoreCase("booscooldowns")) { * , org.bukkit.command.Command, java.lang.String, java.lang.String[])
if (args.length == 1) { */
if (sender.hasPermission("booscooldowns.reload") @SuppressWarnings("deprecation")
&& args[0].equalsIgnoreCase("reload")) { @Override
reload(); public boolean onCommand(CommandSender sender, Command c,
boosChat.sendMessageToCommandSender(sender, String commandLabel, String[] args) {
"&6[" + pdfFile.getName() + "]&e" String command = c.getName().toLowerCase();
+ " config reloaded"); if (command.equalsIgnoreCase("booscooldowns")) {
return true; if (args.length == 1) {
} if (sender.hasPermission("booscooldowns.reload")
if (sender.hasPermission("booscooldowns.list.limits") && args[0].equalsIgnoreCase("reload")) {
&& args[0].equalsIgnoreCase("limits")) { reload();
try { boosChat.sendMessageToCommandSender(sender,
Player send = (Player) sender; "&6[" + pdfFile.getName() + "]&e"
Set<String> commands = BoosConfigManager + " config reloaded");
.getCommands(send); return true;
for (String comm : commands) { }
int lim = BoosConfigManager.getLimit(comm, send); if (sender.hasPermission("booscooldowns.list.limits")
BoosLimitManager.getLimitListMessages(send, comm, && args[0].equalsIgnoreCase("limits")) {
lim); try {
} Player send = (Player) sender;
} catch (ClassCastException e) { Set<String> commands = BoosConfigManager
log.warning("You cannot use this command from console!"); .getCommands(send);
} for (String comm : commands) {
return true; int lim = BoosConfigManager.getLimit(comm, send);
} BoosLimitManager.getLimitListMessages(send, comm,
} lim);
if (args.length == 2) { }
String jmeno = args[1]; } catch (ClassCastException e) {
Player player = Bukkit.getPlayerExact(jmeno); log.warning("You cannot use this command from console!");
UUID uuid = player.getUniqueId(); }
if (sender.hasPermission("booscooldowns.clearcooldowns") return true;
&& args[0].equalsIgnoreCase("clearcooldowns")) { }
String co = "cooldown"; else if (sender.hasPermission("booscooldowns.globalreset")
BoosConfigManager.clearSomething(co, uuid); && args[0].equalsIgnoreCase("startglobalreset")) {
boosChat.sendMessageToCommandSender(sender, BoosLimitManager.setGlobalLimitResetDate();
"&6[" + pdfFile.getName() + "]&e" startLimitResetTimersGlobal();
+ " cooldowns of player " + jmeno return true;
+ " cleared"); }
return true; }
} else if (sender.hasPermission("booscooldowns.clearuses") else if (args.length == 2) {
&& command.equalsIgnoreCase("booscooldowns") String jmeno = args[1];
&& args[0].equalsIgnoreCase("clearuses")) { Player player = Bukkit.getPlayerExact(jmeno);
String co = "uses"; UUID uuid = player.getUniqueId();
BoosConfigManager.clearSomething(co, uuid); if (sender.hasPermission("booscooldowns.clearcooldowns")
boosChat.sendMessageToCommandSender(sender, && args[0].equalsIgnoreCase("clearcooldowns")) {
"&6[" + pdfFile.getName() + "]&e" String co = "cooldown";
+ " uses of player " + jmeno + " cleared"); BoosConfigManager.clearSomething(co, uuid);
return true; boosChat.sendMessageToCommandSender(sender,
} else if (sender.hasPermission("booscooldowns.clearwarmups") "&6[" + pdfFile.getName() + "]&e"
&& command.equalsIgnoreCase("booscooldowns") + " cooldowns of player " + jmeno
&& args[0].equalsIgnoreCase("clearwarmups")) { + " cleared");
String co = "warmup"; return true;
BoosConfigManager.clearSomething(co, uuid); } else if (sender.hasPermission("booscooldowns.clearuses")
boosChat.sendMessageToCommandSender(sender, && command.equalsIgnoreCase("booscooldowns")
"&6[" + pdfFile.getName() + "]&e" && args[0].equalsIgnoreCase("clearuses")) {
+ " warmups of player " + jmeno String co = "uses";
+ " cleared"); BoosConfigManager.clearSomething(co, uuid);
return true; boosChat.sendMessageToCommandSender(sender,
} "&6[" + pdfFile.getName() + "]&e"
} + " uses of player " + jmeno + " cleared");
if (args.length == 3) { return true;
String jmeno = args[1]; } else if (sender.hasPermission("booscooldowns.clearwarmups")
Player player = Bukkit.getPlayerExact(jmeno); && command.equalsIgnoreCase("booscooldowns")
UUID uuid = player.getUniqueId(); && args[0].equalsIgnoreCase("clearwarmups")) {
String command2 = args[2].trim(); String co = "warmup";
if (sender.hasPermission("booscooldowns.clearcooldowns") BoosConfigManager.clearSomething(co, uuid);
&& args[0].equalsIgnoreCase("clearcooldowns")) { boosChat.sendMessageToCommandSender(sender,
String co = "cooldown"; "&6[" + pdfFile.getName() + "]&e"
BoosConfigManager.clearSomething(co, uuid, command2); + " warmups of player " + jmeno
boosChat.sendMessageToCommandSender(sender, + " cleared");
"&6[" + pdfFile.getName() + "]&e" return true;
+ " cooldown for command " + command2 }
+ " of player " + uuid + " cleared"); }
return true; else if (args.length == 3) {
} else if (sender.hasPermission("booscooldowns.clearuses") String jmeno = args[1];
&& args[0].equalsIgnoreCase("clearuses")) { Player player = Bukkit.getPlayerExact(jmeno);
String co = "uses"; UUID uuid = player.getUniqueId();
BoosConfigManager.clearSomething(co, uuid, command2); String command2 = args[2].trim();
boosChat.sendMessageToCommandSender(sender, if (sender.hasPermission("booscooldowns.clearcooldowns")
"&6[" + pdfFile.getName() + "]&e" && args[0].equalsIgnoreCase("clearcooldowns")) {
+ " uses for command " + command2 String co = "cooldown";
+ " of player " + jmeno + " cleared"); BoosConfigManager.clearSomething(co, uuid, command2);
return true; boosChat.sendMessageToCommandSender(sender,
} else if (sender.hasPermission("booscooldowns.clearwarmups") "&6[" + pdfFile.getName() + "]&e"
&& args[0].equalsIgnoreCase("clearwarmups")) { + " cooldown for command " + command2
String co = "warmup"; + " of player " + uuid + " cleared");
BoosConfigManager.clearSomething(co, uuid, command2); return true;
boosChat.sendMessageToCommandSender(sender, } else if (sender.hasPermission("booscooldowns.clearuses")
"&6[" + pdfFile.getName() + "]&e" && args[0].equalsIgnoreCase("clearuses")) {
+ " warmups for command " + command2 String co = "uses";
+ " of player " + jmeno + " cleared"); BoosConfigManager.clearSomething(co, uuid, command2);
return true; boosChat.sendMessageToCommandSender(sender,
"&6[" + pdfFile.getName() + "]&e"
} + " uses for command " + command2
} + " of player " + jmeno + " cleared");
if (args.length == 4) { return true;
if (sender.hasPermission("booscooldowns.set") } else if (sender.hasPermission("booscooldowns.clearwarmups")
&& args[0].equalsIgnoreCase("set")) { && args[0].equalsIgnoreCase("clearwarmups")) {
String what = args[1]; String co = "warmup";
String comm = args[2]; BoosConfigManager.clearSomething(co, uuid, command2);
String value = args[3]; boosChat.sendMessageToCommandSender(sender,
String group = "default"; "&6[" + pdfFile.getName() + "]&e"
if (comm.startsWith("/") || comm.equals("*")) { + " warmups for command " + command2
if (comm.contains("_")) { + " of player " + jmeno + " cleared");
comm = comm.replace("_", " "); return true;
}
BoosConfigManager.setAddToConfigFile(group, comm, what, }
value); }
boosChat.sendMessageToCommandSender(sender, "&6[" else if (args.length == 4) {
+ pdfFile.getName() + "]&e " + what if (sender.hasPermission("booscooldowns.set")
+ " for command" + comm + " in group " + group && args[0].equalsIgnoreCase("set")) {
+ " is now set to " + value); String what = args[1];
return true; String comm = args[2];
} else { String value = args[3];
boosChat.sendMessageToCommandSender(sender, "&6[" String group = "default";
+ pdfFile.getName() + "]&e" if (comm.startsWith("/") || comm.equals("*")) {
+ " Command has to start with \"/\"."); if (comm.contains("_")) {
return true; comm = comm.replace("_", " ");
} }
} BoosConfigManager.setAddToConfigFile(group, comm, what,
value);
} boosChat.sendMessageToCommandSender(sender, "&6["
if (args.length == 5) { + pdfFile.getName() + "]&e " + what
if (sender.hasPermission("booscooldowns.set") + " for command" + comm + " in group " + group
&& args[0].equalsIgnoreCase("set")) { + " is now set to " + value);
String what = args[1]; return true;
String comm = args[2]; } else {
String value = args[3]; boosChat.sendMessageToCommandSender(sender, "&6["
String group = args[4]; + pdfFile.getName() + "]&e"
if (comm.startsWith("/") || comm.equals("*")) { + " Command has to start with \"/\".");
if (comm.contains("_")) { return true;
comm = comm.replace("_", " "); }
} }
BoosConfigManager.setAddToConfigFile(group, comm, what,
value); }
boosChat.sendMessageToCommandSender(sender, "&6[" else if (args.length == 5) {
+ pdfFile.getName() + "]&e " + what if (sender.hasPermission("booscooldowns.set")
+ " for command" + comm + " in group " + group && args[0].equalsIgnoreCase("set")) {
+ " is now set to " + value); String what = args[1];
return true; String comm = args[2];
} else { String value = args[3];
boosChat.sendMessageToCommandSender(sender, "&6[" String group = args[4];
+ pdfFile.getName() + "]&e" if (comm.startsWith("/") || comm.equals("*")) {
+ " Command has to start with \"/\"."); if (comm.contains("_")) {
return true; comm = comm.replace("_", " ");
} }
} BoosConfigManager.setAddToConfigFile(group, comm, what,
value);
} else { boosChat.sendMessageToCommandSender(sender, "&6["
boosChat.sendMessageToCommandSender(sender, + pdfFile.getName() + "]&e " + what
"&6[" + pdfFile.getName() + "]&e" + " for command" + comm + " in group " + group
+ " Invalid command or access denied!"); + " is now set to " + value);
} return true;
} } else {
return false; boosChat.sendMessageToCommandSender(sender, "&6["
+ pdfFile.getName() + "]&e"
} + " Command has to start with \"/\".");
return true;
/* }
* (non-Javadoc) }
*
* @see org.bukkit.plugin.java.JavaPlugin#onDisable() } else {
*/ // boosChat.sendMessageToCommandSender(sender,
@Override // "&6[" + pdfFile.getName() + "]&e"
public void onDisable() { // + " Invalid command or access denied!");
if (BoosConfigManager.getClearOnRestart() == true) { return false;
BoosConfigManager.clear(); }
log.info("[" + pdfFile.getName() + "]" + " cooldowns cleared!"); }
} else { return false;
BoosConfigManager.saveConfusers();
log.info("[" + pdfFile.getName() + "]" + " cooldowns saved!"); }
}
log.info("[" + pdfFile.getName() + "]" + " version " /*
+ pdfFile.getVersion() + " disabled!"); * (non-Javadoc)
} *
* @see org.bukkit.plugin.java.JavaPlugin#onDisable()
/* */
* (non-Javadoc) @Override
* public void onDisable() {
* @see org.bukkit.plugin.java.JavaPlugin#onEnable() if (BoosConfigManager.getClearOnRestart()) {
*/ BoosConfigManager.clear();
@Override log.info("[" + pdfFile.getName() + "]" + " cooldowns cleared!");
public void onEnable() { } else {
pdfFile = this.getDescription(); BoosConfigManager.saveConfusers();
PluginDescriptionFile pdfFile = this.getDescription(); log.info("[" + pdfFile.getName() + "]" + " cooldowns saved!");
log.info("[" + pdfFile.getName() + "]" + " version " }
+ pdfFile.getVersion() + " by " + pdfFile.getAuthors() log.info("[" + pdfFile.getName() + "]" + " version "
+ " is enabled!"); + pdfFile.getVersion() + " disabled!");
new BoosConfigManager(this); }
BoosConfigManager.load();
BoosConfigManager.loadConfusers(); /*
pm = getServer().getPluginManager(); * (non-Javadoc)
registerListeners(); *
initializeVault(); * @see org.bukkit.plugin.java.JavaPlugin#onEnable()
BukkitScheduler scheduler = this.getServer().getScheduler(); */
if (BoosConfigManager.getAutoSave()) { @Override
scheduler.scheduleSyncRepeatingTask(this, this, public void onEnable() {
BoosConfigManager.getSaveInterval() * 1200, pdfFile = this.getDescription();
BoosConfigManager.getSaveInterval() * 1200); PluginDescriptionFile pdfFile = this.getDescription();
} log.info("[" + pdfFile.getName() + "]" + " version "
if (BoosConfigManager.getClearOnRestart()) { + pdfFile.getVersion() + " by " + pdfFile.getAuthors()
BoosConfigManager.clear(); + " is enabled!");
} this.saveDefaultConfig();
try { new BoosConfigManager(this);
MetricsLite metrics = new MetricsLite(this); BoosConfigManager.load();
metrics.start(); BoosConfigManager.loadConfusers();
} catch (IOException e) { pm = getServer().getPluginManager();
// Failed to submit the stats :-( registerListeners();
} initializeVault();
BukkitScheduler scheduler = this.getServer().getScheduler();
} startLimitResetTimersGlobal();
if (BoosConfigManager.getAutoSave()) {
/** scheduler.scheduleSyncRepeatingTask(this, this,
* Metoda registruje poslucha<EFBFBD>e v PluginManageru na z<EFBFBD>klad<EFBFBD> konfigurace BoosConfigManager.getSaveInterval() * 1200,
* pluginu. Registroj<EFBFBD> se v<EFBFBD>dy jen nezbytn<EFBFBD> poslucha<EFBFBD>i. Poslucha<EFBFBD>i pro BoosConfigManager.getSaveInterval() * 1200);
* vypnut<EFBFBD> funkce nejsou registrov<EFBFBD>ni. }
*/
private void registerListeners() { if (BoosConfigManager.getClearOnRestart()) {
HandlerList.unregisterAll(this); BoosConfigManager.clear();
pm.registerEvents(new BoosCoolDownListener(this), this); }
if (BoosConfigManager.getCancelWarmUpOnDamage()) { try {
pm.registerEvents(new BoosEntityDamageListener(), this); MetricsLite metrics = new MetricsLite(this);
} metrics.start();
if (BoosConfigManager.getCleanCooldownsOnDeath() } catch (IOException e) {
|| BoosConfigManager.getCleanUsesOnDeath() // Failed to submit the stats :-(
|| BoosConfigManager.getStartCooldownsOnDeath()) { }
pm.registerEvents(new BoosPlayerDeathListener(), this);
} }
if (BoosConfigManager.getCancelWarmUpOnGameModeChange()) {
pm.registerEvents(new BoosPlayerGameModeChangeListener(), this); static void startLimitResetTimersGlobal() {
} YamlConfiguration confusers = BoosConfigManager.getConfusers();
if (BoosConfigManager.getBlockInteractDuringWarmup()) { ConfigurationSection global = confusers
pm.registerEvents(new BoosPlayerInteractListener(), this); .getConfigurationSection("global");
} if (global != null) {
if (BoosConfigManager.getCancelWarmupOnMove()) { Set<String> globalKeys = global.getKeys(false);
pm.registerEvents(new BoosPlayerMoveListener(), this); BukkitScheduler scheduler = Bukkit.getScheduler();
} for (String key : globalKeys) {
if (BoosConfigManager.getCancelWarmupOnSneak()) { String confTime = confusers.getString("global." + key
pm.registerEvents(new BoosPlayerToggleSneakListener(), this); + ".reset");
} long limitResetDelay = BoosConfigManager
if (BoosConfigManager.getCancelWarmupOnSprint()) { .getLimitResetDelayGlobal(key);
pm.registerEvents(new BoosPlayerToggleSprintListener(), this); Date endDate = getTime(confTime);
} Date startDate = getCurrTime();
if (BoosConfigManager.getSignCommands()) { Calendar calcurrTime = Calendar.getInstance();
pm.registerEvents(new BoosSignChangeListener(), this); calcurrTime.setTime(startDate);
pm.registerEvents(new BoosSignInteractListener(this), this); Calendar callastTime = Calendar.getInstance();
} callastTime.setTime(endDate);
} long time = secondsBetween(calcurrTime, callastTime,
limitResetDelay);
/** if (limitResetDelay != -65535) {
* Metoda vol<EFBFBD> metodu pro znovuna<EFBFBD>ten<EFBFBD> konfigura<EFBFBD>n<EFBFBD>ho souboru a metodu pro if (time <= 0) {
* registraci poslucha<EFBFBD><EFBFBD>. time = 1;
*/ }
private void reload() { BoosCoolDown.getLog().info(
BoosConfigManager.reload(); "[boosCooldowns] Starting timer for " + time
registerListeners(); + " seconds to reset limits for command "
} + key);
scheduler.scheduleSyncDelayedTask(Bukkit.getPluginManager()
/* .getPlugin("boosCooldowns"),
* (non-Javadoc) new BoosGlobalLimitResetRunnable(key), time * 20);
* } else {
* @see java.lang.Runnable#run() BoosCoolDown.getLog().info(
*/ "[boosCooldowns] Stoping timer to reset limits for command "
@Override + key);
public void run() { }
BoosConfigManager.saveConfusers(); }
BoosConfigManager.loadConfusers(); }
log.info("[boosCooldowns] Config saved!"); }
}
static void startLimitResetTimerGlobal(String key) {
/** YamlConfiguration confusers = BoosConfigManager.getConfusers();
* Metoda vrac<EFBFBD> hodnotu true, pokud je na serveru dostupn<EFBFBD> Ekonomick<EFBFBD> plugin BukkitScheduler scheduler = Bukkit.getScheduler();
* kompatibiln<EFBFBD> s pluginem Vault. String confTime = confusers.getString("global." + key + ".reset");
* long limitResetDelay = BoosConfigManager.getLimitResetDelayGlobal(key);
* @return true pokud je dostupn<EFBFBD> ekonomick<EFBFBD> plugin kompatibiln<EFBFBD> s pluginem Date endDate = getTime(confTime);
* Vault, jinak vrac<EFBFBD> hodnotu false Date startDate = getCurrTime();
*/ Calendar calcurrTime = Calendar.getInstance();
private boolean setupEconomy() { calcurrTime.setTime(startDate);
if (usingVault) { Calendar callastTime = Calendar.getInstance();
RegisteredServiceProvider<Economy> economyProvider = getServer() callastTime.setTime(endDate);
.getServicesManager().getRegistration( long time = secondsBetween(calcurrTime, callastTime, limitResetDelay);
net.milkbowl.vault.economy.Economy.class); if (limitResetDelay != -65535) {
if (economyProvider != null) { if (time <= 0) {
economy = economyProvider.getProvider(); time = 1;
} }
return (economy != null); BoosCoolDown.getLog().info(
} "[boosCooldowns] Starting timer for " + time
return false; + " seconds to reset limits for command " + key);
} scheduler.scheduleSyncDelayedTask(Bukkit.getPluginManager()
} .getPlugin("boosCooldowns"),
new BoosGlobalLimitResetRunnable(key), time * 20);
} else {
BoosCoolDown.getLog().info(
"[boosCooldowns] Stoping timer to reset limits for command "
+ key);
}
}
static long secondsBetween(Calendar startDate, Calendar endDate,
long limitResetDelay) {
long secondsBetween = 0;
secondsBetween = ((endDate.getTimeInMillis() - startDate
.getTimeInMillis()) / 1000) + limitResetDelay;
return secondsBetween;
}
static Date getCurrTime() {
String currTime = "";
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
currTime = sdf.format(cal.getTime());
Date time = null;
try {
time = sdf.parse(currTime);
return time;
} catch (ParseException e) {
return null;
}
}
static Date getTime(String confTime) {
if (confTime != null && !confTime.equals("")) {
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
Date lastDate = null;
try {
lastDate = sdf.parse(confTime);
return lastDate;
} catch (ParseException e) {
return null;
}
}
return null;
}
/**
* Metoda registruje poslucha<EFBFBD>e v PluginManageru na z<EFBFBD>klad<EFBFBD> konfigurace
* pluginu. Registroj<EFBFBD> se v<EFBFBD>dy jen nezbytn<EFBFBD> poslucha<EFBFBD>i. Poslucha<EFBFBD>i pro
* vypnut<EFBFBD> funkce nejsou registrov<EFBFBD>ni.
*/
private void registerListeners() {
HandlerList.unregisterAll(this);
pm.registerEvents(new BoosCoolDownListener(this), this);
if (BoosConfigManager.getCancelWarmUpOnDamage()) {
pm.registerEvents(new BoosEntityDamageListener(), this);
}
if (BoosConfigManager.getCleanCooldownsOnDeath()
|| BoosConfigManager.getCleanUsesOnDeath()
|| BoosConfigManager.getStartCooldownsOnDeath()) {
pm.registerEvents(new BoosPlayerDeathListener(), this);
}
if (BoosConfigManager.getCancelWarmUpOnGameModeChange()) {
pm.registerEvents(new BoosPlayerGameModeChangeListener(), this);
}
if (BoosConfigManager.getBlockInteractDuringWarmup()) {
pm.registerEvents(new BoosPlayerInteractListener(), this);
}
if (BoosConfigManager.getCancelWarmupOnMove()) {
pm.registerEvents(new BoosPlayerMoveListener(), this);
}
if (BoosConfigManager.getCancelWarmupOnSneak()) {
pm.registerEvents(new BoosPlayerToggleSneakListener(), this);
}
if (BoosConfigManager.getCancelWarmupOnSprint()) {
pm.registerEvents(new BoosPlayerToggleSprintListener(), this);
}
if (BoosConfigManager.getSignCommands()) {
pm.registerEvents(new BoosSignChangeListener(), this);
pm.registerEvents(new BoosSignInteractListener(this), this);
}
}
/**
* Metoda vol<EFBFBD> metodu pro znovuna<EFBFBD>ten<EFBFBD> konfigura<EFBFBD>n<EFBFBD>ho souboru a metodu pro
* registraci poslucha<EFBFBD><EFBFBD>.
*/
private void reload() {
BoosConfigManager.reload();
registerListeners();
}
/*
* (non-Javadoc)
*
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
BoosConfigManager.saveConfusers();
BoosConfigManager.loadConfusers();
log.info("[boosCooldowns] Config saved!");
}
/**
* Metoda vrac<EFBFBD> hodnotu true, pokud je na serveru dostupn<EFBFBD> Ekonomick<EFBFBD> plugin
* kompatibiln<EFBFBD> s pluginem Vault.
*
* @return true pokud je dostupn<EFBFBD> ekonomick<EFBFBD> plugin kompatibiln<EFBFBD> s pluginem
* Vault, jinak vrac<EFBFBD> hodnotu false
*/
private boolean setupEconomy() {
if (usingVault) {
RegisteredServiceProvider<Economy> economyProvider = getServer()
.getServicesManager().getRegistration(
net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}
return (economy != null);
}
return false;
}
public static BoosCoolDown getInstance() {
if (instance == null) {
instance = new BoosCoolDown();
}
return instance;
}
}

View File

@ -1,295 +1,295 @@
package cz.boosik.boosCooldown; package cz.boosik.boosCooldown;
import java.util.Set; import java.util.Set;
import java.util.regex.Matcher;
import org.bukkit.entity.Player; import java.util.regex.Pattern;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority; import org.bukkit.Bukkit;
import org.bukkit.event.Listener; import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import util.boosChat; import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
/**
* Hlavn<EFBFBD> poslucha<EFBFBD>, kter<EFBFBD> naslouch<EFBFBD> ud<EFBFBD>losti pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kazu hr<EFBFBD><EFBFBD>em. import util.boosChat;
* Kontroluje, jestli jsou pro p<EFBFBD><EFBFBD>kaz nastaveny omezen<EFBFBD> a na z<EFBFBD>klad<EFBFBD> tohoto
* spou<EFBFBD>t<EFBFBD> <EFBFBD>asova<EFBFBD>e a vol<EFBFBD> metody spojen<EFBFBD> s poplatky a limity. /**
* * Hlavn<EFBFBD> poslucha<EFBFBD>, kter<EFBFBD> naslouch<EFBFBD> ud<EFBFBD>losti pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kazu hr<EFBFBD><EFBFBD>em.
* @author Jakub Kol<EFBFBD><EFBFBD> * Kontroluje, jestli jsou pro p<EFBFBD><EFBFBD>kaz nastaveny omezen<EFBFBD> a na z<EFBFBD>klad<EFBFBD> tohoto
* * spou<EFBFBD>t<EFBFBD> <EFBFBD>asova<EFBFBD>e a vol<EFBFBD> metody spojen<EFBFBD> s poplatky a limity.
*/ *
public class BoosCoolDownListener implements Listener { * @author Jakub Kol<EFBFBD><EFBFBD>
private static BoosCoolDown plugin; *
*/
/** public class BoosCoolDownListener implements Listener {
* @param instance private static BoosCoolDown plugin;
*/
public BoosCoolDownListener(BoosCoolDown instance) { /**
plugin = instance; * @param instance
} */
public BoosCoolDownListener(BoosCoolDown instance) {
/** plugin = instance;
* Metoda zkontroluje pomoc<EFBFBD> vol<EFBFBD>n<EFBFBD> dal<EFBFBD><EFBFBD>ch metod, jestli p<EFBFBD>ikaz kter<EFBFBD> hr<EFBFBD><EFBFBD> }
* pou<EFBFBD>il je n<EFBFBD>jak<EFBFBD>m zp<EFBFBD>sobem omezen<EFBFBD> a na z<EFBFBD>klad<EFBFBD> toho je bu<EFBFBD> ud<EFBFBD>lost
* pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kazu stornov<EFBFBD>na, nebo ne. /**
* * Metoda zkontroluje pomoc<EFBFBD> vol<EFBFBD>n<EFBFBD> dal<EFBFBD><EFBFBD>ch metod, jestli p<EFBFBD>ikaz kter<EFBFBD> hr<EFBFBD><EFBFBD>
* @param event * pou<EFBFBD>il je n<EFBFBD>jak<EFBFBD>m zp<EFBFBD>sobem omezen<EFBFBD> a na z<EFBFBD>klad<EFBFBD> toho je bu<EFBFBD> ud<EFBFBD>lost
* ud<EFBFBD>lost PlayerCommandPreprocessEvent * pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kazu stornov<EFBFBD>na, nebo ne.
* @param player *
* hr<EFBFBD><EFBFBD> kter<EFBFBD> spustil tuto ud<EFBFBD>lost * @param event
* @param regexCommad * ud<EFBFBD>lost PlayerCommandPreprocessEvent
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * @param player
* p<EFBFBD><EFBFBD>kazu * hr<EFBFBD><EFBFBD> kter<EFBFBD> spustil tuto ud<EFBFBD>lost
* @param originalCommand * @param regexCommad
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz kter<EFBFBD> hr<EFBFBD><EFBFBD> pou<EFBFBD>il * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* @param warmupTime * p<EFBFBD><EFBFBD>kazu
* warmup doba nastaven<EFBFBD> pro regexCommand * @param originalCommand
* @param cooldownTime * origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz kter<EFBFBD> hr<EFBFBD><EFBFBD> pou<EFBFBD>il
* cooldown doba nastaven<EFBFBD> pro regexCommand * @param warmupTime
* @param price * warmup doba nastaven<EFBFBD> pro regexCommand
* cena nastaven<EFBFBD> pro regexCommand * @param cooldownTime
* @param limit * cooldown doba nastaven<EFBFBD> pro regexCommand
* limit nastaven<EFBFBD> pro regexCommand * @param price
*/ * cena nastaven<EFBFBD> pro regexCommand
private void checkRestrictions(PlayerCommandPreprocessEvent event, * @param limit
Player player, String regexCommad, String originalCommand, * limit nastaven<EFBFBD> pro regexCommand
int warmupTime, int cooldownTime, double price, String item, */
int count, int limit, int xpPrice) { private void checkRestrictions(PlayerCommandPreprocessEvent event,
boolean blocked = BoosLimitManager.blocked(player, regexCommad, Player player, String regexCommad, String originalCommand,
originalCommand, limit); int warmupTime, int cooldownTime, double price, String item,
if (!blocked) { int count, int limit, int xpPrice) {
if (warmupTime > 0) { boolean blocked = BoosLimitManager.blocked(player, regexCommad,
if (!player.hasPermission("booscooldowns.nowarmup") originalCommand, limit);
&& !player.hasPermission("booscooldowns.nowarmup." if (!blocked) {
+ originalCommand)) { if (warmupTime > 0) {
start(event, player, regexCommad, originalCommand, if (!player.hasPermission("booscooldowns.nowarmup")
warmupTime, cooldownTime); && !player.hasPermission("booscooldowns.nowarmup."
} + originalCommand)) {
} else if (BoosPriceManager.has(player, price) start(event, player, regexCommad, originalCommand,
& BoosItemCostManager.has(player, item, count) warmupTime, cooldownTime);
& BoosXpCostManager.has(player, xpPrice)) { }
if (BoosCoolDownManager.coolDown(player, regexCommad, } else if (BoosPriceManager.has(player, price)
originalCommand, cooldownTime)) { & BoosItemCostManager.has(player, item, count)
event.setCancelled(true); & BoosXpCostManager.has(player, xpPrice)) {
} if (BoosCoolDownManager.coolDown(player, regexCommad,
} originalCommand, cooldownTime)) {
if (BoosPriceManager.has(player, price) event.setCancelled(true);
& BoosItemCostManager.has(player, item, count) }
& BoosXpCostManager.has(player, xpPrice)) { }
if (!event.isCancelled()) { if (BoosPriceManager.has(player, price)
BoosPriceManager.payForCommand(event, player, regexCommad, & BoosItemCostManager.has(player, item, count)
originalCommand, price); & BoosXpCostManager.has(player, xpPrice)) {
} if (!event.isCancelled()) {
if (!event.isCancelled()) { BoosPriceManager.payForCommand(event, player, regexCommad,
BoosItemCostManager.payItemForCommand(event, player, originalCommand, price);
regexCommad, originalCommand, item, count); }
} if (!event.isCancelled()) {
if (!event.isCancelled()) { BoosItemCostManager.payItemForCommand(event, player,
BoosXpCostManager.payXPForCommand(event, player, regexCommad, originalCommand, item, count);
regexCommad, originalCommand, xpPrice); }
} if (!event.isCancelled()) {
} else { BoosXpCostManager.payXPForCommand(event, player,
if (!BoosPriceManager.has(player, price) regexCommad, originalCommand, xpPrice);
& !BoosWarmUpManager.isWarmUpProcess(player, }
regexCommad)) { } else {
String unit; if (!BoosPriceManager.has(player, price)
String msg = ""; & !BoosWarmUpManager.isWarmUpProcess(player,
if (price == 1) { regexCommad)) {
unit = BoosCoolDown.getEconomy().currencyNameSingular(); String unit;
} else { String msg = "";
unit = BoosCoolDown.getEconomy().currencyNamePlural(); if (price == 1) {
} unit = BoosCoolDown.getEconomy().currencyNameSingular();
msg = String.format( } else {
BoosConfigManager.getInsufficientFundsMessage(), unit = BoosCoolDown.getEconomy().currencyNamePlural();
(price + " " + unit), }
BoosCoolDown.getEconomy().format( msg = String.format(
BoosCoolDown.getEconomy() BoosConfigManager.getInsufficientFundsMessage(),
.getBalance(player))); (price + " " + unit),
msg = msg.replaceAll("&command&", originalCommand); BoosCoolDown.getEconomy().format(
boosChat.sendMessageToPlayer(player, msg); BoosCoolDown.getEconomy()
} .getBalance(player)));
if (!BoosItemCostManager.has(player, item, count) msg = msg.replaceAll("&command&", originalCommand);
& !BoosWarmUpManager.isWarmUpProcess(player, boosChat.sendMessageToPlayer(player, msg);
regexCommad)) { }
String msg = ""; if (!BoosItemCostManager.has(player, item, count)
msg = String.format( & !BoosWarmUpManager.isWarmUpProcess(player,
BoosConfigManager.getInsufficientItemsMessage(), regexCommad)) {
(count + " " + item)); String msg = "";
msg = msg.replaceAll("&command&", originalCommand); msg = String.format(
boosChat.sendMessageToPlayer(player, msg); BoosConfigManager.getInsufficientItemsMessage(),
} (count + " " + item));
if (!BoosXpCostManager.has(player, xpPrice) msg = msg.replaceAll("&command&", originalCommand);
& !BoosWarmUpManager.isWarmUpProcess(player, boosChat.sendMessageToPlayer(player, msg);
regexCommad)) { }
String msg = ""; if (!BoosXpCostManager.has(player, xpPrice)
msg = String.format( & !BoosWarmUpManager.isWarmUpProcess(player,
BoosConfigManager.getInsufficientXpMessage(), regexCommad)) {
(xpPrice)); String msg = "";
msg = msg.replaceAll("&command&", originalCommand); msg = String.format(
boosChat.sendMessageToPlayer(player, msg); BoosConfigManager.getInsufficientXpMessage(),
} (xpPrice));
event.setCancelled(true); msg = msg.replaceAll("&command&", originalCommand);
} boosChat.sendMessageToPlayer(player, msg);
if (!event.isCancelled()) { }
String msg = String.format(BoosConfigManager.getMessage( event.setCancelled(true);
regexCommad, player)); }
if (!msg.equals("")) { if (!event.isCancelled()) {
boosChat.sendMessageToPlayer(player, msg); String msg = String.format(BoosConfigManager.getMessage(
} regexCommad, player));
} if (!msg.equals("")) {
} else { boosChat.sendMessageToPlayer(player, msg);
event.setCancelled(true); }
String msg = String.format(BoosConfigManager }
.getCommandBlockedMessage()); } else {
boosChat.sendMessageToPlayer(player, msg); event.setCancelled(true);
} }
if (!event.isCancelled()) { if (!event.isCancelled()) {
BoosLimitManager.setUses(player, regexCommad, originalCommand); BoosLimitManager.setUses(player, regexCommad);
if (BoosConfigManager.getCommandLogging()) { if (BoosConfigManager.getCommandLogging()) {
BoosCoolDown.commandLogger(player.getName(), originalCommand); BoosCoolDown.commandLogger(player.getName(), originalCommand);
} }
} }
} }
/** /**
* Poslucha<EFBFBD>, kter<EFBFBD> naslouch<EFBFBD> ud<EFBFBD>losti pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kazu a spou<EFBFBD>t<EFBFBD> se je<EFBFBD>t<EFBFBD> * Poslucha<EFBFBD>, kter<EFBFBD> naslouch<EFBFBD> ud<EFBFBD>losti pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kazu a spou<EFBFBD>t<EFBFBD> se je<EFBFBD>t<EFBFBD>
* p<EFBFBD>ed t<EFBFBD>m, ne<EFBFBD> je vykon<EFBFBD>n efekt tohto p<EFBFBD><EFBFBD>kazu. Metoda zji<EFBFBD><EFBFBD>uje, jestli * p<EFBFBD>ed t<EFBFBD>m, ne<EFBFBD> je vykon<EFBFBD>n efekt tohto p<EFBFBD><EFBFBD>kazu. Metoda zji<EFBFBD><EFBFBD>uje, jestli
* p<EFBFBD><EFBFBD>kaz nen<EFBFBD> alias jin<EFBFBD>ho p<EFBFBD><EFBFBD>kazu a tak<EFBFBD> jestli se p<EFBFBD><EFBFBD>kaz kter<EFBFBD> hr<EFBFBD><EFBFBD> * p<EFBFBD><EFBFBD>kaz nen<EFBFBD> alias jin<EFBFBD>ho p<EFBFBD><EFBFBD>kazu a tak<EFBFBD> jestli se p<EFBFBD><EFBFBD>kaz kter<EFBFBD> hr<EFBFBD><EFBFBD>
* pou<EFBFBD>il shoduje s p<EFBFBD><EFBFBD>kazem nastaven<EFBFBD>m v konfiguraci. Pokud se shoduje, pak * pou<EFBFBD>il shoduje s p<EFBFBD><EFBFBD>kazem nastaven<EFBFBD>m v konfiguraci. Pokud se shoduje, pak
* jsou na<EFBFBD>teny informace o warmup dob<EFBFBD>, cooldown dob<EFBFBD>, poplatku a limitu. * jsou na<EFBFBD>teny informace o warmup dob<EFBFBD>, cooldown dob<EFBFBD>, poplatku a limitu.
* Tyto hodnoty jsou pot<EFBFBD> p<EFBFBD>ed<EFBFBD>ny metod<EFBFBD> checkRestrictions();. * Tyto hodnoty jsou pot<EFBFBD> p<EFBFBD>ed<EFBFBD>ny metod<EFBFBD> checkRestrictions();.
* *
* @param event * @param event
* ud<EFBFBD>lost PlayerCommandPreprocessEvent * ud<EFBFBD>lost PlayerCommandPreprocessEvent
*/ */
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
private void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { private void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer(); Player player = event.getPlayer();
String originalCommand = event.getMessage().replace("\\", "\\\\"); if (event.getMessage().contains(":")) {
originalCommand = originalCommand.replace("$", "S"); Pattern p = Pattern.compile("^/([a-zA-Z0-9_]+):");
originalCommand = originalCommand.trim().replaceAll(" +", " "); Matcher m = p.matcher(event.getMessage());
String regexCommad = ""; if (m.find()) {
Set<String> aliases = null; {
try { boosChat.sendMessageToPlayer(player, BoosConfigManager
aliases = BoosConfigManager.getAliases(); .getInvalidCommandSyntaxMessage(player));
} catch (Exception e1) { event.setCancelled(true);
BoosCoolDown return;
.getLog() }
.warning( }
"Aliases section in config.yml is missing! Please delete your config.yml, restart server and set it again!"); }
} String originalCommand = event.getMessage().replace("\\", "\\\\");
Set<String> commands = BoosConfigManager.getCommands(player); originalCommand = originalCommand.replace("$", "S");
boolean on = true; originalCommand = originalCommand.trim().replaceAll(" +", " ");
String item = ""; String regexCommad = "";
int count = 0; Set<String> aliases = null;
int warmupTime = 0; try {
double price = 0; aliases = BoosConfigManager.getAliases();
int limit = -1; } catch (Exception e1) {
int cooldownTime = 0; BoosCoolDown
int xpPrice = 0; .getLog()
on = BoosCoolDown.isPluginOnForPlayer(player); .warning(
try { "Aliases section in config.yml is missing! Please delete your config.yml, restart server and set it again!");
if (aliases.contains(originalCommand)) { }
originalCommand = BoosConfigManager.getAlias(originalCommand); Set<String> commands = BoosConfigManager.getCommands(player);
if (originalCommand.contains("$player")) { boolean on = true;
originalCommand.replaceAll("$player", player.getName()); String item = "";
} int count = 0;
if (originalCommand.contains("$world")) { int warmupTime = 0;
originalCommand.replaceAll("$world", player.getWorld() double price = 0;
.getName()); int limit = -1;
} int cooldownTime = 0;
event.setMessage(originalCommand); int xpPrice = 0;
} on = BoosCoolDown.isPluginOnForPlayer(player);
} catch (Exception e) { originalCommand = BoosAliasManager.checkCommandAlias(originalCommand,
BoosCoolDown aliases, player);
.getLog() event.setMessage(originalCommand);
.warning( if (on) {
"Aliases section in config.yml is missing! Please delete your config.yml, restart server and set it again!"); for (String group : commands) {
} String group2 = group.replace("*", ".+");
if (on) { if (originalCommand.matches("(?i)" + group2)) {
for (String group : commands) { regexCommad = group;
String group2 = group.replace("*", ".+"); if (BoosConfigManager.getWarmupEnabled()) {
if (originalCommand.matches("(?i)"+group2)) { warmupTime = BoosConfigManager.getWarmUp(regexCommad,
regexCommad = group; player);
if (BoosConfigManager.getWarmupEnabled()) { }
warmupTime = BoosConfigManager.getWarmUp(regexCommad, if (BoosConfigManager.getCooldownEnabled()) {
player); cooldownTime = BoosConfigManager.getCoolDown(
} regexCommad, player);
if (BoosConfigManager.getCooldownEnabled()) { }
cooldownTime = BoosConfigManager.getCoolDown( if (BoosConfigManager.getPriceEnabled()) {
regexCommad, player); price = BoosConfigManager.getPrice(regexCommad, player);
} }
if (BoosConfigManager.getPriceEnabled()) { if (BoosConfigManager.getXpPriceEnabled()) {
price = BoosConfigManager.getPrice(regexCommad, player); xpPrice = BoosConfigManager.getXpPrice(regexCommad,
} player);
if (BoosConfigManager.getXpPriceEnabled()) { }
xpPrice = BoosConfigManager.getXpPrice(regexCommad, if (BoosConfigManager.getItemCostEnabled()) {
player); item = BoosConfigManager.getItemCostItem(regexCommad,
} player);
if (BoosConfigManager.getItemCostEnabled()) { count = BoosConfigManager.getItemCostCount(regexCommad,
item = BoosConfigManager.getItemCostItem(regexCommad, player);
player); }
count = BoosConfigManager.getItemCostCount(regexCommad, if (BoosConfigManager.getLimitEnabled()) {
player); limit = BoosConfigManager.getLimit(regexCommad, player);
} }
if (BoosConfigManager.getLimitEnabled()) { break;
limit = BoosConfigManager.getLimit(regexCommad, player); }
} }
break; this.checkRestrictions(event, player, regexCommad, originalCommand,
} warmupTime, cooldownTime, price, item, count, limit,
} xpPrice);
try { try {
this.checkRestrictions(event, player, regexCommad, originalCommand, } catch (Exception e) {
warmupTime, cooldownTime, price, item, count, limit, BoosCoolDown
xpPrice); .getLog()
} catch (Exception e) { .warning(
BoosCoolDown.getLog().warning("[boosCooldowns] Looks like you have deleted some important part of config file (like default group or aliases section. To get rid of this message, you have to restore it."); "[boosCooldowns] Looks like you have deleted some important part of config file (like default group or aliases section. To get rid of this message, you have to restore it.");
return; return;
} }
} }
} }
/** /**
* Metoda spou<EFBFBD>t<EFBFBD> warmup a cooldown <EFBFBD>asova<EFBFBD>e, p<EFBFBD><EFBFBD>padn<EFBFBD> je ukon<EFBFBD>uje, pokud * Metoda spou<EFBFBD>t<EFBFBD> warmup a cooldown <EFBFBD>asova<EFBFBD>e, p<EFBFBD><EFBFBD>padn<EFBFBD> je ukon<EFBFBD>uje, pokud
* ji<EFBFBD> tyto <EFBFBD>asova<EFBFBD>e skon<EFBFBD>ili. * ji<EFBFBD> tyto <EFBFBD>asova<EFBFBD>e skon<EFBFBD>ili.
* *
* @param event * @param event
* ud<EFBFBD>lost PlayerCommandPreprocessEvent * ud<EFBFBD>lost PlayerCommandPreprocessEvent
* @param player * @param player
* hr<EFBFBD><EFBFBD> kter<EFBFBD> spustil tuto ud<EFBFBD>lost * hr<EFBFBD><EFBFBD> kter<EFBFBD> spustil tuto ud<EFBFBD>lost
* @param regexCommad * @param regexCommad
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kazu
* @param originalCommand * @param originalCommand
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz kter<EFBFBD> hr<EFBFBD><EFBFBD> pou<EFBFBD>il * origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz kter<EFBFBD> hr<EFBFBD><EFBFBD> pou<EFBFBD>il
* @param warmupTime * @param warmupTime
* warmup doba nastaven<EFBFBD> pro regexCommand * warmup doba nastaven<EFBFBD> pro regexCommand
* @param cooldownTime * @param cooldownTime
* cooldown doba nastaven<EFBFBD> pro regexCommand * cooldown doba nastaven<EFBFBD> pro regexCommand
*/ */
private void start(PlayerCommandPreprocessEvent event, Player player, private void start(PlayerCommandPreprocessEvent event, Player player,
String regexCommad, String originalCommand, int warmupTime, String regexCommad, String originalCommand, int warmupTime,
int cooldownTime) { int cooldownTime) {
if (!BoosWarmUpManager.checkWarmUpOK(player, regexCommad)) { if (!BoosWarmUpManager.checkWarmUpOK(player, regexCommad)) {
if (BoosCoolDownManager.checkCoolDownOK(player, regexCommad, if (BoosCoolDownManager.checkCoolDownOK(player, regexCommad,
originalCommand, cooldownTime)) { originalCommand, cooldownTime)) {
BoosWarmUpManager.startWarmUp(plugin, player, regexCommad, BoosWarmUpManager.startWarmUp(plugin, player, regexCommad,
originalCommand, warmupTime); originalCommand, warmupTime);
event.setCancelled(true); event.setCancelled(true);
return; return;
} else { } else {
event.setCancelled(true); event.setCancelled(true);
return; return;
} }
} else { } else {
if (BoosCoolDownManager.coolDown(player, regexCommad, if (BoosCoolDownManager.coolDown(player, regexCommad,
originalCommand, cooldownTime)) { originalCommand, cooldownTime)) {
event.setCancelled(true); event.setCancelled(true);
return; return;
} else { } else {
BoosWarmUpManager.removeWarmUpOK(player, regexCommad); BoosWarmUpManager.removeWarmUpOK(player, regexCommad);
return; return;
} }
} }
} }
} }

View File

@ -1,304 +1,300 @@
package cz.boosik.boosCooldown; package cz.boosik.boosCooldown;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import util.boosChat; import util.boosChat;
/** /**
* T<EFBFBD><EFBFBD>da obsahuje ve<EFBFBD>ker<EFBFBD> metody pot<EFBFBD>ebn<EFBFBD> k <EFBFBD><EFBFBD>zen<EFBFBD> cooldown <EFBFBD>asova<EFBFBD><EFBFBD>. Spou<EFBFBD>t<EFBFBD>n<EFBFBD>, * T<EFBFBD><EFBFBD>da obsahuje ve<EFBFBD>ker<EFBFBD> metody pot<EFBFBD>ebn<EFBFBD> k <EFBFBD><EFBFBD>zen<EFBFBD> cooldown <EFBFBD>asova<EFBFBD><EFBFBD>. Spou<EFBFBD>t<EFBFBD>n<EFBFBD>,
* ukon<EFBFBD>ov<EFBFBD>n<EFBFBD>, zji<EFBFBD><EFBFBD>ov<EFBFBD>n<EFBFBD> zda je cooldown <EFBFBD>asova<EFBFBD> ji<EFBFBD> aktivn<EFBFBD>. * ukon<EFBFBD>ov<EFBFBD>n<EFBFBD>, zji<EFBFBD><EFBFBD>ov<EFBFBD>n<EFBFBD> zda je cooldown <EFBFBD>asova<EFBFBD> ji<EFBFBD> aktivn<EFBFBD>.
* *
* @author Jakub Kol<EFBFBD><EFBFBD> * @author Jakub Kol<EFBFBD><EFBFBD>
* *
*/ */
public class BoosCoolDownManager { public class BoosCoolDownManager {
/** /**
* Metoda ukon<EFBFBD>uje specifikovan<EFBFBD> cooldown <EFBFBD>asova<EFBFBD> pro specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e. * Metoda ukon<EFBFBD>uje specifikovan<EFBFBD> cooldown <EFBFBD>asova<EFBFBD> pro specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e.
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu
*/ */
static void cancelCooldown(Player player, String regexCommand) { static void cancelCooldown(Player player, String regexCommand) {
int pre2 = regexCommand.toLowerCase().hashCode(); int pre2 = regexCommand.toLowerCase().hashCode();
BoosConfigManager.getConfusers().set( BoosConfigManager.getConfusers().set(
"users." + player.getUniqueId() + ".cooldown." + pre2, null); "users." + player.getUniqueId() + ".cooldown." + pre2, null);
} }
/** /**
* Metoda vrac<EFBFBD> hodnotu boolean na z<EFBFBD>klad<EFBFBD> toho, jestli m<EFBFBD> specifikovan<EFBFBD> * Metoda vrac<EFBFBD> hodnotu boolean na z<EFBFBD>klad<EFBFBD> toho, jestli m<EFBFBD> specifikovan<EFBFBD>
* p<EFBFBD><EFBFBD>kaz aktivn<EFBFBD> cooldown <EFBFBD>asova<EFBFBD>. * p<EFBFBD><EFBFBD>kaz aktivn<EFBFBD> cooldown <EFBFBD>asova<EFBFBD>.
* *
* @param player * @param player
* specifikovan<EFBFBD> hr<EFBFBD><EFBFBD> * specifikovan<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu
* @param originalCommand * @param originalCommand
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em * origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em
* @param coolDownSeconds * @param coolDownSeconds
* cooldown doba v sekund<EFBFBD>ch, nastaven<EFBFBD> pro regexCommand v * cooldown doba v sekund<EFBFBD>ch, nastaven<EFBFBD> pro regexCommand v
* konfiguraci * konfiguraci
* @return true pokud je p<EFBFBD><EFBFBD>kaz na cooldown <EFBFBD>asova<EFBFBD>i, jinak false * @return true pokud je p<EFBFBD><EFBFBD>kaz na cooldown <EFBFBD>asova<EFBFBD>i, jinak false
*/ */
static boolean cd(Player player, String regexCommand, static boolean cd(Player player, String regexCommand,
String originalCommand, int coolDownSeconds) { String originalCommand, int coolDownSeconds) {
Date lastTime = getTime(player, regexCommand); Date lastTime = getTime(player, regexCommand);
String link = BoosConfigManager.getLink(regexCommand); List<String> linkGroup = BoosConfigManager.getSharedCooldowns(
if (lastTime == null) { regexCommand, player);
if (link == null) { if (lastTime == null) {
setTime(player, regexCommand); if (linkGroup.isEmpty()) {
} else { setTime(player, regexCommand);
List<String> linkGroup = BoosConfigManager.getLinkList(link); } else {
for (String a : linkGroup) { setTime(player, regexCommand);
setTime(player, a); for (String a : linkGroup) {
} setTime(player, a);
} }
return false; }
} else { return false;
Calendar calcurrTime = Calendar.getInstance(); } else {
calcurrTime.setTime(getCurrTime()); Calendar calcurrTime = Calendar.getInstance();
Calendar callastTime = Calendar.getInstance(); calcurrTime.setTime(getCurrTime());
callastTime.setTime(lastTime); Calendar callastTime = Calendar.getInstance();
long secondsBetween = secondsBetween(callastTime, calcurrTime); callastTime.setTime(lastTime);
long waitSeconds = coolDownSeconds - secondsBetween; long secondsBetween = secondsBetween(callastTime, calcurrTime);
long waitMinutes = Math.round(waitSeconds / 60) + 1; long waitSeconds = coolDownSeconds - secondsBetween;
long waitHours = Math.round(waitMinutes / 60) + 1; long waitMinutes = (long) Math.ceil(waitSeconds / 60.0);
if (secondsBetween > coolDownSeconds) { long waitHours = (long) Math.ceil(waitMinutes / 60.0);
if (link == null) { if (secondsBetween > coolDownSeconds) {
setTime(player, regexCommand); if (linkGroup.isEmpty()) {
} else { setTime(player, regexCommand);
List<String> linkGroup = BoosConfigManager } else {
.getLinkList(link); setTime(player, regexCommand);
for (String a : linkGroup) { for (String a : linkGroup) {
setTime(player, a); setTime(player, a);
} }
} }
return false; return false;
} else { } else {
String msg = BoosConfigManager.getCoolDownMessage(); String msg = BoosConfigManager.getCoolDownMessage();
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
if (waitSeconds >= 60 && 3600 >= waitSeconds) { if (waitSeconds >= 60 && 3600 >= waitSeconds) {
msg = msg.replaceAll("&seconds&", msg = msg.replaceAll("&seconds&",
Long.toString(waitMinutes)); Long.toString(waitMinutes));
msg = msg.replaceAll("&unit&", msg = msg.replaceAll("&unit&",
BoosConfigManager.getUnitMinutesMessage()); BoosConfigManager.getUnitMinutesMessage());
} else if (waitMinutes >= 60) { } else if (waitMinutes >= 60) {
msg = msg.replaceAll("&seconds&", Long.toString(waitHours)); msg = msg.replaceAll("&seconds&", Long.toString(waitHours));
msg = msg.replaceAll("&unit&", msg = msg.replaceAll("&unit&",
BoosConfigManager.getUnitHoursMessage()); BoosConfigManager.getUnitHoursMessage());
} else { } else {
String secs = Long.toString(waitSeconds); String secs = Long.toString(waitSeconds);
if (secs.equals("0")) { if (secs.equals("0")) {
secs = "1"; secs = "1";
} }
msg = msg.replaceAll("&seconds&", secs); msg = msg.replaceAll("&seconds&", secs);
msg = msg.replaceAll("&unit&", msg = msg.replaceAll("&unit&",
BoosConfigManager.getUnitSecondsMessage()); BoosConfigManager.getUnitSecondsMessage());
} }
boosChat.sendMessageToPlayer(player, msg); boosChat.sendMessageToPlayer(player, msg);
return true; return true;
} }
} }
} }
/** /**
* Metoda kontroluje, jestli hr<EFBFBD><EFBFBD> nedisponuje opr<EFBFBD>vn<EFBFBD>n<EFBFBD>mi, kter<EFBFBD> obch<EFBFBD>zej<EFBFBD> * Metoda kontroluje, jestli hr<EFBFBD><EFBFBD> nedisponuje opr<EFBFBD>vn<EFBFBD>n<EFBFBD>mi, kter<EFBFBD> obch<EFBFBD>zej<EFBFBD>
* cooldown <EFBFBD>asova<EFBFBD>e. Pokud t<EFBFBD>mito opr<EFBFBD>vn<EFBFBD>n<EFBFBD>mi hr<EFBFBD><EFBFBD> disponuje, pak metoda * cooldown <EFBFBD>asova<EFBFBD>e. Pokud t<EFBFBD>mito opr<EFBFBD>vn<EFBFBD>n<EFBFBD>mi hr<EFBFBD><EFBFBD> disponuje, pak metoda
* vrac<EFBFBD> false. Pokud hr<EFBFBD><EFBFBD> nedisponuje t<EFBFBD>mito opr<EFBFBD>vn<EFBFBD>n<EFBFBD>mi, vrac<EFBFBD> hodnotu * vrac<EFBFBD> false. Pokud hr<EFBFBD><EFBFBD> nedisponuje t<EFBFBD>mito opr<EFBFBD>vn<EFBFBD>n<EFBFBD>mi, vrac<EFBFBD> hodnotu
* vr<EFBFBD>cenou metodou cd();. * vr<EFBFBD>cenou metodou cd();.
* *
* @param player * @param player
* specifikovan<EFBFBD> hr<EFBFBD><EFBFBD> * specifikovan<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu
* @param originalCommand * @param originalCommand
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em * origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em
* @param time * @param time
* cooldown doba v sekund<EFBFBD>ch, nastaven<EFBFBD> pro regexCommand v * cooldown doba v sekund<EFBFBD>ch, nastaven<EFBFBD> pro regexCommand v
* konfiguraci * konfiguraci
* @return false pokud hr<EFBFBD><EFBFBD> disponuje opr<EFBFBD>vn<EFBFBD>n<EFBFBD>mi, jinak hodnotu vr<EFBFBD>cenou * @return false pokud hr<EFBFBD><EFBFBD> disponuje opr<EFBFBD>vn<EFBFBD>n<EFBFBD>mi, jinak hodnotu vr<EFBFBD>cenou
* metodou cd();. * metodou cd();.
*/ */
static boolean coolDown(Player player, String regexCommand, static boolean coolDown(Player player, String regexCommand,
String originalCommand, int time) { String originalCommand, int time) {
regexCommand = regexCommand.toLowerCase(); regexCommand = regexCommand.toLowerCase();
if (time > 0 if (time > 0
&& !player.hasPermission("booscooldowns.nocooldown") && !player.hasPermission("booscooldowns.nocooldown")
&& !player.hasPermission("booscooldowns.nocooldown." && !player.hasPermission("booscooldowns.nocooldown."
+ originalCommand)) { + originalCommand)) {
return cd(player, regexCommand, originalCommand, time); return cd(player, regexCommand, originalCommand, time);
} }
return false; return false;
} }
/** /**
* Metoda vrac<EFBFBD> sou<EFBFBD>asn<EFBFBD> p<EFBFBD>esn<EFBFBD> datum a <EFBFBD>as. * Metoda vrac<EFBFBD> sou<EFBFBD>asn<EFBFBD> p<EFBFBD>esn<EFBFBD> datum a <EFBFBD>as.
* *
* @return sou<EFBFBD>asn<EFBFBD> <EFBFBD>as a datum * @return sou<EFBFBD>asn<EFBFBD> <EFBFBD>as a datum
*/ */
static Date getCurrTime() { static Date getCurrTime() {
String currTime = ""; String currTime = "";
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
currTime = sdf.format(cal.getTime()); currTime = sdf.format(cal.getTime());
Date time = null; Date time = null;
try { try {
time = sdf.parse(currTime); time = sdf.parse(currTime);
return time; return time;
} catch (ParseException e) { } catch (ParseException e) {
return null; return null;
} }
} }
/** /**
* Metoda vrac<EFBFBD> datum a <EFBFBD>as, kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD> p<EFBFBD><EFBFBD>kaz. * Metoda vrac<EFBFBD> datum a <EFBFBD>as, kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD> p<EFBFBD><EFBFBD>kaz.
* *
* @param player * @param player
* specifikovan<EFBFBD> hr<EFBFBD><EFBFBD> * specifikovan<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu
* @return datum a <EFBFBD>as kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD> p<EFBFBD><EFBFBD>kaz * @return datum a <EFBFBD>as kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD> p<EFBFBD><EFBFBD>kaz
*/ */
static Date getTime(Player player, String regexCommand) { static Date getTime(Player player, String regexCommand) {
int pre2 = regexCommand.toLowerCase().hashCode(); int pre2 = regexCommand.toLowerCase().hashCode();
String confTime = ""; String confTime = "";
confTime = BoosConfigManager.getConfusers().getString( confTime = BoosConfigManager.getConfusers().getString(
"users." + player.getName().toLowerCase().hashCode() "users." + player.getUniqueId() + ".cooldown." + pre2, null);
+ ".cooldown." + pre2, null);
if (confTime != null && !confTime.equals("")) {
if (confTime != null && !confTime.equals("")) { SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); Date lastDate = null;
Date lastDate = null;
try {
try { lastDate = sdf.parse(confTime);
lastDate = sdf.parse(confTime); return lastDate;
return lastDate; } catch (ParseException e) {
} catch (ParseException e) { return null;
return null; }
} }
} return null;
return null; }
}
/**
/** * Metoda vrac<EFBFBD> hodnotu boolean na z<EFBFBD>klad<EFBFBD> toho, jestli m<EFBFBD> specifikovan<EFBFBD>
* Metoda vrac<EFBFBD> hodnotu boolean na z<EFBFBD>klad<EFBFBD> toho, jestli m<EFBFBD> specifikovan<EFBFBD> * p<EFBFBD><EFBFBD>kaz aktivn<EFBFBD> cooldown <EFBFBD>asova<EFBFBD>.
* p<EFBFBD><EFBFBD>kaz aktivn<EFBFBD> cooldown <EFBFBD>asova<EFBFBD>. *
* * @param player
* @param player * specifikovan<EFBFBD> hr<EFBFBD><EFBFBD>
* specifikovan<EFBFBD> hr<EFBFBD><EFBFBD> * @param regexCommand
* @param regexCommand * p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu
* p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu * @param originalCommand
* @param originalCommand * origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em * @param time
* @param time * cooldown doba v sekund<EFBFBD>ch, nastaven<EFBFBD> pro regexCommand v
* cooldown doba v sekund<EFBFBD>ch, nastaven<EFBFBD> pro regexCommand v * konfiguraci
* konfiguraci * @return false pokud m<EFBFBD> p<EFBFBD><EFBFBD>kaz aktivn<EFBFBD> cooldown <EFBFBD>asova<EFBFBD>, jinak false
* @return false pokud m<EFBFBD> p<EFBFBD><EFBFBD>kaz aktivn<EFBFBD> cooldown <EFBFBD>asova<EFBFBD>, jinak false */
*/ static boolean checkCoolDownOK(Player player, String regexCommand,
static boolean checkCoolDownOK(Player player, String regexCommand, String originalCommand, int time) {
String originalCommand, int time) { regexCommand = regexCommand.toLowerCase();
regexCommand = regexCommand.toLowerCase(); if (time > 0) {
if (time > 0) { Date lastTime = getTime(player, regexCommand);
Date lastTime = getTime(player, regexCommand); if (lastTime == null) {
if (lastTime == null) { return true;
return true; } else {
} else { Calendar calcurrTime = Calendar.getInstance();
Calendar calcurrTime = Calendar.getInstance(); calcurrTime.setTime(getCurrTime());
calcurrTime.setTime(getCurrTime()); Calendar callastTime = Calendar.getInstance();
Calendar callastTime = Calendar.getInstance(); callastTime.setTime(lastTime);
callastTime.setTime(lastTime); long secondsBetween = secondsBetween(callastTime, calcurrTime);
long secondsBetween = secondsBetween(callastTime, calcurrTime); long waitSeconds = time - secondsBetween;
long waitSeconds = time - secondsBetween; long waitMinutes = (long) Math.ceil(waitSeconds / 60.0);
long waitMinutes = Math.round(waitSeconds / 60) + 1; long waitHours = (long) Math.ceil(waitMinutes / 60.0);
long waitHours = Math.round(waitMinutes / 60) + 1; if (secondsBetween > time) {
if (secondsBetween > time) { return true;
return true; } else {
} else { String msg = BoosConfigManager.getCoolDownMessage();
String msg = BoosConfigManager.getCoolDownMessage(); msg = msg.replaceAll("&command&", originalCommand);
msg = msg.replaceAll("&command&", originalCommand); if (waitSeconds >= 60 && 3600 >= waitSeconds) {
if (waitSeconds >= 60 && 3600 >= waitSeconds) { msg = msg.replaceAll("&seconds&",
msg = msg.replaceAll("&seconds&", Long.toString(waitMinutes));
Long.toString(waitMinutes)); msg = msg.replaceAll("&unit&",
msg = msg.replaceAll("&unit&", BoosConfigManager.getUnitMinutesMessage());
BoosConfigManager.getUnitMinutesMessage()); } else if (waitMinutes >= 60) {
} else if (waitMinutes >= 60) { msg = msg.replaceAll("&seconds&",
msg = msg.replaceAll("&seconds&", Long.toString(waitHours));
Long.toString(waitHours)); msg = msg.replaceAll("&unit&",
msg = msg.replaceAll("&unit&", BoosConfigManager.getUnitHoursMessage());
BoosConfigManager.getUnitHoursMessage()); } else {
} else { msg = msg.replaceAll("&seconds&",
msg = msg.replaceAll("&seconds&", Long.toString(waitSeconds));
Long.toString(waitSeconds)); msg = msg.replaceAll("&unit&",
msg = msg.replaceAll("&unit&", BoosConfigManager.getUnitSecondsMessage());
BoosConfigManager.getUnitSecondsMessage()); }
} boosChat.sendMessageToPlayer(player, msg);
boosChat.sendMessageToPlayer(player, msg); return false;
return false; }
} }
} }
} return true;
return true; }
}
/**
/** * Metoda vrac<EFBFBD> hodnotu rozd<EFBFBD>lu v sekund<EFBFBD>ch mezi dv<EFBFBD>mi hodnotami datumu a
* Metoda vrac<EFBFBD> hodnotu rozd<EFBFBD>lu v sekund<EFBFBD>ch mezi dv<EFBFBD>mi hodnotami datumu a * <EFBFBD>asu.
* <EFBFBD>asu. *
* * @param startDate
* @param startDate * @param endDate
* @param endDate * @return rozd<EFBFBD>l v sekund<EFBFBD>ch mezi startDate a endDate
* @return rozd<EFBFBD>l v sekund<EFBFBD>ch mezi startDate a endDate */
*/ static long secondsBetween(Calendar startDate, Calendar endDate) {
static long secondsBetween(Calendar startDate, Calendar endDate) { long secondsBetween = 0;
long secondsBetween = 0; secondsBetween = (endDate.getTimeInMillis() - startDate
.getTimeInMillis()) / 1000;
while (startDate.before(endDate)) { return secondsBetween;
startDate.add(Calendar.SECOND, 1); }
secondsBetween++;
} /**
return secondsBetween; * Metoda ukl<EFBFBD>d<EFBFBD> do datab<EFBFBD>ze datum a <EFBFBD>as kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD>
} * p<EFBFBD><EFBFBD>kaz.
*
/** * @param player
* Metoda ukl<EFBFBD>d<EFBFBD> do datab<EFBFBD>ze datum a <EFBFBD>as kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* p<EFBFBD><EFBFBD>kaz. * @param regexCommand
* * p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu
* @param player */
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> static void setTime(Player player, String regexCommand) {
* @param regexCommand int pre2 = regexCommand.toLowerCase().hashCode();
* p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu String currTime = "";
*/ Calendar cal = Calendar.getInstance();
static void setTime(Player player, String regexCommand) { SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
int pre2 = regexCommand.toLowerCase().hashCode(); currTime = sdf.format(cal.getTime());
String currTime = ""; BoosConfigManager.getConfusers()
Calendar cal = Calendar.getInstance(); .set("users." + player.getUniqueId() + ".cooldown." + pre2,
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss"); currTime);
currTime = sdf.format(cal.getTime()); }
BoosConfigManager.getConfusers().set(
"users." + player.getName().toLowerCase().hashCode() /**
+ ".cooldown." + pre2, currTime); * Metoda spou<EFBFBD>t<EFBFBD> ve<EFBFBD>ker<EFBFBD> cooldown <EFBFBD>asova<EFBFBD>e pro specifick<EFBFBD>ho hr<EFBFBD><EFBFBD>e.
} *
* @param player
/** * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* Metoda spou<EFBFBD>t<EFBFBD> ve<EFBFBD>ker<EFBFBD> cooldown <EFBFBD>asova<EFBFBD>e pro specifick<EFBFBD>ho hr<EFBFBD><EFBFBD>e. * @param message
* */
* @param player public static void startAllCooldowns(Player player, String message) {
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> for (String a : BoosConfigManager.getCooldowns(player)) {
* @param message int cooldownTime = BoosConfigManager.getCoolDown(a, player);
*/ coolDown(player, a, message, cooldownTime);
public static void startAllCooldowns(Player player, String message) { }
for (String a : BoosConfigManager.getCooldowns(player)) {
int cooldownTime = BoosConfigManager.getCoolDown(a, player); }
coolDown(player, a, message, cooldownTime);
} }
}
}

View File

@ -1,132 +1,362 @@
package cz.boosik.boosCooldown; package cz.boosik.boosCooldown;
import org.bukkit.entity.Player; import java.text.ParseException;
import java.text.SimpleDateFormat;
import util.boosChat; import java.util.Calendar;
import java.util.Date;
/** import java.util.Set;
* T<EFBFBD><EFBFBD>da obsahuje ve<EFBFBD>ker<EFBFBD> metody pot<EFBFBD>ebn<EFBFBD> k <EFBFBD><EFBFBD>zen<EFBFBD> limit<EFBFBD>. import org.bukkit.entity.Player;
*
* @author Jakub Kol<EFBFBD><EFBFBD> import util.boosChat;
*
*/ /**
public class BoosLimitManager { * T<EFBFBD><EFBFBD>da obsahuje ve<EFBFBD>ker<EFBFBD> metody pot<EFBFBD>ebn<EFBFBD> k <EFBFBD><EFBFBD>zen<EFBFBD> limit<EFBFBD>.
/** *
* Metoda kontroluje zda je mo<EFBFBD>n<EFBFBD> pou<EFBFBD><EFBFBD>t p<EFBFBD><EFBFBD>kaz, nebo zda je p<EFBFBD><EFBFBD>kaz ji<EFBFBD> * @author Jakub Kol<EFBFBD><EFBFBD>
* zablokovan<EFBFBD>. *
* */
* @param player public class BoosLimitManager {
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> /**
* @param regexCommand * Metoda kontroluje zda je mo<EFBFBD>n<EFBFBD> pou<EFBFBD><EFBFBD>t p<EFBFBD><EFBFBD>kaz, nebo zda je p<EFBFBD><EFBFBD>kaz ji<EFBFBD>
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * zablokovan<EFBFBD>.
* p<EFBFBD><EFBFBD>kazu *
* @param originalCommand * @param player
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param limit * @param regexCommand
* limit nastaven<EFBFBD> pro regexCommand * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* @return false pokud p<EFBFBD><EFBFBD>kaz je mo<EFBFBD>n<EFBFBD> pou<EFBFBD><EFBFBD>t, true pokud p<EFBFBD><EFBFBD>kaz nen<EFBFBD> mo<EFBFBD>n<EFBFBD> * p<EFBFBD><EFBFBD>kazu
* pou<EFBFBD><EFBFBD>t * @param originalCommand
*/ * origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em
static boolean blocked(Player player, String regexCommand, * @param limit
String originalCommand, int limit) { * limit nastaven<EFBFBD> pro regexCommand
int uses = getUses(player, regexCommand); * @return false pokud p<EFBFBD><EFBFBD>kaz je mo<EFBFBD>n<EFBFBD> pou<EFBFBD><EFBFBD>t, true pokud p<EFBFBD><EFBFBD>kaz nen<EFBFBD> mo<EFBFBD>n<EFBFBD>
if (player.hasPermission("booscooldowns.nolimit") * pou<EFBFBD><EFBFBD>t
|| player.hasPermission("booscooldowns.nolimit." */
+ originalCommand)) { static boolean blocked(Player player, String regexCommand,
} else { String originalCommand, int limit) {
if (limit == -1) { Date time = getTime(player, regexCommand);
return false; Date confTime = getTime(regexCommand);
} else if (limit <= uses) { Calendar calcurrTime = Calendar.getInstance();
return true; calcurrTime.setTime(getCurrTime());
} Calendar callastTime = Calendar.getInstance();
} Calendar callastTimeGlobal = Calendar.getInstance();
return false; int uses = getUses(player, regexCommand);
} long limitResetDelay = BoosConfigManager.getLimitResetDelay(
regexCommand, player);
/** long limitResetDelayGlobal = BoosConfigManager
* Metoda vrac<EFBFBD> hodnotu, kter<EFBFBD> je ur<EFBFBD>ena t<EFBFBD>m, kolikr<EFBFBD>t ji<EFBFBD> hr<EFBFBD><EFBFBD> pou<EFBFBD>il .getLimitResetDelayGlobal(regexCommand);
* specifikovan<EFBFBD> p<EFBFBD><EFBFBD>kaz. if (time != null) {
* callastTime.setTime(time);
* @param player } else {
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> setTime(player, regexCommand);
* @param regexCommand }
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu if (limit - uses == 1) {
* p<EFBFBD><EFBFBD>kazu setTime(player, regexCommand);
* @return hodnota p<EFBFBD>edstavuj<EFBFBD>ci po<EFBFBD>et pou<EFBFBD>it<EFBFBD> specifikovan<EFBFBD>ho p<EFBFBD><EFBFBD>kazu time = getTime(player, regexCommand);
*/ callastTime.setTime(time);
static int getUses(Player player, String regexCommand) { }
int regexCommand2 = regexCommand.toLowerCase().hashCode(); if (limitResetDelay > 0) {
int uses = 0; if (secondsBetween(callastTime, calcurrTime, limitResetDelay) <= 0) {
uses = BoosConfigManager.getConfusers().getInt( if (uses != 0) {
"users." + player.getUniqueId() + ".uses." + regexCommand2, BoosConfigManager.clearSomething("uses",
uses); player.getUniqueId(), regexCommand);
return uses; uses = getUses(player, regexCommand);
} }
}
/** }
* Metoda nastavuje po<EFBFBD>et pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kazu o jedna v<EFBFBD>t<EFBFBD><EFBFBD> po ka<EFBFBD>d<EFBFBD>m pou<EFBFBD>it<EFBFBD>
* p<EFBFBD><EFBFBD>kazu hr<EFBFBD><EFBFBD>em. Nasteven<EFBFBD> hodnoty prob<EFBFBD>h<EFBFBD> jen pro p<EFBFBD><EFBFBD>kazy, kter<EFBFBD> jsou if (player.hasPermission("booscooldowns.nolimit")
* definov<EFBFBD>ny v konfiguraci. || player.hasPermission("booscooldowns.nolimit."
* + originalCommand)) {
* @param player } else {
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> if (limit == -1) {
* @param regexCommand return false;
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu } else if (limit <= uses) {
* p<EFBFBD><EFBFBD>kazu if (limitResetDelay > 0) {
* @param originalCommand long secondsBetween = secondsBetween(callastTime,
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em calcurrTime, limitResetDelay);
*/ long waitSeconds = secondsBetween;
static void setUses(Player player, String regexCommand, long waitMinutes = Math.round(waitSeconds / 60) + 1;
String originalCommand) { long waitHours = Math.round(waitMinutes / 60) + 1;
if (BoosConfigManager.getLimitsEnabled()) { String msg = BoosConfigManager.getLimitResetMessage();
if (BoosConfigManager.getCommands(player).contains(regexCommand)) { msg = msg.replaceAll("&command&", originalCommand);
int regexCommand2 = regexCommand.toLowerCase().hashCode(); if (waitSeconds >= 60 && 3600 >= waitSeconds) {
int uses = getUses(player, regexCommand); msg = msg.replaceAll("&seconds&",
uses = uses + 1; Long.toString(waitMinutes));
try { msg = msg.replaceAll("&unit&",
BoosConfigManager.getConfusers().set( BoosConfigManager.getUnitMinutesMessage());
"users." } else if (waitMinutes >= 60) {
+ player.getName().toLowerCase().hashCode() msg = msg.replaceAll("&seconds&",
+ ".uses." + regexCommand2, uses); Long.toString(waitHours));
} catch (IllegalArgumentException e) { msg = msg.replaceAll("&unit&",
BoosCoolDown BoosConfigManager.getUnitHoursMessage());
.getLog() } else {
.warning( msg = msg.replaceAll("&seconds&",
"Player " Long.toString(waitSeconds));
+ player.getName() msg = msg.replaceAll("&unit&",
+ " used empty command and caused this error!"); BoosConfigManager.getUnitSecondsMessage());
} }
} else { boosChat.sendMessageToPlayer(player, msg);
return; } else if (limitResetDelayGlobal > 0) {
} if (confTime != null) {
} callastTimeGlobal.setTime(confTime);
} long secondsBetween = secondsBetween(callastTimeGlobal,
calcurrTime, limitResetDelayGlobal);
/** long waitSeconds = secondsBetween;
* Metoda odes<EFBFBD>l<EFBFBD> hr<EFBFBD><EFBFBD>i zpr<EFBFBD>vu o limitovan<EFBFBD>m p<EFBFBD><EFBFBD>kazu, hodnotu tohoto limitu long waitMinutes = (long) Math.ceil(waitSeconds / 60.0);
* a kolikr<EFBFBD>t je je<EFBFBD>t<EFBFBD> mo<EFBFBD>n<EFBFBD> limitovan<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD><EFBFBD>t. long waitHours = (long) Math.ceil(waitMinutes / 60.0);
* String msg = BoosConfigManager.getLimitResetMessage();
* @param send msg = msg.replaceAll("&command&", originalCommand);
* hr<EFBFBD><EFBFBD> kter<EFBFBD>mu bude odesl<EFBFBD>n seznam if (waitSeconds >= 60 && 3600 >= waitSeconds) {
* @param comm msg = msg.replaceAll("&seconds&",
* p<EFBFBD><EFBFBD>kaz o kter<EFBFBD>m si hr<EFBFBD><EFBFBD> vy<EFBFBD><EFBFBD>dal informace Long.toString(waitMinutes));
* @param lim msg = msg.replaceAll("&unit&",
* hodnota limitu na p<EFBFBD><EFBFBD>kazu BoosConfigManager.getUnitMinutesMessage());
*/ } else if (waitMinutes >= 60) {
static void getLimitListMessages(Player send, String comm, int lim) { msg = msg.replaceAll("&seconds&",
if (lim != -1) { Long.toString(waitHours));
int uses = getUses(send, comm); msg = msg.replaceAll("&unit&",
String message = BoosConfigManager.getLimitListMessage(); BoosConfigManager.getUnitHoursMessage());
int num = lim - uses; } else {
if (num < 0) { msg = msg.replaceAll("&seconds&",
num = 0; Long.toString(waitSeconds));
} msg = msg.replaceAll("&unit&",
message = BoosConfigManager.getLimitListMessage(); BoosConfigManager.getUnitSecondsMessage());
message = message.replaceAll("&command&", comm); }
message = message.replaceAll("&limit&", String.valueOf(lim)); boosChat.sendMessageToPlayer(player, msg);
message = message.replaceAll("&times&", String.valueOf(num)); }
boosChat.sendMessageToPlayer(send, message); } else {
} String msg = String.format(BoosConfigManager
} .getCommandBlockedMessage());
boosChat.sendMessageToPlayer(player, msg);
} }
return true;
}
}
return false;
}
/**
* Metoda vrac<EFBFBD> hodnotu, kter<EFBFBD> je ur<EFBFBD>ena t<EFBFBD>m, kolikr<EFBFBD>t ji<EFBFBD> hr<EFBFBD><EFBFBD> pou<EFBFBD>il
* specifikovan<EFBFBD> p<EFBFBD><EFBFBD>kaz.
*
* @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu
* @return hodnota p<EFBFBD>edstavuj<EFBFBD>ci po<EFBFBD>et pou<EFBFBD>it<EFBFBD> specifikovan<EFBFBD>ho p<EFBFBD><EFBFBD>kazu
*/
static int getUses(Player player, String regexCommand) {
int regexCommand2 = regexCommand.toLowerCase().hashCode();
int uses = 0;
uses = BoosConfigManager.getConfusers().getInt(
"users." + player.getUniqueId() + ".uses." + regexCommand2,
uses);
return uses;
}
/**
* Metoda nastavuje po<EFBFBD>et pou<EFBFBD>it<EFBFBD> p<EFBFBD><EFBFBD>kazu o jedna v<EFBFBD>t<EFBFBD><EFBFBD> po ka<EFBFBD>d<EFBFBD>m pou<EFBFBD>it<EFBFBD>
* p<EFBFBD><EFBFBD>kazu hr<EFBFBD><EFBFBD>em. Nasteven<EFBFBD> hodnoty prob<EFBFBD>h<EFBFBD> jen pro p<EFBFBD><EFBFBD>kazy, kter<EFBFBD> jsou
* definov<EFBFBD>ny v konfiguraci.
*
* @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu
* @param originalCommand
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em
*/
static void setUses(Player player, String regexCommand) {
if (BoosConfigManager.getLimitsEnabled()) {
if (BoosConfigManager.getCommands(player).contains(regexCommand)) {
int regexCommand2 = regexCommand.toLowerCase().hashCode();
int uses = getUses(player, regexCommand);
uses = uses + 1;
try {
BoosConfigManager.getConfusers().set(
"users." + player.getUniqueId() + ".uses."
+ regexCommand2, uses);
} catch (IllegalArgumentException e) {
BoosCoolDown
.getLog()
.warning(
"Player "
+ player.getName()
+ " used empty command and caused this error!");
}
} else {
return;
}
}
}
/**
* Metoda odes<EFBFBD>l<EFBFBD> hr<EFBFBD><EFBFBD>i zpr<EFBFBD>vu o limitovan<EFBFBD>m p<EFBFBD><EFBFBD>kazu, hodnotu tohoto limitu
* a kolikr<EFBFBD>t je je<EFBFBD>t<EFBFBD> mo<EFBFBD>n<EFBFBD> limitovan<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD><EFBFBD>t.
*
* @param send
* hr<EFBFBD><EFBFBD> kter<EFBFBD>mu bude odesl<EFBFBD>n seznam
* @param comm
* p<EFBFBD><EFBFBD>kaz o kter<EFBFBD>m si hr<EFBFBD><EFBFBD> vy<EFBFBD><EFBFBD>dal informace
* @param lim
* hodnota limitu na p<EFBFBD><EFBFBD>kazu
*/
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("&times&", String.valueOf(num));
boosChat.sendMessageToPlayer(send, message);
}
}
/**
* Metoda vrac<EFBFBD> sou<EFBFBD>asn<EFBFBD> p<EFBFBD>esn<EFBFBD> datum a <EFBFBD>as.
*
* @return sou<EFBFBD>asn<EFBFBD> <EFBFBD>as a datum
*/
static Date getCurrTime() {
String currTime = "";
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
currTime = sdf.format(cal.getTime());
Date time = null;
try {
time = sdf.parse(currTime);
return time;
} catch (ParseException e) {
return null;
}
}
/**
* Metoda vrac<EFBFBD> datum a <EFBFBD>as, kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD> p<EFBFBD><EFBFBD>kaz.
*
* @param player
* specifikovan<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu
* @return datum a <EFBFBD>as kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD> p<EFBFBD><EFBFBD>kaz
*/
static Date getTime(Player player, String regexCommand) {
int pre2 = regexCommand.toLowerCase().hashCode();
String confTime = "";
confTime = BoosConfigManager.getConfusers().getString(
"users." + player.getUniqueId() + ".lastused." + pre2, null);
if (confTime != null && !confTime.equals("")) {
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
Date lastDate = null;
try {
lastDate = sdf.parse(confTime);
return lastDate;
} catch (ParseException e) {
return null;
}
}
return null;
}
static Date getTime(String regexCommand) {
String confTime = "";
confTime = BoosConfigManager.getConfusers().getString(
"global." + regexCommand + ".reset", null);
if (confTime != null && !confTime.equals("")) {
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
Date lastDate = null;
try {
lastDate = sdf.parse(confTime);
return lastDate;
} catch (ParseException e) {
return null;
}
}
return null;
}
/**
* Metoda ukl<EFBFBD>d<EFBFBD> do datab<EFBFBD>ze datum a <EFBFBD>as kdy hr<EFBFBD><EFBFBD> naposledy pou<EFBFBD>il dan<EFBFBD>
* p<EFBFBD><EFBFBD>kaz.
*
* @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigurace vyhovuj<EFBFBD>c<EFBFBD> origin<EFBFBD>ln<EFBFBD>mu p<EFBFBD><EFBFBD>kazu
*/
static void setTime(Player player, String regexCommand) {
int pre2 = regexCommand.toLowerCase().hashCode();
String currTime = "";
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
currTime = sdf.format(cal.getTime());
BoosConfigManager.getConfusers()
.set("users." + player.getUniqueId() + ".lastused." + pre2,
currTime);
}
/**
* Metoda vrac<EFBFBD> hodnotu rozd<EFBFBD>lu v sekund<EFBFBD>ch mezi dv<EFBFBD>mi hodnotami datumu a
* <EFBFBD>asu.
*
* @param startDate
* @param endDate
* @return rozd<EFBFBD>l v sekund<EFBFBD>ch mezi startDate a endDate
*/
static long secondsBetween(Calendar startDate, Calendar endDate,
long limitResetDelay) {
long secondsBetween = 0;
secondsBetween = ((startDate.getTimeInMillis() - endDate
.getTimeInMillis()) / 1000) + limitResetDelay;
return secondsBetween;
}
static void clearAllLimits(int hashedCommand) {
Set<String> players = BoosConfigManager.getAllPlayers();
for (String player : players) {
BoosConfigManager.clearSomething2("uses", player, hashedCommand);
}
BoosConfigManager.saveConfusers();
BoosConfigManager.loadConfusers();
}
static void setGlobalLimitResetDate() {
for (String command : BoosConfigManager.getLimitResetCommandsGlobal()) {
if (BoosConfigManager.getLimitResetDelayGlobal(command) == -65535) {
BoosConfigManager.getConfusers().set("global." + command, null);
} else {
setTime(command);
}
}
BoosConfigManager.saveConfusers();
BoosConfigManager.loadConfusers();
}
static void setGlobalLimitResetDate(String command) {
setTime(command);
BoosConfigManager.saveConfusers();
BoosConfigManager.loadConfusers();
}
static void setTime(String command) {
String currTime = "";
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
currTime = sdf.format(cal.getTime());
BoosConfigManager.getConfusers().set("global." + command + ".reset",
currTime);
}
}

View File

@ -1,283 +1,283 @@
package cz.boosik.boosCooldown; package cz.boosik.boosCooldown;
import java.util.Iterator; import java.util.Iterator;
import java.util.Timer; import java.util.Timer;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import util.boosChat; import util.boosChat;
/** /**
* T<EFBFBD><EFBFBD>da obsahuje ve<EFBFBD>ker<EFBFBD> metody pot<EFBFBD>ebn<EFBFBD> k <EFBFBD><EFBFBD>zen<EFBFBD> warmup <EFBFBD>asova<EFBFBD><EFBFBD>. Spou<EFBFBD>t<EFBFBD>n<EFBFBD>, * T<EFBFBD><EFBFBD>da obsahuje ve<EFBFBD>ker<EFBFBD> metody pot<EFBFBD>ebn<EFBFBD> k <EFBFBD><EFBFBD>zen<EFBFBD> warmup <EFBFBD>asova<EFBFBD><EFBFBD>. Spou<EFBFBD>t<EFBFBD>n<EFBFBD>,
* ukon<EFBFBD>ov<EFBFBD>n<EFBFBD> a zji<EFBFBD><EFBFBD>ov<EFBFBD>n<EFBFBD> zda je warmup <EFBFBD>asova<EFBFBD> ji<EFBFBD> aktivn<EFBFBD>. * ukon<EFBFBD>ov<EFBFBD>n<EFBFBD> a zji<EFBFBD><EFBFBD>ov<EFBFBD>n<EFBFBD> zda je warmup <EFBFBD>asova<EFBFBD> ji<EFBFBD> aktivn<EFBFBD>.
* *
* @author Jakub Kol<EFBFBD><EFBFBD> * @author Jakub Kol<EFBFBD><EFBFBD>
* *
*/ */
public class BoosWarmUpManager { public class BoosWarmUpManager {
private static ConcurrentHashMap<String, BoosWarmUpTimer> playercommands = new ConcurrentHashMap<String, BoosWarmUpTimer>(); private static ConcurrentHashMap<String, BoosWarmUpTimer> playercommands = new ConcurrentHashMap<String, BoosWarmUpTimer>();
private static ConcurrentHashMap<Player, Location> playerloc = new ConcurrentHashMap<Player, Location>(); private static ConcurrentHashMap<Player, Location> playerloc = new ConcurrentHashMap<Player, Location>();
private static ConcurrentHashMap<Player, String> playerworld = new ConcurrentHashMap<Player, String>(); private static ConcurrentHashMap<Player, String> playerworld = new ConcurrentHashMap<Player, String>();
private static Timer scheduler; private static Timer scheduler;
/** /**
* Metoda aplikuje na hr<EFBFBD><EFBFBD>e magick<EFBFBD> efekt na dobu ur<EFBFBD>enou parametrem * Metoda aplikuje na hr<EFBFBD><EFBFBD>e magick<EFBFBD> efekt na dobu ur<EFBFBD>enou parametrem
* warmUpSeconds. * warmUpSeconds.
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kazu
* @param warmUpSeconds * @param warmUpSeconds
* doba warmup v sekund<EFBFBD>ch, nastaven<EFBFBD> pro regexCommand v * doba warmup v sekund<EFBFBD>ch, nastaven<EFBFBD> pro regexCommand v
* konfiguraci * konfiguraci
*/ */
static void applyPotionEffect(Player player, String regexCommand, static void applyPotionEffect(Player player, String regexCommand,
int warmUpSeconds) { int warmUpSeconds) {
String potion = BoosConfigManager.getPotionEffect(regexCommand, player); String potion = BoosConfigManager.getPotionEffect(regexCommand, player);
if (potion.equals("")) { if (potion.equals("")) {
return; return;
} }
int potionStrength = BoosConfigManager.getPotionEffectStrength( int potionStrength = BoosConfigManager.getPotionEffectStrength(
regexCommand, player); regexCommand, player);
if (potionStrength == 0) { if (potionStrength == 0) {
return; return;
} }
PotionEffectType effect = PotionEffectType.getByName(potion); PotionEffectType effect = PotionEffectType.getByName(potion);
player.addPotionEffect( player.addPotionEffect(
effect.createEffect(warmUpSeconds * 40, potionStrength - 1), effect.createEffect(warmUpSeconds * 40, potionStrength - 1),
true); true);
} }
/** /**
* Metoda stornuje ve<EFBFBD>ker<EFBFBD> prob<EFBFBD>haj<EFBFBD>c<EFBFBD> warmup <EFBFBD>asova<EFBFBD>e specifick<EFBFBD>ho hr<EFBFBD><EFBFBD>e. * Metoda stornuje ve<EFBFBD>ker<EFBFBD> prob<EFBFBD>haj<EFBFBD>c<EFBFBD> warmup <EFBFBD>asova<EFBFBD>e specifick<EFBFBD>ho hr<EFBFBD><EFBFBD>e.
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
*/ */
public static void cancelWarmUps(Player player) { public static void cancelWarmUps(Player player) {
Iterator<String> iter = playercommands.keySet().iterator(); Iterator<String> iter = playercommands.keySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
if (iter.next().startsWith(player.getUniqueId() + "@")) { if (iter.next().startsWith(player.getUniqueId() + "@")) {
killTimer(player); killTimer(player);
iter.remove(); iter.remove();
} }
} }
} }
/** /**
* Metoda pro specifick<EFBFBD>ho hr<EFBFBD><EFBFBD>e vyma<EFBFBD>e ulo<EFBFBD>enou pozici a sv<EFBFBD>t. * Metoda pro specifick<EFBFBD>ho hr<EFBFBD><EFBFBD>e vyma<EFBFBD>e ulo<EFBFBD>enou pozici a sv<EFBFBD>t.
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
*/ */
public static void clearLocWorld(Player player) { public static void clearLocWorld(Player player) {
BoosWarmUpManager.playerloc.remove(player); BoosWarmUpManager.playerloc.remove(player);
BoosWarmUpManager.playerworld.remove(player); BoosWarmUpManager.playerworld.remove(player);
} }
/** /**
* Metoda vrac<EFBFBD> boolean hodnotu v z<EFBFBD>vislosti na tom jestli specifikovan<EFBFBD> * Metoda vrac<EFBFBD> boolean hodnotu v z<EFBFBD>vislosti na tom jestli specifikovan<EFBFBD>
* hr<EFBFBD><EFBFBD> m<EFBFBD> aktivn<EFBFBD> warmup <EFBFBD>asova<EFBFBD>e nebo ne. * hr<EFBFBD><EFBFBD> m<EFBFBD> aktivn<EFBFBD> warmup <EFBFBD>asova<EFBFBD>e nebo ne.
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @return true pokud hr<EFBFBD><EFBFBD> m<EFBFBD> aktivn<EFBFBD> warmup <EFBFBD>asova<EFBFBD>e, jinak false * @return true pokud hr<EFBFBD><EFBFBD> m<EFBFBD> aktivn<EFBFBD> warmup <EFBFBD>asova<EFBFBD>e, jinak false
*/ */
public static boolean hasWarmUps(Player player) { public static boolean hasWarmUps(Player player) {
for (String key : playercommands.keySet()) { for (String key : playercommands.keySet()) {
if (key.startsWith(player.getUniqueId() + "@")) { if (key.startsWith(player.getUniqueId() + "@")) {
return true; return true;
} }
} }
return false; return false;
} }
/** /**
* Metoda zji<EFBFBD><EFBFBD>uje, jestli je dan<EFBFBD> warmup <EFBFBD>asova<EFBFBD> ozna<EFBFBD>en<EFBFBD> jako ji<EFBFBD> prob<EFBFBD>hl<EFBFBD> * Metoda zji<EFBFBD><EFBFBD>uje, jestli je dan<EFBFBD> warmup <EFBFBD>asova<EFBFBD> ozna<EFBFBD>en<EFBFBD> jako ji<EFBFBD> prob<EFBFBD>hl<EFBFBD>
* nebo ne. * nebo ne.
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kazu
* @return true pokud je warmup <EFBFBD>asova<EFBFBD> ozna<EFBFBD>en jako ji<EFBFBD> prob<EFBFBD>hl<EFBFBD>, jinak * @return true pokud je warmup <EFBFBD>asova<EFBFBD> ozna<EFBFBD>en jako ji<EFBFBD> prob<EFBFBD>hl<EFBFBD>, jinak
* false * false
*/ */
static boolean checkWarmUpOK(Player player, String regexCommand) { static boolean checkWarmUpOK(Player player, String regexCommand) {
int pre2 = regexCommand.toLowerCase().hashCode(); int pre2 = regexCommand.toLowerCase().hashCode();
int ok = 0; int ok = 0;
ok = BoosConfigManager.getConfusers().getInt( ok = BoosConfigManager.getConfusers().getInt(
"users." + player.getUniqueId() + ".warmup." + pre2, ok); "users." + player.getUniqueId() + ".warmup." + pre2, ok);
if (ok == 1) { if (ok == 1) {
return true; return true;
} }
return false; return false;
} }
/** /**
* Metoda vrac<EFBFBD> boolean hodnotu na z<EFBFBD>klad<EFBFBD> toho jestli je pro specifikovan<EFBFBD> * Metoda vrac<EFBFBD> boolean hodnotu na z<EFBFBD>klad<EFBFBD> toho jestli je pro specifikovan<EFBFBD>
* p<EFBFBD><EFBFBD>kaz specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e aktivn<EFBFBD> warmup <EFBFBD>asova<EFBFBD>. * p<EFBFBD><EFBFBD>kaz specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e aktivn<EFBFBD> warmup <EFBFBD>asova<EFBFBD>.
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kazu
* @return true pokud je warmup <EFBFBD>asova<EFBFBD> aktivn<EFBFBD>, jinak false * @return true pokud je warmup <EFBFBD>asova<EFBFBD> aktivn<EFBFBD>, jinak false
*/ */
static boolean isWarmUpProcess(Player player, String regexCommand) { static boolean isWarmUpProcess(Player player, String regexCommand) {
regexCommand = regexCommand.toLowerCase(); regexCommand = regexCommand.toLowerCase();
if (playercommands.containsKey(player.getUniqueId() + "@" if (playercommands.containsKey(player.getUniqueId() + "@"
+ regexCommand)) { + regexCommand)) {
return true; return true;
} }
return false; return false;
} }
/** /**
* Metoda odstran<EFBFBD> v<EFBFBD>echny <EFBFBD>asova<EFBFBD>e specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e * Metoda odstran<EFBFBD> v<EFBFBD>echny <EFBFBD>asova<EFBFBD>e specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
*/ */
static void killTimer(Player player) { static void killTimer(Player player) {
for (String key : playercommands.keySet()) { for (String key : playercommands.keySet()) {
if (key.startsWith(player.getUniqueId() + "@")) { if (key.startsWith(player.getUniqueId() + "@")) {
playercommands.get(key).cancel(); playercommands.get(key).cancel();
} }
} }
} }
/** /**
* Metoda odstran<EFBFBD> <EFBFBD>asova<EFBFBD>e na specifikovan<EFBFBD>m p<EFBFBD><EFBFBD>kazu specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e * Metoda odstran<EFBFBD> <EFBFBD>asova<EFBFBD>e na specifikovan<EFBFBD>m p<EFBFBD><EFBFBD>kazu specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kazu
*/ */
static void removeWarmUp(Player player, String regexCommand) { static void removeWarmUp(Player player, String regexCommand) {
int pre2 = regexCommand.toLowerCase().hashCode(); int pre2 = regexCommand.toLowerCase().hashCode();
BoosConfigManager.getConfusers().set( BoosConfigManager.getConfusers().set(
"users." + player.getUniqueId() + ".warmup." + pre2, null); "users." + player.getUniqueId() + ".warmup." + pre2, null);
} }
/** /**
* Metoda odstran<EFBFBD> ukon<EFBFBD>en<EFBFBD> <EFBFBD>asova<EFBFBD>e na specifikovan<EFBFBD>m p<EFBFBD><EFBFBD>kazu * Metoda odstran<EFBFBD> ukon<EFBFBD>en<EFBFBD> <EFBFBD>asova<EFBFBD>e na specifikovan<EFBFBD>m p<EFBFBD><EFBFBD>kazu
* specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e * specifikovan<EFBFBD>ho hr<EFBFBD><EFBFBD>e
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kazu
*/ */
static void removeWarmUpOK(Player player, String regexCommand) { static void removeWarmUpOK(Player player, String regexCommand) {
int pre2 = regexCommand.toLowerCase().hashCode(); int pre2 = regexCommand.toLowerCase().hashCode();
BoosConfigManager.getConfusers().set( BoosConfigManager.getConfusers().set(
"users." + player.getUniqueId() + ".warmup." + pre2, null); "users." + player.getUniqueId() + ".warmup." + pre2, null);
} }
/** /**
* Metoda odstra<EFBFBD>uje dan<EFBFBD> <EFBFBD>et<EFBFBD>zec z Hashmapy * Metoda odstra<EFBFBD>uje dan<EFBFBD> <EFBFBD>et<EFBFBD>zec z Hashmapy
* *
* @param tag * @param tag
* <EFBFBD>et<EFBFBD>zec, kter<EFBFBD> se m<EFBFBD> odstranit z Hasmapy * <EFBFBD>et<EFBFBD>zec, kter<EFBFBD> se m<EFBFBD> odstranit z Hasmapy
*/ */
static void removeWarmUpProcess(String tag) { static void removeWarmUpProcess(String tag) {
BoosWarmUpManager.playercommands.remove(tag); BoosWarmUpManager.playercommands.remove(tag);
} }
/** /**
* Metoda ozna<EFBFBD>uje warmup <EFBFBD>asova<EFBFBD> specifikovan<EFBFBD>ho p<EFBFBD><EFBFBD>kazu specifikovan<EFBFBD>ho * Metoda ozna<EFBFBD>uje warmup <EFBFBD>asova<EFBFBD> specifikovan<EFBFBD>ho p<EFBFBD><EFBFBD>kazu specifikovan<EFBFBD>ho
* hr<EFBFBD><EFBFBD>e jako ji<EFBFBD> ukon<EFBFBD>en<EFBFBD>. * hr<EFBFBD><EFBFBD>e jako ji<EFBFBD> ukon<EFBFBD>en<EFBFBD>.
* *
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kazu
*/ */
static void setWarmUpOK(Player player, String regexCommand) { static void setWarmUpOK(Player player, String regexCommand) {
int pre2 = regexCommand.toLowerCase().hashCode(); int pre2 = regexCommand.toLowerCase().hashCode();
BoosConfigManager.getConfusers().set( BoosConfigManager.getConfusers().set(
"users." + player.getUniqueId() + ".warmup." + pre2, 1); "users." + player.getUniqueId() + ".warmup." + pre2, 1);
} }
/** /**
* Metoda spou<EFBFBD>t<EFBFBD> warmup <EFBFBD>asova<EFBFBD> na z<EFBFBD>klad<EFBFBD> parametr<EFBFBD> pomoc<EFBFBD> Timer(). Pokud * Metoda spou<EFBFBD>t<EFBFBD> warmup <EFBFBD>asova<EFBFBD> na z<EFBFBD>klad<EFBFBD> parametr<EFBFBD> pomoc<EFBFBD> Timer(). Pokud
* je ji<EFBFBD> warmup aktivn<EFBFBD>, ode<EFBFBD>le hr<EFBFBD><EFBFBD>i zpr<EFBFBD>vu kter<EFBFBD> ho o tom informuje. * je ji<EFBFBD> warmup aktivn<EFBFBD>, ode<EFBFBD>le hr<EFBFBD><EFBFBD>i zpr<EFBFBD>vu kter<EFBFBD> ho o tom informuje.
* *
* @param bCoolDown * @param bCoolDown
* instance t<EFBFBD><EFBFBD>dy BoosCooldown * instance t<EFBFBD><EFBFBD>dy BoosCooldown
* @param player * @param player
* specifick<EFBFBD> hr<EFBFBD><EFBFBD> * specifick<EFBFBD> hr<EFBFBD><EFBFBD>
* @param regexCommand * @param regexCommand
* p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu * p<EFBFBD><EFBFBD>kaz z konfigura<EFBFBD>n<EFBFBD>ho souboru, kter<EFBFBD> vyhovuje origin<EFBFBD>ln<EFBFBD>mu
* p<EFBFBD><EFBFBD>kazu * p<EFBFBD><EFBFBD>kazu
* @param originalCommand * @param originalCommand
* origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em * origin<EFBFBD>ln<EFBFBD> p<EFBFBD><EFBFBD>kaz pou<EFBFBD>it<EFBFBD> hr<EFBFBD><EFBFBD>em
* @param warmUpSeconds * @param warmUpSeconds
* warmup doba nastaven<EFBFBD> pro p<EFBFBD><EFBFBD>kaz v sekund<EFBFBD>ch * warmup doba nastaven<EFBFBD> pro p<EFBFBD><EFBFBD>kaz v sekund<EFBFBD>ch
*/ */
static void startWarmUp(BoosCoolDown bCoolDown, Player player, static void startWarmUp(BoosCoolDown bCoolDown, Player player,
String regexCommand, String originalCommand, int warmUpSeconds) { String regexCommand, String originalCommand, int warmUpSeconds) {
regexCommand = regexCommand.toLowerCase(); regexCommand = regexCommand.toLowerCase();
long warmUpMinutes = Math.round(warmUpSeconds / 60); long warmUpMinutes = (long) Math.ceil(warmUpSeconds / 60.0);
long warmUpHours = Math.round(warmUpMinutes / 60); long warmUpHours = (long) Math.ceil(warmUpMinutes / 60.0);
if (!isWarmUpProcess(player, regexCommand)) { if (!isWarmUpProcess(player, regexCommand)) {
BoosWarmUpManager.removeWarmUpOK(player, regexCommand); BoosWarmUpManager.removeWarmUpOK(player, regexCommand);
String msg = BoosConfigManager.getWarmUpMessage(); String msg = BoosConfigManager.getWarmUpMessage();
msg = msg.replaceAll("&command&", originalCommand); msg = msg.replaceAll("&command&", originalCommand);
if (warmUpSeconds >= 60 && 3600 >= warmUpSeconds) { if (warmUpSeconds >= 60 && 3600 >= warmUpSeconds) {
msg = msg.replaceAll("&seconds&", Long.toString(warmUpMinutes)); msg = msg.replaceAll("&seconds&", Long.toString(warmUpMinutes));
msg = msg.replaceAll("&unit&", msg = msg.replaceAll("&unit&",
BoosConfigManager.getUnitMinutesMessage()); BoosConfigManager.getUnitMinutesMessage());
} else if (warmUpMinutes >= 60) { } else if (warmUpMinutes >= 60) {
msg = msg.replaceAll("&seconds&", Long.toString(warmUpHours)); msg = msg.replaceAll("&seconds&", Long.toString(warmUpHours));
msg = msg.replaceAll("&unit&", msg = msg.replaceAll("&unit&",
BoosConfigManager.getUnitHoursMessage()); BoosConfigManager.getUnitHoursMessage());
} else { } else {
msg = msg.replaceAll("&seconds&", Long.toString(warmUpSeconds)); msg = msg.replaceAll("&seconds&", Long.toString(warmUpSeconds));
msg = msg.replaceAll("&unit&", msg = msg.replaceAll("&unit&",
BoosConfigManager.getUnitSecondsMessage()); BoosConfigManager.getUnitSecondsMessage());
} }
boosChat.sendMessageToPlayer(player, msg); boosChat.sendMessageToPlayer(player, msg);
scheduler = new Timer(); scheduler = new Timer();
BoosWarmUpTimer scheduleMe = new BoosWarmUpTimer(bCoolDown, BoosWarmUpTimer scheduleMe = new BoosWarmUpTimer(bCoolDown,
scheduler, player, regexCommand, originalCommand); scheduler, player, regexCommand, originalCommand);
playercommands.put(player.getUniqueId() + "@" + regexCommand, playercommands.put(player.getUniqueId() + "@" + regexCommand,
scheduleMe); scheduleMe);
scheduler.schedule(scheduleMe, warmUpSeconds * 1000); scheduler.schedule(scheduleMe, warmUpSeconds * 1000);
applyPotionEffect(player, regexCommand, warmUpSeconds); applyPotionEffect(player, regexCommand, warmUpSeconds);
} 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);
} }
} }
/** /**
* @return * @return
*/ */
public static ConcurrentHashMap<Player, String> getPlayerworld() { public static ConcurrentHashMap<Player, String> getPlayerworld() {
return playerworld; return playerworld;
} }
/** /**
* @return * @return
*/ */
public static ConcurrentHashMap<Player, Location> getPlayerloc() { public static ConcurrentHashMap<Player, Location> getPlayerloc() {
return playerloc; return playerloc;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,110 +1,110 @@
name: boosCooldowns name: boosCooldowns
main: cz.boosik.boosCooldown.BoosCoolDown main: cz.boosik.boosCooldown.BoosCoolDown
version: 3.8.5 version: 3.9.5
authors: [LordBoos (ingame name boosik)] authors: [LordBoos (ingame name boosik)]
softdepend: [Vault] softdepend: [Vault]
description: > description: >
Shortcuts Shortcuts
commands: commands:
booscooldowns: booscooldowns:
description: Reload command. description: Reload command.
usage: Use /booscooldowns reload, clearcooldowns <player>, clearwarmups <player> or clearuses <player> usage: §6[boosCooldowns] §eInvalid command or access denied!
aliases: bcd aliases: bcd
permissions: permissions:
booscooldowns.exception: booscooldowns.exception:
description: Player wont be affected by plugin at all (no warmups, no cooldowns, no prices, no limits, no aliases). description: Player wont be affected by plugin at all (no warmups, no cooldowns, no prices, no limits, no aliases).
default: false default: false
booscooldowns.norestriction: booscooldowns.norestriction:
description: Player wont be affected by restrictions but will be affected by aliases(no warmups, no cooldowns, no prices, no limits). description: Player wont be affected by restrictions but will be affected by aliases(no warmups, no cooldowns, no prices, no limits).
default: false default: false
children: children:
booscooldowns.noprice: true booscooldowns.noprice: true
booscooldowns.nocooldown: true booscooldowns.nocooldown: true
booscooldowns.nowarmup: true booscooldowns.nowarmup: true
booscooldowns.nolimit: true booscooldowns.nolimit: true
booscooldowns.noitemcost: true booscooldowns.noitemcost: true
booscooldowns.noxpcost: true booscooldowns.noxpcost: true
booscooldowns.nocancel.move: booscooldowns.nocancel.move:
description: Players warmups will not be canceled by moving, even if it's turned on. description: Players warmups will not be canceled by moving, even if it's turned on.
default: false default: false
booscooldowns.nocancel.damage: booscooldowns.nocancel.damage:
description: Players warmups will not be canceled by damage, even if it's turned on. description: Players warmups will not be canceled by damage, even if it's turned on.
default: false default: false
booscooldowns.nocancel.sneak: booscooldowns.nocancel.sneak:
description: Players warmups will not be canceled by sneaking, even if it's turned on. description: Players warmups will not be canceled by sneaking, even if it's turned on.
default: false default: false
booscooldowns.nocancel.sprint: booscooldowns.nocancel.sprint:
description: Players warmups will not be canceled by sprinting, even if it's turned on. description: Players warmups will not be canceled by sprinting, even if it's turned on.
default: false default: false
booscooldowns.nocancel.gamemodechange: booscooldowns.nocancel.gamemodechange:
description: Players warmups will not be canceled by changing gamemode, even if it's turned on. description: Players warmups will not be canceled by changing gamemode, even if it's turned on.
default: false default: false
booscooldowns.dontblock.interact: booscooldowns.dontblock.interact:
description: Players interaction will not be blocked during warmup, even if it's turned on. description: Players interaction will not be blocked during warmup, even if it's turned on.
default: false default: false
booscooldowns.noprice: booscooldowns.noprice:
description: Players commands will always be free of charge. description: Players commands will always be free of charge.
default: false default: false
booscooldowns.noprice./command: booscooldowns.noprice./command:
description: Command "/command" will not be affected by price for users with this permission. description: Command "/command" will not be affected by price for users with this permission.
default: false default: false
booscooldowns.noitemcost: booscooldowns.noitemcost:
description: Players commands will always be free of charge (items). description: Players commands will always be free of charge (items).
default: false default: false
booscooldowns.noitemcost./command: booscooldowns.noitemcost./command:
description: Command "/command" will not be affected by item cost for users with this permission. description: Command "/command" will not be affected by item cost for users with this permission.
default: false default: false
booscooldowns.noxpcost: booscooldowns.noxpcost:
description: Players commands will always be free of charge (XP). description: Players commands will always be free of charge (XP).
default: false default: false
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.nocooldown: booscooldowns.nocooldown:
description: Player wont be affected by cooldowns. description: Player wont be affected by cooldowns.
default: false default: false
booscooldowns.nocooldown./command: booscooldowns.nocooldown./command:
description: Command "/command" will not be affected by cooldown for users with this permission. description: Command "/command" will not be affected by cooldown for users with this permission.
default: false default: false
booscooldowns.nowarmup: booscooldowns.nowarmup:
description: Player wont be affected by warmups. description: Player wont be affected by warmups.
default: false default: false
booscooldowns.nowarmup./command: booscooldowns.nowarmup./command:
description: Command "/command" will not be affected by warmup for users with this permission. description: Command "/command" will not be affected by warmup for users with this permission.
default: false default: false
booscooldowns.nolimit: booscooldowns.nolimit:
description: Player wont be affected by limiting. description: Player wont be affected by limiting.
default: false default: false
booscooldowns.start.cooldowns.death.exception: booscooldowns.start.cooldowns.death.exception:
description: Player's cooldowns wont be started on death. description: Player's cooldowns wont be started on death.
default: false default: false
booscooldowns.nolimit./command: booscooldowns.nolimit./command:
description: Command "/command" will not be affected by limits for users with this permission. description: Command "/command" will not be affected by limits for users with this permission.
default: false default: false
booscooldowns.reload: booscooldowns.reload:
description: Player can use "/booscooldowns reload" to reload config file. description: Player can use "/booscooldowns reload" to reload config file.
default: op default: op
booscooldowns.clear.uses.death: booscooldowns.clear.uses.death:
description: Players uses (limit-uses=how many times playr can still use command) are cleared on death (must be enabled in config file too!). description: Players uses (limit-uses=how many times playr can still use command) are cleared on death (must be enabled in config file too!).
default: false default: false
booscooldowns.clear.cooldowns.death: booscooldowns.clear.cooldowns.death:
description: Players cooldowns are cleared on death (must be enabled in config file too!). description: Players cooldowns are cleared on death (must be enabled in config file too!).
default: false default: false
booscooldowns.list.limits: booscooldowns.list.limits:
description: Player can use "/booscooldowns limits" to see limits and how many times he can still use commands. description: Player can use "/booscooldowns limits" to see limits and how many times he can still use commands.
default: true default: true
booscooldowns.set: booscooldowns.set:
description: Users with this can use "/booscooldowns set" command. description: Users with this can use "/booscooldowns set" command.
default: op default: op
booscooldowns.signs.player.use: booscooldowns.signs.player.use:
description: Player can use boosCooldowns signs (marked as player on second line). description: Player can use boosCooldowns signs (marked as player on second line).
default: false default: false
booscooldowns.signs.server.use: booscooldowns.signs.server.use:
description: Player can use boosCooldowns signs (marked as server on second line). description: Player can use boosCooldowns signs (marked as server on second line).
default: false default: false
booscooldowns.signs.player.place: booscooldowns.signs.player.place:
description: Player can place/create boosCooldowns signs (marked as player on second line). description: Player can place/create boosCooldowns signs (marked as player on second line).
default: false default: false
booscooldowns.signs.server.place: booscooldowns.signs.server.place:
description: Player can place/create boosCooldowns signs (marked as server on second line). !!WARNING!! With this permission, player can create sign with commands that are run as if used from console! description: Player can place/create boosCooldowns signs (marked as server on second line). !!WARNING!! With this permission, player can create sign with commands that are run as if used from console!
default: false default: false