Răsfoiți Sursa

BETA: DP-Part for [L6045]

Rumen Nikiforov 12 ani în urmă
părinte
comite
a1e0037814
22 a modificat fișierele cu 1043 adăugiri și 576 ștergeri
  1. 3 10
      L2J_DataPack_BETA/dist/game/config/adminCommands.xml
  2. 3 0
      L2J_DataPack_BETA/dist/game/data/html/admin/charinfo.htm
  3. 33 0
      L2J_DataPack_BETA/dist/game/data/html/admin/punishment-info.htm
  4. 49 0
      L2J_DataPack_BETA/dist/game/data/html/admin/punishment-player.htm
  5. 59 0
      L2J_DataPack_BETA/dist/game/data/html/admin/punishment.htm
  6. 3 1
      L2J_DataPack_BETA/dist/game/data/html/jail_in.htm
  7. 13 2
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
  8. 0 455
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminBan.java
  9. 328 0
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminPunishment.java
  10. 1 1
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java
  11. 2 2
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/chathandlers/ChatTell.java
  12. 103 0
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/punishmenthandlers/BanHandler.java
  13. 158 0
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/punishmenthandlers/ChatBanHandler.java
  14. 222 0
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/punishmenthandlers/JailHandler.java
  15. 32 83
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/telnethandlers/PlayerHandler.java
  16. 5 0
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/usercommandhandlers/Unstuck.java
  17. 15 18
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/voicedcommandhandlers/ChatAdmin.java
  18. 2 2
      L2J_DataPack_BETA/dist/game/data/scripts/handlers/voicedcommandhandlers/Wedding.java
  19. 0 2
      L2J_DataPack_BETA/dist/sql/game/characters.sql
  20. 10 0
      L2J_DataPack_BETA/dist/sql/game/punishments.sql
  21. 1 0
      L2J_DataPack_BETA/dist/sql/game/updates/20130519update.sql
  22. 1 0
      L2J_DataPack_BETA/dist/tools/gs_cleanup.sql

+ 3 - 10
L2J_DataPack_BETA/dist/game/config/adminCommands.xml

@@ -48,16 +48,9 @@
 	<admin command="admin_del_autoann" accessLevel="7" />
 
 	<!-- ADMIN BAN -->
-	<admin command="admin_ban" accessLevel="7" />
-	<admin command="admin_ban_acc" accessLevel="7" confirmDlg="true" />
-	<admin command="admin_ban_char" accessLevel="7" />
-	<admin command="admin_ban_chat" accessLevel="7" />
-	<admin command="admin_unban" accessLevel="7" />
-	<admin command="admin_unban_acc" accessLevel="7" />
-	<admin command="admin_unban_char" accessLevel="7" />
-	<admin command="admin_unban_chat" accessLevel="7" />
-	<admin command="admin_jail" accessLevel="7" confirmDlg="true" />
-	<admin command="admin_unjail" accessLevel="7" />
+	<admin command="admin_punishment" accessLevel="7" />
+	<admin command="admin_punishment_add" accessLevel="7" confirmDlg="true"  />
+	<admin command="admin_punishment_remove" accessLevel="7" confirmDlg="true" />
 
 	<!-- ADMIN BBS -->
 	<admin command="admin_bbs" accessLevel="7" />

+ 3 - 0
L2J_DataPack_BETA/dist/game/data/html/admin/charinfo.htm

@@ -34,6 +34,9 @@
 <tr>
 <td>Account IP: </td><td><font color="LEVEL"><a action="bypass -h admin_find_ip %ip%">%ip%</a></font></td>
 </tr>
+<tr> 
+<td>Punishment: </td><td><font color="LEVEL"><a action="bypass -h admin_punishment player %name%">Info</a></font></td>
+</tr> 
 </table>
 <br>
 <br>

+ 33 - 0
L2J_DataPack_BETA/dist/game/data/html/admin/punishment-info.htm

@@ -0,0 +1,33 @@
+<html><title>Punishment Information Panel</title><body>
+<center>
+<table width=270>
+<tr>
+<td width=45><button value="Main" action="bypass -h admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+<td width=180><center>%affect_type%: %player_name%</center></td>
+<td width=45><button value="Back" action="bypass -h admin_punishment" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+</tr>
+</table>
+<br>
+<table width=280 bgcolor="666666" cellspacing="0" cellpadding="6">
+	<tr>
+		<td>Affect Type:</td>
+		<td><combobox width=120 height=12 var="affectType" list="%affects%"></td>
+	</tr>
+	<tr>
+		<td>Key:</td>
+		<td><edit var="key" width="130" height="12"></td>
+	</tr>
+	<tr>
+		<td></td>
+		<td><a action="bypass -h admin_punishment info $key $affectType">Check</a></td>
+	</tr>
+</table>
+<br>
+<table width=280 bgcolor="666666" cellspacing="0" cellpadding="6">
+	<tr>
+		<td>Type</td>
+		<td>Expiration</td>
+		<td>Action</td>
+	</tr>
+	%punishments%
+</table>

+ 49 - 0
L2J_DataPack_BETA/dist/game/data/html/admin/punishment-player.htm

@@ -0,0 +1,49 @@
+<html><title>Punishment Information Panel</title><body>
+<center>
+<table width=270>
+<tr>
+<td width=45><button value="Main" action="bypass -h admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+<td width=180><center>Player: %player_name%</center></td>
+<td width=45><button value="Back" action="bypass -h admin_punishment" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+</tr>
+</table>
+<br>
+<br>
+<a action="bypass -h admin_punishment info %acc% ACCOUNT">Punishments for account: %acc%</a><br1>
+<a action="bypass -h admin_punishment info %char% CHARACTER">Punishments for character: %char%</a><br1>
+<a action="bypass -h admin_punishment info %ip% IP">Punishments for IP: %ip%</a><br1>
+<br>
+<table width=280 bgcolor="666666" cellspacing="0" cellpadding="6">
+	<tr>
+		<td>Punishment Type:</td>
+		<td><combobox width=120 height=17 var="punishmentType" list="%punishments%"></td>
+	</tr>
+	<tr>
+		<td>Time:</td>
+		<td><edit var="expiration" width="130" height="12" type="number"></td>
+	</tr>
+	<tr>
+		<td>Reason:</td>
+		<td><multiedit var="reason" width=130 height=32></td>
+	</tr>
+	<tr>
+		<td>Account:</td>
+		<td>%acc%</td>
+		<td><a action="bypass -h admin_punishment_add %acc% ACCOUNT $punishmentType $expiration $reason">Ban</a></td>
+	</tr>
+	<tr>
+		<td>Character:</td>
+		<td>%char%</td>
+		<td><a action="bypass -h admin_punishment_add %char% CHARACTER $punishmentType $expiration $reason">Ban</a></td>
+	</tr>
+	<tr>
+		<td>IP:</td>
+		<td>%ip%</td>
+		<td><a action="bypass -h admin_punishment_add %ip% IP $punishmentType $expiration $reason">Ban</a></td>
+	</tr>
+</table>
+</center>
+<br>
+<font color="LEVEL">For permanent ban use 0 as time.<br1>
+Also the time is in minutes.</font>
+</html>

+ 59 - 0
L2J_DataPack_BETA/dist/game/data/html/admin/punishment.htm

@@ -0,0 +1,59 @@
+<html><title>Punishment Information Panel</title><body>
+<center>
+<table width=270>
+<tr>
+<td width=45><button value="Main" action="bypass -h admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+<td width=180><center>Punishment Panel</center></td>
+<td width=45><button value="Back" action="bypass -h admin_admin7" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+</tr>
+</table>
+<br>
+<table width=280 bgcolor="666666" cellspacing="0" cellpadding="6">
+	<tr>
+		<td>Affect Type:</td>
+		<td><combobox width=120 height=12 var="affectType" list="%affects%"></td>
+	</tr>
+	<tr>
+		<td>Key:</td>
+		<td><edit var="key" width="130" height="12"></td>
+	</tr>
+	<tr>
+		<td></td>
+		<td><a action="bypass -h admin_punishment info $key $affectType">Check</a></td>
+	</tr>
+</table>
+<br>
+<table width=280 bgcolor="666666" cellspacing="0" cellpadding="6">
+	<tr>
+		<td>Punishment Type:</td>
+		<td><combobox width=120 height=12 var="punishmentType" list="%punishments%"></td>
+	</tr>
+	<tr>
+		<td>Time:</td>
+		<td><edit var="expiration" width="130" height="12" type="number"></td>
+	</tr>
+	<tr>
+		<td>Reason:</td>
+		<td><multiedit var="reason" width=130 height=32></td>
+	</tr>
+	<tr>
+		<td>Account:</td>
+		<td><edit var="acc" width="130" height="12"></td>
+		<td><a action="bypass -h admin_punishment_add $acc ACCOUNT $punishmentType $expiration $reason">Ban</a></td>
+	</tr>
+	<tr>
+		<td>Character:</td>
+		<td><edit var="char" width="130" height="12"></td>
+		<td><a action="bypass -h admin_punishment_add $char CHARACTER $punishmentType $expiration $reason">Ban</a></td>
+	</tr>
+	<tr>
+		<td>IP:</td>
+		<td><edit var="ip" width="130" height="12"></td>
+		<td><a action="bypass -h admin_punishment_add $ip IP $punishmentType $expiration $reason">Ban</a></td>
+	</tr>
+</table>
+</center>
+<br>
+<font color="LEVEL">For permanent ban use 0 as time.<br1>
+Also the time is in minutes.</font>
+</html>

+ 3 - 1
L2J_DataPack_BETA/dist/game/data/html/jail_in.htm

@@ -1,4 +1,6 @@
 <html><title>Jail</title><body><br>
 This time you've gone too far.<br>
-You have been put in jail by an admin/GM.
+You have been put in jail by an admin/GM.<br>
+Reason: %reason%<br>
+Applied by: %punishedBy%
 </body></html>

+ 13 - 2
L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java

@@ -29,6 +29,7 @@ import com.l2jserver.gameserver.handler.AdminCommandHandler;
 import com.l2jserver.gameserver.handler.BypassHandler;
 import com.l2jserver.gameserver.handler.ChatHandler;
 import com.l2jserver.gameserver.handler.ItemHandler;
+import com.l2jserver.gameserver.handler.PunishmentHandler;
 import com.l2jserver.gameserver.handler.SkillHandler;
 import com.l2jserver.gameserver.handler.TargetHandler;
 import com.l2jserver.gameserver.handler.TelnetHandler;
@@ -54,7 +55,6 @@ import handlers.actionhandlers.L2TrapAction;
 import handlers.admincommandhandlers.AdminAdmin;
 import handlers.admincommandhandlers.AdminAnnouncements;
 import handlers.admincommandhandlers.AdminBBS;
-import handlers.admincommandhandlers.AdminBan;
 import handlers.admincommandhandlers.AdminBuffs;
 import handlers.admincommandhandlers.AdminCHSiege;
 import handlers.admincommandhandlers.AdminCache;
@@ -104,6 +104,7 @@ import handlers.admincommandhandlers.AdminPcCondOverride;
 import handlers.admincommandhandlers.AdminPetition;
 import handlers.admincommandhandlers.AdminPledge;
 import handlers.admincommandhandlers.AdminPolymorph;
+import handlers.admincommandhandlers.AdminPunishment;
 import handlers.admincommandhandlers.AdminQuest;
 import handlers.admincommandhandlers.AdminRepairChar;
 import handlers.admincommandhandlers.AdminRes;
@@ -202,6 +203,9 @@ import handlers.itemhandlers.SpecialXMas;
 import handlers.itemhandlers.SpiritShot;
 import handlers.itemhandlers.SummonItems;
 import handlers.itemhandlers.TeleportBookmark;
+import handlers.punishmenthandlers.BanHandler;
+import handlers.punishmenthandlers.ChatBanHandler;
+import handlers.punishmenthandlers.JailHandler;
 import handlers.skillhandlers.BallistaBomb;
 import handlers.skillhandlers.Continuous;
 import handlers.skillhandlers.DeluxeKey;
@@ -301,6 +305,7 @@ public class MasterHandler
 		BypassHandler.class,
 		ChatHandler.class,
 		ItemHandler.class,
+		PunishmentHandler.class,
 		SkillHandler.class,
 		UserCommandHandler.class,
 		VoicedCommandHandler.class,
@@ -336,7 +341,6 @@ public class MasterHandler
 			// Admin Command Handlers
 			AdminAdmin.class,
 			AdminAnnouncements.class,
-			AdminBan.class,
 			AdminBBS.class,
 			AdminBuffs.class,
 			AdminCache.class,
@@ -387,6 +391,7 @@ public class MasterHandler
 			AdminPForge.class,
 			AdminPledge.class,
 			AdminPolymorph.class,
+			AdminPunishment.class,
 			AdminQuest.class,
 			AdminRepairChar.class,
 			AdminRes.class,
@@ -495,6 +500,12 @@ public class MasterHandler
 			EnergyStarStone.class,
 			EventItem.class,
 		},
+		{
+			// Punishment Handlers
+			BanHandler.class,
+			ChatBanHandler.class,
+			JailHandler.class,
+		},
 		{
 			// Skill Handlers
 			BallistaBomb.class,

+ 0 - 455
L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminBan.java

@@ -1,455 +0,0 @@
-/*
- * Copyright (C) 2004-2013 L2J DataPack
- * 
- * This file is part of L2J DataPack.
- * 
- * L2J DataPack is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- * 
- * L2J DataPack is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-package handlers.admincommandhandlers;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
-import java.util.StringTokenizer;
-
-import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
-import com.l2jserver.gameserver.LoginServerThread;
-import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
-import com.l2jserver.gameserver.handler.IAdminCommandHandler;
-import com.l2jserver.gameserver.model.L2World;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.network.SystemMessageId;
-import com.l2jserver.gameserver.util.GMAudit;
-
-/**
- * This class handles following admin commands: - ban_acc <account_name> = changes account access level to -1 and logs him off. If no account is specified target's account is used. - ban_char <char_name> = changes a characters access level to -1 and logs him off. If no character is specified target
- * is used. - ban_chat <char_name> <duration> = chat bans a character for the specified duration. If no name is specified the target is chat banned indefinitely. - unban_acc <account_name> = changes account access level to 0. - unban_char <char_name> = changes specified characters access level to 0.
- * - unban_chat <char_name> = lifts chat ban from specified player. If no player name is specified current target is used. - jail charname [penalty_time] = jails character. Time specified in minutes. For ever if no time is specified. - unjail charname = Unjails player, teleport him to Floran.
- * @version $Revision: 1.1.6.3 $ $Date: 2005/04/11 10:06:06 $ con.close() change by Zoey76 24/02/2011
- */
-public class AdminBan implements IAdminCommandHandler
-{
-	private static final String[] ADMIN_COMMANDS =
-	{
-		"admin_ban", // returns ban commands
-		"admin_ban_acc",
-		"admin_ban_char",
-		"admin_ban_chat",
-		"admin_unban", // returns unban commands
-		"admin_unban_acc",
-		"admin_unban_char",
-		"admin_unban_chat",
-		"admin_jail",
-		"admin_unjail"
-	};
-	
-	@Override
-	public boolean useAdminCommand(String command, L2PcInstance activeChar)
-	{
-		StringTokenizer st = new StringTokenizer(command);
-		st.nextToken();
-		String player = "";
-		int duration = -1;
-		L2PcInstance targetPlayer = null;
-		
-		if (st.hasMoreTokens())
-		{
-			player = st.nextToken();
-			targetPlayer = L2World.getInstance().getPlayer(player);
-			
-			if (st.hasMoreTokens())
-			{
-				try
-				{
-					duration = Integer.parseInt(st.nextToken());
-				}
-				catch (NumberFormatException nfe)
-				{
-					activeChar.sendMessage("Invalid number format used: " + nfe);
-					return false;
-				}
-			}
-		}
-		else
-		{
-			if ((activeChar.getTarget() != null) && activeChar.getTarget().isPlayer())
-			{
-				targetPlayer = activeChar.getTarget().getActingPlayer();
-			}
-		}
-		
-		if ((targetPlayer != null) && targetPlayer.equals(activeChar))
-		{
-			activeChar.sendPacket(SystemMessageId.CANNOT_USE_ON_YOURSELF);
-			return false;
-		}
-		
-		if (command.startsWith("admin_ban ") || command.equalsIgnoreCase("admin_ban"))
-		{
-			activeChar.sendMessage("Available ban commands: //ban_acc, //ban_char, //ban_chat");
-			return false;
-		}
-		else if (command.startsWith("admin_ban_acc"))
-		{
-			// May need to check usage in admin_ban_menu as well.
-			
-			if ((targetPlayer == null) && player.isEmpty())
-			{
-				activeChar.sendMessage("Usage: //ban_acc <account_name> (if none, target char's account gets banned)");
-				return false;
-			}
-			else if (targetPlayer == null)
-			{
-				LoginServerThread.getInstance().sendAccessLevel(player, -1);
-				activeChar.sendMessage("Ban request sent for account " + player);
-				auditAction(command, activeChar, player);
-			}
-			else
-			{
-				targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.ACC, 0);
-				activeChar.sendMessage("Account " + targetPlayer.getAccountName() + " banned.");
-				auditAction(command, activeChar, targetPlayer.getAccountName());
-			}
-		}
-		else if (command.startsWith("admin_ban_char"))
-		{
-			if ((targetPlayer == null) && player.isEmpty())
-			{
-				activeChar.sendMessage("Usage: //ban_char <char_name> (if none, target char is banned)");
-				return false;
-			}
-			auditAction(command, activeChar, (targetPlayer == null ? player : targetPlayer.getName()));
-			return changeCharAccessLevel(targetPlayer, player, activeChar, -1);
-		}
-		else if (command.startsWith("admin_ban_chat"))
-		{
-			if ((targetPlayer == null) && player.isEmpty())
-			{
-				activeChar.sendMessage("Usage: //ban_chat <char_name> [penalty_minutes]");
-				return false;
-			}
-			if (targetPlayer != null)
-			{
-				if (targetPlayer.getPunishLevel().value() > 0)
-				{
-					activeChar.sendMessage(targetPlayer.getName() + " is already jailed or banned.");
-					return false;
-				}
-				String banLengthStr = "";
-				
-				targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.CHAT, duration);
-				if (duration > 0)
-				{
-					banLengthStr = " for " + duration + " minutes";
-				}
-				activeChar.sendMessage(targetPlayer.getName() + " is now chat banned" + banLengthStr + ".");
-				auditAction(command, activeChar, targetPlayer.getName());
-			}
-			else
-			{
-				banChatOfflinePlayer(activeChar, player, duration, true);
-				auditAction(command, activeChar, player);
-			}
-		}
-		else if (command.startsWith("admin_unban_chat"))
-		{
-			if ((targetPlayer == null) && player.isEmpty())
-			{
-				activeChar.sendMessage("Usage: //unban_chat <char_name>");
-				return false;
-			}
-			if (targetPlayer != null)
-			{
-				if (targetPlayer.isChatBanned())
-				{
-					targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
-					activeChar.sendMessage(targetPlayer.getName() + "'s chat ban has now been lifted.");
-					auditAction(command, activeChar, targetPlayer.getName());
-				}
-				else
-				{
-					activeChar.sendMessage(targetPlayer.getName() + " is not currently chat banned.");
-				}
-			}
-			else
-			{
-				banChatOfflinePlayer(activeChar, player, 0, false);
-				auditAction(command, activeChar, player);
-			}
-		}
-		else if (command.startsWith("admin_unban ") || command.equalsIgnoreCase("admin_unban"))
-		{
-			activeChar.sendMessage("Available unban commands: //unban_acc, //unban_char, //unban_chat");
-			return false;
-		}
-		else if (command.startsWith("admin_unban_acc"))
-		{
-			// Need to check admin_unban_menu command as well in AdminMenu.java handler.
-			
-			if (targetPlayer != null)
-			{
-				activeChar.sendMessage(targetPlayer.getName() + " is currently online so must not be banned.");
-				return false;
-			}
-			else if (!player.isEmpty())
-			{
-				LoginServerThread.getInstance().sendAccessLevel(player, 0);
-				activeChar.sendMessage("Unban request sent for account " + player);
-				auditAction(command, activeChar, player);
-			}
-			else
-			{
-				activeChar.sendMessage("Usage: //unban_acc <account_name>");
-				return false;
-			}
-		}
-		else if (command.startsWith("admin_unban_char"))
-		{
-			if ((targetPlayer == null) && player.isEmpty())
-			{
-				activeChar.sendMessage("Usage: //unban_char <char_name>");
-				return false;
-			}
-			else if (targetPlayer != null)
-			{
-				activeChar.sendMessage(targetPlayer.getName() + " is currently online so must not be banned.");
-				return false;
-			}
-			else
-			{
-				auditAction(command, activeChar, player);
-				return changeCharAccessLevel(null, player, activeChar, 0);
-			}
-		}
-		else if (command.startsWith("admin_jail"))
-		{
-			if ((targetPlayer == null) && player.isEmpty())
-			{
-				activeChar.sendMessage("Usage: //jail <charname> [penalty_minutes] (if no name is given, selected target is jailed indefinitely)");
-				return false;
-			}
-			if (targetPlayer != null)
-			{
-				if (targetPlayer.isFlyingMounted())
-				{
-					targetPlayer.untransform();
-				}
-				targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.JAIL, duration);
-				activeChar.sendMessage("Character " + targetPlayer.getName() + " jailed for " + (duration > 0 ? duration + " minutes." : "ever!"));
-				auditAction(command, activeChar, targetPlayer.getName());
-			}
-			else
-			{
-				jailOfflinePlayer(activeChar, player, duration);
-				auditAction(command, activeChar, player);
-			}
-		}
-		else if (command.startsWith("admin_unjail"))
-		{
-			if ((targetPlayer == null) && player.isEmpty())
-			{
-				activeChar.sendMessage("Usage: //unjail <charname> (If no name is given target is used)");
-				return false;
-			}
-			else if (targetPlayer != null)
-			{
-				targetPlayer.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
-				activeChar.sendMessage("Character " + targetPlayer.getName() + " removed from jail");
-				auditAction(command, activeChar, targetPlayer.getName());
-			}
-			else
-			{
-				unjailOfflinePlayer(activeChar, player);
-				auditAction(command, activeChar, player);
-			}
-		}
-		return true;
-	}
-	
-	private void auditAction(String fullCommand, L2PcInstance activeChar, String target)
-	{
-		if (!Config.GMAUDIT)
-		{
-			return;
-		}
-		
-		String[] command = fullCommand.split(" ");
-		
-		GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", command[0], (target.isEmpty() ? "no-target" : target), (command.length > 2 ? command[2] : ""));
-	}
-	
-	private void banChatOfflinePlayer(L2PcInstance activeChar, String name, int delay, boolean ban)
-	{
-		int level = 0;
-		long value = 0;
-		if (ban)
-		{
-			level = L2PcInstance.PunishLevel.CHAT.value();
-			value = (delay > 0 ? delay * 60000L : 60000);
-		}
-		else
-		{
-			level = L2PcInstance.PunishLevel.NONE.value();
-			value = 0;
-		}
-		
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
-		{
-			PreparedStatement statement = con.prepareStatement("UPDATE characters SET punish_level=?, punish_timer=? WHERE char_name=?");
-			statement.setInt(1, level);
-			statement.setLong(2, value);
-			statement.setString(3, name);
-			
-			statement.execute();
-			int count = statement.getUpdateCount();
-			statement.close();
-			
-			if (count == 0)
-			{
-				activeChar.sendMessage("Character not found!");
-			}
-			else if (ban)
-			{
-				activeChar.sendMessage("Character " + name + " chat-banned for " + (delay > 0 ? delay + " minutes." : "ever!"));
-			}
-			else
-			{
-				activeChar.sendMessage("Character " + name + "'s chat-banned lifted");
-			}
-		}
-		catch (SQLException se)
-		{
-			activeChar.sendMessage("SQLException while chat-banning player");
-			if (Config.DEBUG)
-			{
-				se.printStackTrace();
-			}
-		}
-	}
-	
-	private void jailOfflinePlayer(L2PcInstance activeChar, String name, int delay)
-	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
-		{
-			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, L2PcInstance.PunishLevel.JAIL.value());
-			statement.setLong(5, (delay > 0 ? delay * 60000L : 0));
-			statement.setString(6, name);
-			
-			statement.execute();
-			int count = statement.getUpdateCount();
-			statement.close();
-			
-			if (count == 0)
-			{
-				activeChar.sendMessage("Character not found!");
-			}
-			else
-			{
-				activeChar.sendMessage("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
-			}
-		}
-		catch (SQLException se)
-		{
-			activeChar.sendMessage("SQLException while jailing player");
-			if (Config.DEBUG)
-			{
-				se.printStackTrace();
-			}
-		}
-	}
-	
-	private void unjailOfflinePlayer(L2PcInstance activeChar, String name)
-	{
-		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
-		{
-			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);
-			statement.setInt(4, 0);
-			statement.setLong(5, 0);
-			statement.setString(6, name);
-			statement.execute();
-			int count = statement.getUpdateCount();
-			statement.close();
-			if (count == 0)
-			{
-				activeChar.sendMessage("Character not found!");
-			}
-			else
-			{
-				activeChar.sendMessage("Character " + name + " removed from jail");
-			}
-		}
-		catch (SQLException se)
-		{
-			activeChar.sendMessage("SQLException while jailing player");
-			if (Config.DEBUG)
-			{
-				se.printStackTrace();
-			}
-		}
-	}
-	
-	private boolean changeCharAccessLevel(L2PcInstance targetPlayer, String player, L2PcInstance activeChar, int lvl)
-	{
-		if (targetPlayer != null)
-		{
-			targetPlayer.setAccessLevel(lvl);
-			targetPlayer.sendMessage("Your character has been banned. Goodbye.");
-			targetPlayer.logout();
-			RegionBBSManager.getInstance().changeCommunityBoard();
-			activeChar.sendMessage("The character " + targetPlayer.getName() + " has now been banned.");
-		}
-		else
-		{
-			try (Connection con = L2DatabaseFactory.getInstance().getConnection())
-			{
-				PreparedStatement statement = con.prepareStatement("UPDATE characters SET accesslevel=? WHERE char_name=?");
-				statement.setInt(1, lvl);
-				statement.setString(2, player);
-				statement.execute();
-				int count = statement.getUpdateCount();
-				statement.close();
-				if (count == 0)
-				{
-					activeChar.sendMessage("Character not found or access level unaltered.");
-					return false;
-				}
-				activeChar.sendMessage(player + " now has an access level of " + lvl);
-			}
-			catch (SQLException se)
-			{
-				activeChar.sendMessage("SQLException while changing character's access level");
-				if (Config.DEBUG)
-				{
-					se.printStackTrace();
-				}
-				return false;
-			}
-		}
-		return true;
-	}
-	
-	@Override
-	public String[] getAdminCommandList()
-	{
-		return ADMIN_COMMANDS;
-	}
-}

+ 328 - 0
L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminPunishment.java

@@ -0,0 +1,328 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package handlers.admincommandhandlers;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.StringTokenizer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.cache.HtmCache;
+import com.l2jserver.gameserver.datatables.CharNameTable;
+import com.l2jserver.gameserver.handler.IAdminCommandHandler;
+import com.l2jserver.gameserver.instancemanager.PunishmentManager;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.punishment.PunishmentAffect;
+import com.l2jserver.gameserver.model.punishment.PunishmentTask;
+import com.l2jserver.gameserver.model.punishment.PunishmentType;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+import com.l2jserver.gameserver.util.GMAudit;
+import com.l2jserver.gameserver.util.Util;
+
+/**
+ * @author UnAfraid
+ */
+public class AdminPunishment implements IAdminCommandHandler
+{
+	private static final Logger _log = Logger.getLogger(AdminPunishment.class.getName());
+	
+	private static final String[] ADMIN_COMMANDS =
+	{
+		"admin_punishment",
+		"admin_punishment_add",
+		"admin_punishment_remove"
+	};
+	
+	private static SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
+	
+	@Override
+	public boolean useAdminCommand(String command, L2PcInstance activeChar)
+	{
+		final StringTokenizer st = new StringTokenizer(command, " ");
+		if (!st.hasMoreTokens())
+		{
+			return false;
+		}
+		final String cmd = st.nextToken();
+		switch (cmd)
+		{
+			case "admin_punishment":
+			{
+				if (!st.hasMoreTokens())
+				{
+					String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment.htm");
+					if (content != null)
+					{
+						content = content.replaceAll("%punishments%", Util.implode(PunishmentType.values(), ";"));
+						content = content.replaceAll("%affects%", Util.implode(PunishmentAffect.values(), ";"));
+						activeChar.sendPacket(new NpcHtmlMessage(5, 5, content));
+					}
+					else
+					{
+						_log.log(Level.WARNING, getClass().getSimpleName() + ": data/html/admin/punishment.htm is missing");
+					}
+				}
+				else
+				{
+					final String subcmd = st.nextToken();
+					switch (subcmd)
+					{
+						case "info":
+						{
+							String key = st.hasMoreTokens() ? st.nextToken() : null;
+							String af = st.hasMoreTokens() ? st.nextToken() : null;
+							String name = key;
+							
+							if ((key == null) || (af == null))
+							{
+								activeChar.sendMessage("Not enough data specified!");
+								break;
+							}
+							final PunishmentAffect affect = PunishmentAffect.getByName(af);
+							if (affect == null)
+							{
+								activeChar.sendMessage("Incorrect value specified for affect type!");
+								break;
+							}
+							
+							// Swap the name of the character with it's id.
+							if (affect == PunishmentAffect.CHARACTER)
+							{
+								key = findCharId(key);
+							}
+							
+							String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment-info.htm");
+							if (content != null)
+							{
+								StringBuilder sb = new StringBuilder();
+								for (PunishmentType type : PunishmentType.values())
+								{
+									if (PunishmentManager.getInstance().hasPunishment(key, affect, type))
+									{
+										long expiration = PunishmentManager.getInstance().getPunishmentExpiration(key, affect, type);
+										String expire = "never";
+										
+										if (expiration > 0)
+										{
+											// Synchronize date formatter since its not thread safe.
+											synchronized (DATE_FORMATTER)
+											{
+												expire = DATE_FORMATTER.format(new Date(expiration));
+											}
+										}
+										sb.append("<tr><td><font color=\"LEVEL\">" + type + "</font></td><td>" + expire + "</td><td><a action=\"bypass -h admin_punishment_remove " + name + " " + affect + " " + type + "\">Remove</a></td></tr>");
+									}
+								}
+								
+								content = content.replaceAll("%player_name%", name);
+								content = content.replaceAll("%punishments%", sb.toString());
+								content = content.replaceAll("%affects%", Util.implode(PunishmentAffect.values(), ";"));
+								content = content.replaceAll("%affect_type%", affect.name());
+								activeChar.sendPacket(new NpcHtmlMessage(5, 5, content));
+							}
+							else
+							{
+								_log.log(Level.WARNING, getClass().getSimpleName() + ": data/html/admin/punishment-info.htm is missing");
+							}
+							break;
+						}
+						case "player":
+						{
+							if ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer())
+							{
+								activeChar.sendMessage("You must target player!");
+								break;
+							}
+							L2PcInstance target = activeChar.getTarget().getActingPlayer();
+							String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment-player.htm");
+							if (content != null)
+							{
+								content = content.replaceAll("%player_name%", target.getName());
+								content = content.replaceAll("%punishments%", Util.implode(PunishmentType.values(), ";"));
+								content = content.replaceAll("%acc%", target.getAccountName());
+								content = content.replaceAll("%char%", target.getName());
+								content = content.replaceAll("%ip%", target.getIPAddress());
+								activeChar.sendPacket(new NpcHtmlMessage(5, 5, content));
+							}
+							else
+							{
+								_log.log(Level.WARNING, getClass().getSimpleName() + ": data/html/admin/punishment-player.htm is missing");
+							}
+							break;
+						}
+					}
+				}
+				break;
+			}
+			case "admin_punishment_add":
+			{
+				// Add new punishment
+				String key = st.hasMoreTokens() ? st.nextToken() : null;
+				String af = st.hasMoreTokens() ? st.nextToken() : null;
+				String t = st.hasMoreTokens() ? st.nextToken() : null;
+				String exp = st.hasMoreTokens() ? st.nextToken() : null;
+				String reason = st.hasMoreTokens() ? st.nextToken() + " " : null;
+				
+				// Let's grab the other part of the reason if there is..
+				if (reason != null)
+				{
+					while (st.hasMoreTokens())
+					{
+						reason += st.nextToken() + " ";
+					}
+					if (!reason.isEmpty())
+					{
+						reason = reason.substring(0, reason.length() - 1);
+						reason = reason.replaceAll("\\$", "\\\\\\$");
+						reason = reason.replaceAll("\r\n", "<br1>");
+						reason = reason.replace("<", "&lt;");
+						reason = reason.replace(">", "&gt;");
+					}
+				}
+				
+				String name = key;
+				
+				if ((key == null) || (af == null) || (t == null) || (exp == null) || (reason == null))
+				{
+					activeChar.sendMessage("Please fill all the fields!");
+					break;
+				}
+				if (!Util.isDigit(exp) && !exp.equals("-1"))
+				{
+					activeChar.sendMessage("Incorrect value specified for expiration time!");
+					break;
+				}
+				
+				long expirationTime = Integer.parseInt(exp);
+				if (expirationTime > 0)
+				{
+					expirationTime = System.currentTimeMillis() + (expirationTime * 60 * 1000);
+				}
+				
+				final PunishmentAffect affect = PunishmentAffect.getByName(af);
+				final PunishmentType type = PunishmentType.getByName(t);
+				if ((affect == null) || (type == null))
+				{
+					activeChar.sendMessage("Incorrect value specified for affect/punishment type!");
+					break;
+				}
+				
+				// Swap the name of the character with it's id.
+				if (affect == PunishmentAffect.CHARACTER)
+				{
+					key = findCharId(key);
+				}
+				else if (affect == PunishmentAffect.IP)
+				{
+					try
+					{
+						InetAddress addr = InetAddress.getByName(key);
+						if (addr.isLoopbackAddress())
+						{
+							throw new UnknownHostException("You cannot ban any local address!");
+						}
+						else if (Config.GAME_SERVER_HOSTS.contains(addr.getHostAddress()))
+						{
+							throw new UnknownHostException("You cannot ban your gameserver's address!");
+						}
+					}
+					catch (UnknownHostException e)
+					{
+						activeChar.sendMessage("You've entered an incorrect IP address!");
+						activeChar.sendMessage(e.getMessage());
+						break;
+					}
+				}
+				
+				// Check if we already put the same punishment on that guy ^^
+				if (PunishmentManager.getInstance().hasPunishment(key, affect, type))
+				{
+					activeChar.sendMessage("Target is already affected by that punishment.");
+					break;
+				}
+				
+				// Punish him!
+				PunishmentManager.getInstance().startPunishment(new PunishmentTask(key, affect, type, expirationTime, reason, activeChar.getName()));
+				activeChar.sendMessage("Punishment " + type.name() + " have been applied to: " + affect + " " + name + "!");
+				GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", cmd, affect.name(), name);
+				return useAdminCommand("admin_punishment info " + name + " " + affect.name(), activeChar);
+			}
+			case "admin_punishment_remove":
+			{
+				// Remove punishment.
+				String key = st.hasMoreTokens() ? st.nextToken() : null;
+				String af = st.hasMoreTokens() ? st.nextToken() : null;
+				String t = st.hasMoreTokens() ? st.nextToken() : null;
+				String name = key;
+				
+				if ((key == null) || (af == null) || (t == null))
+				{
+					activeChar.sendMessage("Not enough data specified!");
+					break;
+				}
+				
+				final PunishmentAffect affect = PunishmentAffect.getByName(af);
+				final PunishmentType type = PunishmentType.getByName(t);
+				if ((affect == null) || (type == null))
+				{
+					activeChar.sendMessage("Incorrect value specified for affect/punishment type!");
+					break;
+				}
+				
+				// Swap the name of the character with it's id.
+				if (affect == PunishmentAffect.CHARACTER)
+				{
+					key = findCharId(key);
+				}
+				
+				if (!PunishmentManager.getInstance().hasPunishment(key, affect, type))
+				{
+					activeChar.sendMessage("Target is not affected by that punishment!");
+					break;
+				}
+				
+				PunishmentManager.getInstance().stopPunishment(key, affect, type);
+				activeChar.sendMessage("Punishment " + type.name() + " have been stopped to: " + affect + " " + name + "!");
+				GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", cmd, affect.name(), name);
+				return useAdminCommand("admin_punishment info " + name + " " + affect.name(), activeChar);
+			}
+		}
+		return true;
+	}
+	
+	private static final String findCharId(String key)
+	{
+		int charId = CharNameTable.getInstance().getIdByName(key);
+		if (charId > 0) // Yeah its a char name!
+		{
+			return Integer.toString(charId);
+		}
+		return key;
+	}
+	
+	@Override
+	public String[] getAdminCommandList()
+	{
+		return ADMIN_COMMANDS;
+	}
+}

+ 1 - 1
L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTeleport.java

@@ -434,7 +434,7 @@ public class AdminTeleport implements IAdminCommandHandler
 		if (player != null)
 		{
 			// Check for jail
-			if (player.isInJail())
+			if (player.isJailed())
 			{
 				activeChar.sendMessage("Sorry, player " + player.getName() + " is in Jail.");
 			}

+ 2 - 2
L2J_DataPack_BETA/dist/game/data/scripts/handlers/chathandlers/ChatTell.java

@@ -51,7 +51,7 @@ public class ChatTell implements IChatHandler
 			return;
 		}
 		
-		if (Config.JAIL_DISABLE_CHAT && activeChar.isInJail() && !activeChar.canOverrideCond(PcCondOverride.CHAT_CONDITIONS))
+		if (Config.JAIL_DISABLE_CHAT && activeChar.isJailed() && !activeChar.canOverrideCond(PcCondOverride.CHAT_CONDITIONS))
 		{
 			activeChar.sendPacket(SystemMessageId.CHATTING_PROHIBITED);
 			return;
@@ -70,7 +70,7 @@ public class ChatTell implements IChatHandler
 		
 		if ((receiver != null) && !receiver.isSilenceMode(activeChar.getObjectId()))
 		{
-			if (Config.JAIL_DISABLE_CHAT && receiver.isInJail() && !activeChar.canOverrideCond(PcCondOverride.CHAT_CONDITIONS))
+			if (Config.JAIL_DISABLE_CHAT && receiver.isJailed() && !activeChar.canOverrideCond(PcCondOverride.CHAT_CONDITIONS))
 			{
 				activeChar.sendMessage("Player is in jail.");
 				return;

+ 103 - 0
L2J_DataPack_BETA/dist/game/data/scripts/handlers/punishmenthandlers/BanHandler.java

@@ -0,0 +1,103 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package handlers.punishmenthandlers;
+
+import com.l2jserver.gameserver.LoginServerThread;
+import com.l2jserver.gameserver.handler.IPunishmentHandler;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.punishment.PunishmentTask;
+import com.l2jserver.gameserver.model.punishment.PunishmentType;
+import com.l2jserver.gameserver.network.L2GameClient;
+
+/**
+ * This class handles ban punishment.
+ * @author UnAfraid
+ */
+public class BanHandler implements IPunishmentHandler
+{
+	@Override
+	public void onStart(PunishmentTask task)
+	{
+		switch (task.getAffect())
+		{
+			case CHARACTER:
+			{
+				int objectId = Integer.parseInt(String.valueOf(task.getKey()));
+				final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
+				if (player != null)
+				{
+					applyToPlayer(player);
+				}
+				break;
+			}
+			case ACCOUNT:
+			{
+				String account = String.valueOf(task.getKey());
+				final L2GameClient client = LoginServerThread.getInstance().getClient(account);
+				if (client != null)
+				{
+					final L2PcInstance player = client.getActiveChar();
+					if (player != null)
+					{
+						applyToPlayer(player);
+					}
+					else
+					{
+						client.closeNow();
+					}
+				}
+				break;
+			}
+			case IP:
+			{
+				String ip = String.valueOf(task.getKey());
+				for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
+				{
+					if (player.getIPAddress().equals(ip))
+					{
+						applyToPlayer(player);
+					}
+				}
+				break;
+			}
+		}
+	}
+	
+	@Override
+	public void onEnd(PunishmentTask task)
+	{
+		
+	}
+	
+	/**
+	 * Applies all punishment effects from the player.
+	 * @param player
+	 */
+	private static void applyToPlayer(L2PcInstance player)
+	{
+		player.logout();
+	}
+	
+	@Override
+	public PunishmentType getType()
+	{
+		return PunishmentType.BAN;
+	}
+}

+ 158 - 0
L2J_DataPack_BETA/dist/game/data/scripts/handlers/punishmenthandlers/ChatBanHandler.java

@@ -0,0 +1,158 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package handlers.punishmenthandlers;
+
+import com.l2jserver.gameserver.LoginServerThread;
+import com.l2jserver.gameserver.handler.IPunishmentHandler;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.punishment.PunishmentTask;
+import com.l2jserver.gameserver.model.punishment.PunishmentType;
+import com.l2jserver.gameserver.network.L2GameClient;
+import com.l2jserver.gameserver.network.serverpackets.EtcStatusUpdate;
+
+/**
+ * This class handles chat ban punishment.
+ * @author UnAfraid
+ */
+public class ChatBanHandler implements IPunishmentHandler
+{
+	@Override
+	public void onStart(PunishmentTask task)
+	{
+		switch (task.getAffect())
+		{
+			case CHARACTER:
+			{
+				int objectId = Integer.parseInt(String.valueOf(task.getKey()));
+				final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
+				if (player != null)
+				{
+					applyToPlayer(task, player);
+				}
+				break;
+			}
+			case ACCOUNT:
+			{
+				String account = String.valueOf(task.getKey());
+				final L2GameClient client = LoginServerThread.getInstance().getClient(account);
+				if (client != null)
+				{
+					final L2PcInstance player = client.getActiveChar();
+					if (player != null)
+					{
+						applyToPlayer(task, player);
+					}
+				}
+				break;
+			}
+			case IP:
+			{
+				String ip = String.valueOf(task.getKey());
+				for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
+				{
+					if (player.getIPAddress().equals(ip))
+					{
+						applyToPlayer(task, player);
+					}
+				}
+				break;
+			}
+		}
+	}
+	
+	@Override
+	public void onEnd(PunishmentTask task)
+	{
+		switch (task.getAffect())
+		{
+			case CHARACTER:
+			{
+				int objectId = Integer.parseInt(String.valueOf(task.getKey()));
+				final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
+				if (player != null)
+				{
+					removeFromPlayer(player);
+				}
+				break;
+			}
+			case ACCOUNT:
+			{
+				String account = String.valueOf(task.getKey());
+				final L2GameClient client = LoginServerThread.getInstance().getClient(account);
+				if (client != null)
+				{
+					final L2PcInstance player = client.getActiveChar();
+					if (player != null)
+					{
+						removeFromPlayer(player);
+					}
+				}
+				break;
+			}
+			case IP:
+			{
+				String ip = String.valueOf(task.getKey());
+				for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
+				{
+					if (player.getIPAddress().equals(ip))
+					{
+						removeFromPlayer(player);
+					}
+				}
+				break;
+			}
+		}
+	}
+	
+	/**
+	 * Applies all punishment effects from the player.
+	 * @param task
+	 * @param player
+	 */
+	private static void applyToPlayer(PunishmentTask task, L2PcInstance player)
+	{
+		long delay = ((task.getExpirationTime() - System.currentTimeMillis()) / 1000);
+		if (delay > 0)
+		{
+			player.sendMessage("You've been chat banned for " + (delay > 60 ? ((delay / 60) + " minutes.") : delay + " seconds."));
+		}
+		else
+		{
+			player.sendMessage("You've been chat banned forever.");
+		}
+		player.sendPacket(new EtcStatusUpdate(player));
+	}
+	
+	/**
+	 * Removes any punishment effects from the player.
+	 * @param player
+	 */
+	private static void removeFromPlayer(L2PcInstance player)
+	{
+		player.sendMessage("Your Chat ban has been lifted");
+		player.sendPacket(new EtcStatusUpdate(player));
+	}
+	
+	@Override
+	public PunishmentType getType()
+	{
+		return PunishmentType.CHAT_BAN;
+	}
+}

+ 222 - 0
L2J_DataPack_BETA/dist/game/data/scripts/handlers/punishmenthandlers/JailHandler.java

@@ -0,0 +1,222 @@
+/*
+ * Copyright (C) 2004-2013 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * L2J DataPack is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+package handlers.punishmenthandlers;
+
+import com.l2jserver.gameserver.LoginServerThread;
+import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.cache.HtmCache;
+import com.l2jserver.gameserver.handler.IPunishmentHandler;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.actor.tasks.player.TeleportTask;
+import com.l2jserver.gameserver.model.entity.TvTEvent;
+import com.l2jserver.gameserver.model.olympiad.OlympiadManager;
+import com.l2jserver.gameserver.model.punishment.PunishmentTask;
+import com.l2jserver.gameserver.model.punishment.PunishmentType;
+import com.l2jserver.gameserver.model.zone.ZoneId;
+import com.l2jserver.gameserver.model.zone.type.L2JailZone;
+import com.l2jserver.gameserver.network.L2GameClient;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+import com.l2jserver.gameserver.scripting.scriptengine.listeners.player.PlayerSpawnListener;
+
+/**
+ * This class handles jail punishment.
+ * @author UnAfraid
+ */
+public class JailHandler extends PlayerSpawnListener implements IPunishmentHandler
+{
+	@Override
+	public void onSpawn(L2PcInstance activeChar)
+	{
+		if (activeChar.isJailed() && !activeChar.isInsideZone(ZoneId.JAIL))
+		{
+			applyToPlayer(null, activeChar);
+		}
+		else if (!activeChar.isJailed() && activeChar.isInsideZone(ZoneId.JAIL) && !activeChar.isGM())
+		{
+			removeFromPlayer(activeChar);
+		}
+	}
+	
+	@Override
+	public void onStart(PunishmentTask task)
+	{
+		switch (task.getAffect())
+		{
+			case CHARACTER:
+			{
+				int objectId = Integer.parseInt(String.valueOf(task.getKey()));
+				final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
+				if (player != null)
+				{
+					applyToPlayer(task, player);
+				}
+				break;
+			}
+			case ACCOUNT:
+			{
+				String account = String.valueOf(task.getKey());
+				final L2GameClient client = LoginServerThread.getInstance().getClient(account);
+				if (client != null)
+				{
+					final L2PcInstance player = client.getActiveChar();
+					if (player != null)
+					{
+						applyToPlayer(task, player);
+					}
+				}
+				break;
+			}
+			case IP:
+			{
+				String ip = String.valueOf(task.getKey());
+				for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
+				{
+					if (player.getIPAddress().equals(ip))
+					{
+						applyToPlayer(task, player);
+					}
+				}
+				break;
+			}
+		}
+	}
+	
+	@Override
+	public void onEnd(PunishmentTask task)
+	{
+		switch (task.getAffect())
+		{
+			case CHARACTER:
+			{
+				int objectId = Integer.parseInt(String.valueOf(task.getKey()));
+				final L2PcInstance player = L2World.getInstance().getPlayer(objectId);
+				if (player != null)
+				{
+					removeFromPlayer(player);
+				}
+				break;
+			}
+			case ACCOUNT:
+			{
+				String account = String.valueOf(task.getKey());
+				final L2GameClient client = LoginServerThread.getInstance().getClient(account);
+				if (client != null)
+				{
+					final L2PcInstance player = client.getActiveChar();
+					if (player != null)
+					{
+						removeFromPlayer(player);
+					}
+				}
+				break;
+			}
+			case IP:
+			{
+				String ip = String.valueOf(task.getKey());
+				for (L2PcInstance player : L2World.getInstance().getAllPlayersArray())
+				{
+					if (player.getIPAddress().equals(ip))
+					{
+						removeFromPlayer(player);
+					}
+				}
+				break;
+			}
+		}
+	}
+	
+	/**
+	 * Applies all punishment effects from the player.
+	 * @param task
+	 * @param player
+	 */
+	private static void applyToPlayer(PunishmentTask task, L2PcInstance player)
+	{
+		player.setInstanceId(0);
+		player.setIsIn7sDungeon(false);
+		
+		if (!TvTEvent.isInactive() && TvTEvent.isPlayerParticipant(player.getObjectId()))
+		{
+			TvTEvent.removeParticipant(player.getObjectId());
+		}
+		
+		if (OlympiadManager.getInstance().isRegisteredInComp(player))
+		{
+			OlympiadManager.getInstance().removeDisconnectedCompetitor(player);
+		}
+		
+		ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(player, L2JailZone.getLocationIn()), 2000);
+		
+		// Open a Html message to inform the player
+		final NpcHtmlMessage msg = new NpcHtmlMessage(0);
+		String content = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/jail_in.htm");
+		if (content != null)
+		{
+			content = content.replaceAll("%reason%", task != null ? task.getReason() : "");
+			content = content.replaceAll("%punishedBy%", task != null ? task.getPunishedBy() : "");
+			msg.setHtml(content);
+		}
+		else
+		{
+			msg.setHtml("<html><body>You have been put in jail by an admin.</body></html>");
+		}
+		player.sendPacket(msg);
+		if (task != null)
+		{
+			long delay = ((task.getExpirationTime() - System.currentTimeMillis()) / 1000);
+			if (delay > 0)
+			{
+				player.sendMessage("You've been jailed for " + (delay > 60 ? ((delay / 60) + " minutes.") : delay + " seconds."));
+			}
+			else
+			{
+				player.sendMessage("You've been jailed forever.");
+			}
+		}
+	}
+	
+	/**
+	 * Removes any punishment effects from the player.
+	 * @param player
+	 */
+	private static void removeFromPlayer(L2PcInstance player)
+	{
+		ThreadPoolManager.getInstance().scheduleGeneral(new TeleportTask(player, L2JailZone.getLocationOut()), 2000);
+		
+		// Open a Html message to inform the player
+		final NpcHtmlMessage msg = new NpcHtmlMessage(0);
+		String content = HtmCache.getInstance().getHtm(player.getHtmlPrefix(), "data/html/jail_out.htm");
+		if (content != null)
+		{
+			msg.setHtml(content);
+		}
+		else
+		{
+			msg.setHtml("<html><body>You are free for now, respect server rules!</body></html>");
+		}
+		player.sendPacket(msg);
+	}
+	
+	@Override
+	public PunishmentType getType()
+	{
+		return PunishmentType.JAIL;
+	}
+}

+ 32 - 83
L2J_DataPack_BETA/dist/game/data/scripts/handlers/telnethandlers/PlayerHandler.java

@@ -20,19 +20,20 @@ package handlers.telnethandlers;
 
 import java.io.PrintWriter;
 import java.net.Socket;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.SQLException;
 import java.util.NoSuchElementException;
 import java.util.StringTokenizer;
 
 import com.l2jserver.Config;
-import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.datatables.CharNameTable;
 import com.l2jserver.gameserver.handler.ITelnetHandler;
+import com.l2jserver.gameserver.instancemanager.PunishmentManager;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.itemcontainer.Inventory;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
+import com.l2jserver.gameserver.model.punishment.PunishmentAffect;
+import com.l2jserver.gameserver.model.punishment.PunishmentTask;
+import com.l2jserver.gameserver.model.punishment.PunishmentType;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.serverpackets.CharInfo;
 import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
@@ -40,6 +41,7 @@ import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.gameserver.network.serverpackets.UserInfo;
 import com.l2jserver.gameserver.util.GMAudit;
+import com.l2jserver.gameserver.util.Util;
 
 /**
  * @author UnAfraid
@@ -206,58 +208,35 @@ public class PlayerHandler implements ITelnetHandler
 			try
 			{
 				String name = st.nextToken();
-				L2PcInstance playerObj = L2World.getInstance().getPlayer(name);
+				int charId = CharNameTable.getInstance().getIdByName(name);
 				int delay = 0;
-				try
-				{
-					delay = Integer.parseInt(st.nextToken());
-				}
-				catch (NumberFormatException nfe)
-				{
-				}
-				catch (NoSuchElementException nsee)
+				String reason = "";
+				if (st.hasMoreTokens())
 				{
+					String token = st.nextToken();
+					if (Util.isDigit(token))
+					{
+						delay = Integer.parseInt(token);
+					}
+					while (st.hasMoreTokens())
+					{
+						reason += st.nextToken() + " ";
+					}
+					if (!reason.isEmpty())
+					{
+						reason = reason.substring(0, reason.length() - 1);
+					}
 				}
-				// L2PcInstance playerObj = L2World.getInstance().getPlayer(player);
 				
-				if (playerObj != null)
+				if (charId > 0)
 				{
-					playerObj.setPunishLevel(L2PcInstance.PunishLevel.JAIL, delay);
-					_print.println("Character " + playerObj.getName() + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
+					long expirationTime = delay > 0 ? System.currentTimeMillis() + (delay * 60 * 1000) : -1;
+					PunishmentManager.getInstance().startPunishment(new PunishmentTask(charId, PunishmentAffect.CHARACTER, PunishmentType.JAIL, expirationTime, reason, "Telnet Admin: " + _cSocket.getInetAddress().getHostAddress()));
+					_print.println("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
 				}
 				else
 				{
-					try (Connection con = L2DatabaseFactory.getInstance().getConnection())
-					{
-						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, L2PcInstance.PunishLevel.JAIL.value());
-						statement.setLong(5, delay * 60000L);
-						statement.setString(6, name);
-						
-						statement.execute();
-						int count = statement.getUpdateCount();
-						statement.close();
-						
-						if (count == 0)
-						{
-							_print.println("Character not found!");
-						}
-						else
-						{
-							_print.println("Character " + name + " jailed for " + (delay > 0 ? delay + " minutes." : "ever!"));
-						}
-					}
-					catch (SQLException se)
-					{
-						_print.println("SQLException while jailing player");
-						if (Config.DEBUG)
-						{
-							se.printStackTrace();
-						}
-					}
+					_print.println("Character with name: " + name + " was not found!");
 				}
 			}
 			catch (NoSuchElementException nsee)
@@ -278,46 +257,16 @@ public class PlayerHandler implements ITelnetHandler
 			try
 			{
 				String name = st.nextToken();
-				L2PcInstance playerObj = L2World.getInstance().getPlayer(name);
+				int charId = CharNameTable.getInstance().getIdByName(name);
 				
-				if (playerObj != null)
+				if (charId > 0)
 				{
-					playerObj.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
-					_print.println("Character " + playerObj.getName() + " removed from jail");
+					PunishmentManager.getInstance().stopPunishment(charId, PunishmentAffect.CHARACTER, PunishmentType.JAIL);
+					_print.println("Character " + name + " have been unjailed");
 				}
 				else
 				{
-					try (Connection con = L2DatabaseFactory.getInstance().getConnection())
-					{
-						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);
-						statement.setInt(4, 0);
-						statement.setLong(5, 0);
-						statement.setString(6, name);
-						
-						statement.execute();
-						int count = statement.getUpdateCount();
-						statement.close();
-						
-						if (count == 0)
-						{
-							_print.println("Character not found!");
-						}
-						else
-						{
-							_print.println("Character " + name + " set free.");
-						}
-					}
-					catch (SQLException se)
-					{
-						_print.println("SQLException while jailing player");
-						if (Config.DEBUG)
-						{
-							se.printStackTrace();
-						}
-					}
+					_print.println("Character with name: " + name + " was not found!");
 				}
 			}
 			catch (NoSuchElementException nsee)

+ 5 - 0
L2J_DataPack_BETA/dist/game/data/scripts/handlers/usercommandhandlers/Unstuck.java

@@ -52,6 +52,11 @@ public class Unstuck implements IUserCommandHandler
 			activeChar.sendPacket(ActionFailed.STATIC_PACKET);
 			return false;
 		}
+		else if (activeChar.isJailed())
+		{
+			activeChar.sendMessage("You cannot use this function while you are jailed.");
+			return false;
+		}
 		
 		int unstuckTimer = (activeChar.getAccessLevel().isGm() ? 1000 : Config.UNSTUCK_INTERVAL * 1000);
 		

+ 15 - 18
L2J_DataPack_BETA/dist/game/data/scripts/handlers/voicedcommandhandlers/ChatAdmin.java

@@ -23,8 +23,13 @@ import java.util.StringTokenizer;
 import com.l2jserver.gameserver.datatables.AdminTable;
 import com.l2jserver.gameserver.datatables.CharNameTable;
 import com.l2jserver.gameserver.handler.IVoicedCommandHandler;
+import com.l2jserver.gameserver.instancemanager.PunishmentManager;
 import com.l2jserver.gameserver.model.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.punishment.PunishmentAffect;
+import com.l2jserver.gameserver.model.punishment.PunishmentTask;
+import com.l2jserver.gameserver.model.punishment.PunishmentType;
+import com.l2jserver.gameserver.util.Util;
 
 public class ChatAdmin implements IVoicedCommandHandler
 {
@@ -53,22 +58,14 @@ public class ChatAdmin implements IVoicedCommandHandler
 			if (st.hasMoreTokens())
 			{
 				String name = st.nextToken();
-				int length = 0;
+				long expirationTime = 0;
 				if (st.hasMoreTokens())
 				{
-					try
+					String token = st.nextToken();
+					if (Util.isDigit(token))
 					{
-						length = Integer.parseInt(st.nextToken());
+						expirationTime = System.currentTimeMillis() + (Integer.parseInt(st.nextToken()) * 60 * 1000);
 					}
-					catch (NumberFormatException e)
-					{
-						activeChar.sendMessage("Wrong ban length !");
-						return false;
-					}
-				}
-				if (length < 0)
-				{
-					length = 0;
 				}
 				
 				int objId = CharNameTable.getInstance().getIdByName(name);
@@ -80,7 +77,7 @@ public class ChatAdmin implements IVoicedCommandHandler
 						activeChar.sendMessage("Player not online !");
 						return false;
 					}
-					if (player.getPunishLevel() != L2PcInstance.PunishLevel.NONE)
+					if (player.isChatBanned())
 					{
 						activeChar.sendMessage("Player is already punished !");
 						return false;
@@ -101,12 +98,12 @@ public class ChatAdmin implements IVoicedCommandHandler
 						return false;
 					}
 					
-					player.setPunishLevel(L2PcInstance.PunishLevel.CHAT, length);
+					PunishmentManager.getInstance().startPunishment(new PunishmentTask(objId, PunishmentAffect.CHARACTER, PunishmentType.JAIL, expirationTime, "Chat banned by moderator", activeChar.getName()));
 					player.sendMessage("Chat banned by moderator " + activeChar.getName());
 					
-					if (length > 0)
+					if (expirationTime > 0)
 					{
-						activeChar.sendMessage("Player " + player.getName() + " chat banned for " + length + " minutes.");
+						activeChar.sendMessage("Player " + player.getName() + " chat banned for " + expirationTime + " minutes.");
 					}
 					else
 					{
@@ -141,13 +138,13 @@ public class ChatAdmin implements IVoicedCommandHandler
 						activeChar.sendMessage("Player not online !");
 						return false;
 					}
-					if (player.getPunishLevel() != L2PcInstance.PunishLevel.CHAT)
+					if (!player.isChatBanned())
 					{
 						activeChar.sendMessage("Player is not chat banned !");
 						return false;
 					}
 					
-					player.setPunishLevel(L2PcInstance.PunishLevel.NONE, 0);
+					PunishmentManager.getInstance().stopPunishment(objId, PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN);
 					
 					activeChar.sendMessage("Player " + player.getName() + " chat unbanned.");
 					player.sendMessage("Chat unbanned by moderator " + activeChar.getName());

+ 2 - 2
L2J_DataPack_BETA/dist/game/data/scripts/handlers/voicedcommandhandlers/Wedding.java

@@ -287,7 +287,7 @@ public class Wedding implements IVoicedCommandHandler
 			return false;
 		}
 		
-		if (activeChar.isInJail())
+		if (activeChar.isJailed())
 		{
 			activeChar.sendMessage("You are in Jail!");
 			return false;
@@ -361,7 +361,7 @@ public class Wedding implements IVoicedCommandHandler
 			return false;
 		}
 		
-		if (partner.isInJail())
+		if (partner.isJailed())
 		{
 			activeChar.sendMessage("Your partner is in Jail.");
 			return false;

+ 0 - 2
L2J_DataPack_BETA/dist/sql/game/characters.sql

@@ -42,8 +42,6 @@ CREATE TABLE IF NOT EXISTS `characters` (
   `clan_privs` MEDIUMINT UNSIGNED DEFAULT 0,
   `wantspeace` TINYINT UNSIGNED DEFAULT 0,
   `isin7sdungeon` TINYINT UNSIGNED NOT NULL DEFAULT 0,
-  `punish_level` TINYINT UNSIGNED NOT NULL DEFAULT 0,
-  `punish_timer` INT UNSIGNED NOT NULL DEFAULT 0,
   `power_grade` TINYINT UNSIGNED DEFAULT NULL,
   `nobless` TINYINT UNSIGNED NOT NULL DEFAULT 0,
   `subpledge` SMALLINT NOT NULL DEFAULT 0,

+ 10 - 0
L2J_DataPack_BETA/dist/sql/game/punishments.sql

@@ -0,0 +1,10 @@
+CREATE TABLE IF NOT EXISTS `punishments` (
+  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
+  `key` varchar(255) NOT NULL,
+  `affect` varchar(255) NOT NULL,
+  `type` varchar(255) NOT NULL,
+  `expiration`  bigint NOT NULL,
+  `reason` TEXT NOT NULL,
+  `punishedBy` varchar(255) NOT NULL,
+  PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;

+ 1 - 0
L2J_DataPack_BETA/dist/sql/game/updates/20130519update.sql

@@ -0,0 +1 @@
+ALTER TABLE `characters` DROP COLUMN `punish_level`, DROP COLUMN `punish_timer`;

+ 1 - 0
L2J_DataPack_BETA/dist/tools/gs_cleanup.sql

@@ -103,6 +103,7 @@ petition_feedback,
 pets,
 pets_skills,
 posts,
+punishments,
 quest_global_data,
 raidboss_spawnlist,
 rainbowsprings_attacker_list,