}
NamedNodeMap attrs = npcNode.getAttributes();
RewardList list = null;
RewardType type = null;
int npcId = parseInt(attrs, "id");
NpcTemplate template = NpcHolder.getInstance().getTemplate(npcId);
if (template == null)
{
_log.warn("Omitted NPC ID: " + npcId + " - NPC template does not exists!");
}
else
{
for (Node dropNode = npcNode.getFirstChild(); dropNode != null; dropNode = dropNode.getNextSibling())
{
if ("droplist".equalsIgnoreCase(dropNode.getNodeName()))
{
type = RewardType.RATED_GROUPED;
list = new RewardList(type, false);
for (Node catNode = dropNode.getFirstChild(); catNode != null; catNode = catNode.getNextSibling())
{
if (!"category".equalsIgnoreCase(catNode.getNodeName()))
{
continue;
}
attrs = catNode.getAttributes();
int chance = (int) (parseDouble(attrs, "chance") * 10000.0D);
RewardGroup group = new RewardGroup(chance);
for (Node itemNode = catNode.getFirstChild(); itemNode != null; itemNode = itemNode.getNextSibling())
{
if (!"item".equalsIgnoreCase(itemNode.getNodeName()))
{
continue;
}
_dropsParsed += 1;
attrs = itemNode.getAttributes();
RewardData data = parseReward(attrs);
group.addData(data);
}
list.add(group);
}
}
else
{
if (!"spoillist".equalsIgnoreCase(dropNode.getNodeName()))
{
continue;
}
RewardGroup g = new RewardGroup(RewardList.MAX_CHANCE);
type = RewardType.SWEEP;
list = new RewardList(type, false);
for (Node itemNode = dropNode.getFirstChild(); itemNode != null; itemNode = itemNode.getNextSibling())
{
if (!"item".equalsIgnoreCase(itemNode.getNodeName()))
{
continue;
}
_spoilsParsed += 1;
attrs = itemNode.getAttributes();
RewardData data = parseReward(attrs);
g.addData(data);
}
list.add(g);
}
template.putRewardList(type, list);
}
}
}
}
}