summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorobnoxint <mail@obnoxint.net>2012-06-10 17:37:24 +0200
committerTravis Watkins <amaranth@ubuntu.com>2012-06-14 20:58:19 -0500
commitd7ff46b10c2be998645b4937094359b8d7c928d4 (patch)
tree6f326b8cb5346fce51113da6d744bd585d8a6c25
parent8c689135063b7cda25b06de8c780f5e812754ee2 (diff)
downloadbukkit-d7ff46b10c2be998645b4937094359b8d7c928d4.tar
bukkit-d7ff46b10c2be998645b4937094359b8d7c928d4.tar.gz
bukkit-d7ff46b10c2be998645b4937094359b8d7c928d4.tar.lz
bukkit-d7ff46b10c2be998645b4937094359b8d7c928d4.tar.xz
bukkit-d7ff46b10c2be998645b4937094359b8d7c928d4.zip
Add NotePlayEvent. Fixes BUKKIT-1779
-rw-r--r--src/main/java/org/bukkit/event/block/NotePlayEvent.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/event/block/NotePlayEvent.java b/src/main/java/org/bukkit/event/block/NotePlayEvent.java
new file mode 100644
index 00000000..4a9778be
--- /dev/null
+++ b/src/main/java/org/bukkit/event/block/NotePlayEvent.java
@@ -0,0 +1,82 @@
+package org.bukkit.event.block;
+
+import org.bukkit.Instrument;
+import org.bukkit.Note;
+import org.bukkit.block.Block;
+import org.bukkit.event.Cancellable;
+import org.bukkit.event.HandlerList;
+
+/**
+ * Called when a note block is being played through player interaction or a redstone current.
+ */
+public class NotePlayEvent extends BlockEvent implements Cancellable {
+
+ private static HandlerList handlers = new HandlerList();
+ private Instrument instrument;
+ private Note note;
+ private boolean cancelled = false;
+
+ public NotePlayEvent(Block block, Instrument instrument, Note note) {
+ super(block);
+ this.instrument = instrument;
+ this.note = note;
+ }
+
+ public boolean isCancelled() {
+ return cancelled;
+ }
+
+ public void setCancelled(boolean cancel) {
+ this.cancelled = cancel;
+ }
+
+ /**
+ * Gets the {@link Instrument} to be used.
+ *
+ * @return the Instrument;
+ */
+ public Instrument getInstrument() {
+ return instrument;
+ }
+
+ /**
+ * Gets the {@link Note} to be played.
+ *
+ * @return the Note.
+ */
+ public Note getNote() {
+ return note;
+ }
+
+ /**
+ * Overrides the {@link Instrument} to be used.
+ *
+ * @param instrument the Instrument. Has no effect if null.
+ */
+ public void setInstrument(Instrument instrument) {
+ if (instrument != null) {
+ this.instrument = instrument;
+ }
+
+ }
+
+ /**
+ * Overrides the {@link Note} to be played.
+ *
+ * @param note the Note. Has no effect if null.
+ */
+ public void setNote(Note note) {
+ if (note != null) {
+ this.note = note;
+ }
+ }
+
+ @Override
+ public HandlerList getHandlers() {
+ return handlers;
+ }
+
+ public static HandlerList getHandlerList() {
+ return handlers;
+ }
+}