Skip to content

Commit dd6f63a

Browse files
committed
v1.1.4
Added support for Spigot 1.8
1 parent 96fa91d commit dd6f63a

File tree

5 files changed

+72
-41
lines changed

5 files changed

+72
-41
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.xxmicloxx</groupId>
88
<artifactId>NoteBlockAPI</artifactId>
9-
<version>1.1.3</version>
9+
<version>1.1.4</version>
1010
<repositories>
1111
<repository>
1212
<id>spigot-repo</id>

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

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,38 @@
55
public class Instrument {
66

77
public static Sound getInstrument(byte instrument) {
8-
switch (instrument) {
9-
case 0:
10-
return Sound.BLOCK_NOTE_HARP;
8+
if (!NoteBlockPlayerMain.plugin.isPre1_9()){
9+
switch (instrument) {
10+
case 0:
11+
return Sound.valueOf("BLOCK_NOTE_HARP");
12+
case 1:
13+
return Sound.valueOf("BLOCK_NOTE_BASS");
14+
case 2:
15+
return Sound.valueOf("BLOCK_NOTE_BASEDRUM");
16+
case 3:
17+
return Sound.valueOf("BLOCK_NOTE_SNARE");
18+
case 4:
19+
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");
1128
case 1:
12-
return Sound.BLOCK_NOTE_BASS;
29+
return Sound.valueOf("NOTE_BASS_GUITAR");
1330
case 2:
14-
return Sound.BLOCK_NOTE_BASEDRUM;
31+
return Sound.valueOf("NOTE_BASS_DRUM");
1532
case 3:
16-
return Sound.BLOCK_NOTE_SNARE;
33+
return Sound.valueOf("NOTE_SNARE_DRUM");
1734
case 4:
18-
return Sound.BLOCK_NOTE_HAT;
35+
return Sound.valueOf("NOTE_STICKS");
1936
default:
20-
return Sound.BLOCK_NOTE_HARP;
21-
22-
}
37+
return Sound.valueOf("NOTE_PIANO");
38+
}
39+
}
2340
}
2441

2542
public static org.bukkit.Instrument getBukkitInstrument(byte instrument) {

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,16 @@ public void onDisable() {
5151
disabling = true;
5252
Bukkit.getScheduler().cancelTasks(this);
5353
}
54+
55+
public boolean isPre1_9(){
56+
if (Bukkit.getVersion().contains("1.8")) {
57+
return true;
58+
}
59+
60+
if (Bukkit.getVersion().contains("1.7")) {
61+
return true;
62+
}
63+
64+
return false;
65+
}
5466
}

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

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,44 +2,46 @@
22

33
public enum NotePitch {
44

5-
NOTE_0(0, 0.50000F),
6-
NOTE_1(1, 0.52973F),
7-
NOTE_2(2, 0.56123F),
8-
NOTE_3(3, 0.59461F),
9-
NOTE_4(4, 0.62995F),
10-
NOTE_5(5, 0.66741F),
11-
NOTE_6(6, 0.70711F),
12-
NOTE_7(7, 0.74916F),
13-
NOTE_8(8, 0.79370F),
14-
NOTE_9(9, 0.84089F),
15-
NOTE_10(10, 0.89091F),
16-
NOTE_11(11, 0.94386F),
17-
NOTE_12(12, 1.00000F),
18-
NOTE_13(13, 1.05945F),
19-
NOTE_14(14, 1.12245F),
20-
NOTE_15(15, 1.18920F),
21-
NOTE_16(16, 1.25993F),
22-
NOTE_17(17, 1.33484F),
23-
NOTE_18(18, 1.41420F),
24-
NOTE_19(19, 1.49832F),
25-
NOTE_20(20, 1.58741F),
26-
NOTE_21(21, 1.68180F),
27-
NOTE_22(22, 1.78180F),
28-
NOTE_23(23, 1.88775F),
29-
NOTE_24(24, 2.00000F);
5+
NOTE_0(0, 0.5F, 0.50000F),
6+
NOTE_1(1, 0.53F, 0.52973F),
7+
NOTE_2(2, 0.56F, 0.56123F),
8+
NOTE_3(3, 0.6F, 0.59461F),
9+
NOTE_4(4, 0.63F, 0.62995F),
10+
NOTE_5(5, 0.67F, 0.66741F),
11+
NOTE_6(6, 0.7F, 0.70711F),
12+
NOTE_7(7, 0.76F, 0.74916F),
13+
NOTE_8(8, 0.8F, 0.79370F),
14+
NOTE_9(9, 0.84F, 0.84089F),
15+
NOTE_10(10, 0.9F, 0.89091F),
16+
NOTE_11(11, 0.94F, 0.94386F),
17+
NOTE_12(12, 1.0F, 1.00000F),
18+
NOTE_13(13, 1.06F, 1.05945F),
19+
NOTE_14(14, 1.12F, 1.12245F),
20+
NOTE_15(15, 1.18F, 1.18920F),
21+
NOTE_16(16, 1.26F, 1.25993F),
22+
NOTE_17(17, 1.34F, 1.33484F),
23+
NOTE_18(18, 1.42F, 1.41420F),
24+
NOTE_19(19, 1.5F, 1.49832F),
25+
NOTE_20(20, 1.6F, 1.58741F),
26+
NOTE_21(21, 1.68F, 1.68180F),
27+
NOTE_22(22, 1.78F, 1.78180F),
28+
NOTE_23(23, 1.88F, 1.88775F),
29+
NOTE_24(24, 2.0F, 2.00000F);
3030

3131
public int note;
32-
public float pitch;
32+
public float pitchPre1_9;
33+
public float pitchPost1_9;
3334

34-
private NotePitch(int note, float pitch) {
35+
private NotePitch(int note, float pitchPre1_9, float pitchPost1_9) {
3536
this.note = note;
36-
this.pitch = pitch;
37+
this.pitchPre1_9 = pitchPre1_9;
38+
this.pitchPost1_9 = pitchPost1_9;
3739
}
3840

3941
public static float getPitch(int note) {
4042
for (NotePitch notePitch : values()) {
4143
if (notePitch.note == note) {
42-
return notePitch.pitch;
44+
return NoteBlockPlayerMain.plugin.isPre1_9() ? notePitch.pitchPre1_9 : notePitch.pitchPost1_9;
4345
}
4446
}
4547

src/main/resources/plugin.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: NoteBlockAPI
22

33
main: com.xxmicloxx.NoteBlockAPI.NoteBlockPlayerMain
4-
version: 1.1.3
4+
version: 1.1.4
55

66
description: a developer interface to play nbs-files ingame
77
authors: [xxmicloxx, michidk, koca2000]

0 commit comments

Comments
 (0)