Removed stream-filter overheads.
Contributed by Sahar.
This commit is contained in:
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2204,17 +2201,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -159,7 +159,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -667,11 +667,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -720,9 +715,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1007,8 +1005,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final int bodypart = item.getBodyPart();
|
final int bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2210,17 +2207,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -159,7 +159,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -667,11 +667,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -720,9 +715,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1007,8 +1005,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final int bodypart = item.getBodyPart();
|
final int bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2210,17 +2207,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -159,7 +159,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -667,11 +667,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -720,9 +715,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1007,8 +1005,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final int bodypart = item.getBodyPart();
|
final int bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2210,17 +2207,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -159,7 +159,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -667,11 +667,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -720,9 +715,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1007,8 +1005,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final int bodypart = item.getBodyPart();
|
final int bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2223,17 +2220,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -160,7 +160,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -668,11 +668,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -721,9 +716,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1008,8 +1006,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final long bodypart = item.getBodyPart();
|
final long bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2520,17 +2517,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -162,7 +162,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -673,11 +673,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -726,9 +721,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1018,8 +1016,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final long bodypart = item.getBodyPart();
|
final long bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2520,17 +2517,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -162,7 +162,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -674,11 +674,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -727,9 +722,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1019,8 +1017,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final long bodypart = item.getBodyPart();
|
final long bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2504,17 +2501,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -162,7 +162,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -674,11 +674,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -727,9 +722,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1019,8 +1017,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final long bodypart = item.getBodyPart();
|
final long bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2210,17 +2207,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -159,7 +159,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -667,11 +667,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -720,9 +715,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1007,8 +1005,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final int bodypart = item.getBodyPart();
|
final int bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2210,17 +2207,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -159,7 +159,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -667,11 +667,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -720,9 +715,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1007,8 +1005,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final int bodypart = item.getBodyPart();
|
final int bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2229,17 +2226,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -160,7 +160,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -668,11 +668,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -721,9 +716,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1008,8 +1006,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final long bodypart = item.getBodyPart();
|
final long bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2520,17 +2517,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -162,7 +162,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -670,11 +670,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -723,9 +718,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1010,8 +1008,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final long bodypart = item.getBodyPart();
|
final long bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2520,17 +2517,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -162,7 +162,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -670,11 +670,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -723,9 +718,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1010,8 +1008,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final long bodypart = item.getBodyPart();
|
final long bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2504,17 +2501,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -162,7 +162,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -670,11 +670,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -723,9 +718,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1010,8 +1008,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final long bodypart = item.getBodyPart();
|
final long bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,9 +20,7 @@ import java.sql.Connection;
|
|||||||
import java.sql.PreparedStatement;
|
import java.sql.PreparedStatement;
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -31,7 +29,6 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import org.l2jmobius.Config;
|
import org.l2jmobius.Config;
|
||||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||||
@@ -2210,17 +2207,35 @@ public abstract class Inventory extends ItemContainer
|
|||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).collect(Collectors.toCollection(LinkedList::new));
|
|
||||||
|
final List<ItemInstance> items = new ArrayList<>();
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
items.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SafeVarargs
|
@SafeVarargs
|
||||||
public final long getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
public final int getPaperdollItemCount(Predicate<ItemInstance>... filters)
|
||||||
{
|
{
|
||||||
Predicate<ItemInstance> filter = Objects::nonNull;
|
Predicate<ItemInstance> filter = Objects::nonNull;
|
||||||
for (Predicate<ItemInstance> additionalFilter : filters)
|
for (Predicate<ItemInstance> additionalFilter : filters)
|
||||||
{
|
{
|
||||||
filter = filter.and(additionalFilter);
|
filter = filter.and(additionalFilter);
|
||||||
}
|
}
|
||||||
return Arrays.stream(_paperdoll).filter(filter).count();
|
|
||||||
|
int count = 0;
|
||||||
|
for (ItemInstance item : _paperdoll)
|
||||||
|
{
|
||||||
|
if (filter.test(item))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package org.l2jmobius.gameserver.model.items;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.EnumMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -159,7 +159,7 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
protected int _type1; // needed for item list (inventory)
|
protected int _type1; // needed for item list (inventory)
|
||||||
protected int _type2; // different lists for armor, weapon, etc
|
protected int _type2; // different lists for armor, weapon, etc
|
||||||
private Map<AttributeType, AttributeHolder> _elementals = null;
|
private Map<AttributeType, AttributeHolder> _elementals = null;
|
||||||
protected List<FuncTemplate> _funcTemplates;
|
protected Map<Stat, FuncTemplate> _funcTemplates;
|
||||||
protected List<Condition> _preConditions;
|
protected List<Condition> _preConditions;
|
||||||
private List<ItemSkillHolder> _skills;
|
private List<ItemSkillHolder> _skills;
|
||||||
|
|
||||||
@@ -667,11 +667,6 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
return getItemType() == EtcItemType.SCROLL;
|
return getItemType() == EtcItemType.SCROLL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<FuncTemplate> getFunctionTemplates()
|
|
||||||
{
|
|
||||||
return _funcTemplates != null ? _funcTemplates : Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the FuncTemplate f to the list of functions used with the item
|
* Add the FuncTemplate f to the list of functions used with the item
|
||||||
* @param template : FuncTemplate to add
|
* @param template : FuncTemplate to add
|
||||||
@@ -720,9 +715,12 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
|
|
||||||
if (_funcTemplates == null)
|
if (_funcTemplates == null)
|
||||||
{
|
{
|
||||||
_funcTemplates = new ArrayList<>();
|
_funcTemplates = new EnumMap<>(Stat.class);
|
||||||
|
}
|
||||||
|
if (_funcTemplates.put(template.getStat(), template) != null)
|
||||||
|
{
|
||||||
|
LOGGER.warning("Item with id " + _itemId + " has 2 func templates with same stat: " + template.getStat());
|
||||||
}
|
}
|
||||||
_funcTemplates.add(template);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attachCondition(Condition c)
|
public void attachCondition(Condition c)
|
||||||
@@ -1007,8 +1005,8 @@ public abstract class Item extends ListenersContainer implements IIdentifiable
|
|||||||
{
|
{
|
||||||
if (_funcTemplates != null)
|
if (_funcTemplates != null)
|
||||||
{
|
{
|
||||||
final FuncTemplate template = _funcTemplates.stream().filter(func -> (func.getStat() == stat) && ((func.getFunctionClass() == FuncAdd.class) || (func.getFunctionClass() == FuncSet.class))).findFirst().orElse(null);
|
final FuncTemplate template = _funcTemplates.get(stat);
|
||||||
if (template != null)
|
if ((template != null) && ((template.getFunctionClass() == FuncAdd.class) || (template.getFunctionClass() == FuncSet.class)))
|
||||||
{
|
{
|
||||||
return template.getValue();
|
return template.getValue();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public interface IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ public interface IStatFunction
|
|||||||
}
|
}
|
||||||
|
|
||||||
double value = 0;
|
double value = 0;
|
||||||
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEquipped, ItemInstance::isEnchanted))
|
for (ItemInstance equippedItem : creature.getInventory().getPaperdollItems(ItemInstance::isEnchanted))
|
||||||
{
|
{
|
||||||
final Item item = equippedItem.getItem();
|
final Item item = equippedItem.getItem();
|
||||||
final int bodypart = item.getBodyPart();
|
final int bodypart = item.getBodyPart();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MDefenseFinalizer implements IStatFunction
|
|||||||
final Inventory inv = creature.getInventory();
|
final Inventory inv = creature.getInventory();
|
||||||
if (inv != null)
|
if (inv != null)
|
||||||
{
|
{
|
||||||
for (ItemInstance item : inv.getPaperdollItems(ItemInstance::isEquipped))
|
for (ItemInstance item : inv.getPaperdollItems())
|
||||||
{
|
{
|
||||||
baseValue += item.getItem().getStats(stat, 0);
|
baseValue += item.getItem().getStats(stat, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user