Search in sources :

Example 16 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method getName.

public String getName(int itemId) {
    if (nameCache.containsKey(itemId)) {
        return nameCache.get(itemId);
    }
    MapleData strings = getStringData(itemId);
    if (strings == null) {
        return null;
    }
    String ret = MapleDataTool.getString("name", strings, null);
    nameCache.put(itemId, ret);
    return ret;
}
Also used : MapleData(provider.MapleData)

Example 17 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method getAllItems.

// public MapleInventoryType getInventoryType(int itemId) {
// if (inventoryTypeCache.containsKey(itemId)) {
// return inventoryTypeCache.get(itemId);
// }
// MapleInventoryType ret;
// String idStr = "0" + String.valueOf(itemId);
// MapleDataDirectoryEntry root = itemData.getRoot();
// for (MapleDataDirectoryEntry topDir : root.getSubdirectories()) {
// for (MapleDataFileEntry iFile : topDir.getFiles()) {
// if (iFile.getName().equals(idStr.substring(0, 4) + ".img")) {
// ret = MapleInventoryType.getByWZName(topDir.getName());
// inventoryTypeCache.put(itemId, ret);
// return ret;
// } else if (iFile.getName().equals(idStr.substring(1) + ".img")) {
// ret = MapleInventoryType.getByWZName(topDir.getName());
// inventoryTypeCache.put(itemId, ret);
// return ret;
// }
// }
// }
// root = equipData.getRoot();
// for (MapleDataDirectoryEntry topDir : root.getSubdirectories()) {
// for (MapleDataFileEntry iFile : topDir.getFiles()) {
// if (iFile.getName().equals(idStr + ".img")) {
// ret = MapleInventoryType.EQUIP;
// inventoryTypeCache.put(itemId, ret);
// return ret;
// }
// }
// }
// ret = MapleInventoryType.UNDEFINED;
// inventoryTypeCache.put(itemId, ret);
// return ret;
// }
public List<Pair<Integer, String>> getAllItems() {
    if (!itemNameCache.isEmpty()) {
        return itemNameCache;
    }
    List<Pair<Integer, String>> itemPairs = new ArrayList<>();
    MapleData itemsData;
    itemsData = stringData.getData("Cash.img");
    for (MapleData itemFolder : itemsData.getChildren()) {
        itemPairs.add(new Pair<>(Integer.parseInt(itemFolder.getName()), MapleDataTool.getString("name", itemFolder, "NO-NAME")));
    }
    itemsData = stringData.getData("Consume.img");
    for (MapleData itemFolder : itemsData.getChildren()) {
        itemPairs.add(new Pair<>(Integer.parseInt(itemFolder.getName()), MapleDataTool.getString("name", itemFolder, "NO-NAME")));
    }
    itemsData = stringData.getData("Eqp.img").getChildByPath("Eqp");
    for (MapleData eqpType : itemsData.getChildren()) {
        for (MapleData itemFolder : eqpType.getChildren()) {
            itemPairs.add(new Pair<>(Integer.parseInt(itemFolder.getName()), MapleDataTool.getString("name", itemFolder, "NO-NAME")));
        }
    }
    itemsData = stringData.getData("Etc.img").getChildByPath("Etc");
    for (MapleData itemFolder : itemsData.getChildren()) {
        itemPairs.add(new Pair<>(Integer.parseInt(itemFolder.getName()), MapleDataTool.getString("name", itemFolder, "NO-NAME")));
    }
    itemsData = stringData.getData("Ins.img");
    for (MapleData itemFolder : itemsData.getChildren()) {
        itemPairs.add(new Pair<>(Integer.parseInt(itemFolder.getName()), MapleDataTool.getString("name", itemFolder, "NO-NAME")));
    }
    itemsData = stringData.getData("Pet.img");
    for (MapleData itemFolder : itemsData.getChildren()) {
        itemPairs.add(new Pair<>(Integer.parseInt(itemFolder.getName()), MapleDataTool.getString("name", itemFolder, "NO-NAME")));
    }
    return itemPairs;
}
Also used : MapleData(provider.MapleData) ArrayList(java.util.ArrayList) Pair(tools.Pair)

Example 18 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method getStringData.

private MapleData getStringData(int itemId) {
    String cat = "null";
    MapleData theData;
    if (itemId >= 5010000) {
        theData = cashStringData;
    } else if (itemId >= 2000000 && itemId < 3000000) {
        theData = consumeStringData;
    } else if ((itemId >= 1010000 && itemId < 1040000) || (itemId >= 1122000 && itemId < 1123000) || (itemId >= 1132000 && itemId < 1133000) || (itemId >= 1142000 && itemId < 1143000)) {
        theData = eqpStringData;
        cat = "Eqp/Accessory";
    } else if (itemId >= 1000000 && itemId < 1010000) {
        theData = eqpStringData;
        cat = "Eqp/Cap";
    } else if (itemId >= 1102000 && itemId < 1103000) {
        theData = eqpStringData;
        cat = "Eqp/Cape";
    } else if (itemId >= 1040000 && itemId < 1050000) {
        theData = eqpStringData;
        cat = "Eqp/Coat";
    } else if (itemId >= 20000 && itemId < 22000) {
        theData = eqpStringData;
        cat = "Eqp/Face";
    } else if (itemId >= 1080000 && itemId < 1090000) {
        theData = eqpStringData;
        cat = "Eqp/Glove";
    } else if (itemId >= 30000 && itemId < 35000) {
        theData = eqpStringData;
        cat = "Eqp/Hair";
    } else if (itemId >= 1050000 && itemId < 1060000) {
        theData = eqpStringData;
        cat = "Eqp/Longcoat";
    } else if (itemId >= 1060000 && itemId < 1070000) {
        theData = eqpStringData;
        cat = "Eqp/Pants";
    } else if (itemId >= 1802000 && itemId < 1842000) {
        theData = eqpStringData;
        cat = "Eqp/PetEquip";
    } else if (itemId >= 1112000 && itemId < 1120000) {
        theData = eqpStringData;
        cat = "Eqp/Ring";
    } else if (itemId >= 1092000 && itemId < 1100000) {
        theData = eqpStringData;
        cat = "Eqp/Shield";
    } else if (itemId >= 1070000 && itemId < 1080000) {
        theData = eqpStringData;
        cat = "Eqp/Shoes";
    } else if (itemId >= 1900000 && itemId < 2000000) {
        theData = eqpStringData;
        cat = "Eqp/Taming";
    } else if (itemId >= 1300000 && itemId < 1800000) {
        theData = eqpStringData;
        cat = "Eqp/Weapon";
    } else if (itemId >= 4000000 && itemId < 5000000) {
        theData = etcStringData;
        cat = "Etc";
    } else if (itemId >= 3000000 && itemId < 4000000) {
        theData = insStringData;
    } else if (ItemConstants.isPet(itemId)) {
        theData = petStringData;
    } else {
        return null;
    }
    if (cat.equalsIgnoreCase("null")) {
        return theData.getChildByPath(String.valueOf(itemId));
    } else {
        return theData.getChildByPath(cat + "/" + itemId);
    }
}
Also used : MapleData(provider.MapleData)

Example 19 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method getSummonMobs.

public int[][] getSummonMobs(int itemId) {
    MapleData data = getItemData(itemId);
    int theInt = data.getChildByPath("mob").getChildren().size();
    int[][] mobs2spawn = new int[theInt][2];
    for (int x = 0; x < theInt; x++) {
        mobs2spawn[x][0] = MapleDataTool.getIntConvert("mob/" + x + "/id", data);
        mobs2spawn[x][1] = MapleDataTool.getIntConvert("mob/" + x + "/prob", data);
    }
    return mobs2spawn;
}
Also used : MapleData(provider.MapleData)

Example 20 with MapleData

use of provider.MapleData in project HeavenMS by ronancpl.

the class MapleItemInformationProvider method getSlotMax.

public short getSlotMax(MapleClient c, int itemId) {
    Short slotMax = slotMaxCache.get(itemId);
    if (slotMax != null) {
        return (short) (slotMax + getExtraSlotMaxFromPlayer(c, itemId));
    }
    short ret = 0;
    MapleData item = getItemData(itemId);
    if (item != null) {
        MapleData smEntry = item.getChildByPath("info/slotMax");
        if (smEntry == null) {
            if (ItemConstants.getInventoryType(itemId).getType() == MapleInventoryType.EQUIP.getType()) {
                ret = 1;
            } else {
                ret = 100;
            }
        } else {
            ret = (short) MapleDataTool.getInt(smEntry);
        }
    }
    slotMaxCache.put(itemId, ret);
    return (short) (ret + getExtraSlotMaxFromPlayer(c, itemId));
}
Also used : MapleData(provider.MapleData)

Aggregations

MapleData (provider.MapleData)90 ArrayList (java.util.ArrayList)19 Pair (tools.Pair)11 File (java.io.File)8 Point (java.awt.Point)7 LinkedList (java.util.LinkedList)6 MapleDataDirectoryEntry (provider.MapleDataDirectoryEntry)6 MapleDataFileEntry (provider.MapleDataFileEntry)6 LinkedHashMap (java.util.LinkedHashMap)5 SQLException (java.sql.SQLException)4 MapleDataProvider (provider.MapleDataProvider)4 Skill (client.Skill)2 IOException (java.io.IOException)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 AbstractLoadedMapleLife (server.life.AbstractLoadedMapleLife)2 MapleCharacter (client.MapleCharacter)1 Item (client.inventory.Item)1 MonsterStatus (client.status.MonsterStatus)1 Rectangle (java.awt.Rectangle)1