org.bukkit.Instrument Java Examples

The following examples show how to use org.bukkit.Instrument. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NotePlayEvent.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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;
    }

}
 
Example #2
Source File: CraftNoteBlock.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@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;
    }
}
 
Example #3
Source File: CraftNoteBlock.java    From Thermos with GNU General Public License v3.0 5 votes vote down vote up
@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;
    }
}
 
Example #4
Source File: NotePlayEvent.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public NotePlayEvent(Block block, Instrument instrument, Note note) {
    super(block);
    this.instrument = instrument;
    this.note = note;
}
 
Example #5
Source File: InstrumentUtils.java    From NoteBlockAPI with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
 * Returns the name of the org.bukkit.Instrument enum for the current server version
 * @param instrument
 * @return Instrument enum (for the current server version)
 */
public static Instrument getBukkitInstrument(byte instrument) {
	switch (instrument) {
		case 0:
			return Instrument.PIANO;
		case 1:
			return Instrument.BASS_GUITAR;
		case 2:
			return Instrument.BASS_DRUM;
		case 3:
			return Instrument.SNARE_DRUM;
		case 4:
			return Instrument.STICKS;
		default: {
			if (CompatibilityUtils.getServerVersion() >= 0.0112f) {
				switch (instrument) {
					case 5:
						return Instrument.valueOf("GUITAR");
					case 6:
						return Instrument.valueOf("FLUTE");
					case 7:
						return Instrument.valueOf("BELL");
					case 8:
						return Instrument.valueOf("CHIME");
					case 9:
						return Instrument.valueOf("XYLOPHONE");
					default: {
						if (CompatibilityUtils.getServerVersion() >= 0.0114f) {
							switch (instrument) {
								case 10:
									return Instrument.valueOf("IRON_XYLOPHONE");
								case 11:
									return Instrument.valueOf("COW_BELL");
								case 12:
									return Instrument.valueOf("DIDGERIDOO");
								case 13:
									return Instrument.valueOf("BIT");
								case 14:
									return Instrument.valueOf("BANJO");
								case 15:
									return Instrument.valueOf("PLING");
							}
						}
						return Instrument.PIANO;
					}
				}
			}
			return Instrument.PIANO;
		}
	}
}
 
Example #6
Source File: WrapperPlayServerBlockAction.java    From PacketWrapper with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
  	 * Get the instrument type.
  	 * @return Instrument type.
  	 */
  	@SuppressWarnings("deprecation")
public Instrument getInstrument() {
  		return Instrument.getByType(getByte1());
  	}
 
Example #7
Source File: WrapperPlayServerBlockAction.java    From PacketWrapper with GNU Lesser General Public License v3.0 4 votes vote down vote up
/**
  	 * Set the instrument type.
  	 * @param value - new instrument type.
  	 */
  	@SuppressWarnings("deprecation")
public void setInstrument(Instrument value) {
  		setByte1(value.getType());
  	}
 
Example #8
Source File: NoteBlock.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * 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);
 
Example #9
Source File: NotePlayEvent.java    From Kettle with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Gets the {@link Instrument} to be used.
 *
 * @return the Instrument;
 */
public Instrument getInstrument() {
    return instrument;
}