-
-
Notifications
You must be signed in to change notification settings - Fork 104
/
SoundHelper_v1_14_R1.java
85 lines (79 loc) · 2.83 KB
/
SoundHelper_v1_14_R1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package net.aufdemrand.denizen.nms.helpers;
import net.aufdemrand.denizen.nms.interfaces.SoundHelper;
import net.aufdemrand.denizencore.utilities.debugging.dB;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.SoundCategory;
import org.bukkit.entity.Player;
public class SoundHelper_v1_14_R1 implements SoundHelper {
@Override
public Sound getMidiInstrumentFromPatch(int patch) {
// look up the instrument matching the patch
// TODO: 1.13 - does this still work?
switch (instruments_1_12[patch]) {
case 0:
return Sound.BLOCK_NOTE_BLOCK_HARP;
case 1:
return Sound.BLOCK_NOTE_BLOCK_BASS;
case 2:
return Sound.BLOCK_NOTE_BLOCK_SNARE;
case 3:
return Sound.BLOCK_NOTE_BLOCK_HAT;
case 4:
return Sound.BLOCK_NOTE_BLOCK_BASEDRUM;
case 5:
return Sound.BLOCK_NOTE_BLOCK_GUITAR;
case 6:
return Sound.BLOCK_NOTE_BLOCK_BELL;
case 7:
return Sound.BLOCK_NOTE_BLOCK_CHIME;
case 8:
return Sound.BLOCK_NOTE_BLOCK_FLUTE;
case 9:
return Sound.BLOCK_NOTE_BLOCK_XYLOPHONE;
case 10:
return Sound.BLOCK_NOTE_BLOCK_PLING;
}
return getDefaultMidiInstrument();
}
@Override
public Sound getDefaultMidiInstrument() {
return Sound.BLOCK_NOTE_BLOCK_HARP;
}
@Override
public void playSound(Player player, Location location, String sound, float volume, float pitch, String category) {
SoundCategory categoryEnum = SoundCategory.MASTER;
try {
if (category != null) {
categoryEnum = SoundCategory.valueOf(category);
}
}
catch (Exception ex) {
dB.echoError(ex);
}
if (player == null) {
location.getWorld().playSound(location, sound, categoryEnum, volume, pitch);
}
else {
player.playSound(location, sound, categoryEnum, volume, pitch);
}
}
@Override
public void playSound(Player player, Location location, Sound sound, float volume, float pitch, String category) {
SoundCategory categoryEnum = SoundCategory.MASTER;
try {
if (category != null) {
categoryEnum = SoundCategory.valueOf(category);
}
}
catch (Exception ex) {
dB.echoError(ex);
}
if (player == null) {
location.getWorld().playSound(location, sound, categoryEnum, volume, pitch);
}
else {
player.playSound(location, sound, categoryEnum, volume, pitch);
}
}
}