Casting from Config to Block

Discussion in 'Plugin Development' started by WattMann, Mar 24, 2018.

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

    WattMann

    Hello, i wanted to cast from Config to Block by loop for but it didnt worked, see code
    PHP:
    for(Block bl : (BlockMain.clazz.getConfig().getStringList("AllowedBlocks")) {
       }
    but it didnt worked do you guys have any ideas ?
     
  2. Offline

    ToldiIII

    Code:
    Block b = e.getBlock();
    //OR
    Block b = player.getLocation().getBlock();
    
    if (Main.clazz.getConfig().getStringList("AllowedBlocks").contains(b)) {}
     
    WattMann likes this.
  3. Offline

    WattMann

    thanks

    Code:
    if (Main.clazz.getConfig().getStringList("AllowedBlocks").contains(b.toString())) {}
    this works better

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Mar 24, 2018
Thread Status:
Not open for further replies.

Share This Page