From ae14d836fb4a97af4fabcec5b3e9ac33586599ff Mon Sep 17 00:00:00 2001
From: MELERIX <MELERIX@users.noreply.github.com>
Date: Sat, 7 Jan 2012 06:00:45 +0000
Subject: [PATCH] BETA: Admin Command "Target Say" (makes talk any target) by
 '''nonom'''.

---
 .../data/scripts/handlers/MasterHandler.java  |  2 +
 .../admincommandhandlers/AdminTargetSay.java  | 78 +++++++++++++++++++
 .../sql/game/admin_command_access_rights.sql  |  3 +
 3 files changed, 83 insertions(+)
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTargetSay.java

diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
index 17fa6dd793..41a8ffa7e7 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
@@ -93,6 +93,7 @@ import handlers.admincommandhandlers.AdminSkill;
 import handlers.admincommandhandlers.AdminSpawn;
 import handlers.admincommandhandlers.AdminSummon;
 import handlers.admincommandhandlers.AdminTarget;
+import handlers.admincommandhandlers.AdminTargetSay;
 import handlers.admincommandhandlers.AdminTeleport;
 import handlers.admincommandhandlers.AdminTerritoryWar;
 import handlers.admincommandhandlers.AdminTest;
@@ -420,6 +421,7 @@ public class MasterHandler
 			AdminSpawn.class,
 			AdminSummon.class,
 			AdminTarget.class,
+			AdminTargetSay.class,
 			AdminTeleport.class,
 			AdminTerritoryWar.class,
 			AdminTest.class,
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTargetSay.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTargetSay.java
new file mode 100644
index 0000000000..e5b210100b
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminTargetSay.java
@@ -0,0 +1,78 @@
+/*
+ * This program 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.
+ * 
+ * This program 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 com.l2jserver.gameserver.handler.IAdminCommandHandler;
+import com.l2jserver.gameserver.model.L2Object;
+import com.l2jserver.gameserver.model.actor.L2Character;
+import com.l2jserver.gameserver.model.actor.instance.L2ControllableMobInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.clientpackets.Say2;
+import com.l2jserver.gameserver.network.serverpackets.CreatureSay;
+
+/**
+ * This class handles following admin commands: - targetsay <message> = makes talk a L2Character
+ * @author nonom
+ */
+public class AdminTargetSay implements IAdminCommandHandler
+{
+	
+	private static final String[] ADMIN_COMMANDS =
+	{
+		"admin_targetsay"
+	};
+	
+	@Override
+	public boolean useAdminCommand(String command, L2PcInstance activeChar)
+	{
+		if (command.startsWith("admin_targetsay"))
+		{
+			try
+			{
+				String message = command.substring(16);
+				
+				L2Object obj = activeChar.getTarget();
+				
+				if ((obj instanceof L2ControllableMobInstance) || !(obj instanceof L2Character))
+				{
+					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
+					return false;
+				}
+				else
+				{
+					talk(activeChar, (L2Character) obj, message);
+				}
+			}
+			catch (StringIndexOutOfBoundsException e)
+			{
+				activeChar.sendPacket(SystemMessageId.INCORRECT_SYNTAX);
+				return false;
+			}
+		}
+		return true;
+	}
+	
+	private void talk(L2PcInstance activeChar, L2Character target, String message)
+	{
+		target.broadcastPacket(new CreatureSay(target.getObjectId(), Say2.ALL, target.getName(), message));
+	}
+	
+	@Override
+	public String[] getAdminCommandList()
+	{
+		return ADMIN_COMMANDS;
+	}
+}
diff --git a/L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql b/L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql
index c005886e55..ee2859bde0 100644
--- a/L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql
+++ b/L2J_DataPack_BETA/dist/sql/game/admin_command_access_rights.sql
@@ -557,6 +557,9 @@ INSERT IGNORE INTO `admin_command_access_rights` VALUES
 -- ADMIN TARGET
 ('admin_target',1,'false'),
 
+-- ADMIN TARGETSAY
+('admin_targetsay',1,'false'),
+
 -- ADMIN TELEPORT
 ('admin_show_moves',1,'false'),
 ('admin_show_moves_other',1,'false'),
-- 
GitLab