Repository reorganisation
Unified kotlin and java into just src/main Unified the rs09 and core packages Took all content out of the core package, and placed it into the new content package Reorganised all source code relating to content to be easier to find and explore
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.RandomFunction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import core.ServerConstants;
|
||||
import core.tools.SystemLogger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the allotment seed drop table.
|
||||
* @author Von Hresvelg
|
||||
*/
|
||||
public final class AllotmentSeedDropTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the allotment seed drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 14430;
|
||||
|
||||
/**
|
||||
* The allotment seed drop table.
|
||||
*/
|
||||
private static final List<WeightedChanceItem> TABLE = new ArrayList<>(20);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
static DocumentBuilder builder;
|
||||
|
||||
static {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public AllotmentSeedDropTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.ASDT_DATA_PATH != null && !new File(ServerConstants.ASDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate ASDT file at " + ServerConstants.ASDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.ASDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Allotment Seed Drop Table from " + ServerConstants.ASDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the allotment seed drop table.
|
||||
* @param file the .xml file containing the allotment seed drop table.
|
||||
*/
|
||||
public static void parse(String file){
|
||||
try {
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
NodeList itemNodes = doc.getElementsByTagName("item");
|
||||
for(int i = 0; i < itemNodes.getLength(); i++){
|
||||
Node itemNode = itemNodes.item(i);
|
||||
if(itemNode.getNodeType() == Node.ELEMENT_NODE){
|
||||
Element item = (Element) itemNode;
|
||||
int itemId = Integer.parseInt(item.getAttribute("id"));
|
||||
int minAmt = Integer.parseInt(item.getAttribute("minAmt"));
|
||||
int maxAmt = Integer.parseInt(item.getAttribute("maxAmt"));
|
||||
int weight = Integer.parseInt(item.getAttribute("weight"));
|
||||
|
||||
TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Item retrieve() {return RandomFunction.rollWeightedChanceTable(TABLE);}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package content.data.tables;
|
||||
|
||||
import org.rs09.consts.Items;
|
||||
import core.game.node.entity.npc.drop.NPCDropTables;
|
||||
import core.game.node.entity.player.Player;
|
||||
import core.game.node.item.ChanceItem;
|
||||
import core.game.node.item.GroundItemManager;
|
||||
import core.game.node.item.Item;
|
||||
import core.tools.RandomFunction;
|
||||
import core.tools.StringUtils;
|
||||
|
||||
/**
|
||||
* Represents a birds nest.
|
||||
* @author Vexia
|
||||
*/
|
||||
public enum BirdNest {
|
||||
SEED(new ChanceItem(5073, 1, 65),
|
||||
new ChanceItem(Items.ACORN_5312, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.APPLE_TREE_SEED_5283, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.WILLOW_SEED_5313, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.BANANA_TREE_SEED_5284, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.ORANGE_TREE_SEED_5285, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.CURRY_TREE_SEED_5286, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.MAPLE_SEED_5314, 1, NPCDropTables.DROP_RATES[1]),
|
||||
new ChanceItem(Items.PINEAPPLE_SEED_5287, 1, NPCDropTables.DROP_RATES[1]),
|
||||
new ChanceItem(Items.PAPAYA_TREE_SEED_5288, 1, NPCDropTables.DROP_RATES[1]),
|
||||
new ChanceItem(Items.YEW_SEED_5315, 1, NPCDropTables.DROP_RATES[2]),
|
||||
new ChanceItem(Items.PALM_TREE_SEED_5289, 1, NPCDropTables.DROP_RATES[2]),
|
||||
new ChanceItem(Items.CALQUAT_TREE_SEED_5290, 1, NPCDropTables.DROP_RATES[2]),
|
||||
new ChanceItem(Items.SPIRIT_SEED_5317, 1, NPCDropTables.DROP_RATES[3]),
|
||||
new ChanceItem(Items.MAGIC_SEED_5316, 1, NPCDropTables.DROP_RATES[3])),
|
||||
RING(new ChanceItem(5074, 1, 30),
|
||||
new ChanceItem(Items.GOLD_RING_1635, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.SAPPHIRE_RING_1637, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.EMERALD_RING_1639, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.RUBY_RING_1641, 1, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.DIAMOND_RING_1643, 1, NPCDropTables.DROP_RATES[2])),
|
||||
RED(new ChanceItem(5070, 1, 5), new ChanceItem(5076)),
|
||||
GREEN(new ChanceItem(5071, 1, 5), new ChanceItem(5078)),
|
||||
BLUE(new ChanceItem(5072, 1, 5), new ChanceItem(5077)),
|
||||
RAVEN(new ChanceItem(11966, 1, 5), new ChanceItem(11964)),
|
||||
|
||||
WYSON(new ChanceItem(7413, 1, 1),
|
||||
new ChanceItem(Items.POTATO_SEED_5318, 14, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.SWEETCORN_SEED_5320, 3, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.TOMATO_SEED_5322, 6, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.CABBAGE_SEED_5324, 9, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.LIMPWURT_SEED_5100, 2, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.ONION_SEED_5319, 11, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.STRAWBERRY_SEED_5323, 3, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.WATERMELON_SEED_5321, 2, NPCDropTables.DROP_RATES[0]),
|
||||
new ChanceItem(Items.ACORN_5312, 1, NPCDropTables.DROP_RATES[2]),
|
||||
new ChanceItem(Items.RANARR_SEED_5295, 1, NPCDropTables.DROP_RATES[2]),
|
||||
new ChanceItem(Items.WILLOW_SEED_5313, 1, NPCDropTables.DROP_RATES[2]),
|
||||
new ChanceItem(Items.MAPLE_SEED_5314, 1, NPCDropTables.DROP_RATES[2]),
|
||||
new ChanceItem(Items.YEW_SEED_5315, 1, NPCDropTables.DROP_RATES[2]),
|
||||
new ChanceItem(Items.MAGIC_SEED_5316, 1, NPCDropTables.DROP_RATES[3]),
|
||||
new ChanceItem(Items.SPIRIT_SEED_5317, 1, NPCDropTables.DROP_RATES[3]));
|
||||
|
||||
/**
|
||||
* The random nest items.
|
||||
*/
|
||||
private static final ChanceItem[] NESTS = new ChanceItem[6];
|
||||
|
||||
/**
|
||||
* The empty birds nest item.
|
||||
*/
|
||||
private static final Item EMPTY = new Item(5075);
|
||||
|
||||
/**
|
||||
* The birds nest item.
|
||||
*/
|
||||
private final ChanceItem nest;
|
||||
|
||||
/**
|
||||
* The loot item from the nest.
|
||||
*/
|
||||
private final ChanceItem[] loot;
|
||||
|
||||
/**
|
||||
* Constructs a new {@code BirdNest} {@code Object}.
|
||||
* @param nest the nest.
|
||||
* @param loot the loot.
|
||||
*/
|
||||
private BirdNest(final ChanceItem nest, final ChanceItem... loot) {
|
||||
this.nest = nest;
|
||||
this.loot = loot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Drops a birds nest.
|
||||
* @param player the player.
|
||||
*/
|
||||
public static void drop(final Player player) {
|
||||
final BirdNest nest = getRandomNest(false);
|
||||
player.getAudioManager().send(1997);
|
||||
GroundItemManager.create(nest.getNest(), player);
|
||||
player.getPacketDispatch().sendMessage("<col=FF0000>A bird's nest falls out of the tree.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches a bird nest.
|
||||
* @param player the player.
|
||||
* @param item the item searched.
|
||||
*/
|
||||
public void search(final Player player, Item item) {
|
||||
if (player.getInventory().freeSlots() < 1) {
|
||||
player.getPacketDispatch().sendMessage("You don't have enough inventory space.");
|
||||
return;
|
||||
}
|
||||
final ChanceItem loot = ordinal() > 1 && this != WYSON ? getLoot()[0] : RandomFunction.getChanceItem(getLoot());
|
||||
final String name = loot.getName().toLowerCase();
|
||||
final String input = (StringUtils.isPlusN(name) ? "an" : "a") + " " + name;
|
||||
player.lock(1);
|
||||
player.getInventory().add(loot);
|
||||
player.getInventory().replace(EMPTY, item.getSlot());
|
||||
player.getPacketDispatch().sendMessage("You take " + input + " out of the bird's nest.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the random nest.
|
||||
* @return the nest.
|
||||
*/
|
||||
public static BirdNest getRandomNest(boolean wyson) {
|
||||
ChanceItem item = RandomFunction.getChanceItem(NESTS);
|
||||
for (BirdNest n : BirdNest.values()) {
|
||||
if (n.getNest() == item) {
|
||||
if (wyson && n == SEED) {
|
||||
return WYSON;
|
||||
} else if (!wyson && n == WYSON) {
|
||||
return SEED;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nest by the id.
|
||||
* @param nest the nest.
|
||||
* @return the nest.
|
||||
*/
|
||||
public static BirdNest forNest(final Item nest) {
|
||||
for (BirdNest n : values()) {
|
||||
if (n.getNest().getId() == nest.getId()) {
|
||||
return n;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the nest.
|
||||
* @return The nest.
|
||||
*/
|
||||
public ChanceItem getNest() {
|
||||
return nest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the loot.
|
||||
* @return The loot.
|
||||
*/
|
||||
public ChanceItem[] getLoot() {
|
||||
return loot;
|
||||
}
|
||||
|
||||
/**
|
||||
* static-block to add nests.
|
||||
*/
|
||||
static {
|
||||
for (int i = 0; i < NESTS.length; i++) {
|
||||
NESTS[i] = values()[i].getNest();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.ServerConstants;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.SystemLogger;
|
||||
import core.tools.RandomFunction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the Chaos Elemental's minor drop table. It is supposed to roll this table alongside its standard major drops on the main table.
|
||||
* @author Crash
|
||||
*/
|
||||
public final class CELEMinorTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the C. Ele minor drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 799; // Crash: Item ID 799 is currently a null, blank paper note object. Unsure if used for cutscene/cutscene items, but hijacking this as C.Ele's item container as it'll never be dropped or obtained in normal gameplay.
|
||||
|
||||
/**
|
||||
* The rare drop table.
|
||||
*/
|
||||
private static final List<WeightedChanceItem> TABLE = new ArrayList<>(20);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
static DocumentBuilder builder;
|
||||
|
||||
static {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public CELEMinorTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.CELEDT_DATA_PATH != null && !new File(ServerConstants.CELEDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate CELEDT file at " + ServerConstants.CELEDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.CELEDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Loaded up Chaos Elemental drop table from " + ServerConstants.CELEDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the CELEDT.
|
||||
* @param file the .xml file containing the CELEDT.
|
||||
*/
|
||||
public static void parse(String file){
|
||||
try {
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
NodeList itemNodes = doc.getElementsByTagName("item");
|
||||
for(int i = 0; i < itemNodes.getLength(); i++){
|
||||
Node itemNode = itemNodes.item(i);
|
||||
if(itemNode.getNodeType() == Node.ELEMENT_NODE){
|
||||
Element item = (Element) itemNode;
|
||||
int itemId = Integer.parseInt(item.getAttribute("id"));
|
||||
int minAmt = Integer.parseInt(item.getAttribute("minAmt"));
|
||||
int maxAmt = Integer.parseInt(item.getAttribute("maxAmt"));
|
||||
int weight = Integer.parseInt(item.getAttribute("weight"));
|
||||
|
||||
TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Item retrieve(){
|
||||
return RandomFunction.rollWeightedChanceTable(TABLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.RandomFunction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import core.ServerConstants;
|
||||
import core.tools.SystemLogger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the gem drop table.
|
||||
* @author Von Hresvelg
|
||||
*/
|
||||
public final class GemDropTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the gem drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 14426;
|
||||
|
||||
/**
|
||||
* The gem drop table.
|
||||
*/
|
||||
private static final List<WeightedChanceItem> TABLE = new ArrayList<>(20);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
static DocumentBuilder builder;
|
||||
|
||||
static {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public GemDropTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.GDT_DATA_PATH != null && !new File(ServerConstants.GDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate GDT file at " + ServerConstants.GDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.GDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Gem Drop Table from " + ServerConstants.GDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the gem drop table.
|
||||
* @param file the .xml file containing the gem drop table.
|
||||
*/
|
||||
public static void parse(String file){
|
||||
try {
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
NodeList itemNodes = doc.getElementsByTagName("item");
|
||||
for(int i = 0; i < itemNodes.getLength(); i++){
|
||||
Node itemNode = itemNodes.item(i);
|
||||
if(itemNode.getNodeType() == Node.ELEMENT_NODE){
|
||||
Element item = (Element) itemNode;
|
||||
int itemId = Integer.parseInt(item.getAttribute("id"));
|
||||
int minAmt = Integer.parseInt(item.getAttribute("minAmt"));
|
||||
int maxAmt = Integer.parseInt(item.getAttribute("maxAmt"));
|
||||
int weight = Integer.parseInt(item.getAttribute("weight"));
|
||||
|
||||
TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Item retrieve(){
|
||||
return RandomFunction.rollWeightedChanceTable(TABLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.RandomFunction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import core.ServerConstants;
|
||||
import core.tools.SystemLogger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the herb drop table.
|
||||
* @author Von Hresvelg
|
||||
*/
|
||||
public final class HerbDropTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the herb drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 14424;
|
||||
|
||||
/**
|
||||
* The herb drop table.
|
||||
*/
|
||||
private static final List<WeightedChanceItem> TABLE = new ArrayList<>(20);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
static DocumentBuilder builder;
|
||||
|
||||
static {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public HerbDropTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.HDT_DATA_PATH != null && !new File(ServerConstants.HDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate HDT file at " + ServerConstants.HDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.HDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Herb Drop Table from " + ServerConstants.HDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the herb drop table.
|
||||
* @param file the .xml file containing the herb drop table.
|
||||
*/
|
||||
public static void parse(String file){
|
||||
try {
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
NodeList itemNodes = doc.getElementsByTagName("item");
|
||||
for(int i = 0; i < itemNodes.getLength(); i++){
|
||||
Node itemNode = itemNodes.item(i);
|
||||
if(itemNode.getNodeType() == Node.ELEMENT_NODE){
|
||||
Element item = (Element) itemNode;
|
||||
int itemId = Integer.parseInt(item.getAttribute("id"));
|
||||
int minAmt = Integer.parseInt(item.getAttribute("minAmt"));
|
||||
int maxAmt = Integer.parseInt(item.getAttribute("maxAmt"));
|
||||
int weight = Integer.parseInt(item.getAttribute("weight"));
|
||||
|
||||
TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Item retrieve(){
|
||||
return RandomFunction.rollWeightedChanceTable(TABLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.ServerConstants;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.SystemLogger;
|
||||
import core.tools.RandomFunction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the rare drop table.
|
||||
* @author Ceikry
|
||||
*/
|
||||
public final class RareDropTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the rare drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 31;
|
||||
|
||||
/**
|
||||
* The rare drop table.
|
||||
*/
|
||||
private static final List<WeightedChanceItem> TABLE = new ArrayList<>(20);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
static DocumentBuilder builder;
|
||||
|
||||
static {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public RareDropTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.RDT_DATA_PATH != null && !new File(ServerConstants.RDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate RDT file at " + ServerConstants.RDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.RDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Rare Drop Table from " + ServerConstants.RDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the RDT.
|
||||
* @param file the .xml file containing the RDT.
|
||||
*/
|
||||
public static void parse(String file){
|
||||
try {
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
NodeList itemNodes = doc.getElementsByTagName("item");
|
||||
for(int i = 0; i < itemNodes.getLength(); i++){
|
||||
Node itemNode = itemNodes.item(i);
|
||||
if(itemNode.getNodeType() == Node.ELEMENT_NODE){
|
||||
Element item = (Element) itemNode;
|
||||
int itemId = Integer.parseInt(item.getAttribute("id"));
|
||||
int minAmt = Integer.parseInt(item.getAttribute("minAmt"));
|
||||
int maxAmt = Integer.parseInt(item.getAttribute("maxAmt"));
|
||||
int weight = Integer.parseInt(item.getAttribute("weight"));
|
||||
|
||||
TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Item retrieve(){
|
||||
return RandomFunction.rollWeightedChanceTable(TABLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.RandomFunction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import core.ServerConstants;
|
||||
import core.tools.SystemLogger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the rare seed drop table.
|
||||
* @author Von Hresvelg
|
||||
*/
|
||||
public final class RareSeedDropTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the rare seed drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 14428;
|
||||
|
||||
/**
|
||||
* The rare seed drop table.
|
||||
*/
|
||||
private static final List<WeightedChanceItem> TABLE = new ArrayList<>(20);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
static DocumentBuilder builder;
|
||||
|
||||
static {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public RareSeedDropTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.RSDT_DATA_PATH != null && !new File(ServerConstants.RSDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate RSDT file at " + ServerConstants.RSDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.RSDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Rare Seed Drop Table from " + ServerConstants.RSDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the rare seed drop table.
|
||||
* @param file the .xml file containing the rare seed drop table.
|
||||
*/
|
||||
public static void parse(String file){
|
||||
try {
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
NodeList itemNodes = doc.getElementsByTagName("item");
|
||||
for(int i = 0; i < itemNodes.getLength(); i++){
|
||||
Node itemNode = itemNodes.item(i);
|
||||
if(itemNode.getNodeType() == Node.ELEMENT_NODE){
|
||||
Element item = (Element) itemNode;
|
||||
int itemId = Integer.parseInt(item.getAttribute("id"));
|
||||
int minAmt = Integer.parseInt(item.getAttribute("minAmt"));
|
||||
int maxAmt = Integer.parseInt(item.getAttribute("maxAmt"));
|
||||
int weight = Integer.parseInt(item.getAttribute("weight"));
|
||||
|
||||
TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Item retrieve(){
|
||||
return RandomFunction.rollWeightedChanceTable(TABLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package content.data.tables;
|
||||
|
||||
import core.api.StartupListener;
|
||||
import core.game.node.item.Item;
|
||||
import core.game.node.item.WeightedChanceItem;
|
||||
import core.tools.RandomFunction;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
import org.w3c.dom.NodeList;
|
||||
import core.ServerConstants;
|
||||
import core.tools.SystemLogger;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static core.tools.SystemLogger.logInfo;
|
||||
|
||||
/**
|
||||
* Handles the uncommon seed drop table.
|
||||
* @author Von Hresvelg
|
||||
*/
|
||||
public final class UncommonSeedDropTable implements StartupListener {
|
||||
|
||||
/**
|
||||
* The item id of the item representing the uncommon seed drop table slot in a drop
|
||||
* table.
|
||||
*/
|
||||
public static final int SLOT_ITEM_ID = 14422;
|
||||
|
||||
/**
|
||||
* The uncommon seed drop table.
|
||||
*/
|
||||
private static final List<WeightedChanceItem> TABLE = new ArrayList<>(20);
|
||||
|
||||
|
||||
/**
|
||||
* Initialize needed objects for xml reading/writing
|
||||
*/
|
||||
static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
|
||||
static DocumentBuilder builder;
|
||||
|
||||
static {
|
||||
try {
|
||||
builder = factory.newDocumentBuilder();
|
||||
} catch (ParserConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public UncommonSeedDropTable() throws ParserConfigurationException {}
|
||||
|
||||
@Override
|
||||
public void startup() {
|
||||
if(ServerConstants.USDT_DATA_PATH != null && !new File(ServerConstants.USDT_DATA_PATH).exists()){
|
||||
SystemLogger.logErr(this.getClass(), "Can't locate USDT file at " + ServerConstants.USDT_DATA_PATH);
|
||||
return;
|
||||
}
|
||||
parse(ServerConstants.USDT_DATA_PATH);
|
||||
logInfo(this.getClass(), "Initialized Uncommon Seed Drop Table from " + ServerConstants.USDT_DATA_PATH);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the xml file for the uncommon seed drop table.
|
||||
* @param file the .xml file containing the uncommon seed drop table.
|
||||
*/
|
||||
public static void parse(String file){
|
||||
try {
|
||||
Document doc = builder.parse(file);
|
||||
|
||||
NodeList itemNodes = doc.getElementsByTagName("item");
|
||||
for(int i = 0; i < itemNodes.getLength(); i++){
|
||||
Node itemNode = itemNodes.item(i);
|
||||
if(itemNode.getNodeType() == Node.ELEMENT_NODE){
|
||||
Element item = (Element) itemNode;
|
||||
int itemId = Integer.parseInt(item.getAttribute("id"));
|
||||
int minAmt = Integer.parseInt(item.getAttribute("minAmt"));
|
||||
int maxAmt = Integer.parseInt(item.getAttribute("maxAmt"));
|
||||
int weight = Integer.parseInt(item.getAttribute("weight"));
|
||||
|
||||
TABLE.add(new WeightedChanceItem(itemId,minAmt,maxAmt,weight));
|
||||
}
|
||||
}
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static Item retrieve(){
|
||||
return RandomFunction.rollWeightedChanceTable(TABLE);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user