Get Ids from custom list?

Discussion in 'Plugin Development' started by Connor2weirdness, Jan 31, 2014.

Thread Status:
Not open for further replies.
  1. Hello, does anyone know how I can get a whole list of items in a config? What I'm trying to do is check if the player right clicks a block (got that part) and if that block is in the blacklist then event.setCancelled(true); if possible, I'd like to make the code as short as possible which is why I'm doing it this way rather than having an if statement or an && for checking if it's that block.

    Thanks!
     
  2. Offline

    beastman3226

    Bring the list in from the config and check if it contains the block that is clicked. I would suggest using material names.
     
  3. Not really sure how I'd do that. I watched a tutorial on configs but it only showed how to set specific values such as the welcome message or whatever. Could I have an example please? :D
     
  4. Offline

    Smartloser

    Do something like this.
    Code:
    Items: 276,311,555,777,998
    
    Now in the plugin

    Code:java
    1.  
    2. String[] itemlist = getConfig().getString(Items).split(",");
    3. for (int i = 0; i < itemlist.length; i++)
    4. {
    5. p.sendMessage("Item id in location " + i + " is: " + itemlist[i]);
    6. }
    7. [/i]

    Didn't test it, but it should work I guess.
     
  5. Thank you but is there a simpler way? My brain hurts just looking at this code D:
     
  6. Offline

    Smartloser

  7. Ok, thanks anyway. The noob needs to do research :p
     
Thread Status:
Not open for further replies.

Share This Page