瀏覽代碼

BETA: Adding two methods in L2PcInstance:
* hasVariables: returns true if PlayerVariables instance is attached to current player's scripts, false otherwise.
* getVariables: return PlayerVariables instance containing parameters regarding player.
* Reviewed by: Zoey76

Rumen Nikiforov 12 年之前
父節點
當前提交
c38d4b5857
共有 1 個文件被更改,包括 17 次插入0 次删除
  1. 17 0
      L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

+ 17 - 0
L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/instance/L2PcInstance.java

@@ -15295,6 +15295,23 @@ public final class L2PcInstance extends L2Playable
 		return false;
 	}
 	
+	/**
+	 * @return {@code true} if {@link PlayerVariables} instance is attached to current player's scripts, {@code false} otherwise.
+	 */
+	public boolean hasVariables()
+	{
+		return getScript(PlayerVariables.class) != null;
+	}
+	
+	/**
+	 * @return {@link PlayerVariables} instance containing parameters regarding player.
+	 */
+	public PlayerVariables getVariables()
+	{
+		final PlayerVariables vars = getScript(PlayerVariables.class);
+		return vars != null ? vars : addScript(new PlayerVariables(getObjectId()));
+	}
+	
 	/**
 	 * Adds a despawn listener
 	 * @param listener