Removal of extend drop data.
This commit is contained in:
@@ -65,7 +65,6 @@ import org.l2jmobius.gameserver.data.xml.impl.EnchantSkillGroupsData;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.EnsoulData;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.EventEngineData;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.ExperienceData;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.ExtendDropData;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.FakePlayerData;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.FenceData;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.FishingData;
|
||||
@@ -322,7 +321,6 @@ public class GameServer
|
||||
NpcData.getInstance();
|
||||
FakePlayerData.getInstance();
|
||||
FakePlayerChatManager.getInstance();
|
||||
ExtendDropData.getInstance();
|
||||
SpawnData.getInstance();
|
||||
MonsterBookData.getInstance();
|
||||
WalkingManager.getInstance();
|
||||
|
@@ -1,203 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.data.xml.impl;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
|
||||
import org.l2jmobius.commons.util.IXmlReader;
|
||||
import org.l2jmobius.gameserver.handler.ConditionHandler;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.conditions.ICondition;
|
||||
import org.l2jmobius.gameserver.model.holders.ExtendDropDataHolder;
|
||||
import org.l2jmobius.gameserver.model.holders.ExtendDropItemHolder;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExtendDropData implements IXmlReader
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger(ExtendDropData.class.getName());
|
||||
private final Map<Integer, ExtendDropDataHolder> _extendDrop = new HashMap<>();
|
||||
|
||||
protected ExtendDropData()
|
||||
{
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
{
|
||||
_extendDrop.clear();
|
||||
parseDatapackFile("data/ExtendDrop.xml");
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + _extendDrop.size() + " extend drops.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseDocument(Document doc, File f)
|
||||
{
|
||||
forEach(doc, "list", listNode -> forEach(listNode, "drop", dropNode ->
|
||||
{
|
||||
final StatSet set = new StatSet(parseAttributes(dropNode));
|
||||
final List<ExtendDropItemHolder> items = new ArrayList<>(1);
|
||||
forEach(dropNode, "items", itemsNode -> forEach(itemsNode, "item", itemNode ->
|
||||
{
|
||||
final int itemId = parseInteger(itemNode.getAttributes(), "id");
|
||||
final int itemCount = parseInteger(itemNode.getAttributes(), "count");
|
||||
final int itemMaxCount = parseInteger(itemNode.getAttributes(), "maxCount");
|
||||
final double itemChance = parseDouble(itemNode.getAttributes(), "chance");
|
||||
final double itemAdditionalChance = parseDouble(itemNode.getAttributes(), "additionalChance");
|
||||
items.add(new ExtendDropItemHolder(itemId, itemCount, itemMaxCount, itemChance, itemAdditionalChance));
|
||||
}));
|
||||
set.set("items", items);
|
||||
|
||||
final List<ICondition> conditions = new ArrayList<>(1);
|
||||
forEach(dropNode, "conditions", conditionsNode -> forEach(conditionsNode, "condition", conditionNode ->
|
||||
{
|
||||
final String conditionName = parseString(conditionNode.getAttributes(), "name");
|
||||
final StatSet params = (StatSet) parseValue(conditionNode);
|
||||
final Function<StatSet, ICondition> conditionFunction = ConditionHandler.getInstance().getHandlerFactory(conditionName);
|
||||
if (conditionFunction != null)
|
||||
{
|
||||
conditions.add(conditionFunction.apply(params));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.warning(getClass().getSimpleName() + ": Missing condition for ExtendDrop Id[" + set.getInt("id") + "] Condition Name[" + conditionName + "]");
|
||||
}
|
||||
}));
|
||||
set.set("conditions", conditions);
|
||||
|
||||
final Map<Long, SystemMessageId> systemMessages = new HashMap<>();
|
||||
forEach(dropNode, "systemMessages", systemMessagesNode -> forEach(systemMessagesNode, "systemMessage", systemMessageNode ->
|
||||
{
|
||||
final long amount = parseLong(systemMessageNode.getAttributes(), "amount");
|
||||
final SystemMessageId systemMessageId = SystemMessageId.getSystemMessageId(parseInteger(systemMessageNode.getAttributes(), "id"));
|
||||
systemMessages.put(amount, systemMessageId);
|
||||
}));
|
||||
set.set("systemMessages", systemMessages);
|
||||
_extendDrop.put(set.getInt("id"), new ExtendDropDataHolder(set));
|
||||
}));
|
||||
}
|
||||
|
||||
private Object parseValue(Node node)
|
||||
{
|
||||
StatSet statSet = null;
|
||||
List<Object> list = null;
|
||||
Object text = null;
|
||||
Node n = node;
|
||||
for (n = n.getFirstChild(); n != null; n = n.getNextSibling())
|
||||
{
|
||||
final String nodeName = n.getNodeName();
|
||||
switch (n.getNodeName())
|
||||
{
|
||||
case "#text":
|
||||
{
|
||||
final String value = n.getNodeValue().trim();
|
||||
if (!value.isEmpty())
|
||||
{
|
||||
text = value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "item":
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
list = new LinkedList<>();
|
||||
}
|
||||
|
||||
final Object value = parseValue(n);
|
||||
if (value != null)
|
||||
{
|
||||
list.add(value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
final Object value = parseValue(n);
|
||||
if (value != null)
|
||||
{
|
||||
if (statSet == null)
|
||||
{
|
||||
statSet = new StatSet();
|
||||
}
|
||||
|
||||
statSet.set(nodeName, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list != null)
|
||||
{
|
||||
if (text != null)
|
||||
{
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + n + "]");
|
||||
}
|
||||
if (statSet != null)
|
||||
{
|
||||
statSet.set(".", list);
|
||||
}
|
||||
else
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
||||
if (text != null)
|
||||
{
|
||||
if (list != null)
|
||||
{
|
||||
throw new IllegalArgumentException("Text and list in same node are not allowed. Node[" + n + "]");
|
||||
}
|
||||
if (statSet != null)
|
||||
{
|
||||
statSet.set(".", text);
|
||||
}
|
||||
else
|
||||
{
|
||||
return text;
|
||||
}
|
||||
}
|
||||
return statSet;
|
||||
}
|
||||
|
||||
public ExtendDropDataHolder getExtendDropById(int id)
|
||||
{
|
||||
return _extendDrop.getOrDefault(id, null);
|
||||
}
|
||||
|
||||
public static ExtendDropData getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final ExtendDropData INSTANCE = new ExtendDropData();
|
||||
}
|
||||
}
|
@@ -463,13 +463,6 @@ public class NpcData implements IXmlReader
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "extenddrop":
|
||||
{
|
||||
final List<Integer> extendDrop = new ArrayList<>();
|
||||
forEach(npcNode, "id", idNode -> extendDrop.add(Integer.parseInt(idNode.getTextContent())));
|
||||
set.set("extendDrop", extendDrop);
|
||||
break;
|
||||
}
|
||||
case "collision":
|
||||
{
|
||||
for (Node collisionNode = npcNode.getFirstChild(); collisionNode != null; collisionNode = collisionNode.getNextSibling())
|
||||
|
@@ -22,7 +22,6 @@ import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -36,7 +35,6 @@ import org.l2jmobius.gameserver.ai.AttackableAI;
|
||||
import org.l2jmobius.gameserver.ai.CreatureAI;
|
||||
import org.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import org.l2jmobius.gameserver.data.xml.impl.ExtendDropData;
|
||||
import org.l2jmobius.gameserver.datatables.EventDroplist;
|
||||
import org.l2jmobius.gameserver.datatables.ItemTable;
|
||||
import org.l2jmobius.gameserver.enums.ChatType;
|
||||
@@ -999,7 +997,6 @@ public class Attackable extends Npc
|
||||
}
|
||||
|
||||
CursedWeaponsManager.getInstance().checkDrop(this, player);
|
||||
npcTemplate.getExtendDrop().stream().map(ExtendDropData.getInstance()::getExtendDropById).filter(Objects::nonNull).forEach(e -> e.reward(player, this));
|
||||
if (isSpoiled() && !_plundered)
|
||||
{
|
||||
_sweepItems.set(npcTemplate.calculateDrops(DropType.SPOIL, this, player));
|
||||
|
@@ -119,8 +119,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
||||
private int _mpRewardTicks;
|
||||
private MpRewardAffectType _mpRewardAffectType;
|
||||
|
||||
private List<Integer> _extendDrop;
|
||||
|
||||
/**
|
||||
* Constructor of Creature.
|
||||
* @param set The StatSet object to transfer data to the method
|
||||
@@ -204,7 +202,6 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
||||
_mpRewardType = set.getEnum("mpRewardType", MpRewardType.class, MpRewardType.DIFF);
|
||||
_mpRewardTicks = set.getInt("mpRewardTicks", 0);
|
||||
_mpRewardAffectType = set.getEnum("mpRewardAffectType", MpRewardAffectType.class, MpRewardAffectType.SOLO);
|
||||
_extendDrop = set.getList("extendDrop", Integer.class);
|
||||
if (Config.ENABLE_NPC_STAT_MULTIPLIERS) // Custom NPC Stat Multipliers
|
||||
{
|
||||
switch (_type)
|
||||
@@ -991,9 +988,4 @@ public class NpcTemplate extends CreatureTemplate implements IIdentifiable
|
||||
{
|
||||
return isAssignableTo(obj.getClass(), clazz);
|
||||
}
|
||||
|
||||
public List<Integer> getExtendDrop()
|
||||
{
|
||||
return _extendDrop == null ? Collections.emptyList() : _extendDrop;
|
||||
}
|
||||
}
|
||||
|
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.l2jmobius.commons.util.Rnd;
|
||||
import org.l2jmobius.gameserver.model.StatSet;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.conditions.ICondition;
|
||||
import org.l2jmobius.gameserver.network.SystemMessageId;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExtendDropDataHolder
|
||||
{
|
||||
private final int _id;
|
||||
private final List<ExtendDropItemHolder> _items;
|
||||
private final List<ICondition> _conditions;
|
||||
private final Map<Long, SystemMessageId> _systemMessages;
|
||||
|
||||
public ExtendDropDataHolder(StatSet set)
|
||||
{
|
||||
_id = set.getInt("id");
|
||||
_items = set.getList("items", ExtendDropItemHolder.class);
|
||||
_conditions = set.getList("conditions", ICondition.class);
|
||||
_systemMessages = set.getMap("systemMessages", Long.class, SystemMessageId.class);
|
||||
}
|
||||
|
||||
public void reward(PlayerInstance player, Npc npc)
|
||||
{
|
||||
if (_conditions.isEmpty() || _conditions.stream().allMatch(cond -> cond.test(player, npc)))
|
||||
{
|
||||
_items.forEach(i ->
|
||||
{
|
||||
final long currentAmount = player.getVariables().getExtendDropCount(_id);
|
||||
if ((Rnd.nextDouble() < i.getChance()) && (currentAmount < i.getMaxCount()))
|
||||
{
|
||||
boolean sendMessage = true;
|
||||
final long newAmount = currentAmount + i.getCount();
|
||||
if (_systemMessages != null)
|
||||
{
|
||||
final SystemMessageId systemMessageId = _systemMessages.get(newAmount);
|
||||
if (systemMessageId != null)
|
||||
{
|
||||
sendMessage = false;
|
||||
player.sendPacket(systemMessageId);
|
||||
}
|
||||
}
|
||||
player.addItem("ExtendDrop", i.getId(), i.getCount(), player, sendMessage);
|
||||
player.getVariables().updateExtendDrop(_id, newAmount);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.l2jmobius.gameserver.model.holders;
|
||||
|
||||
/**
|
||||
* @author Sdw
|
||||
*/
|
||||
public class ExtendDropItemHolder extends ItemHolder
|
||||
{
|
||||
private final long _maxCount;
|
||||
private final double _chance;
|
||||
private final double _additionalChance;
|
||||
|
||||
public ExtendDropItemHolder(int id, long count, long maxCount, double chance, double additionalChance)
|
||||
{
|
||||
super(id, count);
|
||||
|
||||
_maxCount = maxCount;
|
||||
_chance = chance;
|
||||
_additionalChance = additionalChance;
|
||||
}
|
||||
|
||||
public long getMaxCount()
|
||||
{
|
||||
return _maxCount;
|
||||
}
|
||||
|
||||
public double getChance()
|
||||
{
|
||||
return _chance;
|
||||
}
|
||||
|
||||
public double getAdditionalChance()
|
||||
{
|
||||
return _additionalChance;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user