瀏覽代碼

Little cleaning, following an old wise advice

DrHouse 16 年之前
父節點
當前提交
f2eafa96f5

+ 2 - 6
L2_GameServer/java/net/sf/l2j/gameserver/datatables/SkillTable.java

@@ -81,18 +81,14 @@ public class SkillTable
 	
 	public L2Skill getInfo(int skillId, int level)
 	{
-		return _skills.get(SkillTable.getSkillHashCode(skillId, level));
+		return _skills.get(getSkillHashCode(skillId, level));
 	}
 	
 	public int getMaxLevel(int magicId, int level)
 	{
-		L2Skill temp;
-		
 		while (level < 100)
 		{
-			temp = _skills.get(SkillTable.getSkillHashCode(magicId, ++level));
-			
-			if (temp == null)
+			if (_skills.get(getSkillHashCode(magicId, ++level)) == null)
 				return level - 1;
 		}
 		

+ 61 - 0
L2_GameServer/java/net/sf/l2j/gameserver/model/L2ItemInstance.java

@@ -33,8 +33,10 @@ import net.sf.l2j.gameserver.instancemanager.MercTicketManager;
 import net.sf.l2j.gameserver.model.actor.L2Character;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.actor.knownlist.NullKnownList;
+import net.sf.l2j.gameserver.model.quest.QuestState;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.GetItem;
 import net.sf.l2j.gameserver.network.serverpackets.InventoryUpdate;
 import net.sf.l2j.gameserver.network.serverpackets.StatusUpdate;
 import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
@@ -180,6 +182,65 @@ public final class L2ItemInstance extends L2Object
 		_loc = ItemLocation.VOID;
 		_mana = _item.getDuration();
 	}
+	
+	/**
+     * Remove a L2ItemInstance from the world and send server->client GetItem packets.<BR><BR>
+     *
+     * <B><U> Actions</U> :</B><BR><BR>
+     * <li>Send a Server->Client Packet GetItem to player that pick up and its _knowPlayers member </li>
+     * <li>Remove the L2Object from the world</li><BR><BR>
+     *
+     * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR><BR>
+     *
+     * <B><U> Assert </U> :</B><BR><BR>
+     * <li> this instanceof L2ItemInstance</li>
+     * <li> _worldRegion != null <I>(L2Object is visible at the beginning)</I></li><BR><BR>
+     *
+     * <B><U> Example of use </U> :</B><BR><BR>
+     * <li> Do Pickup Item : PCInstance and Pet</li><BR><BR>
+     *
+     * @param player Player that pick up the item
+     *
+     */
+    public final void pickupMe(L2Character player)
+    {
+        if (Config.ASSERT) assert getPosition().getWorldRegion() != null;
+
+        L2WorldRegion oldregion = getPosition().getWorldRegion();
+
+        // Create a server->client GetItem packet to pick up the L2ItemInstance
+        GetItem gi = new GetItem(this, player.getObjectId());
+        player.broadcastPacket(gi);
+
+        synchronized (this)
+        {
+            setIsVisible(false);
+            getPosition().setWorldRegion(null);
+        }
+
+        // if this item is a mercenary ticket, remove the spawns!
+        int itemId = getItemId();
+        
+        if (MercTicketManager.getInstance().getTicketCastleId(itemId) > 0)
+        {
+        	MercTicketManager.getInstance().removeTicket(this);
+        	ItemsOnGroundManager.getInstance().removeObject(this);
+        }
+        
+        if (itemId == 57 || itemId == 6353)
+        {
+        	L2PcInstance actor = player.getActingPlayer();
+        	if (actor != null)
+        	{
+        		QuestState qs = actor.getQuestState("255_Tutorial");
+            	if (qs != null)
+            		qs.getQuest().notifyEvent("CE"+itemId+"",null, actor);
+        	}
+        }
+        // outside of synchronized to avoid deadlocks
+        // Remove the L2ItemInstance from the world
+        L2World.getInstance().removeVisibleObject(this, oldregion);
+    }
 
 	/**
 	 * Sets the ownerID of the item

+ 0 - 73
L2_GameServer/java/net/sf/l2j/gameserver/model/L2Object.java

@@ -18,17 +18,13 @@ import net.sf.l2j.Config;
 import net.sf.l2j.gameserver.idfactory.IdFactory;
 import net.sf.l2j.gameserver.instancemanager.InstanceManager;
 import net.sf.l2j.gameserver.instancemanager.ItemsOnGroundManager;
-import net.sf.l2j.gameserver.instancemanager.MercTicketManager;
 import net.sf.l2j.gameserver.model.actor.L2Character;
-import net.sf.l2j.gameserver.model.actor.L2Summon;
 import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
 import net.sf.l2j.gameserver.model.actor.knownlist.ObjectKnownList;
 import net.sf.l2j.gameserver.model.actor.poly.ObjectPoly;
 import net.sf.l2j.gameserver.model.actor.position.ObjectPosition;
-import net.sf.l2j.gameserver.model.quest.QuestState;
 import net.sf.l2j.gameserver.network.L2GameClient;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
-import net.sf.l2j.gameserver.network.serverpackets.GetItem;
 
 
 /**
@@ -206,75 +202,6 @@ public abstract class L2Object
         	ItemsOnGroundManager.getInstance().removeObject(this);
     }
 
-
-    /**
-     * Remove a L2ItemInstance from the world and send server->client GetItem packets.<BR><BR>
-     *
-     * <B><U> Actions</U> :</B><BR><BR>
-     * <li>Send a Server->Client Packet GetItem to player that pick up and its _knowPlayers member </li>
-     * <li>Remove the L2Object from the world</li><BR><BR>
-     *
-     * <FONT COLOR=#FF0000><B> <U>Caution</U> : This method DOESN'T REMOVE the object from _allObjects of L2World </B></FONT><BR><BR>
-     *
-     * <B><U> Assert </U> :</B><BR><BR>
-     * <li> this instanceof L2ItemInstance</li>
-     * <li> _worldRegion != null <I>(L2Object is visible at the beginning)</I></li><BR><BR>
-     *
-     * <B><U> Example of use </U> :</B><BR><BR>
-     * <li> Do Pickup Item : PCInstance and Pet</li><BR><BR>
-     *
-     * @param player Player that pick up the item
-     *
-     */
-    public final void pickupMe(L2Character player) // NOTE: Should move this function into L2ItemInstance because it does not apply to L2Character
-    {
-        if (Config.ASSERT) assert this instanceof L2ItemInstance;
-        if (Config.ASSERT) assert getPosition().getWorldRegion() != null;
-
-        L2WorldRegion oldregion = getPosition().getWorldRegion();
-
-        // Create a server->client GetItem packet to pick up the L2ItemInstance
-        GetItem gi = new GetItem((L2ItemInstance)this, player.getObjectId());
-        player.broadcastPacket(gi);
-
-        synchronized (this)
-        {
-            _isVisible = false;
-            getPosition().setWorldRegion(null);
-        }
-
-        // if this item is a mercenary ticket, remove the spawns!
-        if (this instanceof L2ItemInstance)
-        {
-        	int itemId = ((L2ItemInstance)this).getItemId();
-        	if (MercTicketManager.getInstance().getTicketCastleId(itemId) > 0)
-        	{
-        		MercTicketManager.getInstance().removeTicket((L2ItemInstance)this);
-        		ItemsOnGroundManager.getInstance().removeObject(this);
-        	}
-        	if (itemId == 57 || itemId == 6353)
-        	{
-        		QuestState qs = null;
-        		if (player instanceof L2Summon)
-        		{
-        			qs = ((L2Summon)player).getOwner().getQuestState("255_Tutorial");
-            		if (qs != null)
-            			qs.getQuest().notifyEvent("CE"+itemId+"",null,((L2Summon)player).getOwner());
-        		}
-        		else if (player instanceof L2PcInstance)
-        		{
-        			qs = ((L2PcInstance)player).getQuestState("255_Tutorial");
-            		if (qs != null)
-            			qs.getQuest().notifyEvent("CE"+itemId+"",null,(L2PcInstance)player);
-        		}
-        	}
-        }
-
-        // outside of synchronized to avoid deadlocks
-        // Remove the L2ItemInstance from the world
-        L2World.getInstance().removeVisibleObject(this, oldregion);
-    }
-
     public void refreshID()
     {
         L2World.getInstance().removeObject(this);