Ver Fonte

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 há 12 anos atrás
pai
commit
c38d4b5857

+ 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