Skip to content

Commit 1220761

Browse files
committed
Fix sounds
1 parent 6af1de8 commit 1220761

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

multification-bukkit/src/com/eternalcode/multification/bukkit/notice/resolver/sound/SoundAccessor.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
package com.eternalcode.multification.bukkit.notice.resolver.sound;
22

33
import java.lang.reflect.Method;
4+
import org.bukkit.NamespacedKey;
45
import org.bukkit.Sound;
56

67
public final class SoundAccessor {
78

89
private static final Method VALUE_OF_METHOD;
910
private static final Method nameMethod;
11+
private static final Method keyMethod;
1012

1113
static {
1214
try {
@@ -15,6 +17,9 @@ public final class SoundAccessor {
1517

1618
nameMethod = Sound.class.getMethod("name");
1719
nameMethod.setAccessible(true);
20+
21+
keyMethod = Sound.class.getMethod("getKey");
22+
keyMethod.setAccessible(true);
1823
}
1924
catch (NoSuchMethodException noSuchMethodException) {
2025
throw new RuntimeException(noSuchMethodException);
@@ -42,4 +47,13 @@ public static String name(Sound sound) {
4247
}
4348
}
4449

50+
public static NamespacedKey key(Sound sound) {
51+
try {
52+
return (NamespacedKey) keyMethod.invoke(sound);
53+
}
54+
catch (ReflectiveOperationException reflectiveOperationException) {
55+
throw new RuntimeException(reflectiveOperationException);
56+
}
57+
}
58+
4559
}

multification-bukkit/src/com/eternalcode/multification/bukkit/notice/resolver/sound/SoundBukkitResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public NoticeKey<SoundBukkit> noticeKey() {
2626

2727
@Override
2828
public void send(Audience audience, ComponentSerializer<Component, Component, String> componentSerializer, SoundBukkit content) {
29-
String soundKey = content.sound().getKey().getKey();
29+
String soundKey = SoundAccessor.key(content.sound()).getKey();
3030
Sound sound = Sound.sound(
3131
Key.key(soundKey),
3232
Sound.Source.valueOf(content.toKyoriCategory().name()),

0 commit comments

Comments
 (0)