How to make IDs with :number?

Discussion in 'Plugin Development' started by euller12, Aug 24, 2013.

?

How to make IDs with :number ?

  1. Can help me.

    0 vote(s)
    0.0%
  2. Knows how to help.

    0 vote(s)
    0.0%
Thread Status:
Not open for further replies.
  1. Offline

    euller12

    I have been try to figure out how to make Bukkit read ID:Something from the config. All I can get it to do is read:
    getConfig().getInt("Something"))

    in config.yml:
    something: 34

    I want it to read
    something: 34:2

    Please Help.:)
     
  2. Offline

    monkeymanboy

    well if it is a string then you would do (getconfigstuff) + ":2"
    EDIT: just noticed its an int and the question is how do you make it read that well make it a string and it should work
     
  3. Offline

    euller12

    What would I do for this, if (ID2 == getConfig().getInt("block_id")){
     
  4. Offline

    Loogeh

    euller12 You'd store it as a string and then use
    Code:
    String item = getConfig.getString("stringhere");
    Then create a String array called split (or whatever you want)
    Code:
    String[] split = item.split(":");
    This will split the item string into an array containing 34 (being element 0) and 2 (being element 1)

    Next parse each element of the array as id (integer) and data (short)
    Code:
    int id;
    short data;
    try {
        id = Integer.parseInt(split[0]);
    } catch(NumberFormatException) {
        System.out.println("Couldn't parse string to int");
    }
     
    try {
        data = Short.parseShort(split[1]);
    } catch(NumberFormatException) {
        System.out.println("Couldn't parse string to short");
    }
    
    This is just off the top of my head but it should work. You could wrap this in a method called strToItem or something
     
Thread Status:
Not open for further replies.

Share This Page