Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
NotePlayEvent.java
1 package org.bukkit.event.block;
2 
3 import org.bukkit.Instrument;
4 import org.bukkit.Note;
5 import org.bukkit.block.Block;
8 
9 /**
10  * Called when a note block is being played through player interaction or a
11  * redstone current.
12  */
13 public class NotePlayEvent extends BlockEvent implements Cancellable {
14 
15  private static HandlerList handlers = new HandlerList();
16  private Instrument instrument;
17  private Note note;
18  private boolean cancelled = false;
19 
20  public NotePlayEvent(Block block, Instrument instrument, Note note) {
21  super(block);
22  this.instrument = instrument;
23  this.note = note;
24  }
25 
26  public boolean isCancelled() {
27  return cancelled;
28  }
29 
30  public void setCancelled(boolean cancel) {
31  this.cancelled = cancel;
32  }
33 
34  /**
35  * Gets the {@link Instrument} to be used.
36  *
37  * @return the Instrument;
38  */
40  return instrument;
41  }
42 
43  /**
44  * Gets the {@link Note} to be played.
45  *
46  * @return the Note.
47  */
48  public Note getNote() {
49  return note;
50  }
51 
52  /**
53  * Overrides the {@link Instrument} to be used.
54  *
55  * @param instrument the Instrument. Has no effect if null.
56  */
57  public void setInstrument(Instrument instrument) {
58  if (instrument != null) {
59  this.instrument = instrument;
60  }
61 
62  }
63 
64  /**
65  * Overrides the {@link Note} to be played.
66  *
67  * @param note the Note. Has no effect if null.
68  */
69  public void setNote(Note note) {
70  if (note != null) {
71  this.note = note;
72  }
73  }
74 
75  @Override
76  public HandlerList getHandlers() {
77  return handlers;
78  }
79 
80  public static HandlerList getHandlerList() {
81  return handlers;
82  }
83 }
void setInstrument(Instrument instrument)