Cow Shooting

Discussion in 'Plugin Development' started by tschagg, Feb 1, 2013.

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

    tschagg

    hey guys.

    i tried to make like a cowshooter, but when i type the command, it only says "/cowcannon"

    Code:JAVA
    1.  
    2. public class cowcannon extends JavaPlugin {
    3.  
    4. int cowtimer = 0;
    5.  
    6. protected void run(CommandSender sender, Command cmd, final String[] args) throws Exception {
    7.  
    8. Player player = (Player) sender;
    9.  
    10. if (cmd.getName().equalsIgnoreCase("cowcannon")) {
    11.  
    12. final Cow cow = (Cow) player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);
    13.  
    14. if (cow == null) {
    15.  
    16. return;
    17.  
    18. }
    19.  
    20. cowtimer = 2;
    21.  
    22. cow.setVelocity(player.getEyeLocation().getDirection().multiply(3));
    23.  
    24. new BukkitRunnable() {@Override
    25.  
    26. public void run() {
    27.  
    28. if (cowtimer == 2) {
    29.  
    30. final Location loc = cow.getLocation();
    31.  
    32. cow.remove();
    33.  
    34. loc.getWorld().createExplosion(loc, 4F);
    35.  
    36. cowtimer--;
    37.  
    38. }
    39.  
    40. if (cowtimer == 1) {
    41.  
    42. this.cancel();
    43.  
    44. }
    45.  
    46. }
    47.  
    48. }.runTaskTimer(this, 0L, 20L);
    49.  
    50. }
    51.  
    52. }
    53.  
    54. }
    55.  


    any ideas?

    Thank you!
     
  2. Offline

    LaxWasHere

    final Cow cow = (Cow) player.getWorld().spawnEntity(player.getLocation(), EntityType.ZOMBIE);

    Thought you wanted cow?
     
  3. Offline

    Cjreek

    Did you register the command in your plugin.yml?
     
  4. Offline

    gomeow

    You should give it a velocity
     
  5. Offline

    tschagg

    yes

    yeah this was only for testing, but it always spawns nothing...

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

Share This Page