diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Effect.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Effect.java index c6e1a8d7d3..171f54e5a6 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Effect.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Effect.java @@ -17,6 +17,7 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -104,8 +105,6 @@ public abstract class Effect NEGATE } - private static final Func[] _emptyFunctionSet = new Func[0]; - // member _effector is the instance of Creature that cast/used the spell/skill that is causing this effect. Do not confuse with the instance of Creature that is being affected by this effect. private final Creature _effector; @@ -538,12 +537,13 @@ public abstract class Effect } } - public Func[] getStatFuncs() + public List getStatFuncs() { if (_funcTemplates == null) { - return _emptyFunctionSet; + return Collections.emptyList(); } + final List funcs = new ArrayList<>(); for (FuncTemplate t : _funcTemplates) { @@ -557,11 +557,8 @@ public abstract class Effect funcs.add(f); } } - if (funcs.isEmpty()) - { - return _emptyFunctionSet; - } - return funcs.toArray(new Func[funcs.size()]); + + return funcs; } public void addIcon(MagicEffectIcons mi) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Skill.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Skill.java index 5c1c206d15..a48fb73b99 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Skill.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/Skill.java @@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.StringTokenizer; import java.util.logging.Logger; @@ -380,9 +381,6 @@ public abstract class Skill public static final int COND_GRADED = 0x080000; public static final int COND_GRADES = 0x100000; - private static final Func[] _emptyFunctionSet = new Func[0]; - private static final Effect[] _emptyEffectSet = new Effect[0]; - // these two build the primary key private final int _id; private final int _level; @@ -2611,16 +2609,16 @@ public abstract class Skill return targets.get(0); } - public Func[] getStatFuncs(Effect effect, Creature creature) + public List getStatFuncs(Effect effect, Creature creature) { if (!(creature instanceof PlayerInstance) && !(creature instanceof Attackable) && !(creature instanceof Summon)) { - return _emptyFunctionSet; + return Collections.emptyList(); } if (_funcTemplates == null) { - return _emptyFunctionSet; + return Collections.emptyList(); } final List funcs = new ArrayList<>(); @@ -2635,12 +2633,8 @@ public abstract class Skill funcs.add(f); } } - if (funcs.isEmpty()) - { - return _emptyFunctionSet; - } - return funcs.toArray(new Func[funcs.size()]); + return funcs; } public boolean hasEffects() @@ -2648,31 +2642,31 @@ public abstract class Skill return (_effectTemplates != null) && (_effectTemplates.length > 0); } - public Effect[] applyEffects(Creature effector, Creature effected) + public List applyEffects(Creature effector, Creature effected) { return applyEffects(effector, effected, false, false, false); } - public Effect[] applyEffects(Creature effector, Creature effected, boolean ss, boolean sps, boolean bss) + public List applyEffects(Creature effector, Creature effected, boolean ss, boolean sps, boolean bss) { if (isPassive()) { - return _emptyEffectSet; + return Collections.emptyList(); } if (_effectTemplates == null) { - return _emptyEffectSet; + return Collections.emptyList(); } if ((effector != effected) && effected.isInvul()) { - return _emptyEffectSet; + return Collections.emptyList(); } if ((_skillType == SkillType.BUFF) && effected.isBlockBuff()) { - return _emptyEffectSet; + return Collections.emptyList(); } final List effects = new ArrayList<>(); @@ -2706,24 +2700,19 @@ public abstract class Skill } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - - return effects.toArray(new Effect[effects.size()]); + return effects; } - public Effect[] applySelfEffects(Creature effector) + public List applySelfEffects(Creature effector) { if (isPassive()) { - return _emptyEffectSet; + return Collections.emptyList(); } if (_effectTemplatesSelf == null) { - return _emptyEffectSet; + return Collections.emptyList(); } final List effects = new ArrayList<>(); @@ -2767,12 +2756,8 @@ public abstract class Skill } } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - return effects.toArray(new Effect[effects.size()]); + return effects; } public void attach(FuncTemplate f) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java index 2b47dbf1a2..e3d1df5bbb 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -4447,7 +4447,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder *
  • Use an active skill

  • * @param funcs The list of Func objects to add to the Calculator corresponding to the state affected */ - public synchronized void addStatFuncs(Func[] funcs) + public synchronized void addStatFuncs(List funcs) { final List modifiedStats = new ArrayList<>(); for (Func f : funcs) diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Armor.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Armor.java index 0e94f64957..dde14760b2 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Armor.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Armor.java @@ -17,6 +17,7 @@ package org.l2jmobius.gameserver.model.items; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.l2jmobius.gameserver.data.SkillTable; @@ -147,26 +148,29 @@ public class Armor extends Item * Returns array of Func objects containing the list of functions used by the armor * @param instance : ItemInstance pointing out the armor * @param creature : Creature pointing out the player - * @return Func[] : array of functions + * @return List : List of functions */ @Override - public Func[] getStatFuncs(ItemInstance instance, Creature creature) + public List getStatFuncs(ItemInstance instance, Creature creature) { - final List funcs = new ArrayList<>(); - if (_funcTemplates != null) + if (_funcTemplates == null) { - for (FuncTemplate t : _funcTemplates) + return Collections.emptyList(); + } + + final List funcs = new ArrayList<>(); + for (FuncTemplate t : _funcTemplates) + { + final Env env = new Env(); + env.player = creature; + env.item = instance; + final Func f = t.getFunc(env, instance); + if (f != null) { - final Env env = new Env(); - env.player = creature; - env.item = instance; - final Func f = t.getFunc(env, instance); - if (f != null) - { - funcs.add(f); - } + funcs.add(f); } } - return funcs.toArray(new Func[funcs.size()]); + + return funcs; } } diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Item.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Item.java index b22ebf6475..7b5eeb3e17 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Item.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Item.java @@ -17,6 +17,7 @@ package org.l2jmobius.gameserver.model.items; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.l2jmobius.Config; @@ -140,9 +141,6 @@ public abstract class Item protected EffectTemplate[] _effectTemplates; protected Skill[] _skills; - private static final Func[] _emptyFunctionSet = new Func[0]; - protected static final Effect[] _emptyEffectSet = new Effect[0]; - /** * Constructor of the Item that fill class variables.
    * Variables filled :
    @@ -507,14 +505,15 @@ public abstract class Item * Returns array of Func objects containing the list of functions used by the item * @param instance : ItemInstance pointing out the item * @param creature : Creature pointing out the player - * @return Func[] : array of functions + * @return List : List of functions */ - public Func[] getStatFuncs(ItemInstance instance, Creature creature) + public List getStatFuncs(ItemInstance instance, Creature creature) { if (_funcTemplates == null) { - return _emptyFunctionSet; + return Collections.emptyList(); } + final List funcs = new ArrayList<>(); for (FuncTemplate t : _funcTemplates) { @@ -528,25 +527,23 @@ public abstract class Item funcs.add(f); } } - if (funcs.isEmpty()) - { - return _emptyFunctionSet; - } - return funcs.toArray(new Func[funcs.size()]); + + return funcs; } /** * Returns the effects associated with the item. * @param instance : ItemInstance pointing out the item * @param creature : Creature pointing out the player - * @return Effect[] : array of effects generated by the item + * @return List : List of effects generated by the item */ - public Effect[] getEffects(ItemInstance instance, Creature creature) + public List getEffects(ItemInstance instance, Creature creature) { if (_effectTemplates == null) { - return _emptyEffectSet; + return Collections.emptyList(); } + final List effects = new ArrayList<>(); for (EffectTemplate et : _effectTemplates) { @@ -560,25 +557,23 @@ public abstract class Item effects.add(e); } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - return effects.toArray(new Effect[effects.size()]); + + return effects; } /** * Returns effects of skills associated with the item. * @param caster : Creature pointing out the caster * @param target : Creature pointing out the target - * @return Effect[] : array of effects generated by the skill + * @return List : List of effects generated by the skill */ - public Effect[] getSkillEffects(Creature caster, Creature target) + public List getSkillEffects(Creature caster, Creature target) { if (_skills == null) { - return _emptyEffectSet; + return Collections.emptyList(); } + final List effects = new ArrayList<>(); for (Skill skill : _skills) { @@ -596,11 +591,8 @@ public abstract class Item effects.add(e); } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - return effects.toArray(new Effect[effects.size()]); + + return effects; } /** diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Weapon.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Weapon.java index 421bac20a8..015ad3e0e2 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Weapon.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/Weapon.java @@ -17,6 +17,7 @@ package org.l2jmobius.gameserver.model.items; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.l2jmobius.gameserver.data.SkillTable; @@ -290,27 +291,30 @@ public class Weapon extends Item * Returns array of Func objects containing the list of functions used by the weapon * @param instance : ItemInstance pointing out the weapon * @param creature : Creature pointing out the player - * @return Func[] : array of functions + * @return List : List of functions */ @Override - public Func[] getStatFuncs(ItemInstance instance, Creature creature) + public List getStatFuncs(ItemInstance instance, Creature creature) { - final List funcs = new ArrayList<>(); - if (_funcTemplates != null) + if (_funcTemplates == null) { - for (FuncTemplate t : _funcTemplates) + return Collections.emptyList(); + } + + final List funcs = new ArrayList<>(); + for (FuncTemplate t : _funcTemplates) + { + final Env env = new Env(); + env.player = creature; + env.item = instance; + final Func f = t.getFunc(env, instance); + if (f != null) { - final Env env = new Env(); - env.player = creature; - env.item = instance; - final Func f = t.getFunc(env, instance); - if (f != null) - { - funcs.add(f); - } + funcs.add(f); } } - return funcs.toArray(new Func[funcs.size()]); + + return funcs; } /** @@ -318,14 +322,15 @@ public class Weapon extends Item * @param caster : Creature pointing out the caster * @param target : Creature pointing out the target * @param crit : boolean tells whether the hit was critical - * @return Effect[] : array of effects generated by the skill + * @return List : List of effects generated by the skill */ - public Effect[] getSkillEffects(Creature caster, Creature target, boolean crit) + public List getSkillEffects(Creature caster, Creature target, boolean crit) { if ((_skillsOnCrit == null) || !crit) { - return _emptyEffectSet; + return Collections.emptyList(); } + final List effects = new ArrayList<>(); for (Skill skill : _skillsOnCrit) { @@ -348,11 +353,8 @@ public class Weapon extends Item effects.add(e); } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - return effects.toArray(new Effect[effects.size()]); + + return effects; } /** @@ -360,7 +362,7 @@ public class Weapon extends Item * @param caster : Creature pointing out the caster * @param target : Creature pointing out the target * @param trigger : Skill pointing out the skill triggering this action - * @return Effect[] : array of effects generated by the skill + * @return List : List of effects generated by the skill */ public boolean getSkillEffects(Creature caster, Creature target, Skill trigger) { diff --git a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/instance/ItemInstance.java b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/instance/ItemInstance.java index f03475ebb2..0197a34719 100644 --- a/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/instance/ItemInstance.java +++ b/L2J_Mobius_C4_ScionsOfDestiny/java/org/l2jmobius/gameserver/model/items/instance/ItemInstance.java @@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.items.instance; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.List; import java.util.concurrent.ScheduledFuture; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -869,9 +870,9 @@ public class ItemInstance extends WorldObject /** * This function basically returns a set of functions from Item/Armor/Weapon, but may add additional functions, if this particular item instance is enhanched for a particular player. * @param creature : Creature designating the player - * @return Func[] + * @return List */ - public Func[] getStatFuncs(Creature creature) + public List getStatFuncs(Creature creature) { return _item.getStatFuncs(this, creature); } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Continuous.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Continuous.java index 11e3874125..f16e276035 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Continuous.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/handler/skillhandlers/Continuous.java @@ -237,15 +237,11 @@ public class Continuous implements ISkillHandler final DuelManager dm = DuelManager.getInstance(); if (dm != null) { - final Effect[] effects = skill.applyEffects(creature, target, ss, sps, bss); - if (effects != null) + for (Effect buff : skill.applyEffects(creature, target, ss, sps, bss)) { - for (Effect buff : effects) + if (buff != null) { - if (buff != null) - { - dm.onBuff(((PlayerInstance) target), buff); - } + dm.onBuff(((PlayerInstance) target), buff); } } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Effect.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Effect.java index c6e1a8d7d3..171f54e5a6 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Effect.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Effect.java @@ -17,6 +17,7 @@ package org.l2jmobius.gameserver.model; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; @@ -104,8 +105,6 @@ public abstract class Effect NEGATE } - private static final Func[] _emptyFunctionSet = new Func[0]; - // member _effector is the instance of Creature that cast/used the spell/skill that is causing this effect. Do not confuse with the instance of Creature that is being affected by this effect. private final Creature _effector; @@ -538,12 +537,13 @@ public abstract class Effect } } - public Func[] getStatFuncs() + public List getStatFuncs() { if (_funcTemplates == null) { - return _emptyFunctionSet; + return Collections.emptyList(); } + final List funcs = new ArrayList<>(); for (FuncTemplate t : _funcTemplates) { @@ -557,11 +557,8 @@ public abstract class Effect funcs.add(f); } } - if (funcs.isEmpty()) - { - return _emptyFunctionSet; - } - return funcs.toArray(new Func[funcs.size()]); + + return funcs; } public void addIcon(MagicEffectIcons mi) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Skill.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Skill.java index 0e4794a7f0..5390ad251c 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Skill.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/Skill.java @@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model; import java.lang.reflect.Constructor; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.List; import java.util.StringTokenizer; import java.util.logging.Logger; @@ -381,9 +382,6 @@ public abstract class Skill public static final int COND_GRADED = 0x080000; public static final int COND_GRADES = 0x100000; - private static final Func[] _emptyFunctionSet = new Func[0]; - private static final Effect[] _emptyEffectSet = new Effect[0]; - // these two build the primary key private final int _id; private final int _level; @@ -2620,16 +2618,16 @@ public abstract class Skill return targets.get(0); } - public Func[] getStatFuncs(Effect effect, Creature creature) + public List getStatFuncs(Effect effect, Creature creature) { if (!(creature instanceof PlayerInstance) && !(creature instanceof Attackable) && !(creature instanceof Summon)) { - return _emptyFunctionSet; + return Collections.emptyList(); } if (_funcTemplates == null) { - return _emptyFunctionSet; + return Collections.emptyList(); } final List funcs = new ArrayList<>(); @@ -2644,12 +2642,8 @@ public abstract class Skill funcs.add(f); } } - if (funcs.isEmpty()) - { - return _emptyFunctionSet; - } - return funcs.toArray(new Func[funcs.size()]); + return funcs; } public boolean hasEffects() @@ -2657,31 +2651,31 @@ public abstract class Skill return (_effectTemplates != null) && (_effectTemplates.length > 0); } - public Effect[] applyEffects(Creature effector, Creature effected) + public List applyEffects(Creature effector, Creature effected) { return applyEffects(effector, effected, false, false, false); } - public Effect[] applyEffects(Creature effector, Creature effected, boolean ss, boolean sps, boolean bss) + public List applyEffects(Creature effector, Creature effected, boolean ss, boolean sps, boolean bss) { if (isPassive()) { - return _emptyEffectSet; + return Collections.emptyList(); } if (_effectTemplates == null) { - return _emptyEffectSet; + return Collections.emptyList(); } if ((effector != effected) && effected.isInvul()) { - return _emptyEffectSet; + return Collections.emptyList(); } if ((_skillType == SkillType.BUFF) && effected.isBlockBuff()) { - return _emptyEffectSet; + return Collections.emptyList(); } final List effects = new ArrayList<>(); @@ -2715,24 +2709,19 @@ public abstract class Skill } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - - return effects.toArray(new Effect[effects.size()]); + return effects; } - public Effect[] applySelfEffects(Creature effector) + public List applySelfEffects(Creature effector) { if (isPassive()) { - return _emptyEffectSet; + return Collections.emptyList(); } if (_effectTemplatesSelf == null) { - return _emptyEffectSet; + return Collections.emptyList(); } final List effects = new ArrayList<>(); @@ -2777,12 +2766,8 @@ public abstract class Skill } } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - return effects.toArray(new Effect[effects.size()]); + return effects; } public void attach(FuncTemplate f) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java index 822ce41b7c..851fca4eb0 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/actor/Creature.java @@ -4493,7 +4493,7 @@ public abstract class Creature extends WorldObject implements ISkillsHolder *
  • Use an active skill

  • * @param funcs The list of Func objects to add to the Calculator corresponding to the state affected */ - public synchronized void addStatFuncs(Func[] funcs) + public synchronized void addStatFuncs(List funcs) { final List modifiedStats = new ArrayList<>(); for (Func f : funcs) diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Armor.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Armor.java index 0e94f64957..dde14760b2 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Armor.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Armor.java @@ -17,6 +17,7 @@ package org.l2jmobius.gameserver.model.items; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.l2jmobius.gameserver.data.SkillTable; @@ -147,26 +148,29 @@ public class Armor extends Item * Returns array of Func objects containing the list of functions used by the armor * @param instance : ItemInstance pointing out the armor * @param creature : Creature pointing out the player - * @return Func[] : array of functions + * @return List : List of functions */ @Override - public Func[] getStatFuncs(ItemInstance instance, Creature creature) + public List getStatFuncs(ItemInstance instance, Creature creature) { - final List funcs = new ArrayList<>(); - if (_funcTemplates != null) + if (_funcTemplates == null) { - for (FuncTemplate t : _funcTemplates) + return Collections.emptyList(); + } + + final List funcs = new ArrayList<>(); + for (FuncTemplate t : _funcTemplates) + { + final Env env = new Env(); + env.player = creature; + env.item = instance; + final Func f = t.getFunc(env, instance); + if (f != null) { - final Env env = new Env(); - env.player = creature; - env.item = instance; - final Func f = t.getFunc(env, instance); - if (f != null) - { - funcs.add(f); - } + funcs.add(f); } } - return funcs.toArray(new Func[funcs.size()]); + + return funcs; } } diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Item.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Item.java index 614bb10055..c28ed362fd 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Item.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Item.java @@ -17,6 +17,7 @@ package org.l2jmobius.gameserver.model.items; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.l2jmobius.Config; @@ -140,9 +141,6 @@ public abstract class Item protected EffectTemplate[] _effectTemplates; protected Skill[] _skills; - private static final Func[] _emptyFunctionSet = new Func[0]; - protected static final Effect[] _emptyEffectSet = new Effect[0]; - /** * Constructor of the Item that fill class variables.
    * Variables filled :
    @@ -507,14 +505,15 @@ public abstract class Item * Returns array of Func objects containing the list of functions used by the item * @param instance : ItemInstance pointing out the item * @param creature : Creature pointing out the player - * @return Func[] : array of functions + * @return List : List of functions */ - public Func[] getStatFuncs(ItemInstance instance, Creature creature) + public List getStatFuncs(ItemInstance instance, Creature creature) { if (_funcTemplates == null) { - return _emptyFunctionSet; + return Collections.emptyList(); } + final List funcs = new ArrayList<>(); for (FuncTemplate t : _funcTemplates) { @@ -528,25 +527,23 @@ public abstract class Item funcs.add(f); } } - if (funcs.isEmpty()) - { - return _emptyFunctionSet; - } - return funcs.toArray(new Func[funcs.size()]); + + return funcs; } /** * Returns the effects associated with the item. * @param instance : ItemInstance pointing out the item * @param creature : Creature pointing out the player - * @return Effect[] : array of effects generated by the item + * @return List : List of effects generated by the item */ - public Effect[] getEffects(ItemInstance instance, Creature creature) + public List getEffects(ItemInstance instance, Creature creature) { if (_effectTemplates == null) { - return _emptyEffectSet; + return Collections.emptyList(); } + final List effects = new ArrayList<>(); for (EffectTemplate et : _effectTemplates) { @@ -560,25 +557,23 @@ public abstract class Item effects.add(e); } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - return effects.toArray(new Effect[effects.size()]); + + return effects; } /** * Returns effects of skills associated with the item. * @param caster : Creature pointing out the caster * @param target : Creature pointing out the target - * @return Effect[] : array of effects generated by the skill + * @return List : List of effects generated by the skill */ - public Effect[] getSkillEffects(Creature caster, Creature target) + public List getSkillEffects(Creature caster, Creature target) { if (_skills == null) { - return _emptyEffectSet; + return Collections.emptyList(); } + final List effects = new ArrayList<>(); for (Skill skill : _skills) { @@ -596,11 +591,8 @@ public abstract class Item effects.add(e); } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - return effects.toArray(new Effect[effects.size()]); + + return effects; } /** diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Weapon.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Weapon.java index 421bac20a8..015ad3e0e2 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Weapon.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/Weapon.java @@ -17,6 +17,7 @@ package org.l2jmobius.gameserver.model.items; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.l2jmobius.gameserver.data.SkillTable; @@ -290,27 +291,30 @@ public class Weapon extends Item * Returns array of Func objects containing the list of functions used by the weapon * @param instance : ItemInstance pointing out the weapon * @param creature : Creature pointing out the player - * @return Func[] : array of functions + * @return List : List of functions */ @Override - public Func[] getStatFuncs(ItemInstance instance, Creature creature) + public List getStatFuncs(ItemInstance instance, Creature creature) { - final List funcs = new ArrayList<>(); - if (_funcTemplates != null) + if (_funcTemplates == null) { - for (FuncTemplate t : _funcTemplates) + return Collections.emptyList(); + } + + final List funcs = new ArrayList<>(); + for (FuncTemplate t : _funcTemplates) + { + final Env env = new Env(); + env.player = creature; + env.item = instance; + final Func f = t.getFunc(env, instance); + if (f != null) { - final Env env = new Env(); - env.player = creature; - env.item = instance; - final Func f = t.getFunc(env, instance); - if (f != null) - { - funcs.add(f); - } + funcs.add(f); } } - return funcs.toArray(new Func[funcs.size()]); + + return funcs; } /** @@ -318,14 +322,15 @@ public class Weapon extends Item * @param caster : Creature pointing out the caster * @param target : Creature pointing out the target * @param crit : boolean tells whether the hit was critical - * @return Effect[] : array of effects generated by the skill + * @return List : List of effects generated by the skill */ - public Effect[] getSkillEffects(Creature caster, Creature target, boolean crit) + public List getSkillEffects(Creature caster, Creature target, boolean crit) { if ((_skillsOnCrit == null) || !crit) { - return _emptyEffectSet; + return Collections.emptyList(); } + final List effects = new ArrayList<>(); for (Skill skill : _skillsOnCrit) { @@ -348,11 +353,8 @@ public class Weapon extends Item effects.add(e); } } - if (effects.isEmpty()) - { - return _emptyEffectSet; - } - return effects.toArray(new Effect[effects.size()]); + + return effects; } /** @@ -360,7 +362,7 @@ public class Weapon extends Item * @param caster : Creature pointing out the caster * @param target : Creature pointing out the target * @param trigger : Skill pointing out the skill triggering this action - * @return Effect[] : array of effects generated by the skill + * @return List : List of effects generated by the skill */ public boolean getSkillEffects(Creature caster, Creature target, Skill trigger) { diff --git a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/instance/ItemInstance.java b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/instance/ItemInstance.java index 698d4cc6bb..e9bac6e60d 100644 --- a/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/instance/ItemInstance.java +++ b/L2J_Mobius_C6_Interlude/java/org/l2jmobius/gameserver/model/items/instance/ItemInstance.java @@ -19,6 +19,7 @@ package org.l2jmobius.gameserver.model.items.instance; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.util.List; import java.util.concurrent.ScheduledFuture; import java.util.logging.Level; import java.util.logging.LogRecord; @@ -918,9 +919,9 @@ public class ItemInstance extends WorldObject /** * This function basically returns a set of functions from Item/Armor/Weapon, but may add additional functions, if this particular item instance is enhanched for a particular player. * @param creature : Creature designating the player - * @return Func[] + * @return List */ - public Func[] getStatFuncs(Creature creature) + public List getStatFuncs(Creature creature) { return _item.getStatFuncs(this, creature); }