MapleItemInformationProvider issue

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Enthusiast cljnilsson is offline
    MemberRank
    Jul 2017 Join Date
    26Posts

    MapleItemInformationProvider issue

    I set up a local v83 server with MoopleDEV to learn a bit of coding.
    I figured I'd start with creating a few useful commands.

    So I was trying to create the following command:
    !getplayerinventory <tab> <name>
    So !getplayerinventory etc Swag would list all items in the etc tab of Swag.

    I got it to work, but it displays the ID and not the name of the item, but I cannot get it to work.

    I tried to post the code in code and php tags but it does not keep the structure so here is a picture instead.

    https://i.gyazo.com/71273faab463eaea...9ffe011d70.png

    It is the last commented line that crashes it, the first free writes out properly.


  2. #2
    Valued Member Umbreon is offline
    MemberRank
    Apr 2012 Join Date
    100Posts

    Re: MapleItemInformationProvider issue

    When you print an object in java, by default, it invokes the toString() method.
    Your toString() method for the item object likely just prints out the itemID; what you have commented out is drawing the item's name and other information from your cache. I don't see why you want to print out the mii object itself, maybe try to uncomment one 'message' method call at a time.

  3. #3
    Enthusiast cljnilsson is offline
    MemberRank
    Jul 2017 Join Date
    26Posts

    Re: MapleItemInformationProvider issue

    That is what I am doing.

    MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
    player.message(item.getItemId() + ""); //prints properly
    player.message(item.getQuantity() + ""); //prints properly
    player.message(mii + ""); //prints out properly
    player.message(mii.getName(item.getItemId())); //crash

  4. #4
    Valued Member Umbreon is offline
    MemberRank
    Apr 2012 Join Date
    100Posts

    Re: MapleItemInformationProvider issue

    Quote Originally Posted by cljnilsson View Post
    That is what I am doing.

    MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
    player.message(item.getItemId() + ""); //prints properly
    player.message(item.getQuantity() + ""); //prints properly
    player.message(mii + ""); //prints out properly
    player.message(mii.getName(item.getItemId())); //crash
    mii.getName(item.getItemId()) could be returning null, as the item's name may not be in the cache. Look at the getName method for more information.
    I'd try this
    PHP Code:
    String name mii.getName(item.getItemId());
    if(
    name == nullplayer.message("no name in the cache"); 
    else 
    player.message(name); 

  5. #5
    Enthusiast cljnilsson is offline
    MemberRank
    Jul 2017 Join Date
    26Posts

    Re: MapleItemInformationProvider issue

    I get the "No name in the cache" for all the items in the inventory.
    What does this mean? and how can I fix it.

    It is just normal items, items dropped from green snails specifically.

    From what I can see the item should be added automatically to the namecache but apparently doesn't.
    Last edited by cljnilsson; 25-07-17 at 11:15 PM.

  6. #6
    Valued Member Umbreon is offline
    MemberRank
    Apr 2012 Join Date
    100Posts

    Re: MapleItemInformationProvider issue

    Study the MapleItemInformationProvider class, figure out how it works.
    Perhaps the names are never cached at all.

  7. #7
    Enthusiast cljnilsson is offline
    MemberRank
    Jul 2017 Join Date
    26Posts

    Re: MapleItemInformationProvider issue

    Quote Originally Posted by Umbreon View Post
    Study the MapleItemInformationProvider class, figure out how it works.
    Perhaps the names are never cached at all.
    Right.
    I was gonna test to see if it works with some sort of debug message but realized I do not know where this debug message appear. In the console window where the server is running?

  8. #8
    Enthusiast cljnilsson is offline
    MemberRank
    Jul 2017 Join Date
    26Posts

    Re: MapleItemInformationProvider issue

    I've done some digging and it seems like getStringData in MapleItemInformationProvider is the function returning null.

    PHP Code:
    if (cat.equalsIgnoreCase("null")) {    
        
    System.out.println("IT REUTNRS NULL! (2)" itemId);
        
    System.out.println(theData.getChildByPath(String.valueOf(itemId)) + "");
        
    System.out.println(etcStringData "");
        return 
    theData.getChildByPath(String.valueOf(itemId));

    Output
    PHP Code:
    IT REUTNRS NULL! (2)4161001
    null
    provider
    .wz.XMLDomMapleData@2cc5c898 
    However, it seems to work fine for use/equips, it is only the etc items that return null.

  9. #9
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: MapleItemInformationProvider issue

    Quote Originally Posted by cljnilsson View Post
    However, it seems to work fine for use/equips, it is only the etc items that return null.
    Try comparing #getStringData with #getAllItems (and constructor). Perhaps you'll find out why only ETC items are not loaded properly.

  10. #10
    Enthusiast cljnilsson is offline
    MemberRank
    Jul 2017 Join Date
    26Posts

    Re: MapleItemInformationProvider issue

    Looks all fair to me.
    PHP Code:
    //constructor
    cashStringData stringData.getData("Cash.img");
    consumeStringData stringData.getData("Consume.img");
    eqpStringData stringData.getData("Eqp.img");
    etcStringData stringData.getData("Etc.img");
    insStringData stringData.getData("Ins.img");
    petStringData stringData.getData("Pet.img"); 
    PHP Code:
    //getAllItems()
    List<Pair<IntegerString>> 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

  11. #11
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: MapleItemInformationProvider issue

    @cljnilsson
    and compared with #getStringData ? (pay attention to 'path')

  12. #12
    Enthusiast cljnilsson is offline
    MemberRank
    Jul 2017 Join Date
    26Posts

    Re: MapleItemInformationProvider issue



    getStringData returns
    stringData.getData("Etc.img").getChildByPath(String.valueOf(itemId))

    getAllItems
    stringData.getData("Etc.img").getChildByPath("Etc").getChildren()
    So if I use that and then loop through the list and look for the id to get the name?

  13. #13
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: MapleItemInformationProvider issue

    no, I mean

    Eqp.img/Eqp/Weapon/ItemID
    *see getStringData, cat = "Eqp/Weapon" -> now you can get items directly

    Consume.img/ItemID *you can get items directly
    Ins.img/ItemID *you can get items directly

    Etc.img/Etc/ItemID
    *you're missing cat = ???

  14. #14
    Enthusiast cljnilsson is offline
    MemberRank
    Jul 2017 Join Date
    26Posts

    Re: MapleItemInformationProvider issue

    The cat is for equips only since the eqp.img got sub categories.

    Etc does not have this.

    I edited the return to this:
    PHP Code:
    MapleData md theData.getChildByPath(String.valueOf(itemId));
    if(
    theData == etcStringData) {
        List<
    MapleDatatheData.getChildByPath("Etc").getChildren();
        for(
    MapleData iteml) {
            if(
    Integer.parseInt(item.getName()) == itemId) {
                
    md item;
                break;
            }
        }
    }
    return 
    md
    Which works though I know that using such an iteration is not ideal.

  15. #15
    ・ARC:+200 Yuuroido is offline
    MemberRank
    Jul 2010 Join Date
    Saitama, JPLocation
    333Posts

    Re: MapleItemInformationProvider issue

    Quote Originally Posted by cljnilsson View Post
    The cat is for equips only since the eqp.img got sub categories.
    Etc.img has "Etc" directory... so it should be [cat = "Etc"]



Page 1 of 2 12 LastLast

Advertisement