下面列出了怎么用org.bukkit.Note的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public boolean play(Instrument instrument, Note note) {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
CraftWorld world = (CraftWorld) this.getWorld();
world.getHandle().addBlockEvent(new BlockPos(getX(), getY(), getZ()), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
return true;
} else {
return false;
}
}
@Override
public boolean play(Instrument instrument, Note note) {
Block block = getBlock();
if (block.getType() == Material.NOTE_BLOCK) {
world.getHandle().addBlockEvent(getX(), getY(), getZ(), CraftMagicNumbers.getBlock(block), instrument.getType(), note.getId());
return true;
} else {
return false;
}
}
public NotePlayEvent(Block block, Instrument instrument, Note note) {
super(block);
this.instrument = instrument;
this.note = note;
}
/**
* 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 Note getNote() {
return new Note(this.getSnapshot().note);
}
@Override
public void setNote(Note note) {
this.getSnapshot().note = note.getId();
}
public Note getNote() {
return new Note(note.note);
}
public void setNote(Note n) {
note.note = n.getId();
}
/**
* Gets the note.
*
* @return The note.
*/
public Note getNote();
/**
* Set the note.
*
* @param note The note.
*/
public void setNote(Note note);
/**
* Plays an arbitrary note with an arbitrary instrument at the block.
* <p>
* If the block represented by this block state is no longer a note block,
* this will return false.
*
* @param instrument The instrument
* @param note The note
* @return true if successful, otherwise false
* @throws IllegalStateException if this block state is not placed
* @see Instrument Note
*/
public boolean play(Instrument instrument, Note note);
/**
* Gets the {@link Note} to be played.
*
* @return the Note.
*/
public Note getNote() {
return note;
}