Solved Spawn Falling Block

Discussion in 'Plugin Development' started by Jay23, Jul 29, 2014.

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

    Jay23

    The purpose of this plugin is to spawn a falling wood block above the map that lands on the surface, and displays the location of the wood block. All displays are working fine, the only problem is that it's not spawning a block. Here's the code.
    Code:java
    1. package coeus.airdrop;
    2.  
    3. import java.util.Random;
    4.  
    5. import me.confuser.barapi.BarAPI;
    6.  
    7. import org.bukkit.Bukkit;
    8. import org.bukkit.ChatColor;
    9. import org.bukkit.Location;
    10. import org.bukkit.Material;
    11. import org.bukkit.command.Command;
    12. import org.bukkit.command.CommandSender;
    13. import org.bukkit.entity.Player;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15.  
    16. public class Airdrop extends JavaPlugin {
    17.  
    18.  
    19. public void onEnable() {
    20. }
    21.  
    22. public void onDisable() {
    23.  
    24. }
    25.  
    26. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    27. if(cmd.getName().equalsIgnoreCase("airdrop")) {
    28.  
    29. @SuppressWarnings("unused")
    30. Random random = new Random();
    31.  
    32. //int xcoord = (random.nextInt(20000) - 10000);
    33. //int ycoord = 150;
    34. //int zcoord = (random.nextInt(20000) - 10000);
    35. int xcoord = -500;
    36. int zcoord = 460;
    37. int ycoord = 150;
    38.  
    39. Bukkit.getServer().getWorld(label);
    40.  
    41. Location airdrop = new Location(null, xcoord, ycoord, zcoord);
    42.  
    43. sender.sendMessage(ChatColor.GOLD + "Airdrop coordinates - X: " + xcoord + " Y: " + ycoord + " Z: " + zcoord);
    44.  
    45. Bukkit.broadcastMessage(ChatColor.GREEN + "There is a new airdrop at X: " + xcoord + " Y: " + ycoord + " Z: " + zcoord);
    46. BarAPI.setMessage((Player)sender, ChatColor.GOLD + "Airdrop located at X: " + xcoord + " Y: " + ycoord + " Z: " + zcoord, 100f);
    47. spawnFallingBlock(airdrop);
    48. setType(Material.WOOD);
    49. return true;
    50. }
    51. return false;
    52. }
    53.  
    54. private void setType(Material wood) {
    55.  
    56. }
    57.  
    58. private void spawnFallingBlock(Location airdrop) {
    59.  
    60. }
    61. }


    I commented out the random location generator part so I could have the wood block spawn above my current location.
     
  2. Offline

    valon750

    Jay23

    According to this code snippet, there's nothing in your "spawnFallingBlock" method.
     
  3. Offline

    Jay23

    valon750

    So it has to be it's own method? It can't be in the onCommand method like I have it?
     
  4. Offline

    Necrodoom

    Jay23 no, you need to call the spawn falling block one way or another, calling a method named "spawnFallingBlock" is not going to do anything at all.
    Also, get a world object and put it at the location constructor, you ain't going to spawn a falling block on a null world.
     
Thread Status:
Not open for further replies.

Share This Page