event in what world?

Discussion in 'Plugin Development' started by Minecrafter_NL, Oct 25, 2013.

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

    Minecrafter_NL

    hey guys im making a plugin and i have an IF.
    I want the IF to be true when an END stone breaks in world ''new''
    this is my code:
    Code:java
    1. @EventHandler
    2. public void onBlockBreak(BlockBreakEvent event)
    3. {
    4. if (event.getBlock().getType() == Material.ENDER_STONE)
    5. {
    6. ////MY CODE HERE
    7. }

    as you can see it already executes my code when end stone breaks.
    i want it only to execute when end stone breaks in world ''new''
     
  2. Code:java
    1. @EventHandler
    2. public void onBlockBreak(BlockBreakEvent event)
    3. {
    4. if (event.getBlock().getType() == Material.ENDER_STONE && event.getBlock().getWorld().getName().equals("new"))
    5. {
    6. ////MY CODE HERE
    7. }
    8. }


    You can also look in the JavaDocs if you want to know how to do something. You can for example see that the block has a method getWorld() and you can the world's name with new.
     
Thread Status:
Not open for further replies.

Share This Page