mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-09 01:47:54 +01:00
swap utils to registry
This commit is contained in:
parent
4179e5b91e
commit
c25dbaa936
@ -13,17 +13,5 @@ import java.util.stream.Collectors;
|
|||||||
* Adventure related utilities.
|
* Adventure related utilities.
|
||||||
*/
|
*/
|
||||||
public class AdventureUtils {
|
public class AdventureUtils {
|
||||||
private static final Map<String, Sound> SOUND_MAP =
|
|
||||||
Arrays.stream(Sound.values()).collect(Collectors.toMap(Sound::getNamespaceID, sound -> sound));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to get an NMS sound from an Adventure key.
|
|
||||||
*
|
|
||||||
* @param name the key
|
|
||||||
*
|
|
||||||
* @return the sound, if found
|
|
||||||
*/
|
|
||||||
public static @Nullable Sound asSound(@NotNull Key name) {
|
|
||||||
return SOUND_MAP.get(name.asString());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ import net.minestom.server.network.player.NettyPlayerConnection;
|
|||||||
import net.minestom.server.network.player.PlayerConnection;
|
import net.minestom.server.network.player.PlayerConnection;
|
||||||
import net.minestom.server.recipe.Recipe;
|
import net.minestom.server.recipe.Recipe;
|
||||||
import net.minestom.server.recipe.RecipeManager;
|
import net.minestom.server.recipe.RecipeManager;
|
||||||
|
import net.minestom.server.registry.Registries;
|
||||||
import net.minestom.server.resourcepack.ResourcePack;
|
import net.minestom.server.resourcepack.ResourcePack;
|
||||||
import net.minestom.server.scoreboard.BelowNameTag;
|
import net.minestom.server.scoreboard.BelowNameTag;
|
||||||
import net.minestom.server.scoreboard.Team;
|
import net.minestom.server.scoreboard.Team;
|
||||||
@ -917,7 +918,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void playSound(net.kyori.adventure.sound.@NotNull Sound sound, double x, double y, double z) {
|
public void playSound(net.kyori.adventure.sound.@NotNull Sound sound, double x, double y, double z) {
|
||||||
Sound minestomSound = AdventureUtils.asSound(sound.name());
|
Sound minestomSound = Registries.getSound(sound.name());
|
||||||
|
|
||||||
if (minestomSound == null) {
|
if (minestomSound == null) {
|
||||||
NamedSoundEffectPacket packet = new NamedSoundEffectPacket();
|
NamedSoundEffectPacket packet = new NamedSoundEffectPacket();
|
||||||
|
Loading…
Reference in New Issue
Block a user