swap utils to registry

This commit is contained in:
Kieran Wallbanks 2021-03-05 18:53:04 +00:00
parent 4179e5b91e
commit c25dbaa936
2 changed files with 2 additions and 13 deletions

View File

@ -13,17 +13,5 @@ import java.util.stream.Collectors;
* Adventure related utilities.
*/
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());
}
}

View File

@ -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();