Skip to content

Commit 454ac92

Browse files
committed
implement easier to manage versioning
1 parent c5e7395 commit 454ac92

File tree

3 files changed

+41
-95
lines changed

3 files changed

+41
-95
lines changed

src/main/java/com/xxmicloxx/NoteBlockAPI/CompatibilityUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,12 @@ protected static void playSound(Player p, Location location, String sound, Sound
7676
} catch (SecurityException e) {
7777
e.printStackTrace();
7878
} catch (IllegalAccessException e) {
79-
// TODO Auto-generated catch block
8079
e.printStackTrace();
8180
} catch (IllegalArgumentException e) {
82-
// TODO Auto-generated catch block
8381
e.printStackTrace();
8482
} catch (InvocationTargetException e) {
85-
// TODO Auto-generated catch block
8683
e.printStackTrace();
8784
} catch (ClassNotFoundException e) {
88-
// TODO Auto-generated catch block
8985
e.printStackTrace();
9086
}
9187
}
Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,20 @@
11
package com.xxmicloxx.NoteBlockAPI;
22

3-
import org.bukkit.Sound;
4-
5-
import com.xxmicloxx.NoteBlockAPI.CompatibilityUtils.NoteBlockCompatibility;
6-
73
public class CustomInstrument {
84

95
private byte index;
106
private String name;
117
private String soundfile;
128
private byte pitch;
139
private byte press;
14-
private Sound sound;
10+
private org.bukkit.Sound sound;
1511

1612
public CustomInstrument(byte index, String name, String soundfile, byte pitch, byte press){
1713
this.index = index;
1814
this.name = name;
1915
this.soundfile = soundfile.replaceAll(".ogg", "");
2016
if (this.soundfile.equalsIgnoreCase("pling")){
21-
switch (CompatibilityUtils.getCompatibility()){
22-
case NoteBlockCompatibility.pre1_9:
23-
this.sound = Sound.valueOf("NOTE_PLING");
24-
break;
25-
case CompatibilityUtils.NoteBlockCompatibility.pre1_12:
26-
case NoteBlockCompatibility.v1_12:
27-
this.sound = Sound.valueOf("BLOCK_NOTE_PLING");
28-
break;
29-
case NoteBlockCompatibility.post1_13:
30-
this.sound = Sound.valueOf("BLOCK_NOTE_BLOCK_PLING");
31-
break;
32-
}
17+
this.sound = Sound.getFromBukkitName("BLOCK_NOTE_PLING");
3318
}
3419
this.pitch = pitch;
3520
this.press = press;
@@ -47,7 +32,7 @@ public String getSoundfile() {
4732
return soundfile;
4833
}
4934

50-
public Sound getSound(){
35+
public org.bukkit.Sound getSound() {
5136
return sound;
5237
}
5338
}

src/main/java/com/xxmicloxx/NoteBlockAPI/Instrument.java

Lines changed: 38 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,38 @@
11
package com.xxmicloxx.NoteBlockAPI;
22

3-
import org.bukkit.Sound;
4-
53
import com.xxmicloxx.NoteBlockAPI.CompatibilityUtils.NoteBlockCompatibility;
64

75
public 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

Comments
 (0)