Calling custom events

Discussion in 'Plugin Development' started by 1SmallVille1, May 21, 2013.

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

    1SmallVille1

    Hey so before you link me to the wiki about custom events, I've already poured over that for the last week. I don't know if bukkit changed their ways or what but I do what it says exactly and I can't get my event to call. This is what I have:

    Code:Java
    1. public class PlayerMiningEvent extends Event {
    2.  
    3. private static final long serialVersionUID = 1L;
    4.  
    5. public Boolean cancelled;
    6.  
    7. private Location loc;
    8.  
    9. private Player player;
    10.  
    11. private static final HandlerList handlers = new HandlerList();
    12.  
    13. public PlayerMiningEvent(Player p, Location l) {
    14.  
    15. super(p, 1, l);
    16.  
    17. this.loc = l;
    18. this.player = p;
    19.  
    20. }
    21.  
    22. public Player getPlayer() {
    23.  
    24. return this.player;
    25.  
    26. }
    27.  
    28. public Location getLocation() {
    29.  
    30. return this.loc;
    31.  
    32. }
    33.  
    34. public HandlerList getHandlers() {
    35.  
    36. return handlers;
    37.  
    38. }
    39.  
    40. public static HandlerList getHandlerList() {
    41.  
    42. return handlers;
    43.  
    44. }
    45.  
    46. }


    and then when I call it:
    Code:Java
    1. public class CustomEventListener implements Listener {
    2.  
    3. @EventHandler
    4. public void onBlockBreak(BlockBreakEvent evt) {
    5.  
    6. if (evt.getBlock().getType() == Material.STONE
    7. || evt.getBlock().getType() == Material.DIRT
    8. || evt.getBlock().getType() == Material.OBSIDIAN
    9. || evt.getBlock().getType() == Material.COAL_ORE
    10. || evt.getBlock().getType() == Material.IRON_ORE
    11. || evt.getBlock().getType() == Material.DIAMOND_ORE
    12. || evt.getBlock().getType() == Material.REDSTONE_ORE
    13. || evt.getBlock().getType() == Material.GOLD_ORE) {
    14.  
    15. Player player = evt.getPlayer();
    16.  
    17. Location loc = player.getLocation();
    18.  
    19. PlayerMiningEvent event = new PlayerMiningEvent(player, loc);
    20.  
    21. Bukkit.getServer().getPluginManager().callEvent(event);
    22.  
    23. }
    24.  
    25. }
    26.  
    27. }


    so I get an error when I say .callEvent(event), it says that event needs to be an instance of Event
     
  2. Offline

    russjr08

    Are you perhaps importing the incorrect 'Event' class?
     
Thread Status:
Not open for further replies.

Share This Page