类org.bukkit.Instrument源码实例Demo

下面列出了怎么用org.bukkit.Instrument的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Kettle   文件: NotePlayEvent.java
/**
 * 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;
    }

}
 
源代码2 项目: Kettle   文件: CraftNoteBlock.java
@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;
    }
}
 
源代码3 项目: Thermos   文件: CraftNoteBlock.java
@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;
    }
}
 
源代码4 项目: Kettle   文件: NotePlayEvent.java
public NotePlayEvent(Block block, Instrument instrument, Note note) {
    super(block);
    this.instrument = instrument;
    this.note = note;
}
 
源代码5 项目: NoteBlockAPI   文件: InstrumentUtils.java
/**
 * 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;
		}
	}
}
 
/**
  	 * Get the instrument type.
  	 * @return Instrument type.
  	 */
  	@SuppressWarnings("deprecation")
public Instrument getInstrument() {
  		return Instrument.getByType(getByte1());
  	}
 
/**
  	 * Set the instrument type.
  	 * @param value - new instrument type.
  	 */
  	@SuppressWarnings("deprecation")
public void setInstrument(Instrument value) {
  		setByte1(value.getType());
  	}
 
源代码8 项目: Kettle   文件: NoteBlock.java
/**
 * 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);
 
源代码9 项目: Kettle   文件: NotePlayEvent.java
/**
 * Gets the {@link Instrument} to be used.
 *
 * @return the Instrument;
 */
public Instrument getInstrument() {
    return instrument;
}
 
 类所在包
 类方法
 同包方法