001 package org.bukkit.event.block;
002
003 import org.bukkit.Instrument;
004 import org.bukkit.Note;
005 import org.bukkit.block.Block;
006 import org.bukkit.event.Cancellable;
007 import org.bukkit.event.HandlerList;
008
009 /**
010 * Called when a note block is being played through player interaction or a
011 * redstone current.
012 */
013 public class NotePlayEvent extends BlockEvent implements Cancellable {
014
015 private static HandlerList handlers = new HandlerList();
016 private Instrument instrument;
017 private Note note;
018 private boolean cancelled = false;
019
020 public NotePlayEvent(Block block, Instrument instrument, Note note) {
021 super(block);
022 this.instrument = instrument;
023 this.note = note;
024 }
025
026 public boolean isCancelled() {
027 return cancelled;
028 }
029
030 public void setCancelled(boolean cancel) {
031 this.cancelled = cancel;
032 }
033
034 /**
035 * Gets the {@link Instrument} to be used.
036 *
037 * @return the Instrument;
038 */
039 public Instrument getInstrument() {
040 return instrument;
041 }
042
043 /**
044 * Gets the {@link Note} to be played.
045 *
046 * @return the Note.
047 */
048 public Note getNote() {
049 return note;
050 }
051
052 /**
053 * Overrides the {@link Instrument} to be used.
054 *
055 * @param instrument the Instrument. Has no effect if null.
056 */
057 public void setInstrument(Instrument instrument) {
058 if (instrument != null) {
059 this.instrument = instrument;
060 }
061
062 }
063
064 /**
065 * Overrides the {@link Note} to be played.
066 *
067 * @param note the Note. Has no effect if null.
068 */
069 public void setNote(Note note) {
070 if (note != null) {
071 this.note = note;
072 }
073 }
074
075 @Override
076 public HandlerList getHandlers() {
077 return handlers;
078 }
079
080 public static HandlerList getHandlerList() {
081 return handlers;
082 }
083 }