mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-16 20:41:23 +01:00
Bugfix: On join cooldowns not working correctly
This commit is contained in:
parent
f197bc2667
commit
669f94493f
@ -33,7 +33,7 @@
|
|||||||
public class EventListener implements Listener
|
public class EventListener implements Listener
|
||||||
{
|
{
|
||||||
private MinePacks plugin;
|
private MinePacks plugin;
|
||||||
private boolean drop_on_death, showCloseMessageOwn, showCloseMessageOther, onJoinCooldown;
|
private boolean drop_on_death, showCloseMessageOwn, showCloseMessageOther;
|
||||||
private long joinCooldown;
|
private long joinCooldown;
|
||||||
private String message_OwnBPClose, message_PlayerBPClose;
|
private String message_OwnBPClose, message_PlayerBPClose;
|
||||||
|
|
||||||
@ -46,7 +46,6 @@ public EventListener(MinePacks mp)
|
|||||||
showCloseMessageOther = message_PlayerBPClose != null && plugin.config.getShowCloseMessage();
|
showCloseMessageOther = message_PlayerBPClose != null && plugin.config.getShowCloseMessage();
|
||||||
showCloseMessageOwn = message_OwnBPClose != null && plugin.config.getShowCloseMessage();
|
showCloseMessageOwn = message_OwnBPClose != null && plugin.config.getShowCloseMessage();
|
||||||
joinCooldown = plugin.config.getCommandCooldownAfterJoin();
|
joinCooldown = plugin.config.getCommandCooldownAfterJoin();
|
||||||
onJoinCooldown = joinCooldown > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@ -135,9 +134,9 @@ public void onClick(InventoryClickEvent event)
|
|||||||
public void onPlayerLoginEvent(PlayerJoinEvent event)
|
public void onPlayerLoginEvent(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
plugin.DB.updatePlayerAndLoadBackpack(event.getPlayer());
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,17 +69,14 @@ public boolean onCommand(CommandSender sender, Command cmd, String arg, String[]
|
|||||||
{
|
{
|
||||||
if(gameModes.contains(player.getGameMode()) || player.hasPermission("backpack.ignoreGameMode"))
|
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);
|
plugin.openBackpack(player, player, true);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user