mirror of
https://github.com/PaperMC/Paper.git
synced 2025-07-31 04:02:06 -07:00
Expose more data for MusicInstrument (#12415)
This commit is contained in:
@@ -5,10 +5,12 @@ import io.papermc.paper.registry.RegistryAccess;
|
||||
import io.papermc.paper.registry.RegistryKey;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.jspecify.annotations.NullMarked;
|
||||
import org.jspecify.annotations.Nullable;
|
||||
|
||||
public abstract class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable { // Paper - translation keys
|
||||
@NullMarked
|
||||
public abstract class MusicInstrument implements Keyed, net.kyori.adventure.translation.Translatable {
|
||||
|
||||
// Start generate - MusicInstrument
|
||||
// @GeneratedFrom 1.21.5
|
||||
@@ -38,7 +40,7 @@ public abstract class MusicInstrument implements Keyed, net.kyori.adventure.tran
|
||||
*/
|
||||
@Nullable
|
||||
@Deprecated(since = "1.20.1")
|
||||
public static MusicInstrument getByKey(@NotNull NamespacedKey namespacedKey) {
|
||||
public static MusicInstrument getByKey(final NamespacedKey namespacedKey) {
|
||||
return Registry.INSTRUMENT.get(namespacedKey);
|
||||
}
|
||||
|
||||
@@ -48,25 +50,50 @@ public abstract class MusicInstrument implements Keyed, net.kyori.adventure.tran
|
||||
* @return the memoryKeys
|
||||
* @deprecated use {@link Registry#iterator()}.
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated(since = "1.20.1")
|
||||
public static Collection<MusicInstrument> values() {
|
||||
return Collections.unmodifiableCollection(Lists.newArrayList(Registry.INSTRUMENT));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static MusicInstrument getInstrument(@NotNull String key) {
|
||||
private static MusicInstrument getInstrument(final String key) {
|
||||
return RegistryAccess.registryAccess().getRegistry(RegistryKey.INSTRUMENT).getOrThrow(NamespacedKey.minecraft(key));
|
||||
}
|
||||
|
||||
// Paper start - deprecate getKey
|
||||
/**
|
||||
* Gets the use duration of this music instrument.
|
||||
*
|
||||
* @return the duration expressed in seconds.
|
||||
*/
|
||||
public abstract float getDuration();
|
||||
|
||||
/**
|
||||
* Gets the range of the sound.
|
||||
*
|
||||
* @return the range of the sound.
|
||||
*/
|
||||
public abstract float getRange();
|
||||
|
||||
/**
|
||||
* Provides the description of this instrument as displayed to the client.
|
||||
*
|
||||
* @return the description component.
|
||||
*/
|
||||
public abstract Component description();
|
||||
|
||||
/**
|
||||
* Gets the sound for this instrument.
|
||||
*
|
||||
* @return the sound
|
||||
*/
|
||||
public abstract Sound getSound();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
|
||||
* and {@link io.papermc.paper.registry.RegistryKey#INSTRUMENT}. MusicInstruments can exist without a key.
|
||||
*/
|
||||
@Deprecated(forRemoval = true, since = "1.20.5")
|
||||
@Override
|
||||
public abstract @NotNull NamespacedKey getKey();
|
||||
public abstract NamespacedKey getKey();
|
||||
|
||||
/**
|
||||
* @deprecated use {@link Registry#getKey(Keyed)}, {@link io.papermc.paper.registry.RegistryAccess#getRegistry(io.papermc.paper.registry.RegistryKey)},
|
||||
@@ -78,15 +105,11 @@ public abstract class MusicInstrument implements Keyed, net.kyori.adventure.tran
|
||||
return Keyed.super.key();
|
||||
}
|
||||
|
||||
// Paper end - deprecate getKey
|
||||
|
||||
// Paper start - mark translation key as deprecated
|
||||
/**
|
||||
* @deprecated this method assumes that the instrument description
|
||||
* always be a translatable component which is not guaranteed.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated(forRemoval = true)
|
||||
public abstract @NotNull String translationKey();
|
||||
// Paper end - mark translation key as deprecated
|
||||
public abstract String translationKey();
|
||||
}
|
||||
|
Reference in New Issue
Block a user