Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import:
- java.io.BufferedWriter
- java.io.File
- java.io.FileOutputStream
- java.io.OutputStreamWriter
- java.io.PrintWriter
- org.bukkit.Bukkit
- org.bukkit.Sound
- com.comphenix.protocol.wrappers.EnumWrappers$SoundCategory
- on load:
- if file "plugins/BetterNoteBlocks/config.yml" does not exist:
- create file "plugins/BetterNoteBlocks/config.yml"
- set {_serverpath} to Bukkit.getServer().getWorldContainer().getAbsolutePath()
- replace "\" in {_serverpath} with "/"
- set {_configpath} to "%first length of {_serverpath}-1 characters of {_serverpath}%plugins/BetterNoteBlocks/config.yml"
- set {_config} to new File({_configpath})
- wait 1 tick
- set {_writer} to new PrintWriter(new BufferedWriter(new OutputStreamWriter(new FileOutputStream({_config}),"UTF-8")))
- {_writer}.println("##追加したい音の設定をします")
- {_writer}.println("##記述法: - ブロックID 音の名前")
- {_writer}.println("Notes:")
- {_writer}.println("- 89 BLOCK_NOTE_PLING")
- {_writer}.close()
- clear {note.blockids::*}
- clear {note.sounds::*}
- set {_noteconfig::*} to yaml list "Notes" from file "plugins/BetterNoteBlocks/config.yml"
- loop {_noteconfig::*}:
- set {_values::*} to split loop-value by " "
- size of {_values::*} is 2
- set {note.blockids::%loop-index%} to {_values::1} parsed as integer
- {note.blockids::%loop-index%} is set
- set {note.sounds::%loop-index%} to Sound.valueOf({_values::2} in upper case)
- {note.sounds::%loop-index%} is not set
- delete {note.blockids::%loop-index%}
- on packet event play_server_named_sound_effect:
- event-packet.getSoundCategories().read(0) is SoundCategory.RECORDS!
- first 11 characters of "%event-packet.getSoundEffects().read(0)%" is "BLOCK_NOTE_"
- set {_loc} to location at int pnum 0 of event-packet/8, int pnum 1 of event-packet/8, int pnum 2 of event-packet/8 in world "%player's world%"
- block at {_loc} is note block
- loop {note.blockids::*}:
- id of block at location 1 meter below {_loc} is loop-value
- event-packet.getSoundEffects().write(0, {note.sounds::%loop-index%})
- stop loop
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement