Skip to content

Commit f896d79

Browse files
committed
Added new 1.12 sounds (v1.1.6)
1 parent c5fa50c commit f896d79

File tree

4 files changed

+56
-25
lines changed

4 files changed

+56
-25
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<dependency>
1818
<groupId>org.bukkit</groupId>
1919
<artifactId>bukkit</artifactId>
20-
<version>1.11-R0.1-SNAPSHOT</version>
20+
<version>1.12-pre2-SNAPSHOT</version>
2121
<scope>provided</scope>
2222
</dependency>
2323
</dependencies>

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

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,28 @@
22

33
import org.bukkit.Sound;
44

5+
import com.xxmicloxx.NoteBlockAPI.NoteBlockPlayerMain.NoteBlockCompatibility;
6+
57
public class Instrument {
68

79
public static Sound getInstrument(byte instrument) {
8-
if (!NoteBlockPlayerMain.isPre1_9()){
9-
switch (instrument) {
10+
if (NoteBlockPlayerMain.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+
} else {
26+
switch (instrument) {
1027
case 0:
1128
return Sound.valueOf("BLOCK_NOTE_HARP");
1229
case 1:
@@ -17,25 +34,25 @@ public static Sound getInstrument(byte instrument) {
1734
return Sound.valueOf("BLOCK_NOTE_SNARE");
1835
case 4:
1936
return Sound.valueOf("BLOCK_NOTE_HAT");
20-
default:
21-
return Sound.valueOf("BLOCK_NOTE_HARP");
22-
23-
}
24-
} else {
25-
switch (instrument) {
26-
case 0:
27-
return Sound.valueOf("NOTE_PIANO");
28-
case 1:
29-
return Sound.valueOf("NOTE_BASS_GUITAR");
30-
case 2:
31-
return Sound.valueOf("NOTE_BASS_DRUM");
32-
case 3:
33-
return Sound.valueOf("NOTE_SNARE_DRUM");
34-
case 4:
35-
return Sound.valueOf("NOTE_STICKS");
36-
default:
37-
return Sound.valueOf("NOTE_PIANO");
38-
}
37+
}
38+
39+
if (NoteBlockPlayerMain.getCompatibility() == NoteBlockCompatibility.post1_12){
40+
switch (instrument) {
41+
case 5:
42+
return Sound.valueOf("BLOCK_NOTE_FLUTE");
43+
case 6:
44+
return Sound.valueOf("BLOCK_NOTE_BELL");
45+
case 7:
46+
return Sound.valueOf("BLOCK_NOTE_GUITAR");
47+
case 8:
48+
return Sound.valueOf("BLOCK_NOTE_CHIME");
49+
case 9:
50+
return Sound.valueOf("BLOCK_NOTE_XYLOPHONE");
51+
}
52+
}
53+
54+
return Sound.valueOf("BLOCK_NOTE_HARP");
55+
3956
}
4057
}
4158

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

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,14 @@ public void onDisable() {
5555
Bukkit.getScheduler().cancelTasks(this);
5656
}
5757

58-
public static boolean isPre1_9(){
59-
return Bukkit.getVersion().contains("1.8") || Bukkit.getVersion().contains("1.7");
58+
protected static int getCompatibility(){
59+
if (Bukkit.getVersion().contains("1.8") || Bukkit.getVersion().contains("1.7")){
60+
return NoteBlockCompatibility.pre1_9;
61+
} else if (Bukkit.getVersion().contains("1.9") || Bukkit.getVersion().contains("1.10") || Bukkit.getVersion().contains("1.11")){
62+
return NoteBlockCompatibility.pre1_12;
63+
} else {
64+
return NoteBlockCompatibility.post1_12;
65+
}
6066
}
6167

6268
public void doSync(Runnable r) {
@@ -70,4 +76,10 @@ public void doAsync(Runnable r) {
7076
protected boolean isDisabling(){
7177
return disabling;
7278
}
79+
80+
public class NoteBlockCompatibility{
81+
public static final int pre1_9 = 0;
82+
public static final int pre1_12 = 1;
83+
public static final int post1_12 = 2;
84+
}
7385
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.xxmicloxx.NoteBlockAPI;
22

3+
import com.xxmicloxx.NoteBlockAPI.NoteBlockPlayerMain.NoteBlockCompatibility;
4+
35
public enum NotePitch {
46

57
NOTE_0(0, 0.5F, 0.50000F),
@@ -41,7 +43,7 @@ private NotePitch(int note, float pitchPre1_9, float pitchPost1_9) {
4143
public static float getPitch(int note) {
4244
for (NotePitch notePitch : values()) {
4345
if (notePitch.note == note) {
44-
return NoteBlockPlayerMain.isPre1_9() ? notePitch.pitchPre1_9 : notePitch.pitchPost1_9;
46+
return NoteBlockPlayerMain.getCompatibility() == NoteBlockCompatibility.pre1_9 ? notePitch.pitchPre1_9 : notePitch.pitchPost1_9;
4547
}
4648
}
4749

0 commit comments

Comments
 (0)