In MapleCharacter:
Add this variable:
PHP Code:
private int jailtime;
Add this in loadCharFromDb:
PHP Code:
ret.jailtime = rs.getInt("jailtime");
Add this with all the other things in saveToDb (I don't feel like showing you how to add...)
Add these methods in MapleCharacter:
PHP Code:
public void setJailTime(int x) {
this.jailtime = x;
}
public int getJailTime() {
return this.jailtime;
}
public boolean inJail() {
return getMapId() == 200090300;
}
public void jail(int minutes) {
changeMap(200090300, 0);
this.canTalk = false;
jailTimeReset();
setJailTime(minutes);
}
public void unJail() {
if (getMapId() == 200090300) {
changeMap(100000000, 0);
this.canTalk = true;
dropMessage("You have been unjailed");
}
}
public void jailTimeReset() {
TimerManager.getInstance().schedule(new Runnable() {
public void run() {
if (inJail() && getJailTime() > 0) { // If not in Jail Map / do not have any jail time does nothing
setJailTime(getJailTime() - 1);
dropMessage(5, "One minute has passed. You now have " + getJailTime() + " minutes left to go.");
jailTimeReset();
if (getJailTime() <= 0) {
unJail();
}
}
}
}, 1 * 60 * 1000);
}
Add this in PlayerLoggedInHandler:
PHP Code:
if (player.inJail() && player.getJailTime() > 0) {
player.message("You have scheduled jailtime for " + player.getJailTime() + " minutes. You will have to make up for jail-time you have missed if you have log off.");
player.jailTimeReset();
}
Add these commands to temp jail / perm jail:
PHP Code:
} else if (splitted[0].equals("!permjail")) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
if (victim != null) {
victim.jail(-1);
victim.message("You have been permenently jailed, but your account is not banned. This character will not be available any longer.");
} else {
player.message("The player is not in this channel or offline.");
}
} else if (splitted[0].equals("!tempjail")) {
MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
if (victim != null) {
if (!splitted[3].equalsIgnoreCase("quiet")) {
try {
cserv.getWorldInterface().broadcastMessage(player.getName(), MaplePacketCreator.serverNotice(6, ServerConstants.SERVER_NAME + " Jail: " + victim.getName() + " has been jailed for " + splitted[2] + " minutes. Reason: " + StringUtil.joinStringFrom(splitted, 4)).getBytes());
} catch (RemoteException e) {
c.getChannelServer().reconnectWorld();
}
}
victim.jail(Integer.parseInt(splitted[2]));
mc.dropMessage(victim.getName() + " was temporary jailed! for " + splitted[2] + " minutes.");
victim.dropMessage(5, "You have been temporary jailed for " + splitted[2] + " minutes. You will have to make up for minutes you have missed if you log off.");
} else {
mc.dropMessage(splitted[1] + " not found!");
}