Solved list to Material[]

Discussion in 'Plugin Development' started by DeathWizsh, Apr 2, 2015.

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

    DeathWizsh

    Hey guys and gals, I've ran into a problem I need a bit of help with.
    I've set a list of materials in my config and I need to convert them to an Material[] array
    This will allow ppl to configure the blocks affected by my plugin.

    Currently I got my hard coded Material[] like this:
    Code:
    Material[] list1 = { Material.STONE, Material.COBBLESTONE, Material.SANDSTONE };
    
    I've already got the list from the config
    Code:
    List<?> listHM = plugin.getConfig().getList("listHM");
    
    I've tried different things like .toArray and casting it to Material and such but I'm kinda stuck atm.
    Hope someone can help me into the right direction.
     
  2. Offline

    1Rogue

    cast it to a List<Material> and then do .toArray(Material[]::new).

    Though I'm not sure why you're bothering to convert anything to an array. A collection is more powerful.
     
  3. Offline

    DeathWizsh

    I have a for loop that checks the blocks Material with the Materials in the Material[] array at the moment.
    My current list is just a test list, its going to be alot longer.

    I fogot to mention I'm only a beginner and I don't understand much from your example above.
     
    Last edited: Apr 2, 2015
  4. Offline

    DeathWizsh

    I've found a different method to solve my problem, thx for your time 1Rogue.
     
Thread Status:
Not open for further replies.

Share This Page