Bugfix: On join cooldowns not working correctly

This commit is contained in:
GeorgH93 2017-06-03 14:14:10 +02:00
parent f197bc2667
commit 669f94493f
2 changed files with 8 additions and 12 deletions

View File

@ -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);
}
}

View File

@ -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);
}