Looping through material names (ArrayIndexOutOfBoundsException)

Discussion in 'Plugin Development' started by gomeow, Nov 5, 2012.

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

    gomeow

    So I wrote this to help me generate my config for a plugin, and I can't figure out why it isn't working. I get a ArrayIndexOutOfBoundsException in this code:

    Code:java
    1. for(Material each : Material.values()) {
    2. int materialid = each.getId();
    3. String pathmaterial = cap(each.toString());
    4. this.getConfig().set("Prices." + pathmaterial.replaceAll("_", ""), materialid);
    5.  
    6. }
    7. saveConfig();
     
  2. Offline

    Murderscene

    Change Material.values() to
    Material.class.getEnumConstants()
     
  3. Offline

    gomeow

    I get the same error
     
  4. Offline

    Murderscene

    I just tried it and I get no errors?
     
  5. Offline

    gomeow

    ok, you might yell at me for this, I was checking the wrong arg[]...
    Thanks though, you solved my .values() error though
     
  6. Offline

    Murderscene

    NP, glad you sorted it out :)
     
    CeramicTitan likes this.
Thread Status:
Not open for further replies.

Share This Page