Fixed SetUses, Fixed Interact Blocking during warmup, Fixed lag

This commit is contained in:
Boos 2012-05-12 03:50:58 +02:00
parent b13e53e434
commit 88ed363774
3 changed files with 62 additions and 68 deletions

View File

@ -40,16 +40,8 @@ public class boosCoolDownListener<a> implements Listener {
on = isPluginOnForPlayer(player); on = isPluginOnForPlayer(player);
if (on) { if (on) {
playerloc.put(player, player.getLocation());
playerworld.put(player, player.getWorld().getName());
int i = message.indexOf(' ');
if (i < 0) {
i = message.length();
}
String preCommand = message.substring(0, i);
String messageCommand = message.substring(i, message.length());
boolean used = false; boolean used = false;
String messageCommand = "";
String preSub = ""; String preSub = "";
String preSub2 = ""; String preSub2 = "";
String preSub3 = ""; String preSub3 = "";
@ -59,59 +51,61 @@ public class boosCoolDownListener<a> implements Listener {
int preSubCheck = -1; int preSubCheck = -1;
int preSubCheck2 = -1; int preSubCheck2 = -1;
int preSubCheck3 = -1; int preSubCheck3 = -1;
if (!used && messageCommand.length() > 1) { playerloc.put(player, player.getLocation());
int j = messageCommand.indexOf(' ', 1); playerworld.put(player, player.getWorld().getName());
if (j < 0) { String[] splitCommand;
j = messageCommand.length(); splitCommand = message.split(" ");
} String preCommand = splitCommand[0];
preSub = messageCommand.substring(1, j); if (splitCommand.length > 1){
messageSub = messageCommand.substring(j, for (int i = 1; i < splitCommand.length; i++) {
messageCommand.length()); messageCommand = messageCommand + " " + splitCommand[i];
preSub = preCommand + ' ' + preSub; }}
} if (splitCommand.length > 1){
if (messageSub.length() > 1) { preSub = splitCommand[0] + " " + splitCommand[1];
int k = messageSub.indexOf(' ', 1); for (int i = 2; i < splitCommand.length; i++) {
if (k < 0) { messageSub = messageSub + " " + splitCommand[i];
k = messageSub.length(); }}
} if (splitCommand.length > 2){
preSub2 = messageSub.substring(1, k); preSub2 = splitCommand[0] + " " + splitCommand[1] + " " + splitCommand[2];
messageSub2 = messageSub.substring(k, messageSub.length()); for (int i = 3; i < splitCommand.length; i++) {
preSub2 = preCommand + ' ' + preSub + ' ' + preSub2; messageSub2 = messageSub2 + " " + splitCommand[i];
} }}
if (messageSub2.length() > 1) { if (splitCommand.length > 3){
int l = messageSub2.indexOf(' ', 1); preSub3 = splitCommand[0] + " " + splitCommand[1] + " " + splitCommand[2] + " " + splitCommand[3];
if (l < 0) { for (int i = 4; i < splitCommand.length; i++) {
l = messageSub2.length(); messageSub3 = messageSub3 + " " + splitCommand[i];
} }}
preSub3 = messageSub2.substring(1, l);
messageSub3 = messageSub2.substring(l, messageSub2.length()); if(preSub3 != null){
preSub3 = preCommand + ' ' + preSub + ' ' + preSub2 + ' '
+ preSub3;
}
preSubCheck3 = preSubCheck(player, preSub3); preSubCheck3 = preSubCheck(player, preSub3);
if(preSubCheck3 < 0){
if (preCDCheck(player, preSub3) > 0) { if (preCDCheck(player, preSub3) > 0) {
preSubCheck3 = 0; preSubCheck3 = 0;
} else if (prePriceCheck(player, preSub3) > 0) { } else if (prePriceCheck(player, preSub3) > 0) {
preSubCheck3 = 0; preSubCheck3 = 0;
} else if (preLimitCheck(player, preSub3) > 0) { } else if (preLimitCheck(player, preSub3) > 0) {
preSubCheck3 = 0; preSubCheck3 = 0;
} }}}
if(preSub2 != null && preSubCheck3 < 0){
preSubCheck2 = preSubCheck(player, preSub2); preSubCheck2 = preSubCheck(player, preSub2);
if(preSubCheck2 < 0){
if (preCDCheck(player, preSub2) > 0) { if (preCDCheck(player, preSub2) > 0) {
preSubCheck2 = 0; preSubCheck2 = 0;
} else if (prePriceCheck(player, preSub2) > 0) { } else if (prePriceCheck(player, preSub2) > 0) {
preSubCheck2 = 0; preSubCheck2 = 0;
} else if (preLimitCheck(player, preSub2) > 0) { } else if (preLimitCheck(player, preSub2) > 0) {
preSubCheck2 = 0; preSubCheck2 = 0;
} }}}
if(preSub != null && preSubCheck2 < 0){
preSubCheck = preSubCheck(player, preSub); preSubCheck = preSubCheck(player, preSub);
if(preSubCheck < 0){
if (preCDCheck(player, preSub2) > 0) { if (preCDCheck(player, preSub2) > 0) {
preSubCheck = 0; preSubCheck = 0;
} else if (prePriceCheck(player, preSub) > 0) { } else if (prePriceCheck(player, preSub) > 0) {
preSubCheck = 0; preSubCheck = 0;
} else if (preLimitCheck(player, preSub) > 0) { } else if (preLimitCheck(player, preSub) > 0) {
preSubCheck = 0; preSubCheck = 0;
} }}}
if (preSubCheck3 >= 0) { if (preSubCheck3 >= 0) {
blocked = blocked(player, preSub3, messageSub3); blocked = blocked(player, preSub3, messageSub3);
this.checkCooldown(event, player, preSub3, messageSub3); this.checkCooldown(event, player, preSub3, messageSub3);
@ -237,7 +231,7 @@ public class boosCoolDownListener<a> implements Listener {
private boolean blocked(Player player, String pre, String msg) { private boolean blocked(Player player, String pre, String msg) {
boolean blocked = false; boolean blocked = false;
int limit = -1; int limit = -1;
int uses = boosCoolDownManager.getUses(player, pre); int uses = boosCoolDownManager.getUses(player, pre, msg);
if (boosCoolDown.isUsingPermissions()) { if (boosCoolDown.isUsingPermissions()) {
if (boosCoolDown.getPermissions().has(player, if (boosCoolDown.getPermissions().has(player,
"booscooldowns.nolimit") "booscooldowns.nolimit")
@ -600,26 +594,26 @@ public class boosCoolDownListener<a> implements Listener {
&& !boosCoolDown.getPermissions().has(player, && !boosCoolDown.getPermissions().has(player,
"booscooldowns.dontblock.interact")) { "booscooldowns.dontblock.interact")) {
if (boosWarmUpManager.hasWarmUps(player)) { if (boosWarmUpManager.hasWarmUps(player)) {
if (event.getClickedBlock().getType().equals("CHEST") if (event.getClickedBlock().getType().name().equals("CHEST")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("FURNACE") .equals("FURNACE")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("BURNING_FURNACE") .equals("BURNING_FURNACE")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("WORKBENCH") .equals("WORKBENCH")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("DISPENSER") .equals("DISPENSER")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("JUKEBOX") .equals("JUKEBOX")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("LOCKED_CHEST") .equals("LOCKED_CHEST")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("ENCHANTMENT_TABLE") .equals("ENCHANTMENT_TABLE")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("BREWING_STAND") .equals("BREWING_STAND")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("CAULDRON") .equals("CAULDRON")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("STORAGE_MINECART")) { .equals("STORAGE_MINECART")) {
event.setCancelled(true); event.setCancelled(true);
boosChat.sendMessageToPlayer(player, boosChat.sendMessageToPlayer(player,
@ -632,26 +626,26 @@ public class boosCoolDownListener<a> implements Listener {
} else { } else {
if (player != null) { if (player != null) {
if (boosWarmUpManager.hasWarmUps(player)) { if (boosWarmUpManager.hasWarmUps(player)) {
if (event.getClickedBlock().getType().equals("CHEST") if (event.getClickedBlock().getType().name().equals("CHEST")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("FURNACE") .equals("FURNACE")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("BURNING_FURNACE") .equals("BURNING_FURNACE")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("WORKBENCH") .equals("WORKBENCH")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("DISPENSER") .equals("DISPENSER")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("JUKEBOX") .equals("JUKEBOX")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("LOCKED_CHEST") .equals("LOCKED_CHEST")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("ENCHANTMENT_TABLE") .equals("ENCHANTMENT_TABLE")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("BREWING_STAND") .equals("BREWING_STAND")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("CAULDRON") .equals("CAULDRON")
|| event.getClickedBlock().getType() || event.getClickedBlock().getType().name()
.equals("STORAGE_MINECART")) { .equals("STORAGE_MINECART")) {
event.setCancelled(true); event.setCancelled(true);
boosChat.sendMessageToPlayer(player, boosChat.sendMessageToPlayer(player,

View File

@ -335,17 +335,17 @@ public class boosCoolDownManager {
static void setUses(Player player, String pre, String message) { static void setUses(Player player, String pre, String message) {
pre = pre.toLowerCase(); pre = pre.toLowerCase();
int uses = getUses(player, pre); int uses = getUses(player, pre, message);
uses = uses + 1; uses = uses + 1;
confusers.set("users." + player.getName() + ".uses." + pre + message, confusers.set("users." + player.getName() + ".uses." + pre + message,
uses); uses);
save(); save();
} }
static int getUses(Player player, String pre) { static int getUses(Player player, String pre, String message) {
pre = pre.toLowerCase(); pre = pre.toLowerCase();
int uses = 0; int uses = 0;
uses = confusers.getInt("users." + player.getName() + ".uses." + pre, uses = confusers.getInt("users." + player.getName() + ".uses." + pre + message,
uses); uses);
return uses; return uses;
} }

View File

@ -1,6 +1,6 @@
name: boosCooldown name: boosCooldown
main: cz.boosik.boosCooldown.boosCoolDown main: cz.boosik.boosCooldown.boosCoolDown
version: 2.6.6 version: 2.6.7
author: boosik author: boosik
softdepend: [Vault,PermissionsEX] softdepend: [Vault,PermissionsEX]
description: > description: >