Event Handlers?

Discussion in 'Plugin Development' started by TheDiamond06, Dec 15, 2014.

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

    TheDiamond06

    Event Handlers are not working for me, I checked everything and compared it with other plugins but none of all my EventHandlers are working.
    Here is my code.

    @EventHandler
    public void ballFiring(PlayerInteractEvent e){
    Player p = e.getPlayer();
    if (!(e.getAction() == Action.RIGHT_CLICK_AIR)) return;
    if (!(e.getItem().getType() == Material.WHEAT)) return;
    if(!p.hasPermission("example.example")) return;
    Fireball s = e.getPlayer().launchProjectile(Fireball.class);
    p.sendMessage(ChatColor.GREEN + "BURRP");
    p.sendMessage(ChatColor.DARK_GREEN + "You smoke weed for an hour....");
    p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 30, 4));
    p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 0));
    p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 5, 0));
    }
    @EventHandler
    public void onPlayerJoin(PlayerJoinEvent e)
    {
    Player player = e.getPlayer();
    player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
    player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5, 2));
    player.sendMessage(ChatColor.GOLD + "---------------------------------------------");
    player.sendMessage(ChatColor.GOLD + " ");
    player.sendMessage(ChatColor.AQUA + "Welcome Back to LightningMcHD!");
    player.sendMessage(ChatColor.AQUA + "Running LightningCustom Version 1.0 by " + ChatColor.RED + " TheDiamond06");
    player.sendMessage(ChatColor.AQUA + "Enjoy your Stay at LightningMcHd " + ChatColor.RED + " " + player.getName());
    player.sendMessage(ChatColor.AQUA + " ");
    player.sendMessage(ChatColor.GOLD + "---------------------------------------------");
    player.sendMessage(ChatColor.RED + "[PvP] Given Speed to get away from your attacker. Make sure you don't PvP Log for this!");
    }
    @EventHandler
    public void onBlockBreak(BlockBreakEvent e)
    {
    Player p = e.getPlayer();
    p.playSound(p.getLocation(), Sound.CHICKEN_EGG_POP, 1, 1);
    }
     
  2. Offline

    teej107

    Use the code tag or people will be less likely to want to read your code, like me for example. So I am going to go for a common question. Did you register your events?
     
  3. Offline

    FlipSide_Mike

    Did you register the events?
     
  4. Offline

    ChipDev

    For those who must:
    Code:
    @EventHandler
        public void ballFiring(PlayerInteractEvent e) {
            Player p = e.getPlayer();
            if (!(e.getAction() == Action.RIGHT_CLICK_AIR))
                return;
            if (!(e.getItem().getType() == Material.WHEAT))
                return;
            if (!p.hasPermission("example.example"))
                return;
            Fireball s = e.getPlayer().launchProjectile(Fireball.class);
            p.sendMessage(ChatColor.GREEN + "BURRP");
            p.sendMessage(ChatColor.DARK_GREEN + "You smoke weed for an hour....");
            p.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 30, 4));
            p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 10, 0));
            p.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 5,
                    0));
        }
    
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent e) {
            Player player = e.getPlayer();
            player.playSound(player.getLocation(), Sound.LEVEL_UP, 1, 1);
            player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5, 2));
            player.sendMessage(ChatColor.GOLD
                    + "---------------------------------------------");
            player.sendMessage(ChatColor.GOLD + " ");
            player.sendMessage(ChatColor.AQUA + "Welcome Back to LightningMcHD!");
            player.sendMessage(ChatColor.AQUA
                    + "Running LightningCustom Version 1.0 by " + ChatColor.RED
                    + " TheDiamond06");
            player.sendMessage(ChatColor.AQUA + "Enjoy your Stay at LightningMcHd "
                    + ChatColor.RED + " " + player.getName());
            player.sendMessage(ChatColor.AQUA + " ");
            player.sendMessage(ChatColor.GOLD
                    + "---------------------------------------------");
            player.sendMessage(ChatColor.RED
                    + "[PvP] Given Speed to get away from your attacker. Make sure you don't PvP Log for this!");
        }
    
        @EventHandler
        public void onBlockBreak(BlockBreakEvent e) {
            Player p = e.getPlayer();
            p.playSound(p.getLocation(), Sound.CHICKEN_EGG_POP, 1, 1);
        }
     
Thread Status:
Not open for further replies.

Share This Page