When unjailing someone, if they've never been online and have time
remaining then forcefully remove them.
This commit is contained in:
parent
2acfbf098e
commit
cab6d7fdf9
@ -389,4 +389,17 @@ public class PrisonerManager {
|
||||
|
||||
player.sendMessage(pl.getJailIO().getLanguageString(LangString.UNJAILED));
|
||||
}
|
||||
|
||||
public void forceUnJail(Jail jail, Cell cell, Player player, Prisoner prisoner) {
|
||||
if(player == null) {
|
||||
//Player is offline, we just forcefully remove them from the database
|
||||
pl.getJailIO().removePrisoner(jail, cell, prisoner);
|
||||
}else {
|
||||
try {
|
||||
unJail(jail, cell, player, prisoner);
|
||||
} catch (Exception e) {
|
||||
releasePrisoner(player, prisoner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.graywolf336.jail.JailManager;
|
||||
import com.graywolf336.jail.beans.Jail;
|
||||
import com.graywolf336.jail.beans.Prisoner;
|
||||
import com.graywolf336.jail.command.Command;
|
||||
import com.graywolf336.jail.command.CommandInfo;
|
||||
import com.graywolf336.jail.enums.LangString;
|
||||
@ -25,18 +26,26 @@ public class UnjailCommand implements Command {
|
||||
//Check if the player is jailed
|
||||
if(jm.isPlayerJailed(args[0])) {
|
||||
Jail j = jm.getJailPlayerIsIn(args[0]);
|
||||
Prisoner pris = j.getPrisoner(args[0]);
|
||||
Player p = jm.getPlugin().getServer().getPlayerExact(args[0]);
|
||||
|
||||
//Check if the player is on the server or not
|
||||
if(p == null) {
|
||||
//The player is not, so we'll set the remaining time to zero and do it when they login next
|
||||
j.getPrisoner(args[0]).setRemainingTime(0L);
|
||||
j.getPrisoner(args[0]).setOfflinePending(true);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.WILLBEUNJAILED, args[0]));
|
||||
//Check if the player has offline pending and their remaining time is above 0, if so then
|
||||
//forceably unjail them
|
||||
if(pris.isOfflinePending() && pris.getRemainingTime() != 0L) {
|
||||
jm.getPlugin().getPrisonerManager().forceUnJail(j, j.getCellPrisonerIsIn(args[0]), p, pris);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.FORCEUNJAILED, args[0]));
|
||||
}else {
|
||||
//The player is not, so we'll set the remaining time to zero and do it when they login next
|
||||
pris.setRemainingTime(0L);
|
||||
pris.setOfflinePending(true);
|
||||
sender.sendMessage(jm.getPlugin().getJailIO().getLanguageString(LangString.WILLBEUNJAILED, args[0]));
|
||||
}
|
||||
}else {
|
||||
//Player is online, so let's try unjailing them
|
||||
try {
|
||||
jm.getPlugin().getPrisonerManager().unJail(j, j.getCellPrisonerIsIn(args[0]), p, j.getPrisoner(args[0]));
|
||||
jm.getPlugin().getPrisonerManager().unJail(j, j.getCellPrisonerIsIn(args[0]), p, pris);
|
||||
} catch (Exception e) {
|
||||
sender.sendMessage(ChatColor.RED + e.getMessage());
|
||||
}
|
||||
|
@ -38,6 +38,8 @@ public enum LangString {
|
||||
CELLNOTEMPTY ("jailing"),
|
||||
/** The message sent when someone is jailed without a reason. */
|
||||
DEFAULTJAILEDREASON ("jailing"),
|
||||
/** The message sent when someone is unjailed yet they never came online and so they were forcefully unjailed. */
|
||||
FORCEUNJAILED ("jailing"),
|
||||
/** The message sent when players are jailed without a reason. */
|
||||
JAILED ("jailing"),
|
||||
/** The message sent when players are jailed with a reason. */
|
||||
|
@ -32,6 +32,7 @@ language:
|
||||
cantbejailed: '&cThat player can not be jailed.'
|
||||
cellnotempty: '&cThe destination cell, %0%, already has a prisoner in it.'
|
||||
defaultjailedreason: 'Breaking the rules.'
|
||||
forceunjailed: '&c%0% was jailed but never came online and was forcefully unjailed.'
|
||||
jailed: '&cYou have been jailed!'
|
||||
jailedwithreason: '&cYou have been jailed for: %0%'
|
||||
muted: '&cStop talking, you are in jail.'
|
||||
|
Loading…
Reference in New Issue
Block a user