Solved Help with item damage from config. Possible Bug?

Discussion in 'Plugin Development' started by quaz3l, Jan 1, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    quaz3l

    This has been bugging me for a while, when I try to get a string from a config that is in the item damage type for things like wool and spawn eggs, (35:2), and output the string to the console, it outputs as an Integer, 35:2 turn into 2101, and 1:1 turn to 61. Is this a bug? If not how would I get the true string so I can get item damage?
    Code:
    PHP:
    String slug qQuests.plugin.Config.getQuestConfig().getString(questName ".tasks." tRoot ".id");
                                
    String[] info slug.split(":");
                                
    Chat.logger("debug""Slug: " slug);
                                
    Chat.logger("debug""ID: " info[0]);
                                if(
    info.length == 2) {
                                    try {
                                        
    Chat.logger("debug""DR: " info[1]);
                                        
    task.id(Integer.parseInt(info[0]));
                                        
    task.durability(((Integer)Integer.parseInt(info[1])).shortValue());
                                    } catch(
    Exception e) {
                                        
    Chat.logger("severe""The #" tRoot +" task of '" root "' does not have valid material ids! Disabling this quest...");
                                    }
                                } else {
                                    try {
                                        
    task.id(Integer.parseInt(info[0]));
                                    } catch(
    Exception e) {
                                        
    Chat.logger("severe""The #" tRoot +" task of '" root "' does not have valid material ids! Disabling this quest...");
                                    }
                                }
    quaz3l
    Solved it, it is because ":" is a mapping value, so it messes up the YAML, just wrap the whole thing in quotes like so "35:1". This isn't the best, most clean fix, but it does the job.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 30, 2016
  2. Offline

    EnvisionRed

    Did that guy just explain something, out loud, to himself?
     
  3. Offline

    quaz3l

    I just thought other people might want to know the simple solution.
     
Thread Status:
Not open for further replies.

Share This Page