All pastes #990788 Raw Edit

Anonymous

public text v1 · immutable
#990788 ·published 2008-04-20 12:54 UTC
rendered paste body
Index: D:/Projects/skyhunter/branches/L2jFree_GameServer_IL(Zones)/src/main/java/net/sf/l2j/gameserver/network/clientpackets/Say2.java
===================================================================
--- D:/Projects/skyhunter/branches/L2jFree_GameServer_IL(Zones)/src/main/java/net/sf/l2j/gameserver/network/clientpackets/Say2.java	(revision 52)
+++ D:/Projects/skyhunter/branches/L2jFree_GameServer_IL(Zones)/src/main/java/net/sf/l2j/gameserver/network/clientpackets/Say2.java	(working copy)
@@ -19,7 +19,6 @@
 package net.sf.l2j.gameserver.network.clientpackets;
 
 import java.nio.BufferUnderflowException;
-import java.util.StringTokenizer;
 
 import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.handler.ChatHandler;
@@ -109,30 +108,28 @@
             }
         }       
 
-        if (_text.startsWith(".") && !_text.startsWith("..") &&
-            _type == SystemChatChannelId.Chat_Normal)
+        if (_text.startsWith(".") && !_text.startsWith("@") &&
+        		_type == SystemChatChannelId.Chat_Normal)
         {
-            StringTokenizer st = new StringTokenizer(_text);
+        	String [] _commandParams = _text.split(" ");
 
-            if (st.countTokens()>=1)
-            {
-                String command = st.nextToken().substring(1);
-                String params = "";
-                if (st.countTokens()==0)
-                {
-                    if (activeChar.getTarget()!=null) params=activeChar.getTarget().getName();
-                }
-                else params=st.nextToken().trim();
+        	String command = _commandParams[0].substring(1);
+        	String params = "";
 
-                IVoicedCommandHandler vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
+        	// if entered "command text"
+        	if (_commandParams.length > 1)
+        		params = _text.substring(1 + command.length()).trim(); // get all text
+        	else
+        		if (activeChar.getTarget()!=null) params=activeChar.getTarget().getName();
 
-                if (vch != null) 
-                    vch.useVoicedCommand(command, activeChar, params);
-                else
-                    _log.warn("No handler registered for voice command '"+command+"'");
-            }
-            
-            return;
+        	IVoicedCommandHandler vch = VoicedCommandHandler.getInstance().getVoicedCommandHandler(command);
+
+        	if (vch != null) 
+        		vch.useVoicedCommand(command, activeChar, params);
+        	else
+        		_log.warn("No handler registered for voice command '"+command+"'");
+
+        	return;
         }
         // Some custom implementation to show how to add channels
         // (for me Chat_System is used for emotes - further informations