Use equals for contains method object comparison.
Contributed by Sahar.
This commit is contained in:
@ -226,7 +226,7 @@ public final class CommonUtil
|
||||
{
|
||||
for (T element : array)
|
||||
{
|
||||
if (element == obj)
|
||||
if (element.equals(obj))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -34,6 +34,7 @@ import org.w3c.dom.NamedNodeMap;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.commons.util.IGameXmlReader;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.enums.AISkillScope;
|
||||
@ -740,7 +741,7 @@ public class NpcData implements IGameXmlReader
|
||||
*/
|
||||
public List<L2NpcTemplate> getAllOfLevel(int... lvls)
|
||||
{
|
||||
return getTemplates(template -> Util.contains(lvls, template.getLevel()));
|
||||
return getTemplates(template -> CommonUtil.contains(lvls, template.getLevel()));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -750,7 +751,7 @@ public class NpcData implements IGameXmlReader
|
||||
*/
|
||||
public List<L2NpcTemplate> getAllMonstersOfLevel(int... lvls)
|
||||
{
|
||||
return getTemplates(template -> Util.contains(lvls, template.getLevel()) && template.isType("L2Monster"));
|
||||
return getTemplates(template -> CommonUtil.contains(lvls, template.getLevel()) && template.isType("L2Monster"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -37,6 +37,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.concurrent.ThreadPool;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.commons.util.EmptyQueue;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.GameTimeController;
|
||||
@ -5781,7 +5782,7 @@ public abstract class L2Character extends L2Object implements ISkillsHolder, IDe
|
||||
|
||||
if (player.hasSummon())
|
||||
{
|
||||
if ((targets.length == 1) && Util.contains(targets, player.getSummon()))
|
||||
if ((targets.length == 1) && CommonUtil.contains(targets, player.getSummon()))
|
||||
{
|
||||
skillEffectPoint = 0;
|
||||
}
|
||||
|
@ -17,6 +17,7 @@
|
||||
package com.l2jmobius.gameserver.model.actor;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.commons.util.Rnd;
|
||||
import com.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import com.l2jmobius.gameserver.ai.L2CharacterAI;
|
||||
@ -69,7 +70,6 @@ import com.l2jmobius.gameserver.network.serverpackets.RelationChanged;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.TeleportToLocation;
|
||||
import com.l2jmobius.gameserver.taskmanager.DecayTaskManager;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public abstract class L2Summon extends L2Playable
|
||||
{
|
||||
@ -979,7 +979,7 @@ public abstract class L2Summon extends L2Playable
|
||||
|
||||
// Sin eater, Big Boom, Wyvern can't attack with attack button.
|
||||
final int npcId = getId();
|
||||
if (Util.contains(PASSIVE_SUMMONS, npcId))
|
||||
if (CommonUtil.contains(PASSIVE_SUMMONS, npcId))
|
||||
{
|
||||
getOwner().sendPacket(ActionFailed.STATIC_PACKET);
|
||||
return false;
|
||||
|
@ -16,11 +16,11 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.conditions;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.enums.Race;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* The Class ConditionPlayerRace.
|
||||
@ -42,6 +42,6 @@ public class ConditionPlayerRace extends Condition
|
||||
@Override
|
||||
public boolean testImpl(L2Character effector, L2Character effected, Skill skill, L2Item item)
|
||||
{
|
||||
return (effector != null) && effector.isPlayer() && Util.contains(_races, effector.getActingPlayer().getRace());
|
||||
return (effector != null) && effector.isPlayer() && CommonUtil.contains(_races, effector.getActingPlayer().getRace());
|
||||
}
|
||||
}
|
||||
|
@ -16,12 +16,12 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.conditions;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.model.L2World;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Character;
|
||||
import com.l2jmobius.gameserver.model.actor.L2Npc;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
import com.l2jmobius.gameserver.model.skills.Skill;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* Exist NPC condition.
|
||||
@ -51,7 +51,7 @@ public class ConditionPlayerRangeFromNpc extends Condition
|
||||
{
|
||||
for (L2Npc target : L2World.getInstance().getVisibleObjects(effector, L2Npc.class, _radius))
|
||||
{
|
||||
if (Util.contains(_npcIds, target.getId()))
|
||||
if (CommonUtil.contains(_npcIds, target.getId()))
|
||||
{
|
||||
existNpc = true;
|
||||
break;
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.l2jmobius.gameserver.model.events;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.model.events.impl.IBaseEvent;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureAttack;
|
||||
import com.l2jmobius.gameserver.model.events.impl.character.OnCreatureAttackAvoid;
|
||||
@ -103,7 +104,6 @@ import com.l2jmobius.gameserver.model.events.impl.sieges.fort.OnFortSiegeFinish;
|
||||
import com.l2jmobius.gameserver.model.events.impl.sieges.fort.OnFortSiegeStart;
|
||||
import com.l2jmobius.gameserver.model.events.returns.ChatFilterReturn;
|
||||
import com.l2jmobius.gameserver.model.events.returns.TerminateReturn;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
@ -251,6 +251,6 @@ public enum EventType
|
||||
|
||||
public boolean isReturnClass(Class<?> clazz)
|
||||
{
|
||||
return Util.contains(_returnClass, clazz);
|
||||
return CommonUtil.contains(_returnClass, clazz);
|
||||
}
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.Config;
|
||||
import com.l2jmobius.commons.database.DatabaseFactory;
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.enums.ItemLocation;
|
||||
import com.l2jmobius.gameserver.model.TradeItem;
|
||||
@ -42,7 +43,6 @@ import com.l2jmobius.gameserver.network.SystemMessageId;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.InventoryUpdate;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.ItemList;
|
||||
import com.l2jmobius.gameserver.network.serverpackets.StatusUpdate;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
public class PcInventory extends Inventory
|
||||
{
|
||||
@ -933,7 +933,7 @@ public class PcInventory extends Inventory
|
||||
*/
|
||||
public boolean canManipulateWithItemId(int itemId)
|
||||
{
|
||||
return ((_blockMode != 0) || !Util.contains(_blockItems, itemId)) && ((_blockMode != 1) || Util.contains(_blockItems, itemId));
|
||||
return ((_blockMode != 0) || !CommonUtil.contains(_blockItems, itemId)) && ((_blockMode != 1) || CommonUtil.contains(_blockItems, itemId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ package com.l2jmobius.gameserver.model.items.enchant;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.l2jmobius.commons.util.CommonUtil;
|
||||
import com.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import com.l2jmobius.gameserver.model.StatsSet;
|
||||
import com.l2jmobius.gameserver.model.items.L2Item;
|
||||
@ -25,7 +26,6 @@ import com.l2jmobius.gameserver.model.items.instance.L2ItemInstance;
|
||||
import com.l2jmobius.gameserver.model.items.type.CrystalType;
|
||||
import com.l2jmobius.gameserver.model.items.type.EtcItemType;
|
||||
import com.l2jmobius.gameserver.model.items.type.ItemType;
|
||||
import com.l2jmobius.gameserver.util.Util;
|
||||
|
||||
/**
|
||||
* @author UnAfraid
|
||||
@ -58,7 +58,7 @@ public abstract class AbstractEnchantItem
|
||||
{
|
||||
throw new NullPointerException();
|
||||
}
|
||||
else if (!Util.contains(ENCHANT_TYPES, getItem().getItemType()))
|
||||
else if (!CommonUtil.contains(ENCHANT_TYPES, getItem().getItemType()))
|
||||
{
|
||||
throw new IllegalAccessError();
|
||||
}
|
||||
|
@ -499,41 +499,6 @@ public final class Util
|
||||
return date == null ? null : (new SimpleDateFormat(format)).format(date);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param <T>
|
||||
* @param array - the array to look into
|
||||
* @param obj - the object to search for
|
||||
* @return {@code true} if the {@code array} contains the {@code obj}, {@code false} otherwise.
|
||||
*/
|
||||
public static <T> boolean contains(T[] array, T obj)
|
||||
{
|
||||
for (T element : array)
|
||||
{
|
||||
if (element == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array - the array to look into
|
||||
* @param obj - the integer to search for
|
||||
* @return {@code true} if the {@code array} contains the {@code obj}, {@code false} otherwise
|
||||
*/
|
||||
public static boolean contains(int[] array, int obj)
|
||||
{
|
||||
for (int element : array)
|
||||
{
|
||||
if (element == obj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static File[] getDatapackFiles(String dirname, String extention)
|
||||
{
|
||||
final File dir = new File(Config.DATAPACK_ROOT, "data/" + dirname);
|
||||
|
Reference in New Issue
Block a user