"World" help

Discussion in 'Plugin Development' started by Cosmicluck, Jun 14, 2013.

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

    Cosmicluck

    Just a quick question, i'm wanting to spawn tnt at specified locations and I cannot figure out how to add world to the code:

    Code:
    }
                Location loc18 = new Location(Bukkit.getWorld("world"), 1, 60, 1);
                if(event.getPlayer().getItemInHand().getTypeId() == Material.GHAST_TEAR.getId()){
                    TNTPrimed tnt = (TNTPrimed) world.spawn(loc18, TNTPrimed.class);
                    player.getInventory().remove(Material.GHAST_TEAR);
                }
    
    The error is world.spawn.....

    I know I have to do something like
    World world = I dont know what goes here


    Thanks!
    -Cosmicluck
     
  2. Offline

    chasechocolate

    Well you can do this:
    Code:java
    1. TNTPrimed tnt = (TNTPrimed) loc18.getWorld().spawn(loc18, TNTPrimed.class);
     
  3. Offline

    metalhedd

    You already used the exact code that you need in the first line...
    the new Location(world, x, y, z); wanted a World as the first argument, and look at what you passed into it:

    so thats how you get a world. (though its far from the best way, that's a topic for a different discussion)

    now you just put 2 and 2 together:

    World world = I dont know what goes here Bukkit.getWorld("world");
     
Thread Status:
Not open for further replies.

Share This Page