From 88ed36377456c2645832e363d4e16c6673ed2b64 Mon Sep 17 00:00:00 2001 From: Boos Date: Sat, 12 May 2012 03:50:58 +0200 Subject: [PATCH] Fixed SetUses, Fixed Interact Blocking during warmup, Fixed lag --- .../boosCooldown/boosCoolDownListener.java | 122 +++++++++--------- .../boosCooldown/boosCoolDownManager.java | 6 +- src/plugin.yml | 2 +- 3 files changed, 62 insertions(+), 68 deletions(-) diff --git a/src/cz/boosik/boosCooldown/boosCoolDownListener.java b/src/cz/boosik/boosCooldown/boosCoolDownListener.java index 3d30edc..db613c6 100644 --- a/src/cz/boosik/boosCooldown/boosCoolDownListener.java +++ b/src/cz/boosik/boosCooldown/boosCoolDownListener.java @@ -40,16 +40,8 @@ public class boosCoolDownListener implements Listener { on = isPluginOnForPlayer(player); 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; + String messageCommand = ""; String preSub = ""; String preSub2 = ""; String preSub3 = ""; @@ -59,59 +51,61 @@ public class boosCoolDownListener implements Listener { int preSubCheck = -1; int preSubCheck2 = -1; int preSubCheck3 = -1; - if (!used && messageCommand.length() > 1) { - int j = messageCommand.indexOf(' ', 1); - if (j < 0) { - j = messageCommand.length(); - } - preSub = messageCommand.substring(1, j); - messageSub = messageCommand.substring(j, - messageCommand.length()); - preSub = preCommand + ' ' + preSub; - } - if (messageSub.length() > 1) { - int k = messageSub.indexOf(' ', 1); - if (k < 0) { - k = messageSub.length(); - } - preSub2 = messageSub.substring(1, k); - messageSub2 = messageSub.substring(k, messageSub.length()); - preSub2 = preCommand + ' ' + preSub + ' ' + preSub2; - } - if (messageSub2.length() > 1) { - int l = messageSub2.indexOf(' ', 1); - if (l < 0) { - l = messageSub2.length(); - } - preSub3 = messageSub2.substring(1, l); - messageSub3 = messageSub2.substring(l, messageSub2.length()); - preSub3 = preCommand + ' ' + preSub + ' ' + preSub2 + ' ' - + preSub3; - } + playerloc.put(player, player.getLocation()); + playerworld.put(player, player.getWorld().getName()); + String[] splitCommand; + splitCommand = message.split(" "); + String preCommand = splitCommand[0]; + if (splitCommand.length > 1){ + for (int i = 1; i < splitCommand.length; i++) { + messageCommand = messageCommand + " " + splitCommand[i]; + }} + if (splitCommand.length > 1){ + preSub = splitCommand[0] + " " + splitCommand[1]; + for (int i = 2; i < splitCommand.length; i++) { + messageSub = messageSub + " " + splitCommand[i]; + }} + if (splitCommand.length > 2){ + preSub2 = splitCommand[0] + " " + splitCommand[1] + " " + splitCommand[2]; + for (int i = 3; i < splitCommand.length; i++) { + messageSub2 = messageSub2 + " " + splitCommand[i]; + }} + if (splitCommand.length > 3){ + preSub3 = splitCommand[0] + " " + splitCommand[1] + " " + splitCommand[2] + " " + splitCommand[3]; + for (int i = 4; i < splitCommand.length; i++) { + messageSub3 = messageSub3 + " " + splitCommand[i]; + }} + + if(preSub3 != null){ preSubCheck3 = preSubCheck(player, preSub3); + if(preSubCheck3 < 0){ if (preCDCheck(player, preSub3) > 0) { preSubCheck3 = 0; } else if (prePriceCheck(player, preSub3) > 0) { preSubCheck3 = 0; } else if (preLimitCheck(player, preSub3) > 0) { preSubCheck3 = 0; - } + }}} + if(preSub2 != null && preSubCheck3 < 0){ preSubCheck2 = preSubCheck(player, preSub2); + if(preSubCheck2 < 0){ if (preCDCheck(player, preSub2) > 0) { preSubCheck2 = 0; } else if (prePriceCheck(player, preSub2) > 0) { preSubCheck2 = 0; } else if (preLimitCheck(player, preSub2) > 0) { preSubCheck2 = 0; - } + }}} + if(preSub != null && preSubCheck2 < 0){ preSubCheck = preSubCheck(player, preSub); + if(preSubCheck < 0){ if (preCDCheck(player, preSub2) > 0) { preSubCheck = 0; } else if (prePriceCheck(player, preSub) > 0) { preSubCheck = 0; } else if (preLimitCheck(player, preSub) > 0) { preSubCheck = 0; - } + }}} if (preSubCheck3 >= 0) { blocked = blocked(player, preSub3, messageSub3); this.checkCooldown(event, player, preSub3, messageSub3); @@ -237,7 +231,7 @@ public class boosCoolDownListener implements Listener { private boolean blocked(Player player, String pre, String msg) { boolean blocked = false; int limit = -1; - int uses = boosCoolDownManager.getUses(player, pre); + int uses = boosCoolDownManager.getUses(player, pre, msg); if (boosCoolDown.isUsingPermissions()) { if (boosCoolDown.getPermissions().has(player, "booscooldowns.nolimit") @@ -600,26 +594,26 @@ public class boosCoolDownListener implements Listener { && !boosCoolDown.getPermissions().has(player, "booscooldowns.dontblock.interact")) { if (boosWarmUpManager.hasWarmUps(player)) { - if (event.getClickedBlock().getType().equals("CHEST") - || event.getClickedBlock().getType() + if (event.getClickedBlock().getType().name().equals("CHEST") + || event.getClickedBlock().getType().name() .equals("FURNACE") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("BURNING_FURNACE") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("WORKBENCH") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("DISPENSER") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("JUKEBOX") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("LOCKED_CHEST") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("ENCHANTMENT_TABLE") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("BREWING_STAND") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("CAULDRON") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("STORAGE_MINECART")) { event.setCancelled(true); boosChat.sendMessageToPlayer(player, @@ -632,26 +626,26 @@ public class boosCoolDownListener implements Listener { } else { if (player != null) { if (boosWarmUpManager.hasWarmUps(player)) { - if (event.getClickedBlock().getType().equals("CHEST") - || event.getClickedBlock().getType() + if (event.getClickedBlock().getType().name().equals("CHEST") + || event.getClickedBlock().getType().name() .equals("FURNACE") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("BURNING_FURNACE") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("WORKBENCH") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("DISPENSER") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("JUKEBOX") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("LOCKED_CHEST") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("ENCHANTMENT_TABLE") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("BREWING_STAND") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("CAULDRON") - || event.getClickedBlock().getType() + || event.getClickedBlock().getType().name() .equals("STORAGE_MINECART")) { event.setCancelled(true); boosChat.sendMessageToPlayer(player, diff --git a/src/cz/boosik/boosCooldown/boosCoolDownManager.java b/src/cz/boosik/boosCooldown/boosCoolDownManager.java index 594a881..d903eb4 100644 --- a/src/cz/boosik/boosCooldown/boosCoolDownManager.java +++ b/src/cz/boosik/boosCooldown/boosCoolDownManager.java @@ -335,17 +335,17 @@ public class boosCoolDownManager { static void setUses(Player player, String pre, String message) { pre = pre.toLowerCase(); - int uses = getUses(player, pre); + int uses = getUses(player, pre, message); uses = uses + 1; confusers.set("users." + player.getName() + ".uses." + pre + message, uses); save(); } - static int getUses(Player player, String pre) { + static int getUses(Player player, String pre, String message) { pre = pre.toLowerCase(); int uses = 0; - uses = confusers.getInt("users." + player.getName() + ".uses." + pre, + uses = confusers.getInt("users." + player.getName() + ".uses." + pre + message, uses); return uses; } diff --git a/src/plugin.yml b/src/plugin.yml index 471439a..a648660 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: boosCooldown main: cz.boosik.boosCooldown.boosCoolDown -version: 2.6.6 +version: 2.6.7 author: boosik softdepend: [Vault,PermissionsEX] description: >