summaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java b/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java
new file mode 100644
index 00000000..9da222c7
--- /dev/null
+++ b/src/main/java/org/bukkit/event/entity/BatToggleSleepEvent.java
@@ -0,0 +1,52 @@
+package org.bukkit.event.entity;
+
+import org.bukkit.entity.Bat;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Called when a bat attempts to sleep or wake up from its slumber.
+ * <p>
+ * If a Bat Toggle Sleep event is cancelled, the Bat will not toggle its sleep
+ * state.
+ */
+public class BatToggleSleepEvent extends EntityEvent implements Cancellable {
+
+ private static final HandlerList handlers = new HandlerList();
+
+ private boolean cancel = false;
+ private final boolean awake;
+
+ public BatToggleSleepEvent(Bat what, boolean awake) {
+ super(what);
+ this.awake = awake;
+ }
+
+ /**
+ * Get whether or not the bat is attempting to awaken.
+ *
+ * @return true if trying to awaken, false otherwise
+ */
+ public boolean isAwake() {
+ return awake;
+ }
+
+ @Override
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
+
+ @Override
+ public boolean isCancelled() {
+ return cancel;
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}