mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
SPIGOT-7034: Add methods for set/get instrument in Goat Horn
By: byquanton <32410361+byquanton@users.noreply.github.com>
This commit is contained in:
parent
5c925130eb
commit
0171060ae2
2 changed files with 93 additions and 0 deletions
66
paper-api/src/main/java/org/bukkit/MusicInstrument.java
Normal file
66
paper-api/src/main/java/org/bukkit/MusicInstrument.java
Normal file
|
@ -0,0 +1,66 @@
|
|||
package org.bukkit;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public final class MusicInstrument implements Keyed {
|
||||
|
||||
private static final Map<NamespacedKey, MusicInstrument> INSTRUMENTS = new HashMap<>();
|
||||
//
|
||||
public static final MusicInstrument PONDER = getInstrument("ponder_goat_horn");
|
||||
public static final MusicInstrument SING = getInstrument("sing_goat_horn");
|
||||
public static final MusicInstrument SEEK = getInstrument("seek_goat_horn");
|
||||
public static final MusicInstrument FEEL = getInstrument("feel_goat_horn");
|
||||
public static final MusicInstrument ADMIRE = getInstrument("admire_goat_horn");
|
||||
public static final MusicInstrument CALL = getInstrument("call_goat_horn");
|
||||
public static final MusicInstrument YEARN = getInstrument("yearn_goat_horn");
|
||||
public static final MusicInstrument DREAM = getInstrument("dream_goat_horn");
|
||||
//
|
||||
private final NamespacedKey key;
|
||||
|
||||
private MusicInstrument(NamespacedKey key) {
|
||||
this.key = key;
|
||||
|
||||
INSTRUMENTS.put(key, this);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link MusicInstrument} by a {@link NamespacedKey}.
|
||||
*
|
||||
* @param namespacedKey the key
|
||||
* @return the event or null
|
||||
*/
|
||||
@Nullable
|
||||
public static MusicInstrument getByKey(@NotNull NamespacedKey namespacedKey) {
|
||||
Preconditions.checkArgument(namespacedKey != null, "NamespacedKey cannot be null");
|
||||
|
||||
return INSTRUMENTS.get(namespacedKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all known MusicInstruments.
|
||||
*
|
||||
* @return the memoryKeys
|
||||
*/
|
||||
@NotNull
|
||||
public static Collection<MusicInstrument> values() {
|
||||
return Collections.unmodifiableCollection(INSTRUMENTS.values());
|
||||
}
|
||||
|
||||
private static MusicInstrument getInstrument(@NotNull String name) {
|
||||
Preconditions.checkArgument(name != null, "Instrument name cannot be null");
|
||||
|
||||
return new MusicInstrument(NamespacedKey.minecraft(name));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package org.bukkit.inventory.meta;
|
||||
|
||||
import org.bukkit.MusicInstrument;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface MusicInstrumentMeta extends ItemMeta {
|
||||
|
||||
/**
|
||||
* Sets the goat horn's instrument.
|
||||
*
|
||||
* @param instrument the instrument to set
|
||||
*/
|
||||
void setInstrument(@Nullable MusicInstrument instrument);
|
||||
|
||||
/**
|
||||
* Gets the instrument of the goat horn.
|
||||
*
|
||||
* @return The instrument of the goat horn
|
||||
*/
|
||||
@Nullable
|
||||
MusicInstrument getInstrument();
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
MusicInstrumentMeta clone();
|
||||
}
|
Loading…
Reference in a new issue