Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
RegisteredListener.java
1 package org.bukkit.plugin;
2 
3 import org.bukkit.event.*;
4 
5 /**
6  * Stores relevant information for plugin listeners
7  */
8 public class RegisteredListener {
9  private final Listener listener;
10  private final EventPriority priority;
11  private final Plugin plugin;
12  private final EventExecutor executor;
13  private final boolean ignoreCancelled;
14 
15  public RegisteredListener(final Listener listener, final EventExecutor executor, final EventPriority priority, final Plugin plugin, final boolean ignoreCancelled) {
16  this.listener = listener;
17  this.priority = priority;
18  this.plugin = plugin;
19  this.executor = executor;
20  this.ignoreCancelled = ignoreCancelled;
21  }
22 
23  /**
24  * Gets the listener for this registration
25  *
26  * @return Registered Listener
27  */
28  public Listener getListener() {
29  return listener;
30  }
31 
32  /**
33  * Gets the plugin for this registration
34  *
35  * @return Registered Plugin
36  */
37  public Plugin getPlugin() {
38  return plugin;
39  }
40 
41  /**
42  * Gets the priority for this registration
43  *
44  * @return Registered Priority
45  */
47  return priority;
48  }
49 
50  /**
51  * Calls the event executor
52  *
53  * @param event The event
54  * @throws EventException If an event handler throws an exception.
55  */
56  public void callEvent(final Event event) throws EventException {
57  if (event instanceof Cancellable){
58  if (((Cancellable) event).isCancelled() && isIgnoringCancelled()){
59  return;
60  }
61  }
62  executor.execute(listener, event);
63  }
64 
65  /**
66  * Whether this listener accepts cancelled events
67  *
68  * @return True when ignoring cancelled events
69  */
70  public boolean isIgnoringCancelled() {
71  return ignoreCancelled;
72  }
73 }