From d74b3c2d6a54d511dfd8dbefe98958d739030bc7 Mon Sep 17 00:00:00 2001
From: Rumen Nikiforov <unafraid89@gmail.com>
Date: Sun, 20 Oct 2013 20:46:45 +0000
Subject: [PATCH] BETA: Adding back the quick ban, jail commands.

---
 .../dist/game/data/html/admin/char_menu.htm   |  2 +-
 .../admincommandhandlers/AdminPunishment.java | 84 ++++++++++++++++++-
 2 files changed, 82 insertions(+), 4 deletions(-)

diff --git a/L2J_DataPack_BETA/dist/game/data/html/admin/char_menu.htm b/L2J_DataPack_BETA/dist/game/data/html/admin/char_menu.htm
index 61622332c7..3c67834d57 100644
--- a/L2J_DataPack_BETA/dist/game/data/html/admin/char_menu.htm
+++ b/L2J_DataPack_BETA/dist/game/data/html/admin/char_menu.htm
@@ -62,7 +62,7 @@ Characters Related:<br1>
 <td><button value="Jail Out" action="bypass -h admin_unjail $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
 </tr><tr>
 <td><button value="Kick" action="bypass -h admin_kick_menu $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
-<td><button value="Ban" action="bypass -h admin_ban_menu $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+<td><button value="Punish" action="bypass -h admin_punishment player $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
 <td><button value="Find" action="bypass -h admin_find_character $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
 <td><button value="Repair" action="bypass -h admin_repair $qbox" width=65 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
 </tr></table>
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminPunishment.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminPunishment.java
index 1a06cad8ae..8e2948e1d1 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminPunishment.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminPunishment.java
@@ -31,6 +31,7 @@ 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.L2World;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.punishment.PunishmentAffect;
 import com.l2jserver.gameserver.model.punishment.PunishmentTask;
@@ -50,7 +51,15 @@ public class AdminPunishment implements IAdminCommandHandler
 	{
 		"admin_punishment",
 		"admin_punishment_add",
-		"admin_punishment_remove"
+		"admin_punishment_remove",
+		"admin_ban_acc",
+		"admin_unban_acc",
+		"admin_ban_chat",
+		"admin_unban_chat",
+		"admin_ban_char",
+		"admin_unban_char",
+		"admin_jail",
+		"admin_unjail"
 	};
 	
 	private static SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
@@ -148,12 +157,25 @@ public class AdminPunishment implements IAdminCommandHandler
 						}
 						case "player":
 						{
-							if ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer())
+							L2PcInstance target = null;
+							if (st.hasMoreTokens())
+							{
+								final String playerName = st.nextToken();
+								if (playerName.isEmpty() && ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer()))
+								{
+									return useAdminCommand("admin_punishment", activeChar);
+								}
+								target = L2World.getInstance().getPlayer(playerName);
+							}
+							if ((target == null) && ((activeChar.getTarget() == null) || !activeChar.getTarget().isPlayer()))
 							{
 								activeChar.sendMessage("You must target player!");
 								break;
 							}
-							L2PcInstance target = activeChar.getTarget().getActingPlayer();
+							if (target == null)
+							{
+								target = activeChar.getTarget().getActingPlayer();
+							}
 							String content = HtmCache.getInstance().getHtm(activeChar.getHtmlPrefix(), "data/html/admin/punishment-player.htm");
 							if (content != null)
 							{
@@ -305,6 +327,62 @@ public class AdminPunishment implements IAdminCommandHandler
 				GMAudit.auditGMAction(activeChar.getName() + " [" + activeChar.getObjectId() + "]", cmd, affect.name(), name);
 				return useAdminCommand("admin_punishment info " + name + " " + affect.name(), activeChar);
 			}
+			case "admin_ban_char":
+			{
+				if (st.hasMoreTokens())
+				{
+					return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.BAN, 0, "Banned by admin"), activeChar);
+				}
+			}
+			case "admin_unban_char":
+			{
+				if (st.hasMoreTokens())
+				{
+					return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.BAN), activeChar);
+				}
+			}
+			case "admin_ban_acc":
+			{
+				if (st.hasMoreTokens())
+				{
+					return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.ACCOUNT, PunishmentType.BAN, 0, "Banned by admin"), activeChar);
+				}
+			}
+			case "admin_unban_acc":
+			{
+				if (st.hasMoreTokens())
+				{
+					return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.ACCOUNT, PunishmentType.BAN), activeChar);
+				}
+			}
+			case "admin_ban_chat":
+			{
+				if (st.hasMoreTokens())
+				{
+					return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN, 0, "Chat banned by admin"), activeChar);
+				}
+			}
+			case "admin_unban_chat":
+			{
+				if (st.hasMoreTokens())
+				{
+					return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.CHAT_BAN), activeChar);
+				}
+			}
+			case "admin_jail":
+			{
+				if (st.hasMoreTokens())
+				{
+					return useAdminCommand(String.format("admin_punishment_add %s %s %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.JAIL, 0, "Jailed by admin"), activeChar);
+				}
+			}
+			case "admin_unjail":
+			{
+				if (st.hasMoreTokens())
+				{
+					return useAdminCommand(String.format("admin_punishment_remove %s %s %s", st.nextToken(), PunishmentAffect.CHARACTER, PunishmentType.JAIL), activeChar);
+				}
+			}
 		}
 		return true;
 	}
-- 
GitLab