• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java NotePlayEvent类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中org.bukkit.event.block.NotePlayEvent的典型用法代码示例。如果您正苦于以下问题:Java NotePlayEvent类的具体用法?Java NotePlayEvent怎么用?Java NotePlayEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

NotePlayEvent类属于org.bukkit.event.block包,在下文中一共展示了NotePlayEvent类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: loadNoteBlock

点赞 2

import org.bukkit.event.block.NotePlayEvent; //导入依赖的package包/类
private static void loadNoteBlock() {
    Map<String, Note> noteMap = new HashMap<>();
    for (int octave : new int[]{0, 1})
        for (Note.Tone tone : Note.Tone.values())
            for (int deviation : new int[]{-1, 0, 1}) {
                if (deviation == 1 && (tone == Note.Tone.B || tone == Note.Tone.E)) {
                    continue;
                }
                if (deviation == -1 && (tone == Note.Tone.C || tone == Note.Tone.F)) {
                    continue;
                }
                Note note = Note.natural(octave, tone);
                if (deviation == 1) {
                    note = note.sharped();
                } else if (deviation == -1) {
                    note = note.flattened();
                }
                String noteName = tone.name() + (deviation == 1 ? "+" : deviation == -1 ? "-" : "") + octave;
                noteMap.put("N" + noteName, note);
                if (octave == 0) {
                    noteMap.put("N" + noteName.substring(0, noteName.length() - 1), note);
                }
            }
    Note fSharp2 = Note.sharp(2, Note.Tone.F);
    noteMap.put("NF+2", fSharp2);
    noteMap.put("NG-2", fSharp2);
    EnumClassInfo<Note> noteEnumClassInfo = Registration.registerEnum(Note.class, "note", noteMap);
    if (!MundoUtil.serverHasPlugin("RandomSK")) {
        noteMap.forEach((noteName, note) -> noteEnumClassInfo.pair(noteName.substring(1), note));
    }
    Registration.registerEnum(Instrument.class, "instrument", Instrument.values())
            .document("Instrument", "1.6", "An instrument to which a note can be played using a noteblock.");
    Registration.registerEffect(EffPlayNoteBlock.class, "play [[%-note% with] %-instrument% on] noteblock %block%")
            .document("Play Note on Noteblock", "1.6", "Plays the specified noteblock, optionally with a specified instrument and a specified note.");
    Registration.registerEvent("Note Play", SimpleEvent.class, NotePlayEvent.class, "note play")
            .document("Note Play", "1.6", "Called when a noteblock is played.")
            .eventValue(Note.class, "1.6", "The note that was played.")
            .eventValue(Instrument.class, "1.6", "The instrument using which the note was played.")
            .eventValue(Block.class, "1.6", "The noteblock that was played.");
    Registration.registerEventValue(NotePlayEvent.class, Note.class, NotePlayEvent::getNote);
    Registration.registerEventValue(NotePlayEvent.class, Instrument.class, NotePlayEvent::getInstrument);
    Registration.registerEventValue(NotePlayEvent.class, Block.class, NotePlayEvent::getBlock);
    Registration.registerPropertyExpression(ExprNoteOfBlock.class, Note.class, "block", "note")
            .document("Note of Noteblock", "1.6", "The current note of the specified noteblock.");
}
 

开发者ID:MundoSK,
项目名称:MundoSK,
代码行数:46,
代码来源:MiscMundo.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)