MARKDOWN 110
DropType Guest on 13th March 2021 10:15:43 AM

diff --git a/aCis/data/xml/dropType.xml b/aCis/data/xml/dropType.xml new file mode 100644 index 0000000..a30f1f7 --- /dev/null +++ b/aCis/data/xml/dropType.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> + +

  • + \ No newline at end of file diff --git a/aCis/java/net/sf/l2j/gameserver/GameServer.java b/aCis/java/net/sf/l2j/gameserver/GameServer.java index d10ac2b..3c23a09 100644 --- a/aCis/java/net/sf/l2j/gameserver/GameServer.java +++ b/aCis/java/net/sf/l2j/gameserver/GameServer.java @@ -60,6 +60,7 @@ import net.sf.l2j.gameserver.data.xml.AugmentationData; import net.sf.l2j.gameserver.data.xml.DoorData; import net.sf.l2j.gameserver.data.xml.DressMeData; +import net.sf.l2j.gameserver.data.xml.DropTypeData; import net.sf.l2j.gameserver.data.xml.FishData; import net.sf.l2j.gameserver.data.xml.HennaData; import net.sf.l2j.gameserver.data.xml.HerbDropData; @@ -238,6 +239,7 @@

    StringUtil.printSection("NPCs");
    BufferManager.getInstance();
  • DropTypeData.getInstance(); HerbDropData.getInstance(); NpcData.getInstance(); WalkerRouteData.getInstance(); diff --git a/aCis/java/net/sf/l2j/gameserver/data/xml/DropTypeData.java b/aCis/java/net/sf/l2j/gameserver/data/xml/DropTypeData.java new file mode 100644 index 0000000..2a6b225 --- /dev/null +++ b/aCis/java/net/sf/l2j/gameserver/data/xml/DropTypeData.java @@ -0,0 +1,84 @@ +package net.sf.l2j.gameserver.data.xml;
  • +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List;

  • +import net.sf.l2j.commons.data.xml.IXmlReader;

  • +import net.sf.l2j.gameserver.model.actor.template.NpcTemplate; +import net.sf.l2j.gameserver.model.item.DropCategory; +import net.sf.l2j.gameserver.model.item.DropType;

  • +import org.w3c.dom.Document;

  • +/**

    • @author Williams
  • *
  • */ +public class DropTypeData implements IXmlReader +{
  • private final List _data = new ArrayList<>();
  • public DropTypeData()
  • {
  • load();
  • }
  • @Override
  • public void load()
  • {
  • parseFile("./data/xml/dropType.xml");
  • LOGGER.info("Loaded {} drop data.", _data.size());
  • }
  • @Override
  • public void parseDocument(Document doc, Path path)
  • {
  • forEach(doc, "list", listNode ->
  • {
  • forEach(listNode, "drops", dropNode ->
  • {
  • final DropType data = new DropType(parseAttributes(dropNode));
  • final DropCategory category = new DropCategory(data.getItemId());
  • if (ItemData.getInstance().getTemplate(data.getItemId()) == null)
  • {
  • LOGGER.warn("Droplist data for undefined itemId: {}.", data.getItemId());
  • return;
  • }
  • category.addDropData(data, false);
  • for (NpcTemplate template : NpcData.getInstance().getAllNpcs())
  • {
  • if (data.getType().equalsIgnoreCase(template.getType()) || data.getNpcId() == template.getNpcId())
  • template.addDropCategory(category);
  • }
  • _data.add(data);
  • });
  • });
  • }
  • public void reload()
  • {
  • _data.clear();
  • load();
  • }
  • public List getDrops()
  • {
  • return _data;
  • }
  • public static DropTypeData getInstance()
  • {
  • return SingletonHolder.INSTANCE;
  • }
  • private static class SingletonHolder
  • {
  • protected static final DropTypeData INSTANCE = new DropTypeData();
  • } +} \ No newline at end of file diff --git a/aCis/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReload.java b/aCis/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReload.java index f322922..2dc7f5c 100644 --- a/aCis/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReload.java +++ b/aCis/java/net/sf/l2j/gameserver/handler/admincommandhandlers/AdminReload.java @@ -13,6 +13,7 @@ import net.sf.l2j.gameserver.data.xml.AnnouncementData; import net.sf.l2j.gameserver.data.xml.DoorData; import net.sf.l2j.gameserver.data.xml.DressMeData; +import net.sf.l2j.gameserver.data.xml.DropTypeData; import net.sf.l2j.gameserver.data.xml.EnchantData; import net.sf.l2j.gameserver.data.xml.InstantTeleportData; import net.sf.l2j.gameserver.data.xml.ItemData; @@ -74,6 +75,11 @@ CursedWeaponManager.getInstance().reload(); player.sendMessage("Cursed weapons have been reloaded."); }
  • else if (type.startsWith("drop"))
  • {
  • DropTypeData.getInstance().reload();
  • player.sendMessage("Drop have been reloaded.");
  • } else if (type.startsWith("door")) { DoorData.getInstance().reload(); @@ -160,7 +166,7 @@ public void sendUsage(Player player) { player.sendMessage("Usage : //reload <admin|announcement|buylist|config>");
  • player.sendMessage("Usage : //reload <crest|cw|door|dress|enchant|htm|item|multisell|npc>");
  • player.sendMessage("Usage : //reload <crest|cw|drop|door|dress|enchant|htm|item|multisell|npc>"); player.sendMessage("Usage : //reload <npcwalker|poly|script|skill|spree|teleport|zone>"); }

diff --git a/aCis/java/net/sf/l2j/gameserver/model/actor/template/NpcTemplate.java b/aCis/java/net/sf/l2j/gameserver/model/actor/template/NpcTemplate.java index 2bf8cca..0944739 100644 --- a/aCis/java/net/sf/l2j/gameserver/model/actor/template/NpcTemplate.java +++ b/aCis/java/net/sf/l2j/gameserver/model/actor/template/NpcTemplate.java @@ -340,7 +340,38 @@ } return list; } +

  • public final void addDropCategory(DropCategory category)
  • {
  • synchronized (_categories)
  • {
  • if (_categories.isEmpty())
  • _categories = new ArrayList<>(); // empty means _categories is instance of Collections.emptyList(); - cannot add items to this container
  • else
  • {
  • // category already exists, return
  • for (DropCategory cat : _categories)
  • {
  • if (cat.getCategoryType() == category.getCategoryType())
  • return;
  • }
  • }
  • _categories.add(category);
  • }
  • }

  • public final void removeDropCategory(DropCategory category)
  • {
  • synchronized (_categories)
  • {
  • if (_categories.isEmpty())
  • return;
  • _categories.remove(category);
  • }
  • }
  • /**

    • @return the {@link List} of all possible {@link DropData}s of this {@link NpcTemplate} linked to SPOIL behavior. */ @@ -354,36 +385,7 @@ } return list; }
  • /**
    • Add a {@link DropData} to a given category. If the category does not exist, create it.
    • @param drop : The DropData to add.
    • @param categoryType : The category type we refer.
  • */
  • public void addDropData(DropData drop, int categoryType)
  • {
  • final boolean isBossType = isType("RaidBoss") || isType("GrandBoss");
  • synchronized (_categories)
  • {
  • // Category exists, stores the drop and return.
  • for (DropCategory cat : _categories)
  • {
  • if (cat.getCategoryType() == categoryType)
  • {
  • cat.addDropData(drop, isBossType);
  • return;
  • }
  • }
  • // Category doesn't exist, create and store it.
  • final DropCategory cat = new DropCategory(categoryType);
  • cat.addDropData(drop, isBossType);
  • _categories.add(cat);
  • }
  • }
  • /**

    • @return the {@link List} of all {@link MinionData}. */ diff --git a/aCis/java/net/sf/l2j/gameserver/model/item/DropType.java b/aCis/java/net/sf/l2j/gameserver/model/item/DropType.java new file mode 100644 index 0000000..fa43cf8 --- /dev/null +++ b/aCis/java/net/sf/l2j/gameserver/model/item/DropType.java @@ -0,0 +1,31 @@ +package net.sf.l2j.gameserver.model.item;
  • +import net.sf.l2j.commons.data.StatSet;

  • +/**

    • @author Williams
  • *
  • */ +public class DropType extends DropData +{
  • private final String _type;
  • private final int _npcId;
  • public DropType(StatSet set)
  • {
  • super(set.getInteger("itemId"), set.getInteger("minDrop"), set.getInteger("maxDrop"), set.getInteger("chance"));
  • _npcId = set.getInteger("npcId", 0);
  • _type = set.getString("type", "");
  • }
  • public int getNpcId()
  • {
  • return _npcId;
  • }
  • public String getType()
  • {
  • return _type;
  • } +} \ No newline at end of file

Pastebin Tech is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.