소스 검색

New condition <player hasPet="list of control item ids, comma separated" />
Also moved all conditions and tables from FastList to ArrayList with predefined size.

_DS_ 15 년 전
부모
커밋
fcc4a8eb3e

+ 20 - 16
L2_GameServer/java/com/l2jserver/gameserver/skills/DocumentBase.java

@@ -25,7 +25,6 @@ import java.util.logging.Logger;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 
-import javolution.util.FastList;
 import javolution.util.FastMap;
 
 import org.w3c.dom.Document;
@@ -554,8 +553,8 @@ abstract class DocumentBase
             }
             else if ("clanHall".equalsIgnoreCase(a.getNodeName()))
             {
-            	FastList<Integer> array = new FastList<Integer>();
             	StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+            	ArrayList<Integer> array = new ArrayList<Integer>(st.countTokens());
             	while (st.hasMoreTokens())
                 {
                     String item = st.nextToken().trim();
@@ -614,8 +613,8 @@ abstract class DocumentBase
             }
             else if ("class_id_restriction".equalsIgnoreCase(a.getNodeName()))
             {
-            	FastList<Integer> array = new FastList<Integer>();
             	StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+            	ArrayList<Integer> array = new ArrayList<Integer>(st.countTokens());
             	while (st.hasMoreTokens())
                 {
                     String item = st.nextToken().trim();
@@ -628,10 +627,10 @@ abstract class DocumentBase
 				boolean val = Boolean.valueOf(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerSubclass(val));
 			}
-			else if ("instanceid".equalsIgnoreCase(a.getNodeName()))
+			else if ("instanceId".equalsIgnoreCase(a.getNodeName()))
 			{
-            	FastList<Integer> array = new FastList<Integer>();
             	StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+	        	ArrayList<Integer> array = new ArrayList<Integer>(st.countTokens());
             	while (st.hasMoreTokens())
                 {
                     String item = st.nextToken().trim();
@@ -649,6 +648,17 @@ abstract class DocumentBase
 				int val = Integer.valueOf(a.getNodeValue());
 				cond = joinAnd(cond, new ConditionPlayerCloakStatus(val));
 			}
+			else if ("hasPet".equalsIgnoreCase(a.getNodeName()))
+			{
+	        	StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+	        	ArrayList<Integer> array = new ArrayList<Integer>(st.countTokens());
+	        	while (st.hasMoreTokens())
+	        	{
+	        		String item = st.nextToken().trim();
+	        		array.add(Integer.decode(getValue(item, null)));
+	        	}
+	        	cond = joinAnd(cond, new ConditionPlayerHasPet(array));
+			}
         }
 
         if (forces[0] + forces[1] > 0)
@@ -682,8 +692,8 @@ abstract class DocumentBase
             }
             else if ("class_id_restriction".equalsIgnoreCase(a.getNodeName()))
             {
-            	FastList<Integer> array = new FastList<Integer>();
             	StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+            	ArrayList<Integer> array = new ArrayList<Integer>(st.countTokens());
             	while (st.hasMoreTokens())
                 {
                     String item = st.nextToken().trim();
@@ -728,8 +738,8 @@ abstract class DocumentBase
             // used for npc race
             else if ("race_id".equalsIgnoreCase(a.getNodeName()))
             {
-            	ArrayList<Integer> array = new ArrayList<Integer>();
             	StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+            	ArrayList<Integer> array = new ArrayList<Integer>(st.countTokens());
             	while (st.hasMoreTokens())
             	{
             		String item = st.nextToken().trim();
@@ -771,8 +781,8 @@ abstract class DocumentBase
             }
             else if ("npcId".equalsIgnoreCase(a.getNodeName()))
             {
-            	ArrayList<Integer> array = new ArrayList<Integer>();
             	StringTokenizer st = new StringTokenizer(a.getNodeValue(), ",");
+            	ArrayList<Integer> array = new ArrayList<Integer>(st.countTokens());
             	while (st.hasMoreTokens())
             	{
             		String item = st.nextToken().trim();
@@ -888,16 +898,10 @@ abstract class DocumentBase
         String name = attrs.getNamedItem("name").getNodeValue();
         if (name.charAt(0) != '#') throw new IllegalArgumentException("Table name must start with #");
         StringTokenizer data = new StringTokenizer(n.getFirstChild().getNodeValue());
-        List<String> array = new FastList<String>();
+        List<String> array = new ArrayList<String>(data.countTokens());
         while (data.hasMoreTokens())
             array.add(data.nextToken());
-        String[] res = new String[array.size()];
-        int i = 0;
-        for (String str : array)
-        {
-            res[i++] = str;
-        }
-        setTable(name, res);
+        setTable(name, array.toArray(new String[array.size()]));
     }
 
     protected void parseBeanSet(Node n, StatsSet set, Integer level)

+ 4 - 4
L2_GameServer/java/com/l2jserver/gameserver/skills/conditions/ConditionPlayerClassIdRestriction.java

@@ -14,16 +14,16 @@
  */
 package com.l2jserver.gameserver.skills.conditions;
 
+import java.util.ArrayList;
+
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.skills.Env;
 
-import javolution.util.FastList;
-
 public class ConditionPlayerClassIdRestriction extends Condition
 {
-	private final FastList<Integer> _classIds;
+	private final ArrayList<Integer> _classIds;
 
-	public ConditionPlayerClassIdRestriction(FastList<Integer> classId)
+	public ConditionPlayerClassIdRestriction(ArrayList<Integer> classId)
 	{
 		_classIds = classId;
 	}

+ 11 - 12
L2_GameServer/java/com/l2jserver/gameserver/skills/conditions/ConditionPlayerHasClanHall.java

@@ -14,26 +14,25 @@
  */
 package com.l2jserver.gameserver.skills.conditions;
 
+import java.util.ArrayList;
+
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.skills.Env;
 
-import javolution.util.FastList;
-
 /**
  * @author MrPoke
  *
  */
 public final class ConditionPlayerHasClanHall extends Condition
 {
-	
-	private final FastList<Integer> _clanHall;
-	
-	public ConditionPlayerHasClanHall(FastList<Integer> clanHall)
+	private final ArrayList<Integer> _clanHall;
+
+	public ConditionPlayerHasClanHall(ArrayList<Integer> clanHall)
 	{
 		_clanHall = clanHall;
 	}
-	
+
 	/**
 	 * 
 	 * @see com.l2jserver.gameserver.skills.conditions.Condition#testImpl(com.l2jserver.gameserver.skills.Env)
@@ -43,15 +42,15 @@ public final class ConditionPlayerHasClanHall extends Condition
 	{
 		if (!(env.player instanceof L2PcInstance))
 			return false;
-		
+
 		L2Clan clan = ((L2PcInstance)env.player).getClan();
 		if (clan == null)
-			return (_clanHall.size() == 1 && _clanHall.getFirst() == 0);
-		
+			return (_clanHall.size() == 1 && _clanHall.get(0) == 0);
+
 		// All Clan Hall
-		if (_clanHall.size() == 1 && _clanHall.getFirst() == -1)
+		if (_clanHall.size() == 1 && _clanHall.get(0) == -1)
 			return clan.getHasHideout() > 0;
-		
+
 		return _clanHall.contains(clan.getHasHideout());
 	}
 }

+ 48 - 0
L2_GameServer/java/com/l2jserver/gameserver/skills/conditions/ConditionPlayerHasPet.java

@@ -0,0 +1,48 @@
+/*
+ * 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 com.l2jserver.gameserver.skills.conditions;
+
+import java.util.ArrayList;
+
+import com.l2jserver.gameserver.model.L2ItemInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2PetInstance;
+import com.l2jserver.gameserver.skills.Env;
+
+public class ConditionPlayerHasPet extends Condition
+{
+	private final ArrayList<Integer> _controlItemIds;
+
+	public ConditionPlayerHasPet(ArrayList<Integer> itemIds)
+	{
+		_controlItemIds = itemIds;
+	}
+
+	@Override
+	public boolean testImpl(Env env)
+	{
+		if (!(env.player instanceof L2PcInstance))
+			return false;
+
+		if (!(env.player.getPet() instanceof L2PetInstance))
+			return false;
+
+		final L2ItemInstance controlItem = ((L2PetInstance)env.player.getPet()).getControlItem();
+		if (controlItem == null)
+			return false;
+
+		return _controlItemIds.contains(controlItem.getItemId());
+	}
+}

+ 4 - 4
L2_GameServer/java/com/l2jserver/gameserver/skills/conditions/ConditionPlayerInstanceId.java

@@ -14,18 +14,18 @@
  */
 package com.l2jserver.gameserver.skills.conditions;
 
+import java.util.ArrayList;
+
 import com.l2jserver.gameserver.instancemanager.InstanceManager;
 import com.l2jserver.gameserver.instancemanager.InstanceManager.InstanceWorld;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.skills.Env;
 
-import javolution.util.FastList;
-
 public class ConditionPlayerInstanceId extends Condition
 {
-	private final FastList<Integer> _instanceIds;
+	private final ArrayList<Integer> _instanceIds;
 
-	public ConditionPlayerInstanceId(FastList<Integer> instanceIds)
+	public ConditionPlayerInstanceId(ArrayList<Integer> instanceIds)
 	{
 		_instanceIds = instanceIds;
 	}

+ 8 - 7
L2_GameServer/java/com/l2jserver/gameserver/skills/conditions/ConditionTargetClassIdRestriction.java

@@ -14,22 +14,23 @@
  */
 package com.l2jserver.gameserver.skills.conditions;
 
+import java.util.ArrayList;
+
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.skills.Env;
 
-import javolution.util.FastList;
-
-public class ConditionTargetClassIdRestriction extends Condition {
+public class ConditionTargetClassIdRestriction extends Condition
+{
+	private final ArrayList<Integer> _classIds;
 
-	private final FastList<Integer> _classIds;
-
-	public ConditionTargetClassIdRestriction(FastList<Integer> classId)
+	public ConditionTargetClassIdRestriction(ArrayList<Integer> classId)
 	{
 		_classIds = classId;
 	}
 
 	@Override
-	public boolean testImpl(Env env) {
+	public boolean testImpl(Env env)
+	{
 		if (!(env.target instanceof L2PcInstance))
 			return false;
 		return (_classIds.contains(((L2PcInstance)env.target).getClassId().getId()));