From 669f94493f46c07ab055070524803265dac3b802 Mon Sep 17 00:00:00 2001 From: GeorgH93 Date: Sat, 3 Jun 2017 14:14:10 +0200 Subject: [PATCH] Bugfix: On join cooldowns not working correctly --- src/at/pcgamingfreaks/MinePacks/EventListener.java | 7 +++---- src/at/pcgamingfreaks/MinePacks/OnCommand.java | 13 +++++-------- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/at/pcgamingfreaks/MinePacks/EventListener.java b/src/at/pcgamingfreaks/MinePacks/EventListener.java index 348a50f..ba7e2bd 100644 --- a/src/at/pcgamingfreaks/MinePacks/EventListener.java +++ b/src/at/pcgamingfreaks/MinePacks/EventListener.java @@ -33,7 +33,7 @@ public class EventListener implements Listener { private MinePacks plugin; - private boolean drop_on_death, showCloseMessageOwn, showCloseMessageOther, onJoinCooldown; + private boolean drop_on_death, showCloseMessageOwn, showCloseMessageOther; private long joinCooldown; private String message_OwnBPClose, message_PlayerBPClose; @@ -46,7 +46,6 @@ public EventListener(MinePacks mp) showCloseMessageOther = message_PlayerBPClose != null && plugin.config.getShowCloseMessage(); showCloseMessageOwn = message_OwnBPClose != null && plugin.config.getShowCloseMessage(); joinCooldown = plugin.config.getCommandCooldownAfterJoin(); - onJoinCooldown = joinCooldown > 0; } @EventHandler @@ -135,9 +134,9 @@ public void onClick(InventoryClickEvent event) public void onPlayerLoginEvent(PlayerJoinEvent event) { plugin.DB.updatePlayerAndLoadBackpack(event.getPlayer()); - if(onJoinCooldown) + if(joinCooldown > 0 && !event.getPlayer().hasPermission("backpack.noCooldown")) { - plugin.cooldowns.put(event.getPlayer(), joinCooldown); + plugin.cooldowns.put(event.getPlayer(), System.currentTimeMillis() + joinCooldown); } } diff --git a/src/at/pcgamingfreaks/MinePacks/OnCommand.java b/src/at/pcgamingfreaks/MinePacks/OnCommand.java index 4530abc..b9455c1 100644 --- a/src/at/pcgamingfreaks/MinePacks/OnCommand.java +++ b/src/at/pcgamingfreaks/MinePacks/OnCommand.java @@ -69,17 +69,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String arg, String[] { if(gameModes.contains(player.getGameMode()) || player.hasPermission("backpack.ignoreGameMode")) { - if(cooldown > 0 && !player.hasPermission("backpack.noCooldown")) + if(!player.hasPermission("backpack.noCooldown")) { - if(plugin.cooldowns.containsKey(player)) + if(plugin.cooldowns.containsKey(player) && (System.currentTimeMillis() - plugin.cooldowns.get(player)) < 0) { - if((System.currentTimeMillis() - plugin.cooldowns.get(player)) < cooldown) - { - sender.sendMessage(messageCooldown); - return true; - } + sender.sendMessage(messageCooldown); + return true; } - plugin.cooldowns.put(player, System.currentTimeMillis()); + if(cooldown > 0) plugin.cooldowns.put(player, System.currentTimeMillis() + cooldown); } plugin.openBackpack(player, player, true); }