szumielxd

Untitled

Sep 12th, 2019
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.32 KB | None | 0 0
  1. options:
  2. patch: plugins/Skript/music
  3.  
  4.  
  5. import:
  6. org.bukkit.Bukkit
  7. java.io.File
  8. java.util.ArrayList
  9. java.util.Arrays
  10. com.xxmicloxx.NoteBlockAPI.event.SongNextEvent
  11. com.xxmicloxx.NoteBlockAPI.model.Playlist
  12. com.xxmicloxx.NoteBlockAPI.model.Song
  13. com.xxmicloxx.NoteBlockAPI.utils.NBSDecoder
  14. com.xxmicloxx.NoteBlockAPI.songplayer.RadioSongPlayer
  15.  
  16.  
  17. on load:
  18. set {_dir} to new File("{@patch}")
  19. set {_iter} to Arrays.asList({_dir}.listFiles()).iterator()
  20. while {_iter}.hasNext():
  21. set {_file} to {_iter}.next()
  22. if {_file}.exists() is true:
  23. if {_file}.isFile() is true:
  24. set {_song} to NBSDecoder.parse({_file})
  25. if {_playlist} is not set:
  26. set {_playlist} to new Playlist({_song})
  27. else:
  28. {_playlist}.add({_song})
  29. set {_pl} to new RadioSongPlayer({_playlist})
  30. {_pl}.setAutoDestroy(false)
  31. {_pl}.setPlaying(true)
  32. set {songplayer} to {_pl}
  33.  
  34. loop all players:
  35. {songplayer}.addPlayer(loop-player)
  36.  
  37.  
  38. on SongNextEvent:
  39. set {_song} to event.getSongPlayer().getSong()
  40. set {_iter} to event.getSongPlayer().getPlayerUUIDs().iterator()
  41. set {_rand} to random integer between 1 and 5
  42. set {_time} to round({_song}.getLength()/20)
  43. set {_s} to mod({_time}, 60)
  44. set {_m} to floor({_time}/60)
  45. if {_s} < 10:
  46. set {_s} to "0%{_s}%"
  47. if {_m} < 10:
  48. set {_m} to "0%{_m}%"
  49. while {_iter}.hasNext():
  50. set {_pl} to Bukkit.getPlayer({_iter}.next())
  51. if {_pl} is set:
  52. if {_rand} is 1:
  53. send {_pl} title "&2&l%{_song}.getTitle()%" with subtitle "&7Autor: &a%{_song}.getAuthor()% &7Czas: &a%{_m}%:%{_s}%"
  54. else if {_rand} is 2:
  55. send {_pl} title "&d&l%{_song}.getTitle()%" with subtitle "&7Autor: &3%{_song}.getAuthor()% &7Czas: &3%{_m}%:%{_s}%"
  56. else if {_rand} is 3:
  57. send {_pl} title "&3&l%{_song}.getTitle()%" with subtitle "&7Autor: &b%{_song}.getAuthor()% &7Czas: &b%{_m}%:%{_s}%"
  58. else if {_rand} is 4:
  59. send {_pl} title "&5&l%{_song}.getTitle()%" with subtitle "&7Autor: &b%{_song}.getAuthor()% &7Czas: &b%{_m}%:%{_s}%"
  60. else:
  61. send {_pl} title "&6&l%{_song}.getTitle()%" with subtitle "&2Autor: &e%{_song}.getAuthor()% &7Czas: &e%{_m}%:%{_s}%"
  62.  
  63.  
  64. on script unload:
  65. {songplayer}.destroy()
  66. delete {songplayer}
  67.  
  68. on join:
  69. if {songplayer} is set:
  70. {songplayer}.addPlayer(player)
  71.  
  72. on disconnect:
  73. if {songplayer} is set:
  74. {songplayer}.removePlayer(player)
Advertisement
Add Comment
Please, Sign In to add comment