mirror of
https://github.com/LordBoos/boosCooldowns.git
synced 2024-11-29 22:24:04 +01:00
Formating
This commit is contained in:
parent
08b646da0b
commit
0af02c541e
94
build.xml
94
build.xml
@ -6,69 +6,39 @@
|
|||||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||||
<!-- the Compile on Save feature is turned off for the project. -->
|
<!-- the Compile on Save feature is turned off for the project. -->
|
||||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||||
<!-- in the project's Project Properties dialog box.-->
|
<!-- in the project's Project Properties dialog box. -->
|
||||||
<project name="boosCooldown" default="default" basedir=".">
|
<project name="boosCooldown" default="default" basedir=".">
|
||||||
<description>Builds, tests, and runs the project boosCooldown.</description>
|
<description>Builds, tests, and runs the project boosCooldown.</description>
|
||||||
<import file="nbproject/build-impl.xml"/>
|
<import file="nbproject/build-impl.xml" />
|
||||||
<!--
|
<!-- There exist several targets which are by default empty and which can
|
||||||
|
be used for execution of your tasks. These targets are usually executed before
|
||||||
There exist several targets which are by default empty and which can be
|
and after some main targets. They are: -pre-init: called before initialization
|
||||||
used for execution of your tasks. These targets are usually executed
|
of project properties -post-init: called after initialization of project
|
||||||
before and after some main targets. They are:
|
properties -pre-compile: called before javac compilation -post-compile: called
|
||||||
|
after javac compilation -pre-compile-single: called before javac compilation
|
||||||
-pre-init: called before initialization of project properties
|
of single file -post-compile-single: called after javac compilation of single
|
||||||
-post-init: called after initialization of project properties
|
file -pre-compile-test: called before javac compilation of JUnit tests -post-compile-test:
|
||||||
-pre-compile: called before javac compilation
|
called after javac compilation of JUnit tests -pre-compile-test-single: called
|
||||||
-post-compile: called after javac compilation
|
before javac compilation of single JUnit test -post-compile-test-single:
|
||||||
-pre-compile-single: called before javac compilation of single file
|
called after javac compilation of single JUunit test -pre-jar: called before
|
||||||
-post-compile-single: called after javac compilation of single file
|
JAR building -post-jar: called after JAR building -post-clean: called after
|
||||||
-pre-compile-test: called before javac compilation of JUnit tests
|
cleaning build products (Targets beginning with '-' are not intended to be
|
||||||
-post-compile-test: called after javac compilation of JUnit tests
|
called on their own.) Example of inserting an obfuscator after compilation
|
||||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
could look like this: <target name="-post-compile"> <obfuscate> <fileset
|
||||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
dir="${build.classes.dir}"/> </obfuscate> </target> For list of available
|
||||||
-pre-jar: called before JAR building
|
properties check the imported nbproject/build-impl.xml file. Another way
|
||||||
-post-jar: called after JAR building
|
to customize the build is by overriding existing main targets. The targets
|
||||||
-post-clean: called after cleaning build products
|
of interest are: -init-macrodef-javac: defines macro for javac compilation
|
||||||
|
-init-macrodef-junit: defines macro for junit execution -init-macrodef-debug:
|
||||||
(Targets beginning with '-' are not intended to be called on their own.)
|
defines macro for class debugging -init-macrodef-java: defines macro for
|
||||||
|
class execution -do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||||
Example of inserting an obfuscator after compilation could look like this:
|
|
||||||
|
|
||||||
<target name="-post-compile">
|
|
||||||
<obfuscate>
|
|
||||||
<fileset dir="${build.classes.dir}"/>
|
|
||||||
</obfuscate>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
For list of available properties check the imported
|
|
||||||
nbproject/build-impl.xml file.
|
|
||||||
|
|
||||||
|
|
||||||
Another way to customize the build is by overriding existing main targets.
|
|
||||||
The targets of interest are:
|
|
||||||
|
|
||||||
-init-macrodef-javac: defines macro for javac compilation
|
|
||||||
-init-macrodef-junit: defines macro for junit execution
|
|
||||||
-init-macrodef-debug: defines macro for class debugging
|
|
||||||
-init-macrodef-java: defines macro for class execution
|
|
||||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
|
||||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||||
run: execution of project
|
run: execution of project -javadoc-build: Javadoc generation test-report:
|
||||||
-javadoc-build: Javadoc generation
|
JUnit report generation An example of overriding the target for project execution
|
||||||
test-report: JUnit report generation
|
could look like this: <target name="run" depends="boosCooldown-impl.jar">
|
||||||
|
<exec dir="bin" executable="launcher.exe"> <arg file="${dist.jar}"/> </exec>
|
||||||
An example of overriding the target for project execution could look like this:
|
</target> Notice that the overridden target depends on the jar target and
|
||||||
|
not only on the compile target as the regular run target does. Again, for
|
||||||
<target name="run" depends="boosCooldown-impl.jar">
|
a list of available properties which you can use, check the target you are
|
||||||
<exec dir="bin" executable="launcher.exe">
|
overriding in the nbproject/build-impl.xml file. -->
|
||||||
<arg file="${dist.jar}"/>
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
Notice that the overridden target depends on the jar target and not only on
|
|
||||||
the compile target as the regular run target does. Again, for a list of available
|
|
||||||
properties which you can use, check the target you are overriding in the
|
|
||||||
nbproject/build-impl.xml file.
|
|
||||||
|
|
||||||
-->
|
|
||||||
</project>
|
</project>
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -5,10 +5,10 @@
|
|||||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
||||||
<name>boosCooldown</name>
|
<name>boosCooldown</name>
|
||||||
<source-roots>
|
<source-roots>
|
||||||
<root id="src.dir"/>
|
<root id="src.dir" />
|
||||||
</source-roots>
|
</source-roots>
|
||||||
<test-roots>
|
<test-roots>
|
||||||
<root id="test.src.dir"/>
|
<root id="test.src.dir" />
|
||||||
</test-roots>
|
</test-roots>
|
||||||
</data>
|
</data>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -21,13 +21,11 @@ public class boosConfigManager {
|
|||||||
File f = new File(boosCoolDown.getDataFolder(), "config.yml");
|
File f = new File(boosCoolDown.getDataFolder(), "config.yml");
|
||||||
conf = null;
|
conf = null;
|
||||||
|
|
||||||
if (f.exists())
|
if (f.exists()) {
|
||||||
{
|
|
||||||
conf = new Configuration(f);
|
conf = new Configuration(f);
|
||||||
conf.load();
|
conf.load();
|
||||||
|
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
this.confFile = new File(boosCoolDown.getDataFolder(), "config.yml");
|
this.confFile = new File(boosCoolDown.getDataFolder(), "config.yml");
|
||||||
this.conf = new Configuration(confFile);
|
this.conf = new Configuration(confFile);
|
||||||
conf.setProperty("commands.cooldown./spawn", 60);
|
conf.setProperty("commands.cooldown./spawn", 60);
|
||||||
@ -39,10 +37,14 @@ public class boosConfigManager {
|
|||||||
conf.setProperty("commands.options.unit_seconds", "seconds");
|
conf.setProperty("commands.options.unit_seconds", "seconds");
|
||||||
conf.setProperty("commands.options.unit_minutes", "minutes");
|
conf.setProperty("commands.options.unit_minutes", "minutes");
|
||||||
conf.setProperty("commands.options.unit_hours", "hours");
|
conf.setProperty("commands.options.unit_hours", "hours");
|
||||||
conf.setProperty("commands.options.message_warmup_cancelled", "&6Warm-ups have been cancelled due to receiving damage.&f");
|
conf.setProperty("commands.options.message_warmup_cancelled",
|
||||||
conf.setProperty("commands.options.message_cooldown", "&6Wait&e &seconds& &unit&&6 before you can use command&e &command& &6again.&f");
|
"&6Warm-ups have been cancelled due to receiving damage.&f");
|
||||||
conf.setProperty("commands.options.message_warmup", "&6Wait&e &seconds& &unit&&6 before command&e &command& &6has warmed up.&f");
|
conf.setProperty("commands.options.message_cooldown",
|
||||||
conf.setProperty("commands.options.message_warmup_alreadystarted", "&6Warm-Up process for&e &command& &6has already started.&f");
|
"&6Wait&e &seconds& &unit&&6 before you can use command&e &command& &6again.&f");
|
||||||
|
conf.setProperty("commands.options.message_warmup",
|
||||||
|
"&6Wait&e &seconds& &unit&&6 before command&e &command& &6has warmed up.&f");
|
||||||
|
conf.setProperty("commands.options.message_warmup_alreadystarted",
|
||||||
|
"&6Warm-Up process for&e &command& &6has already started.&f");
|
||||||
conf.save();
|
conf.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -70,31 +72,47 @@ public class boosConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static String getCoolDownMessage() {
|
static String getCoolDownMessage() {
|
||||||
return conf.getString("commands.options.message_cooldown", "&6Wait&e &seconds& seconds&6 before you can use command&e &command& &6again.&f");
|
return conf
|
||||||
|
.getString(
|
||||||
|
"commands.options.message_cooldown",
|
||||||
|
"&6Wait&e &seconds& seconds&6 before you can use command&e &command& &6again.&f");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getWarmUpCancelledMessage() {
|
static String getWarmUpCancelledMessage() {
|
||||||
return conf.getString("commands.options.message_warmup_cancelled", "&6Warm-ups have been cancelled due to receiving damage.&f");
|
return conf.getString("commands.options.message_warmup_cancelled",
|
||||||
|
"&6Warm-ups have been cancelled due to receiving damage.&f");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getWarmUpMessage() {
|
static String getWarmUpMessage() {
|
||||||
return conf.getString("commands.options.message_warmup", "&6Wait&e &seconds& seconds&6 before command&e &command& &6has warmed up.&f");
|
return conf
|
||||||
|
.getString("commands.options.message_warmup",
|
||||||
|
"&6Wait&e &seconds& seconds&6 before command&e &command& &6has warmed up.&f");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getWarmUpAlreadyStartedMessage() {
|
static String getWarmUpAlreadyStartedMessage() {
|
||||||
return conf.getString("commands.options.message_warmup_alreadystarted", "&6Warm-Up process for&e &command& &6has already started.&f");
|
return conf.getString("commands.options.message_warmup_alreadystarted",
|
||||||
|
"&6Warm-Up process for&e &command& &6has already started.&f");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getUnitSecondsMessage() {
|
static String getUnitSecondsMessage() {
|
||||||
return conf.getString("commands.options.unit_seconds", "seconds");
|
return conf.getString("commands.options.unit_seconds", "seconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getUnitMinutesMessage() {
|
static String getUnitMinutesMessage() {
|
||||||
return conf.getString("commands.options.unit_minutes", "minutes");
|
return conf.getString("commands.options.unit_minutes", "minutes");
|
||||||
}
|
}
|
||||||
|
|
||||||
static String getUnitHoursMessage() {
|
static String getUnitHoursMessage() {
|
||||||
return conf.getString("commands.options.unit_hours", "hours");
|
return conf.getString("commands.options.unit_hours", "hours");
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean getClearOnRestart() {
|
static boolean getClearOnRestart() {
|
||||||
return conf.getBoolean("commands.options.clear_on_restart", false);
|
return conf.getBoolean("commands.options.clear_on_restart", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean getCancelWarmUpOnDamage() {
|
static boolean getCancelWarmUpOnDamage() {
|
||||||
return conf.getBoolean("commands.options.cancel_warmup_on_damage", false);
|
return conf.getBoolean("commands.options.cancel_warmup_on_damage",
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,10 @@ import java.util.logging.Logger;
|
|||||||
|
|
||||||
public class boosCoolDown extends JavaPlugin {
|
public class boosCoolDown extends JavaPlugin {
|
||||||
|
|
||||||
private final boosCoolDownPlayerListener playerListener = new boosCoolDownPlayerListener(this);
|
private final boosCoolDownPlayerListener playerListener = new boosCoolDownPlayerListener(
|
||||||
private final boosCoolDownEntityListener entityListener = new boosCoolDownEntityListener(this);
|
this);
|
||||||
|
private final boosCoolDownEntityListener entityListener = new boosCoolDownEntityListener(
|
||||||
|
this);
|
||||||
public static final Logger log = Logger.getLogger("Minecraft");
|
public static final Logger log = Logger.getLogger("Minecraft");
|
||||||
public static PluginDescriptionFile pdfFile;
|
public static PluginDescriptionFile pdfFile;
|
||||||
public static Configuration conf;
|
public static Configuration conf;
|
||||||
@ -28,18 +30,22 @@ public class boosCoolDown extends JavaPlugin {
|
|||||||
|
|
||||||
pdfFile = this.getDescription();
|
pdfFile = this.getDescription();
|
||||||
PluginManager pm = getServer().getPluginManager();
|
PluginManager pm = getServer().getPluginManager();
|
||||||
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener, Event.Priority.Lowest, this);
|
pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESS, playerListener,
|
||||||
|
Event.Priority.Lowest, this);
|
||||||
|
|
||||||
PluginDescriptionFile pdfFile = this.getDescription();
|
PluginDescriptionFile pdfFile = this.getDescription();
|
||||||
log.info("[" + pdfFile.getName() + "]" + " version " + pdfFile.getVersion() + " by " + pdfFile.getAuthors() + " is enabled!");
|
log.info("[" + pdfFile.getName() + "]" + " version "
|
||||||
|
+ pdfFile.getVersion() + " by " + pdfFile.getAuthors()
|
||||||
|
+ " is enabled!");
|
||||||
|
|
||||||
boosConfigManager boosConfigManager = new boosConfigManager(this);
|
boosConfigManager boosConfigManager = new boosConfigManager(this);
|
||||||
boosConfigManager.load();
|
boosConfigManager.load();
|
||||||
conf = boosConfigManager.conf;
|
conf = boosConfigManager.conf;
|
||||||
boosCoolDownManager boosCoolDownManager = new boosCoolDownManager(this);
|
boosCoolDownManager boosCoolDownManager = new boosCoolDownManager(this);
|
||||||
boosCoolDownManager.load();
|
boosCoolDownManager.load();
|
||||||
if(boosConfigManager.getCancelWarmUpOnDamage()) {
|
if (boosConfigManager.getCancelWarmUpOnDamage()) {
|
||||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener, Event.Priority.Normal, this);
|
pm.registerEvent(Event.Type.ENTITY_DAMAGE, entityListener,
|
||||||
|
Event.Priority.Normal, this);
|
||||||
}
|
}
|
||||||
if (boosConfigManager.getClearOnRestart() == true) {
|
if (boosConfigManager.getClearOnRestart() == true) {
|
||||||
boosCoolDownManager.clear();
|
boosCoolDownManager.clear();
|
||||||
@ -54,19 +60,21 @@ public class boosCoolDown extends JavaPlugin {
|
|||||||
boosCoolDownManager.clear();
|
boosCoolDownManager.clear();
|
||||||
} else {
|
} else {
|
||||||
}
|
}
|
||||||
log.info("[" + pdfFile.getName() + "]" + " version " + pdfFile.getVersion() + " disabled!");
|
log.info("[" + pdfFile.getName() + "]" + " version "
|
||||||
|
+ pdfFile.getVersion() + " disabled!");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command c, String commandLabel, String[] args) {
|
public boolean onCommand(CommandSender sender, Command c,
|
||||||
|
String commandLabel, String[] args) {
|
||||||
String command = c.getName().toLowerCase();
|
String command = c.getName().toLowerCase();
|
||||||
if (command.equalsIgnoreCase("boosCoolDown")) {
|
if (command.equalsIgnoreCase("boosCoolDown")) {
|
||||||
boosConfigManager.reload();
|
boosConfigManager.reload();
|
||||||
boosChat.sendMessageToCommandSender(sender, "&6[" + pdfFile.getName() + "]" + " config reloaded");
|
boosChat.sendMessageToCommandSender(sender,
|
||||||
|
"&6[" + pdfFile.getName() + "]" + " config reloaded");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,12 @@ public class boosCoolDownEntityListener extends EntityListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = event.getEntity();
|
Entity entity = event.getEntity();
|
||||||
if(entity != null && entity instanceof Player) {
|
if (entity != null && entity instanceof Player) {
|
||||||
Player player = (Player)entity;
|
Player player = (Player) entity;
|
||||||
if(player != null) {
|
if (player != null) {
|
||||||
if(boosWarmUpManager.hasWarmUps(player)) {
|
if (boosWarmUpManager.hasWarmUps(player)) {
|
||||||
boosChat.sendMessageToPlayer(player,boosConfigManager.getWarmUpCancelledMessage());
|
boosChat.sendMessageToPlayer(player,
|
||||||
|
boosConfigManager.getWarmUpCancelledMessage());
|
||||||
boosWarmUpManager.cancelWarmUps(player);
|
boosWarmUpManager.cancelWarmUps(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,22 +61,26 @@ public class boosCoolDownManager {
|
|||||||
// clear cooldown
|
// clear cooldown
|
||||||
cooldown.clear();
|
cooldown.clear();
|
||||||
if (confusers.getKeys("users." + players.get(i) + ".cooldown") != null) {
|
if (confusers.getKeys("users." + players.get(i) + ".cooldown") != null) {
|
||||||
cooldown.addAll(confusers.getKeys("users." + players.get(i) + ".cooldown"));
|
cooldown.addAll(confusers.getKeys("users." + players.get(i)
|
||||||
|
+ ".cooldown"));
|
||||||
}
|
}
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (j < cooldown.size()) {
|
while (j < cooldown.size()) {
|
||||||
confusers.removeProperty("users." + players.get(i) + ".cooldown." + cooldown.get(j));
|
confusers.removeProperty("users." + players.get(i)
|
||||||
|
+ ".cooldown." + cooldown.get(j));
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
confusers.removeProperty("users." + players.get(i) + ".cooldown");
|
confusers.removeProperty("users." + players.get(i) + ".cooldown");
|
||||||
// clear warmup
|
// clear warmup
|
||||||
warmup.clear();
|
warmup.clear();
|
||||||
if (confusers.getKeys("users." + players.get(i) + ".warmup") != null) {
|
if (confusers.getKeys("users." + players.get(i) + ".warmup") != null) {
|
||||||
warmup.addAll(confusers.getKeys("users." + players.get(i) + ".warmup"));
|
warmup.addAll(confusers.getKeys("users." + players.get(i)
|
||||||
|
+ ".warmup"));
|
||||||
}
|
}
|
||||||
int k = 0;
|
int k = 0;
|
||||||
while (k < warmup.size()) {
|
while (k < warmup.size()) {
|
||||||
confusers.removeProperty("users." + players.get(i) + ".warmup." + warmup.get(k));
|
confusers.removeProperty("users." + players.get(i) + ".warmup."
|
||||||
|
+ warmup.get(k));
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
confusers.removeProperty("users." + players.get(i) + ".warmup");
|
confusers.removeProperty("users." + players.get(i) + ".warmup");
|
||||||
@ -103,8 +107,8 @@ public class boosCoolDownManager {
|
|||||||
callastTime.setTime(lastTime);
|
callastTime.setTime(lastTime);
|
||||||
long secondsBetween = secondsBetween(callastTime, calcurrTime);
|
long secondsBetween = secondsBetween(callastTime, calcurrTime);
|
||||||
long waitSeconds = coolDownSeconds - secondsBetween;
|
long waitSeconds = coolDownSeconds - secondsBetween;
|
||||||
long waitMinutes = Math.round(waitSeconds / 60)+1;
|
long waitMinutes = Math.round(waitSeconds / 60) + 1;
|
||||||
long waitHours = Math.round(waitMinutes / 60)+1;
|
long waitHours = Math.round(waitMinutes / 60) + 1;
|
||||||
if (secondsBetween > coolDownSeconds) {
|
if (secondsBetween > coolDownSeconds) {
|
||||||
setTime(player, pre);
|
setTime(player, pre);
|
||||||
return false;
|
return false;
|
||||||
@ -112,14 +116,20 @@ public class boosCoolDownManager {
|
|||||||
String msg = boosConfigManager.getCoolDownMessage();
|
String msg = boosConfigManager.getCoolDownMessage();
|
||||||
msg = msg.replaceAll("&command&", pre);
|
msg = msg.replaceAll("&command&", pre);
|
||||||
if (waitSeconds >= 60 && 3600 >= waitSeconds) {
|
if (waitSeconds >= 60 && 3600 >= waitSeconds) {
|
||||||
msg = msg.replaceAll("&seconds&", Long.toString(waitMinutes));
|
msg = msg.replaceAll("&seconds&",
|
||||||
msg = msg.replaceAll("&unit&", boosConfigManager.getUnitMinutesMessage());
|
Long.toString(waitMinutes));
|
||||||
|
msg = msg.replaceAll("&unit&",
|
||||||
|
boosConfigManager.getUnitMinutesMessage());
|
||||||
} else if (waitMinutes >= 60) {
|
} else if (waitMinutes >= 60) {
|
||||||
msg = msg.replaceAll("&seconds&", Long.toString(waitHours));
|
msg = msg.replaceAll("&seconds&",
|
||||||
msg = msg.replaceAll("&unit&", boosConfigManager.getUnitHoursMessage());
|
Long.toString(waitHours));
|
||||||
|
msg = msg.replaceAll("&unit&",
|
||||||
|
boosConfigManager.getUnitHoursMessage());
|
||||||
} else {
|
} else {
|
||||||
msg = msg.replaceAll("&seconds&", Long.toString(waitSeconds));
|
msg = msg.replaceAll("&seconds&",
|
||||||
msg = msg.replaceAll("&unit&", boosConfigManager.getUnitSecondsMessage());
|
Long.toString(waitSeconds));
|
||||||
|
msg = msg.replaceAll("&unit&",
|
||||||
|
boosConfigManager.getUnitSecondsMessage());
|
||||||
}
|
}
|
||||||
boosChat.sendMessageToPlayer(player, msg);
|
boosChat.sendMessageToPlayer(player, msg);
|
||||||
return true;
|
return true;
|
||||||
@ -132,10 +142,12 @@ public class boosCoolDownManager {
|
|||||||
static void cancelCoolDowns(Player player) {
|
static void cancelCoolDowns(Player player) {
|
||||||
List<String> cooldown = new LinkedList<String>();
|
List<String> cooldown = new LinkedList<String>();
|
||||||
cooldown.clear();
|
cooldown.clear();
|
||||||
cooldown.addAll(confusers.getKeys("users." + player.getName() + ".cooldown"));
|
cooldown.addAll(confusers.getKeys("users." + player.getName()
|
||||||
|
+ ".cooldown"));
|
||||||
int j = 0;
|
int j = 0;
|
||||||
while (j < cooldown.size()) {
|
while (j < cooldown.size()) {
|
||||||
confusers.removeProperty("users." + player.getName() + ".cooldown." + cooldown.get(j));
|
confusers.removeProperty("users." + player.getName() + ".cooldown."
|
||||||
|
+ cooldown.get(j));
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
confusers.removeProperty("users." + player.getName() + ".cooldown");
|
confusers.removeProperty("users." + player.getName() + ".cooldown");
|
||||||
@ -155,22 +167,28 @@ public class boosCoolDownManager {
|
|||||||
callastTime.setTime(lastTime);
|
callastTime.setTime(lastTime);
|
||||||
long secondsBetween = secondsBetween(callastTime, calcurrTime);
|
long secondsBetween = secondsBetween(callastTime, calcurrTime);
|
||||||
long waitSeconds = coolDownSeconds - secondsBetween;
|
long waitSeconds = coolDownSeconds - secondsBetween;
|
||||||
long waitMinutes = Math.round(waitSeconds / 60)+1;
|
long waitMinutes = Math.round(waitSeconds / 60) + 1;
|
||||||
long waitHours = Math.round(waitMinutes / 60)+1;
|
long waitHours = Math.round(waitMinutes / 60) + 1;
|
||||||
if (secondsBetween > coolDownSeconds) {
|
if (secondsBetween > coolDownSeconds) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
String msg = boosConfigManager.getCoolDownMessage();
|
String msg = boosConfigManager.getCoolDownMessage();
|
||||||
msg = msg.replaceAll("&command&", pre);
|
msg = msg.replaceAll("&command&", pre);
|
||||||
if (waitSeconds >= 60 && 3600 >= waitSeconds) {
|
if (waitSeconds >= 60 && 3600 >= waitSeconds) {
|
||||||
msg = msg.replaceAll("&seconds&", Long.toString(waitMinutes));
|
msg = msg.replaceAll("&seconds&",
|
||||||
msg = msg.replaceAll("&unit&", boosConfigManager.getUnitMinutesMessage());
|
Long.toString(waitMinutes));
|
||||||
|
msg = msg.replaceAll("&unit&",
|
||||||
|
boosConfigManager.getUnitMinutesMessage());
|
||||||
} else if (waitMinutes >= 60) {
|
} else if (waitMinutes >= 60) {
|
||||||
msg = msg.replaceAll("&seconds&", Long.toString(waitHours));
|
msg = msg.replaceAll("&seconds&",
|
||||||
msg = msg.replaceAll("&unit&", boosConfigManager.getUnitHoursMessage());
|
Long.toString(waitHours));
|
||||||
|
msg = msg.replaceAll("&unit&",
|
||||||
|
boosConfigManager.getUnitHoursMessage());
|
||||||
} else {
|
} else {
|
||||||
msg = msg.replaceAll("&seconds&", Long.toString(waitSeconds));
|
msg = msg.replaceAll("&seconds&",
|
||||||
msg = msg.replaceAll("&unit&", boosConfigManager.getUnitSecondsMessage());
|
Long.toString(waitSeconds));
|
||||||
|
msg = msg.replaceAll("&unit&",
|
||||||
|
boosConfigManager.getUnitSecondsMessage());
|
||||||
}
|
}
|
||||||
boosChat.sendMessageToPlayer(player, msg);
|
boosChat.sendMessageToPlayer(player, msg);
|
||||||
return false;
|
return false;
|
||||||
@ -186,7 +204,8 @@ public class boosCoolDownManager {
|
|||||||
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());
|
||||||
confusers.setProperty("users." + player.getName() + ".cooldown." + pre, currTime);
|
confusers.setProperty("users." + player.getName() + ".cooldown." + pre,
|
||||||
|
currTime);
|
||||||
confusers.save();
|
confusers.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,9 +227,10 @@ public class boosCoolDownManager {
|
|||||||
static Date getTime(Player player, String pre) {
|
static Date getTime(Player player, String pre) {
|
||||||
pre = pre.toLowerCase();
|
pre = pre.toLowerCase();
|
||||||
String confTime = "";
|
String confTime = "";
|
||||||
confTime = confusers.getString("users." + player.getName() + ".cooldown." + pre, null);
|
confTime = confusers.getString("users." + player.getName()
|
||||||
|
+ ".cooldown." + pre, 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;
|
||||||
|
|
||||||
@ -236,14 +256,16 @@ public class boosCoolDownManager {
|
|||||||
|
|
||||||
static void setWarmUpOK(Player player, String pre, String message) {
|
static void setWarmUpOK(Player player, String pre, String message) {
|
||||||
pre = pre.toLowerCase();
|
pre = pre.toLowerCase();
|
||||||
confusers.setProperty("users." + player.getName() + ".warmup." + pre, 1);
|
confusers
|
||||||
|
.setProperty("users." + player.getName() + ".warmup." + pre, 1);
|
||||||
confusers.save();
|
confusers.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean checkWarmUpOK(Player player, String pre, String message) {
|
static boolean checkWarmUpOK(Player player, String pre, String message) {
|
||||||
pre = pre.toLowerCase();
|
pre = pre.toLowerCase();
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
ok = confusers.getInt("users." + player.getName() + ".warmup." + pre, ok);
|
ok = confusers.getInt("users." + player.getName() + ".warmup." + pre,
|
||||||
|
ok);
|
||||||
if (ok == 1) {
|
if (ok == 1) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -252,7 +274,8 @@ public class boosCoolDownManager {
|
|||||||
|
|
||||||
static void removeWarmUpOK(Player player, String pre, String message) {
|
static void removeWarmUpOK(Player player, String pre, String message) {
|
||||||
pre = pre.toLowerCase();
|
pre = pre.toLowerCase();
|
||||||
confusers.removeProperty("users." + player.getName() + ".warmup." + pre);
|
confusers
|
||||||
|
.removeProperty("users." + player.getName() + ".warmup." + pre);
|
||||||
confusers.save();
|
confusers.save();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
|
|
||||||
//import org.bukkit.event.entity.EntityDamageEvent;
|
//import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
|
|
||||||
public class boosCoolDownPlayerListener extends PlayerListener {
|
public class boosCoolDownPlayerListener extends PlayerListener {
|
||||||
private final boosCoolDown plugin;
|
private final boosCoolDown plugin;
|
||||||
|
|
||||||
@ -23,65 +22,69 @@ public class boosCoolDownPlayerListener extends PlayerListener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
boolean on = true;
|
boolean on = true;
|
||||||
|
|
||||||
if(player.isOp()) {
|
if (player.isOp()) {
|
||||||
on = false;
|
on = false;
|
||||||
}
|
}
|
||||||
if(player.hasPermission("boosCoolDown.exception") || player.isOp()) {
|
if (player.hasPermission("boosCoolDown.exception") || player.isOp()) {
|
||||||
on = false;
|
on = false;
|
||||||
} else {
|
} else {
|
||||||
on = true;
|
on = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (on) {
|
||||||
if(on) {
|
|
||||||
int i = message.indexOf(' ');
|
int i = message.indexOf(' ');
|
||||||
if(i < 0) { i = message.length(); }
|
if (i < 0) {
|
||||||
|
i = message.length();
|
||||||
|
}
|
||||||
|
|
||||||
String preCommand = message.substring(0, i);
|
String preCommand = message.substring(0, i);
|
||||||
String messageCommand = message.substring(i, message.length());
|
String messageCommand = message.substring(i, message.length());
|
||||||
|
|
||||||
boolean onCooldown = this.checkCooldown(event, player, preCommand, messageCommand);
|
boolean onCooldown = this.checkCooldown(event, player, preCommand,
|
||||||
|
messageCommand);
|
||||||
|
|
||||||
if (!onCooldown && messageCommand.length() > 1) {
|
if (!onCooldown && messageCommand.length() > 1) {
|
||||||
int j = messageCommand.indexOf(' ', 1);
|
int j = messageCommand.indexOf(' ', 1);
|
||||||
if(j < 0) { j = messageCommand.length(); }
|
if (j < 0) {
|
||||||
|
j = messageCommand.length();
|
||||||
|
}
|
||||||
|
|
||||||
String preSub = messageCommand.substring(1, j);
|
String preSub = messageCommand.substring(1, j);
|
||||||
String messageSub = messageCommand.substring(j, messageCommand.length());
|
String messageSub = messageCommand.substring(j,
|
||||||
preSub = preCommand+' '+preSub;
|
messageCommand.length());
|
||||||
|
preSub = preCommand + ' ' + preSub;
|
||||||
|
|
||||||
onCooldown = this.checkCooldown(event, player, preSub, messageSub);
|
onCooldown = this.checkCooldown(event, player, preSub,
|
||||||
|
messageSub);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the command is on cooldown, false otherwise
|
// Returns true if the command is on cooldown, false otherwise
|
||||||
private boolean checkCooldown(PlayerCommandPreprocessEvent event, Player player, String pre, String message) {
|
private boolean checkCooldown(PlayerCommandPreprocessEvent event,
|
||||||
|
Player player, String pre, String message) {
|
||||||
int warmUpSeconds = boosConfigManager.getWarmUp(player, pre);
|
int warmUpSeconds = boosConfigManager.getWarmUp(player, pre);
|
||||||
if(warmUpSeconds > 0) {
|
if (warmUpSeconds > 0) {
|
||||||
if(!boosCoolDownManager.checkWarmUpOK(player, pre, message)) {
|
if (!boosCoolDownManager.checkWarmUpOK(player, pre, message)) {
|
||||||
if(boosCoolDownManager.checkCoolDownOK(player, pre, message)) {
|
if (boosCoolDownManager.checkCoolDownOK(player, pre, message)) {
|
||||||
boosWarmUpManager.startWarmUp(this.plugin, player, pre, message, warmUpSeconds);
|
boosWarmUpManager.startWarmUp(this.plugin, player, pre,
|
||||||
|
message, warmUpSeconds);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
} else {
|
||||||
|
if (boosCoolDownManager.coolDown(player, pre, message)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(boosCoolDownManager.coolDown(player, pre, message)) {
|
|
||||||
event.setCancelled(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
boosCoolDownManager.removeWarmUpOK(player, pre, message);
|
boosCoolDownManager.removeWarmUpOK(player, pre, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
if (boosCoolDownManager.coolDown(player, pre, message)) {
|
||||||
if(boosCoolDownManager.coolDown(player, pre, message)) {
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -12,39 +12,44 @@ public class boosWarmUpManager {
|
|||||||
|
|
||||||
static Timer scheduler;
|
static Timer scheduler;
|
||||||
|
|
||||||
public static void startWarmUp(boosCoolDown bCoolDown, Player player, String pre, String message, int warmUpSeconds) {
|
public static void startWarmUp(boosCoolDown bCoolDown, Player player,
|
||||||
|
String pre, String message, int warmUpSeconds) {
|
||||||
pre = pre.toLowerCase();
|
pre = pre.toLowerCase();
|
||||||
long warmUpMinutes = Math.round(warmUpSeconds / 60)+1;
|
long warmUpMinutes = Math.round(warmUpSeconds / 60) + 1;
|
||||||
long warmUpHours = Math.round(warmUpMinutes / 60)+1;
|
long warmUpHours = Math.round(warmUpMinutes / 60) + 1;
|
||||||
if(!isWarmUpProcess(player, pre, message)) {
|
if (!isWarmUpProcess(player, pre, message)) {
|
||||||
boosCoolDownManager.removeWarmUpOK(player, pre, message);
|
boosCoolDownManager.removeWarmUpOK(player, pre, message);
|
||||||
String msg = boosConfigManager.getWarmUpMessage();
|
String msg = boosConfigManager.getWarmUpMessage();
|
||||||
msg = msg.replaceAll("&command&", pre);
|
msg = msg.replaceAll("&command&", pre);
|
||||||
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&", boosConfigManager.getUnitMinutesMessage());
|
msg = msg.replaceAll("&unit&",
|
||||||
|
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&", boosConfigManager.getUnitHoursMessage());
|
msg = msg.replaceAll("&unit&",
|
||||||
|
boosConfigManager.getUnitHoursMessage());
|
||||||
} else {
|
} else {
|
||||||
msg = msg.replaceAll("&seconds&", Long.toString(warmUpSeconds));
|
msg = msg.replaceAll("&seconds&", Long.toString(warmUpSeconds));
|
||||||
msg = msg.replaceAll("&unit&", boosConfigManager.getUnitSecondsMessage());
|
msg = msg.replaceAll("&unit&",
|
||||||
|
boosConfigManager.getUnitSecondsMessage());
|
||||||
}
|
}
|
||||||
boosChat.sendMessageToPlayer(player, msg);
|
boosChat.sendMessageToPlayer(player, msg);
|
||||||
|
|
||||||
scheduler = new Timer();
|
scheduler = new Timer();
|
||||||
boosWarmUpTimer scheduleMe = new boosWarmUpTimer(bCoolDown, scheduler, player, pre, message);
|
boosWarmUpTimer scheduleMe = new boosWarmUpTimer(bCoolDown,
|
||||||
|
scheduler, player, pre, message);
|
||||||
playercommands.put(player.getName() + "@" + pre, scheduleMe);
|
playercommands.put(player.getName() + "@" + pre, scheduleMe);
|
||||||
scheduler.schedule(scheduleMe, warmUpSeconds * 1000);
|
scheduler.schedule(scheduleMe, warmUpSeconds * 1000);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
String msg = boosConfigManager.getWarmUpAlreadyStartedMessage();
|
String msg = boosConfigManager.getWarmUpAlreadyStartedMessage();
|
||||||
msg = msg.replaceAll("&command&", pre);
|
msg = msg.replaceAll("&command&", pre);
|
||||||
boosChat.sendMessageToPlayer(player, msg);
|
boosChat.sendMessageToPlayer(player, msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isWarmUpProcess(Player player, String pre, String message) {
|
public static boolean isWarmUpProcess(Player player, String pre,
|
||||||
|
String message) {
|
||||||
pre = pre.toLowerCase();
|
pre = pre.toLowerCase();
|
||||||
if (playercommands.containsKey(player.getName() + "@" + pre)) {
|
if (playercommands.containsKey(player.getName() + "@" + pre)) {
|
||||||
return true;
|
return true;
|
||||||
@ -57,16 +62,16 @@ public class boosWarmUpManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void cancelWarmUps(Player player) {
|
public static void cancelWarmUps(Player player) {
|
||||||
for(String key: playercommands.keySet()) {
|
for (String key : playercommands.keySet()) {
|
||||||
if(key.startsWith(player.getName() + "@")) {
|
if (key.startsWith(player.getName() + "@")) {
|
||||||
removeWarmUpProcess(key);
|
removeWarmUpProcess(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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.getName() + "@")) {
|
if (key.startsWith(player.getName() + "@")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import java.util.TimerTask;
|
|||||||
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public class boosWarmUpTimer extends TimerTask {
|
public class boosWarmUpTimer extends TimerTask {
|
||||||
|
|
||||||
boosCoolDown bCoolDown;
|
boosCoolDown bCoolDown;
|
||||||
@ -13,19 +12,22 @@ public class boosWarmUpTimer extends TimerTask {
|
|||||||
String pre;
|
String pre;
|
||||||
String message;
|
String message;
|
||||||
|
|
||||||
public boosWarmUpTimer(boosCoolDown bCoolDown, Timer timer, Player player, String pre, String message){
|
public boosWarmUpTimer(boosCoolDown bCoolDown, Timer timer, Player player,
|
||||||
|
String pre, String message) {
|
||||||
this.bCoolDown = bCoolDown;
|
this.bCoolDown = bCoolDown;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.pre = pre;
|
this.pre = pre;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boosWarmUpTimer() {
|
public boosWarmUpTimer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
if(player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
boosCoolDownManager.setWarmUpOK(player, pre, message);
|
boosCoolDownManager.setWarmUpOK(player, pre, message);
|
||||||
boosWarmUpManager.removeWarmUpProcess(this.player.getName() + "@" + pre);
|
boosWarmUpManager.removeWarmUpProcess(this.player.getName() + "@"
|
||||||
|
+ pre);
|
||||||
player.chat(pre + message);
|
player.chat(pre + message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user