Browse Source

BETA: New admin command for testing purposing:
* Extends the already existing command msg, the msgx allows the use of parameters.
* Command format: !//msgx <SYSTEM_MSG_ID> [item:Id] [skill:Id] [npc:Id] [zone:x,y,x] [castle:Id] [str:'text']
* No order required for the [] parameters, but at least one must be specified.
* More types will be added in time.
* Examples:
!//msgx 2913 str:'L2JClan' castle:81
Produces the following output in the NA client: Clan L2JClan has succeeded in Capturing Gludio Territory's territory ward.
!//msgx 1987 str:'Only this will be print.'
Produces the following output in any client: Only this will be print.

Zoey76 12 years ago
parent
commit
af68bce22c

+ 62 - 2
L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminMessages.java

@@ -17,21 +17,26 @@ package handlers.admincommandhandlers;
 import com.l2jserver.gameserver.handler.IAdminCommandHandler;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.util.Util;
 
 /**
+ * Allows Game Masters to test System Messages.<br>
+ * admin_msg display the raw message.<br>
+ * admin_msgx is an extended version that allows to set parameters.
  * @author Zoey76
  */
 public class AdminMessages implements IAdminCommandHandler
 {
 	private static final String[] ADMIN_COMMANDS =
 	{
-		"admin_msg"
+		"admin_msg",
+		"admin_msgx"
 	};
 	
 	@Override
 	public boolean useAdminCommand(String command, L2PcInstance activeChar)
 	{
-		if (command.startsWith("admin_msg"))
+		if (command.startsWith("admin_msg "))
 		{
 			try
 			{
@@ -43,6 +48,61 @@ public class AdminMessages implements IAdminCommandHandler
 				activeChar.sendMessage("Command format: //msg <SYSTEM_MSG_ID>");
 			}
 		}
+		else if (command.startsWith("admin_msgx "))
+		{
+			String[] tokens = command.split(" ");
+			if (tokens.length <= 2 || !Util.isDigit(tokens[1]))
+			{
+				activeChar.sendMessage("Command format: //msgx <SYSTEM_MSG_ID> [item:Id] [skill:Id] [npc:Id] [zone:x,y,x] [castle:Id] [str:'text']");
+				return false;
+			}
+			
+			SystemMessage sm = SystemMessage.getSystemMessage(Integer.parseInt(tokens[1]));
+			String val;
+			int lastPos = 0;
+			for (int i = 2; i < tokens.length; i++)
+			{
+				try
+				{
+					val = tokens[i];
+					if (val.startsWith("item:"))
+					{
+						sm.addItemName(Integer.parseInt(val.substring(5)));
+					}
+					else if (val.startsWith("skill:"))
+					{
+						sm.addSkillName(Integer.parseInt(val.substring(6)));
+					}
+					else if (val.startsWith("npc:"))
+					{
+						sm.addNpcName(Integer.parseInt(val.substring(4)));
+					}
+					else if (val.startsWith("zone:"))
+					{
+						int x = Integer.parseInt(val.substring(5, val.indexOf(",")));
+						int y = Integer.parseInt(val.substring(val.indexOf(",") + 1, val.lastIndexOf(",")));
+						int z = Integer.parseInt(val.substring(val.lastIndexOf(",") + 1, val.length()));
+						sm.addZoneName(x, y, z);
+					}
+					else if (val.startsWith("castle:"))
+					{
+						sm.addCastleId(Integer.parseInt(val.substring(7)));
+					}
+					else if (val.startsWith("str:"))
+					{
+						final int pos = command.indexOf("'", lastPos+1);
+						lastPos = command.indexOf("'", pos + 1);
+						sm.addString(command.substring(pos + 1, lastPos));
+					}
+				}
+				catch (Exception e)
+				{
+					activeChar.sendMessage("Exception: " + e.getMessage());
+					continue;
+				}
+			}
+			activeChar.sendPacket(sm);
+		}
 		return false;
 	}