From d691f1104b91ec4e27f857c2b4b2b5e5a94329e0 Mon Sep 17 00:00:00 2001 From: graywolf336 Date: Tue, 21 Jan 2014 14:09:18 -0600 Subject: [PATCH] If the time of the prisoner on joining is 0, then unjail them. Also, ignore the sleeping state if enabled in the config. --- .../jail/listeners/PlayerListener.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java b/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java index dab1914..ae525ac 100644 --- a/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java +++ b/src/main/java/com/graywolf336/jail/listeners/PlayerListener.java @@ -58,7 +58,7 @@ public class PlayerListener implements Listener { } } - //If the config has recieve messages set to false, let's remove all the prisoners + //If the config has receive messages set to false, let's remove all the prisoners //from getting the chat messages. if(!pl.getConfig().getBoolean(Settings.RECIEVEMESSAGES.getPath())) { if(pl.inDebug()) pl.getLogger().info("Debug - There are " + event.getRecipients().size() + " players getting the message before."); @@ -77,10 +77,23 @@ public class PlayerListener implements Listener { } @EventHandler - public void checkForOfflineJail(PlayerJoinEvent event) { + public void checkForOfflineJailStuff(PlayerJoinEvent event) { + //Let's check if the player is jailed if(pl.getJailManager().isPlayerJailed(event.getPlayer().getName())) { - if(pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName()).getPrisoner(event.getPlayer().getName()).isOfflinePending()) { + //Get the prisoner object + Prisoner p = pl.getJailManager().getJailPlayerIsIn(event.getPlayer().getName()).getPrisoner(event.getPlayer().getName()); + //Check if they're offline pending, as if this is true then they were jailed offline + if(p.isOfflinePending()) { + //Proceed with jailing the prisoner pl.getPrisonerManager().jailPrisoner(event.getPlayer().getName()); + }else if(p.getRemainingTime() == 0L) { + //If their remaining time is 0, let's unjail them + pl.getPrisonerManager().releasePrisoner(event.getPlayer(), p); + } + + //if we are ignoring a prisoner's sleeping state, then let's set that + if(pl.getConfig().getBoolean(Settings.IGNORESLEEPINGSTATE.getPath())) { + event.getPlayer().setSleepingIgnored(true); } } }