From c25dbaa9367292181c8622c12f12b03cec544172 Mon Sep 17 00:00:00 2001 From: Kieran Wallbanks Date: Fri, 5 Mar 2021 18:53:04 +0000 Subject: [PATCH] swap utils to registry --- .../minestom/server/adventure/AdventureUtils.java | 12 ------------ src/main/java/net/minestom/server/entity/Player.java | 3 ++- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/src/main/java/net/minestom/server/adventure/AdventureUtils.java b/src/main/java/net/minestom/server/adventure/AdventureUtils.java index cd23b178c..e61f9c181 100644 --- a/src/main/java/net/minestom/server/adventure/AdventureUtils.java +++ b/src/main/java/net/minestom/server/adventure/AdventureUtils.java @@ -13,17 +13,5 @@ import java.util.stream.Collectors; * Adventure related utilities. */ public class AdventureUtils { - private static final Map 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()); - } } diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index adebaab5e..22b999f45 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -53,6 +53,7 @@ import net.minestom.server.network.player.NettyPlayerConnection; import net.minestom.server.network.player.PlayerConnection; import net.minestom.server.recipe.Recipe; import net.minestom.server.recipe.RecipeManager; +import net.minestom.server.registry.Registries; import net.minestom.server.resourcepack.ResourcePack; import net.minestom.server.scoreboard.BelowNameTag; import net.minestom.server.scoreboard.Team; @@ -917,7 +918,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable { @Override 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) { NamedSoundEffectPacket packet = new NamedSoundEffectPacket();