[URGENT] Gun Help

Discussion in 'Plugin Development' started by XxZHALO13Xx, Jun 13, 2014.

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

    XxZHALO13Xx

    Hey im making a game kinda like QuakeCraft, basically u click a hoe and it launches a egg.. well, it works but if u right click the ground it makes the click noise i set and it says in the chat the message i set.. heres my code. how do i make it not do anything when i click the ground?

    Code:java
    1. package me.XxZHALO13Xx.Gun1;
    2.  
    3.  
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Material;
    6. import org.bukkit.Sound;
    7. import org.bukkit.entity.*;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.event.block.Action;
    11. import org.bukkit.event.entity.EntityDamageByEntityEvent;
    12. import org.bukkit.event.player.PlayerInteractEvent;
    13. import org.bukkit.plugin.PluginManager;
    14. import org.bukkit.plugin.java.JavaPlugin;
    15. import org.bukkit.potion.PotionEffect;
    16. import org.bukkit.potion.PotionEffectType;
    17.  
    18. /**
    19. * Created by Tyler on 1/14/14.
    20. */
    21. public class Gun1 extends JavaPlugin implements Listener {
    22.  
    23.  
    24. public static String TAG = ChatColor.GOLD + "[Gun Game] ";
    25. public static String FIRE = ChatColor.AQUA + "You Fired!";
    26.  
    27.  
    28.  
    29.  
    30.  
    31. public void onEnable() {
    32. getServer().getPluginManager().registerEvents(this, this);
    33.  
    34. }
    35.  
    36.  
    37. @EventHandler
    38. public void onPlayerInteract(PlayerInteractEvent e) {
    39. Player p = e.getPlayer();
    40. p.playSound(p.getLocation(), Sound.CLICK, 100, 20);
    41. p.sendMessage(TAG + FIRE);
    42. if (!(e.getAction() == Action.RIGHT_CLICK_AIR)) {
    43. return;
    44. }
    45. if (!(e.getItem().getType() == Material.WOOD_HOE)) {
    46. return;
    47. }
    48. Egg egg = p.launchProjectile(Egg.class);
    49. egg.setVelocity(e.getPlayer().getLocation().getDirection().normalize().multiply(2));
    50. return;
    51. }
    52.  
    53.  
    54.  
    55.  
    56.  
    57. }
    58.  
    59.  
    60.  
    61.  
    62.  
     
  2. Offline

    fireblast709

    XxZHALO13Xx just move the playSound and sendMessage below the if statements?
     
Thread Status:
Not open for further replies.

Share This Page