mirror of
https://github.com/LordBoos/boosCooldowns.git
synced 2024-11-25 12:05:25 +01:00
optimisation
This commit is contained in:
parent
bd6d6859a6
commit
046df72e38
@ -111,8 +111,13 @@ public class BoosConfigManager {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static Set<String> getAliases() {
|
static Set<String> getAliases() {
|
||||||
Set<String> aliases = conf.getConfigurationSection("commands.aliases")
|
Set<String> aliases = null;
|
||||||
.getKeys(false);
|
ConfigurationSection aliasesSection = conf
|
||||||
|
.getConfigurationSection("commands.aliases");
|
||||||
|
if (aliasesSection != null) {
|
||||||
|
aliases = conf.getConfigurationSection("commands.aliases").getKeys(
|
||||||
|
false);
|
||||||
|
}
|
||||||
return aliases;
|
return aliases;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,9 +253,12 @@ public class BoosConfigManager {
|
|||||||
*/
|
*/
|
||||||
static String getCommandGroup(Player player) {
|
static String getCommandGroup(Player player) {
|
||||||
String cmdGroup = "default";
|
String cmdGroup = "default";
|
||||||
for (String group : getCommandGroups()) {
|
Set<String> groups = getCommandGroups();
|
||||||
if (player.hasPermission("booscooldowns." + group)) {
|
if (groups != null) {
|
||||||
cmdGroup = group;
|
for (String group : groups) {
|
||||||
|
if (player.hasPermission("booscooldowns." + group)) {
|
||||||
|
cmdGroup = group;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmdGroup;
|
return cmdGroup;
|
||||||
@ -260,8 +268,12 @@ public class BoosConfigManager {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
static Set<String> getCommandGroups() {
|
static Set<String> getCommandGroups() {
|
||||||
Set<String> groups = conf.getConfigurationSection("commands.groups")
|
ConfigurationSection groupsSection = conf
|
||||||
.getKeys(false);
|
.getConfigurationSection("commands.groups");
|
||||||
|
Set<String> groups = null;
|
||||||
|
if (groupsSection != null) {
|
||||||
|
groups = groupsSection.getKeys(false);
|
||||||
|
}
|
||||||
return groups;
|
return groups;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,8 +290,12 @@ public class BoosConfigManager {
|
|||||||
*/
|
*/
|
||||||
static Set<String> getCommands(Player player) {
|
static Set<String> getCommands(Player player) {
|
||||||
String group = getCommandGroup(player);
|
String group = getCommandGroup(player);
|
||||||
Set<String> commands = conf.getConfigurationSection(
|
Set<String> commands = null;
|
||||||
"commands.groups." + group).getKeys(false);
|
ConfigurationSection commandsSection = conf
|
||||||
|
.getConfigurationSection("commands.groups." + group);
|
||||||
|
if (commandsSection != null) {
|
||||||
|
commands = commandsSection.getKeys(false);
|
||||||
|
}
|
||||||
return commands;
|
return commands;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -861,7 +877,7 @@ public class BoosConfigManager {
|
|||||||
|
|
||||||
static int parseTime(String time) {
|
static int parseTime(String time) {
|
||||||
String[] timeString = time.split(" ", 2);
|
String[] timeString = time.split(" ", 2);
|
||||||
if (timeString[0].equals("cancel")){
|
if (timeString[0].equals("cancel")) {
|
||||||
return -65535;
|
return -65535;
|
||||||
}
|
}
|
||||||
int timeNumber = Integer.valueOf(timeString[0]);
|
int timeNumber = Integer.valueOf(timeString[0]);
|
||||||
@ -886,9 +902,7 @@ public class BoosConfigManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String getLimitResetNowMessage() {
|
public static String getLimitResetNowMessage() {
|
||||||
return conf
|
return conf.getString("options.messages.limit_reset_now",
|
||||||
.getString(
|
"&6Reseting limits for command&e &command& &6now.&f");
|
||||||
"options.messages.limit_reset_now",
|
|
||||||
"&6Reseting limits for command&e &command& &6now.&f");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,8 +57,11 @@ public class BoosCoolDownListener implements Listener {
|
|||||||
Player player, String regexCommad, String originalCommand,
|
Player player, String regexCommad, String originalCommand,
|
||||||
int warmupTime, int cooldownTime, double price, String item,
|
int warmupTime, int cooldownTime, double price, String item,
|
||||||
int count, int limit, int xpPrice) {
|
int count, int limit, int xpPrice) {
|
||||||
boolean blocked = BoosLimitManager.blocked(player, regexCommad,
|
boolean blocked = false;
|
||||||
originalCommand, limit);
|
if (limit != -1) {
|
||||||
|
blocked = BoosLimitManager.blocked(player, regexCommad,
|
||||||
|
originalCommand, limit);
|
||||||
|
}
|
||||||
if (!blocked) {
|
if (!blocked) {
|
||||||
if (warmupTime > 0) {
|
if (warmupTime > 0) {
|
||||||
if (!player.hasPermission("booscooldowns.nowarmup")
|
if (!player.hasPermission("booscooldowns.nowarmup")
|
||||||
@ -180,15 +183,7 @@ public class BoosCoolDownListener implements Listener {
|
|||||||
originalCommand = originalCommand.replace("$", "S");
|
originalCommand = originalCommand.replace("$", "S");
|
||||||
originalCommand = originalCommand.trim().replaceAll(" +", " ");
|
originalCommand = originalCommand.trim().replaceAll(" +", " ");
|
||||||
String regexCommad = "";
|
String regexCommad = "";
|
||||||
Set<String> aliases = null;
|
Set<String> aliases = BoosConfigManager.getAliases();
|
||||||
try {
|
|
||||||
aliases = BoosConfigManager.getAliases();
|
|
||||||
} catch (Exception e1) {
|
|
||||||
BoosCoolDown
|
|
||||||
.getLog()
|
|
||||||
.warning(
|
|
||||||
"Aliases section in config.yml is missing! Please delete your config.yml, restart server and set it again!");
|
|
||||||
}
|
|
||||||
Set<String> commands = BoosConfigManager.getCommands(player);
|
Set<String> commands = BoosConfigManager.getCommands(player);
|
||||||
boolean on = true;
|
boolean on = true;
|
||||||
String item = "";
|
String item = "";
|
||||||
@ -199,10 +194,12 @@ public class BoosCoolDownListener implements Listener {
|
|||||||
int cooldownTime = 0;
|
int cooldownTime = 0;
|
||||||
int xpPrice = 0;
|
int xpPrice = 0;
|
||||||
on = BoosCoolDown.isPluginOnForPlayer(player);
|
on = BoosCoolDown.isPluginOnForPlayer(player);
|
||||||
originalCommand = BoosAliasManager.checkCommandAlias(originalCommand,
|
if (aliases != null) {
|
||||||
aliases, player);
|
originalCommand = BoosAliasManager.checkCommandAlias(
|
||||||
event.setMessage(originalCommand);
|
originalCommand, aliases, player);
|
||||||
if (on) {
|
event.setMessage(originalCommand);
|
||||||
|
}
|
||||||
|
if (on && commands != null) {
|
||||||
for (String group : commands) {
|
for (String group : commands) {
|
||||||
String group2 = group.replace("*", ".+");
|
String group2 = group.replace("*", ".+");
|
||||||
if (originalCommand.matches("(?i)" + group2)) {
|
if (originalCommand.matches("(?i)" + group2)) {
|
||||||
@ -237,14 +234,6 @@ public class BoosCoolDownListener implements Listener {
|
|||||||
this.checkRestrictions(event, player, regexCommad, originalCommand,
|
this.checkRestrictions(event, player, regexCommad, originalCommand,
|
||||||
warmupTime, cooldownTime, price, item, count, limit,
|
warmupTime, cooldownTime, price, item, count, limit,
|
||||||
xpPrice);
|
xpPrice);
|
||||||
try {
|
|
||||||
} catch (Exception e) {
|
|
||||||
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.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,6 +104,9 @@ public class BoosItemCostManager {
|
|||||||
if (item.equals("")) {
|
if (item.equals("")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
if (count <= 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Material material = Material.getMaterial(item);
|
Material material = Material.getMaterial(item);
|
||||||
Inventory inventory = player.getInventory();
|
Inventory inventory = player.getInventory();
|
||||||
if (inventory.contains(material, count)) {
|
if (inventory.contains(material, count)) {
|
||||||
|
@ -109,6 +109,8 @@ public class BoosPriceManager {
|
|||||||
public static boolean has(Player player, double price) {
|
public static boolean has(Player player, double price) {
|
||||||
if (economy == null) {
|
if (economy == null) {
|
||||||
return true;
|
return true;
|
||||||
|
} else if (price <= 0){
|
||||||
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return economy.has(player, price);
|
return economy.has(player, price);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cz.boosik.boosCooldown;
|
package cz.boosik.boosCooldown;
|
||||||
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Timer;
|
import java.util.Timer;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
@ -62,7 +63,8 @@ public class BoosWarmUpManager {
|
|||||||
* 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();
|
Map<String, BoosWarmUpTimer> playercommands2 = playercommands;
|
||||||
|
Iterator<String> iter = playercommands2.keySet().iterator();
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
if (iter.next().startsWith(player.getUniqueId() + "@")) {
|
if (iter.next().startsWith(player.getUniqueId() + "@")) {
|
||||||
killTimer(player);
|
killTimer(player);
|
||||||
@ -91,7 +93,8 @@ public class BoosWarmUpManager {
|
|||||||
* @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()) {
|
Map<String, BoosWarmUpTimer> playercommands2 = playercommands;
|
||||||
|
for (String key : playercommands2.keySet()) {
|
||||||
if (key.startsWith(player.getUniqueId() + "@")) {
|
if (key.startsWith(player.getUniqueId() + "@")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -149,7 +152,8 @@ public class BoosWarmUpManager {
|
|||||||
* 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()) {
|
Map<String, BoosWarmUpTimer> playercommands2 = playercommands;
|
||||||
|
for (String key : playercommands2.keySet()) {
|
||||||
if (key.startsWith(player.getUniqueId() + "@")) {
|
if (key.startsWith(player.getUniqueId() + "@")) {
|
||||||
playercommands.get(key).cancel();
|
playercommands.get(key).cancel();
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,9 @@ public class BoosXpCostManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean has(Player player, int xpPrice) {
|
public static boolean has(Player player, int xpPrice) {
|
||||||
|
if (xpPrice <= 0){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
int xp = player.getLevel();
|
int xp = player.getLevel();
|
||||||
if (xp >= xpPrice) {
|
if (xp >= xpPrice) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: boosCooldowns
|
name: boosCooldowns
|
||||||
main: cz.boosik.boosCooldown.BoosCoolDown
|
main: cz.boosik.boosCooldown.BoosCoolDown
|
||||||
version: 3.9.5
|
version: 3.9.5c
|
||||||
authors: [LordBoos (ingame name boosik)]
|
authors: [LordBoos (ingame name boosik)]
|
||||||
softdepend: [Vault]
|
softdepend: [Vault]
|
||||||
description: >
|
description: >
|
||||||
|
Loading…
Reference in New Issue
Block a user