Select the material in the config.

Discussion in 'Plugin Development' started by zDubsCrazy, Apr 9, 2014.

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

    zDubsCrazy

    I need a config to select the block that will be used as repair block in my plugin! Example> material: iron_block (to select IRON_BLOCK), diamond_block (to select DIAMOND_BLOCK).... Please hel-me!

    Thanks.
     
  2. Offline

    rfsantos1996


    Code:java
    1. Material material = Material.valueOf(<String being the material name>.toUpperCase());
     
  3. Offline

    zDubsCrazy

    Where's the string I put the block type? and in the same config? :confused:

    can someone explain me better? :eek:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Wizehh

    getConfig().getString("material")..
    I don't understand what you're asking.
     
    KingFaris11 likes this.
  5. Offline

    zDubsCrazy

    I wanna know what I put in the code that I was past! For example:
    Code:java
    1. Material material = Material.valueOf("IRON_BLOCK".toUpperCase());
    ?
     
  6. Offline

    Wizehh

    Get the Material by using the built-in enum function
    Code:
    Material#valueOf("your string here").toUpperCase();
    You get a String from your configuration file by using
    Code:
    getConfig().getString("material")
     
  7. Offline

    zDubsCrazy

    Ok, but how the plugin will identify the material if I put for example:
    Code:java
    1. Material material = Material.valueOf("MyEggs".toUpperCase());
    ?
     
  8. Offline

    Wolfey

    zDubsCrazy MyEggs isn't a material... Get the string from the config, and put it in the Material.valueOf().
     
  9. Offline

    zDubsCrazy

    Wolfey Bad I want, more than one material! Example: iron_block, diamond_block, emerald_block, like this. In the config!
     
  10. Offline

    Wolfey

    Then get the string from the config, and split it by ", ", run a for loop on it, and use the method I said above.
     
  11. Offline

    mazentheamazin

  12. Offline

    zDubsCrazy

    Thanks to all who answered, but I've got with the help of my fellow rfsantos1996 .
     
Thread Status:
Not open for further replies.

Share This Page