Use of simple ArrayList to store drops.

This commit is contained in:
MobiusDevelopment
2021-07-22 10:21:06 +00:00
parent db65b65a19
commit 0e745ad289
23 changed files with 167 additions and 161 deletions

View File

@@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import org.l2jmobius.Config;
import org.l2jmobius.commons.util.Rnd;
@@ -101,8 +100,8 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
private Map<AISkillScope, List<Skill>> _aiSkillLists;
private Set<Integer> _clans;
private Set<Integer> _ignoreClanNpcIds;
private CopyOnWriteArrayList<DropHolder> _dropListDeath;
private CopyOnWriteArrayList<DropHolder> _dropListSpoil;
private List<DropHolder> _dropListDeath;
private List<DropHolder> _dropListSpoil;
private double _collisionRadiusGrown;
private double _collisionHeightGrown;
@@ -601,7 +600,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
{
if (_dropListDeath == null)
{
_dropListDeath = new CopyOnWriteArrayList<>();
_dropListDeath = new ArrayList<>(1);
}
_dropListDeath.add(dropHolder);
}
@@ -610,7 +609,7 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
{
if (_dropListSpoil == null)
{
_dropListSpoil = new CopyOnWriteArrayList<>();
_dropListSpoil = new ArrayList<>(1);
}
_dropListSpoil.add(dropHolder);
}
@@ -633,12 +632,13 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
public Collection<ItemHolder> calculateDrops(DropType dropType, Creature victim, Creature killer)
{
if (getDropList(dropType) == null)
final List<DropHolder> templateList = getDropList(dropType);
if (templateList == null)
{
return null;
}
final List<DropHolder> dropList = new ArrayList<>(getDropList(dropType));
final List<DropHolder> dropList = new ArrayList<>(templateList);
// randomize drop order
Collections.shuffle(dropList);