Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminBan.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminBan.java (revision 3968)
- +++ java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminBan.java (working copy)
- -124,7 +124,7 @@
- L2PcInstance playerObj = L2World.getInstance().getPlayer(player);
- if (playerObj != null)
- {
- - playerObj.setInJail(true, delay);
- + playerObj.setPunishLevel(L2PcInstance.PunishLevel.JAIL, delay);
- activeChar.sendMessage("Character "+player+" jailed for "+(delay>0 ? delay+" minutes." : "ever!"));
- }
- else
- -149,7 +149,7 @@
- if (playerObj != null)
- {
- - playerObj.setInJail(false, 0);
- + playerObj.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
- activeChar.sendMessage("Character "+player+" removed from jail");
- }
- else
- -176,7 +176,7 @@
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- - PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, in_jail=?, jail_timer=? WHERE char_name=?");
- + PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
- statement.setInt(1, -114356);
- statement.setInt(2, -249645);
- statement.setInt(3, -2984);
- -212,7 +212,7 @@
- try
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- - PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, in_jail=?, jail_timer=? WHERE char_name=?");
- + PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
- statement.setInt(1, 17836);
- statement.setInt(2, 170178);
- statement.setInt(3, -3507);
- Index: java/net/sf/l2j/gameserver/ThreadPoolManager.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/ThreadPoolManager.java (revision 3968)
- +++ java/net/sf/l2j/gameserver/ThreadPoolManager.java (working copy)
- -118,6 +118,11 @@
- _aiScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.AI_MAX_THREAD, new PriorityThreadFactory("AISTPool", Thread.NORM_PRIORITY));
- }
- +
- + public boolean removeGeneral(Runnable r)
- + {
- + return _generalScheduledThreadPool.remove(r);
- + }
- public ScheduledFuture scheduleEffect(Runnable r, long delay)
- {
- Index: java/net/sf/l2j/gameserver/util/IllegalPlayerAction.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/util/IllegalPlayerAction.java (revision 3968)
- +++ java/net/sf/l2j/gameserver/util/IllegalPlayerAction.java (working copy)
- -97,7 +97,7 @@
- _actor.closeNetConnection();
- break;
- case PUNISH_JAIL:
- - _actor.setInJail(true, Config.DEFAULT_PUNISH_PARAM);
- + _actor.setPunishLevel(L2PcInstance.PunishLevel.JAIL, Config.DEFAULT_PUNISH_PARAM);
- break;
- }
- }
- Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
- ===================================================================
- --- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (revision 3968)
- +++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java (working copy)
- -215,8 +215,8 @@
- private static final String RESTORE_SKILL_SAVE = "SELECT skill_id,skill_level,effect_count,effect_cur_time, reuse_delay FROM character_skills_save WHERE char_obj_id=? AND class_index=? AND restore_type=? ORDER BY buff_index ASC";
- private static final String DELETE_SKILL_SAVE = "DELETE FROM character_skills_save WHERE char_obj_id=? AND class_index=?";
- - private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,in_jail=?,jail_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
- - private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, in_jail, jail_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
- + private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,str=?,con=?,dex=?,_int=?,men=?,wit=?,face=?,hairStyle=?,hairColor=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,rec_have=?,rec_left=?,clanid=?,maxload=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,newbie=?,nobless=?,power_grade=?,subpledge=?,last_recom_date=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=? WHERE obj_id=?";
- + private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, acc, crit, evasion, mAtk, mDef, mSpd, pAtk, pDef, pSpd, runSpd, walkSpd, str, con, dex, _int, men, wit, face, hairStyle, hairColor, sex, heading, x, y, z, movement_multiplier, attack_speed_multiplier, colRad, colHeight, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, maxload, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, char_slot, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, newbie, nobless, power_grade, subpledge, last_recom_date, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level FROM characters WHERE obj_id=?";
- private static final String RESTORE_CHAR_SUBCLASSES = "SELECT class_id,exp,sp,level,class_index FROM character_subclasses WHERE char_obj_id=? ORDER BY class_index ASC";
- private static final String ADD_CHAR_SUBCLASS = "INSERT INTO character_subclasses (char_obj_id,class_id,exp,sp,level,class_index) VALUES (?,?,?,?,?,?)";
- private static final String UPDATE_CHAR_SUBCLASS = "UPDATE character_subclasses SET exp=?,sp=?,level=?,class_id=? WHERE char_obj_id=? AND class_index =?";
- -365,9 +365,37 @@
- private boolean _isIn7sDungeon = false;
- - private boolean _inJail = false;
- - private long _jailTimer = 0;
- - private ScheduledFuture _jailTask;
- + private PunishLevel _punishLevel = PunishLevel.NONE;
- + private long _punishTimer = 0;
- + private ScheduledFuture<?> _punishTask;
- +
- + public enum PunishLevel
- + {
- + NONE(0, ""),
- + CHAT(1, "chat banned"),
- + JAIL(2, "jailed"),
- + CHAR(3, "banned"),
- + ACC(4, "banned");
- +
- + private final int punValue;
- + private final String punString;
- +
- + PunishLevel(int value, String string)
- + {
- + punValue = value;
- + punString = string;
- + }
- +
- + public int value()
- + {
- + return punValue;
- + }
- +
- + public String string()
- + {
- + return punString;
- + }
- + }
- /** Olympiad */
- private boolean _inOlympiadMode = false;
- -4715,7 +4743,7 @@
- stopWaterTask();
- stopRentPet();
- stopPvpRegTask();
- - stopJailTask(true);
- + stopPunishTask(true);
- }
- /**
- -5686,11 +5714,11 @@
- player.setSponsor(rset.getInt("sponsor"));
- player.setLvlJoinedAcademy(rset.getInt("lvl_joined_academy"));
- player.setIsIn7sDungeon((rset.getInt("isin7sdungeon")==1)? true : false);
- - player.setInJail((rset.getInt("in_jail")==1)? true : false);
- - if (player.isInJail())
- - player.setJailTimer(rset.getLong("jail_timer"));
- + player.setPunishLevel(rset.getInt("punish_level"));
- + if (player.getPunishLevel() != PunishLevel.NONE)
- + player.setPunishTimer(rset.getLong("punish_timer"));
- else
- - player.setJailTimer(0);
- + player.setPunishTimer(0);
- CursedWeaponsManager.getInstance().checkPlayer(player);
- -6046,8 +6074,8 @@
- totalOnlineTime += (System.currentTimeMillis()-_onlineBeginTime)/1000;
- statement.setLong(41, totalOnlineTime);
- - statement.setInt(42, isInJail() ? 1 : 0);
- - statement.setLong(43, getJailTimer());
- + statement.setInt(42, getPunishLevel().value());
- + statement.setLong(43, getPunishTimer());
- statement.setInt(44, isNewbie() ? 1 : 0);
- statement.setInt(45, isNoble() ? 1 : 0);
- statement.setLong(46, getPowerGrade());
- -8037,11 +8065,6 @@
- sendPacket(new EtcStatusUpdate(this));
- }
- - public boolean isChatBanned()
- - {
- - return _chatBanned;
- - }
- -
- public void setChatUnbanTask(ScheduledFuture task)
- {
- _chatUnbanTask = task;
- -8199,7 +8222,7 @@
- */
- public boolean canDuel()
- {
- - if (isInCombat() || isInJail()) { _noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_CURRENTLY_ENGAGED_IN_BATTLE; return false; }
- + if (isInCombat() || getPunishLevel() == PunishLevel.JAIL) { _noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_CURRENTLY_ENGAGED_IN_BATTLE; return false; }
- if (isDead() || isAlikeDead() || (getCurrentHp() < getMaxHp()/2 || getCurrentMp() < getMaxMp()/2)) { _noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1S_HP_OR_MP_IS_BELOW_50_PERCENT; return false; }
- if (isInDuel()) { _noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_ALREADY_ENGAGED_IN_A_DUEL; return false;}
- if (isInOlympiadMode()) { _noDuelReason = SystemMessageId.S1_CANNOT_DUEL_BECAUSE_S1_IS_PARTICIPATING_IN_THE_OLYMPIAD; return false; }
- -8775,8 +8798,7 @@
- }
- }
- - // jail task
- - updateJailState();
- + updatePunishState();
- if (_isInvul)
- sendMessage("Entering world in Invulnerable mode.");
- -9863,121 +9885,240 @@
- _queuedSkill = new SkillDat(queuedSkill, ctrlPressed, shiftPressed);
- }
- +
- + /**
- + * returns punishment level of player
- + * @return
- + */
- + public PunishLevel getPunishLevel()
- + {
- + return _punishLevel;
- + }
- + /**
- + * @return True if player is jailed
- + */
- public boolean isInJail()
- {
- - return _inJail;
- + return _punishLevel == PunishLevel.JAIL;
- }
- -
- - public void setInJail(boolean state)
- +
- + /**
- + * @return True if player is chat banned
- + */
- + public boolean isChatBanned()
- {
- - _inJail = state;
- + return _punishLevel == PunishLevel.CHAT;
- }
- +
- + public void setPunishLevel(int state)
- + {
- + switch (state){
- + case 0 :
- + {
- + _punishLevel = PunishLevel.NONE;
- + break;
- + }
- + case 1 :
- + {
- + _punishLevel = PunishLevel.CHAT;
- + break;
- + }
- + case 2 :
- + {
- + _punishLevel = PunishLevel.JAIL;
- + break;
- + }
- + case 3 :
- + {
- + _punishLevel = PunishLevel.CHAR;
- + break;
- + }
- + case 4 :
- + {
- + _punishLevel = PunishLevel.ACC;
- + break;
- + }
- + }
- + }
- - public void setInJail(boolean state, int delayInMinutes)
- + /**
- + * Sets punish level for player based on delay
- + * @param state
- + * @param delayInMinutes
- + * 0 - Indefinite
- + */
- + public void setPunishLevel(PunishLevel state, int delayInMinutes)
- {
- - _inJail = state;
- - _jailTimer = 0;
- - // Remove the task if any
- - stopJailTask(false);
- + long delayInMilliseconds = delayInMinutes * 60000L;
- + switch (state)
- + {
- + case NONE: // Remove Punishments
- + {
- + switch (_punishLevel)
- + {
- + case CHAT:
- + {
- + _punishLevel = state;
- + stopPunishTask(true);
- + sendPacket(new EtcStatusUpdate(this));
- + sendMessage("Your Chat ban has been lifted");
- + break;
- + }
- + case JAIL:
- + {
- + _punishLevel = state;
- + // Open a Html message to inform the player
- + NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
- + String jailInfos = HtmCache.getInstance().getHtm("data/html/jail_out.htm");
- + if (jailInfos != null)
- + htmlMsg.setHtml(jailInfos);
- + else
- + htmlMsg.setHtml("<html><body>You are free for now, respect server rules!</body></html>");
- + sendPacket(htmlMsg);
- + stopPunishTask(true);
- + teleToLocation(17836, 170178, -3507, true); // Floran
- + break;
- + }
- + }
- + break;
- + }
- + case CHAT: // Chat Ban
- + {
- + // not allow player to escape jail using chat ban
- + if (_punishLevel == PunishLevel.JAIL)
- + break;
- + _punishLevel = state;
- + _punishTimer = 0;
- + sendPacket(new EtcStatusUpdate(this));
- + // Remove the task if any
- + stopPunishTask(false);
- +
- + if (delayInMinutes > 0)
- + {
- + _punishTimer = delayInMilliseconds;
- +
- + // start the countdown
- + _punishTask = ThreadPoolManager.getInstance().scheduleGeneral(new PunishTask(this), _punishTimer);
- + sendMessage("You are chat banned for "+delayInMinutes+" minutes.");
- + }
- + else
- + sendMessage("You have been chat banned");
- + break;
- +
- + }
- + case JAIL: // Jail Player
- + {
- + _punishLevel = state;
- + _punishTimer = 0;
- + // Remove the task if any
- + stopPunishTask(false);
- +
- + if (delayInMinutes > 0)
- + {
- + _punishTimer = delayInMilliseconds;
- +
- + // start the countdown
- + _punishTask = ThreadPoolManager.getInstance().scheduleGeneral(new PunishTask(this), _punishTimer);
- + sendMessage("You are in jail for "+delayInMinutes+" minutes.");
- + }
- +
- + // Open a Html message to inform the player
- + NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
- + String jailInfos = HtmCache.getInstance().getHtm("data/html/jail_in.htm");
- + if (jailInfos != null)
- + htmlMsg.setHtml(jailInfos);
- + else
- + htmlMsg.setHtml("<html><body>You have been put in jail by an admin.</body></html>");
- + sendPacket(htmlMsg);
- + setIsIn7sDungeon(false);
- +
- + teleToLocation(-114356, -249645, -2984, false); // Jail
- + break;
- + }
- + case CHAR: // Ban Character
- + {
- + setAccessLevel(-100);
- + logout();
- + break;
- + }
- + case ACC: // Ban Account
- + {
- + setAccountAccesslevel(-100);
- + logout();
- + break;
- + }
- + default:
- + {
- + _punishLevel = state;
- + break;
- + }
- + }
- - if (_inJail)
- - {
- - if (delayInMinutes > 0)
- - {
- - _jailTimer = delayInMinutes * 60000L; // in millisec
- -
- - // start the countdown
- - _jailTask = ThreadPoolManager.getInstance().scheduleGeneral(new JailTask(this), _jailTimer);
- - sendMessage("You are in jail for "+delayInMinutes+" minutes.");
- - }
- -
- - // Open a Html message to inform the player
- - NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
- - String jailInfos = HtmCache.getInstance().getHtm("data/html/jail_in.htm");
- - if (jailInfos != null)
- - htmlMsg.setHtml(jailInfos);
- - else
- - htmlMsg.setHtml("<html><body>You have been put in jail by an admin.</body></html>");
- - sendPacket(htmlMsg);
- -
- - teleToLocation(-114356, -249645, -2984, true); // Jail
- - } else
- - {
- - // Open a Html message to inform the player
- - NpcHtmlMessage htmlMsg = new NpcHtmlMessage(0);
- - String jailInfos = HtmCache.getInstance().getHtm("data/html/jail_out.htm");
- - if (jailInfos != null)
- - htmlMsg.setHtml(jailInfos);
- - else
- - htmlMsg.setHtml("<html><body>You are free for now, respect server rules!</body></html>");
- - sendPacket(htmlMsg);
- -
- - teleToLocation(17836, 170178, -3507, true); // Floran
- - }
- -
- // store in database
- storeCharBase();
- }
- - public long getJailTimer()
- + public long getPunishTimer()
- {
- - return _jailTimer;
- + return _punishTimer;
- }
- - public void setJailTimer(long time)
- + public void setPunishTimer(long time)
- {
- - _jailTimer = time;
- + _punishTimer = time;
- }
- - private void updateJailState()
- + private void updatePunishState()
- {
- - if (isInJail())
- + if (getPunishLevel() != PunishLevel.NONE)
- {
- - // If jail time is elapsed, free the player
- - if (_jailTimer > 0)
- + // If punish timer exists, restart punishtask.
- + if (_punishTimer > 0)
- {
- - // restart the countdown
- - _jailTask = ThreadPoolManager.getInstance().scheduleGeneral(new JailTask(this), _jailTimer);
- - sendMessage("You are still in jail for "+Math.round(_jailTimer/60000)+" minutes.");
- + _punishTask = ThreadPoolManager.getInstance().scheduleGeneral(new PunishTask(this), _punishTimer);
- + sendMessage("You are still "+getPunishLevel().string()+" for "+Math.round(_punishTimer/60000)+" minutes.");
- }
- -
- - // If player escaped, put him back in jail
- - if (!isInsideZone(ZONE_JAIL))
- - teleToLocation(-114356,-249645,-2984, true);
- + if (getPunishLevel() == PunishLevel.JAIL)
- + {
- + // If player escaped, put him back in jail
- + if (!isInsideZone(ZONE_JAIL))
- + teleToLocation(-114356,-249645,-2984, true);
- + }
- }
- }
- - public void stopJailTask(boolean save)
- + public void stopPunishTask(boolean save)
- {
- - if (_jailTask != null)
- + if (_punishTask != null)
- {
- if (save)
- {
- - long delay = _jailTask.getDelay(TimeUnit.MILLISECONDS);
- + long delay = _punishTask.getDelay(TimeUnit.MILLISECONDS);
- if (delay < 0)
- delay = 0;
- - setJailTimer(delay);
- + setPunishTimer(delay);
- }
- - _jailTask.cancel(false);
- - _jailTask = null;
- + _punishTask.cancel(false);
- + ThreadPoolManager.getInstance().removeGeneral((Runnable)_punishTask);
- + _punishTask = null;
- }
- }
- - private class JailTask implements Runnable
- + private class PunishTask implements Runnable
- {
- L2PcInstance _player;
- - protected long _startedAt;
- + // protected long _startedAt;
- - protected JailTask(L2PcInstance player)
- + protected PunishTask(L2PcInstance player)
- {
- _player = player;
- - _startedAt = System.currentTimeMillis();
- + // _startedAt = System.currentTimeMillis();
- }
- public void run()
- {
- - _player.setInJail(false, 0);
- + _player.setPunishLevel(PunishLevel.NONE, 0);
- }
- }
- Index: java/net/sf/l2j/status/GameStatusThread.java
- ===================================================================
- --- java/net/sf/l2j/status/GameStatusThread.java (revision 3968)
- +++ java/net/sf/l2j/status/GameStatusThread.java (working copy)
- -510,7 +510,7 @@
- if (playerObj != null)
- {
- - playerObj.setInJail(true, delay);
- + playerObj.setPunishLevel(L2PcInstance.PunishLevel.JAIL, delay);
- _print.println("Character "+playerObj.getName()+" jailed for "+(delay>0 ? delay+" minutes." : "ever!"));
- } else
- jailOfflinePlayer(playerObj.getName(), delay);
- -531,8 +531,7 @@
- if (playerObj != null)
- {
- - playerObj.stopJailTask(false);
- - playerObj.setInJail(false, 0);
- + playerObj.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
- _print.println("Character "+playerObj.getName()+" removed from jail");
- } else
- unjailOfflinePlayer(playerObj.getName());
- -811,11 +810,11 @@
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- - PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, in_jail=?, jail_timer=? WHERE char_name=?");
- + PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
- statement.setInt(1, -114356);
- statement.setInt(2, -249645);
- statement.setInt(3, -2984);
- - statement.setInt(4, 1);
- + statement.setInt(4, L2PcInstance.PunishLevel.JAIL.value());
- statement.setLong(5, delay * 60000L);
- statement.setString(6, name);
- -844,7 +843,7 @@
- {
- con = L2DatabaseFactory.getInstance().getConnection();
- - PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, in_jail=?, jail_timer=? WHERE char_name=?");
- + PreparedStatement statement = con.prepareStatement("UPDATE characters SET x=?, y=?, z=?, punish_level=?, punish_timer=? WHERE char_name=?");
- statement.setInt(1, 17836);
- statement.setInt(2, 170178);
- statement.setInt(3, -3507);
Advertisement
Add Comment
Please, Sign In to add comment