11package com .xxmicloxx .NoteBlockAPI ;
22
3- import org .bukkit .Sound ;
4-
53import com .xxmicloxx .NoteBlockAPI .CompatibilityUtils .NoteBlockCompatibility ;
64
75public class Instrument {
86
9- public static Sound getInstrument (byte instrument ) {
10- if (CompatibilityUtils .getCompatibility () == NoteBlockCompatibility .pre1_9 ){
11- switch (instrument ) {
12- case 0 :
13- return Sound .valueOf ("NOTE_PIANO" );
14- case 1 :
15- return Sound .valueOf ("NOTE_BASS_GUITAR" );
16- case 2 :
17- return Sound .valueOf ("NOTE_BASS_DRUM" );
18- case 3 :
19- return Sound .valueOf ("NOTE_SNARE_DRUM" );
20- case 4 :
21- return Sound .valueOf ("NOTE_STICKS" );
22- default :
23- return Sound .valueOf ("NOTE_PIANO" );
24- }
25-
26- } else if (CompatibilityUtils .getCompatibility () == NoteBlockCompatibility .pre1_12 ||
27- CompatibilityUtils .getCompatibility () == NoteBlockCompatibility .v1_12 ){
28- switch (instrument ) {
29- case 0 :
30- return Sound .valueOf ("BLOCK_NOTE_HARP" );
31- case 1 :
32- return Sound .valueOf ("BLOCK_NOTE_BASS" );
33- case 2 :
34- return Sound .valueOf ("BLOCK_NOTE_BASEDRUM" );
35- case 3 :
36- return Sound .valueOf ("BLOCK_NOTE_SNARE" );
37- case 4 :
38- return Sound .valueOf ("BLOCK_NOTE_HAT" );
39- }
40- if (CompatibilityUtils .getCompatibility () == NoteBlockCompatibility .v1_12 ){
41- switch (instrument ) {
42- case 5 :
43- return Sound .valueOf ("BLOCK_NOTE_GUITAR" );
44- case 6 :
45- return Sound .valueOf ("BLOCK_NOTE_FLUTE" );
46- case 7 :
47- return Sound .valueOf ("BLOCK_NOTE_BELL" );
48- case 8 :
49- return Sound .valueOf ("BLOCK_NOTE_CHIME" );
50- case 9 :
51- return Sound .valueOf ("BLOCK_NOTE_XYLOPHONE" );
52- }
53- }
54-
55- } else if (CompatibilityUtils .getCompatibility () == NoteBlockCompatibility .post1_13 ) {
56- switch (instrument ) {
57- case 0 :
58- return Sound .valueOf ("BLOCK_NOTE_BLOCK_HARP" );
59- case 1 :
60- return Sound .valueOf ("BLOCK_NOTE_BLOCK_BASS" );
61- case 2 :
62- return Sound .valueOf ("BLOCK_NOTE_BLOCK_BASEDRUM" );
63- case 3 :
64- return Sound .valueOf ("BLOCK_NOTE_BLOCK_SNARE" );
65- case 4 :
66- return Sound .valueOf ("BLOCK_NOTE_BLOCK_HAT" );
67- case 5 :
68- return Sound .valueOf ("BLOCK_NOTE_BLOCK_GUITAR" );
69- case 6 :
70- return Sound .valueOf ("BLOCK_NOTE_BLOCK_FLUTE" );
71- case 7 :
72- return Sound .valueOf ("BLOCK_NOTE_BLOCK_BELL" );
73- case 8 :
74- return Sound .valueOf ("BLOCK_NOTE_BLOCK_CHIME" );
75- case 9 :
76- return Sound .valueOf ("BLOCK_NOTE_BLOCK_XYLOPHONE" );
77- }
78- }
7+ public static org .bukkit .Sound getInstrument (byte instrument ) {
8+ return org .bukkit .Sound .valueOf (getInstrumentName (instrument ));
9+ }
7910
80- return Sound .valueOf ("BLOCK_NOTE_BLOCK_HARP" );
11+ public static String getInstrumentName (byte instrument ) {
12+ switch (instrument ) {
13+ case 0 :
14+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_HARP" ).name ();
15+ case 1 :
16+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_BASS" ).name ();
17+ case 2 :
18+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_BASEDRUM" ).name ();
19+ case 3 :
20+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_SNARE" ).name ();
21+ case 4 :
22+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_HAT" ).name ();
23+ case 5 :
24+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_GUITAR" ).name ();
25+ case 6 :
26+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_FLUTE" ).name ();
27+ case 7 :
28+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_BELL" ).name ();
29+ case 8 :
30+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_CHIME" ).name ();
31+ case 9 :
32+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_XYLOPHONE" ).name ();
33+ default :
34+ return Sound .getFromBukkitName ("BLOCK_NOTE_BLOCK_HARP" ).name ();
35+ }
8136 }
8237
8338 public static org .bukkit .Instrument getBukkitInstrument (byte instrument ) {
@@ -92,6 +47,16 @@ public static org.bukkit.Instrument getBukkitInstrument(byte instrument) {
9247 return org .bukkit .Instrument .SNARE_DRUM ;
9348 case 4 :
9449 return org .bukkit .Instrument .STICKS ;
50+ case 5 :
51+ return org .bukkit .Instrument .GUITAR ;
52+ case 6 :
53+ return org .bukkit .Instrument .FLUTE ;
54+ case 7 :
55+ return org .bukkit .Instrument .BELL ;
56+ case 8 :
57+ return org .bukkit .Instrument .CHIME ;
58+ case 9 :
59+ return org .bukkit .Instrument .XYLOPHONE ;
9560 default :
9661 return org .bukkit .Instrument .PIANO ;
9762 }
0 commit comments