use of org.bukkit.event.block.NotePlayEvent in project Glowstone by GlowstoneMC.
the class GlowNoteBlock method play.
////////////////////////////////////////////////////////////////////////////
// Internals
@Override
public boolean play(Instrument instrument, Note note) {
if (getBlock().getType() != Material.NOTE_BLOCK) {
return false;
}
NotePlayEvent event = EventFactory.callEvent(new NotePlayEvent(getBlock(), instrument, note));
if (event.isCancelled()) {
return false;
}
Location location = getBlock().getLocation();
Key key = new Key(getX() >> 4, getZ() >> 4);
getWorld().getRawPlayers().stream().filter(player -> player.canSeeChunk(key)).forEach(player -> player.playNote(location, instrument, note));
return true;
}
Aggregations