mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-04 10:11:29 +01:00
#800: Add support for NoteBlock sounds in Skulls
By: Doc <nachito94@msn.com>
This commit is contained in:
parent
05e63c40e1
commit
9048c2fc06
4 changed files with 81 additions and 1 deletions
|
@ -74,11 +74,43 @@ public enum Instrument {
|
||||||
/**
|
/**
|
||||||
* Pling is normally played when a note block is on top of a glowstone block.
|
* Pling is normally played when a note block is on top of a glowstone block.
|
||||||
*/
|
*/
|
||||||
PLING(0xF);
|
PLING(0xF),
|
||||||
|
/**
|
||||||
|
* Zombie is normally played when a Zombie Head is on top of the note block.
|
||||||
|
*/
|
||||||
|
ZOMBIE,
|
||||||
|
/**
|
||||||
|
* Skeleton is normally played when a Skeleton Head is on top of the note block.
|
||||||
|
*/
|
||||||
|
SKELETON,
|
||||||
|
/**
|
||||||
|
* Creeper is normally played when a Creeper Head is on top of the note block.
|
||||||
|
*/
|
||||||
|
CREEPER,
|
||||||
|
/**
|
||||||
|
* Dragon is normally played when a Dragon Head is on top of the note block.
|
||||||
|
*/
|
||||||
|
DRAGON,
|
||||||
|
/**
|
||||||
|
* Wither Skeleton is normally played when a Wither Skeleton Head is on top of the note block.
|
||||||
|
*/
|
||||||
|
WITHER_SKELETON,
|
||||||
|
/**
|
||||||
|
* Piglin is normally played when a Piglin Head is on top of the note block.
|
||||||
|
*/
|
||||||
|
PIGLIN,
|
||||||
|
/**
|
||||||
|
* Custom Sound is normally played when a Player Head with the required data is on top of the note block.
|
||||||
|
*/
|
||||||
|
CUSTOM_HEAD;
|
||||||
|
|
||||||
private final byte type;
|
private final byte type;
|
||||||
private static final Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
|
private static final Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
|
||||||
|
|
||||||
|
private Instrument() {
|
||||||
|
this(-1);
|
||||||
|
}
|
||||||
|
|
||||||
private Instrument(final int type) {
|
private Instrument(final int type) {
|
||||||
this.type = (byte) type;
|
this.type = (byte) type;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.bukkit.block;
|
package org.bukkit.block;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.SkullType;
|
import org.bukkit.SkullType;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
@ -85,6 +86,27 @@ public interface Skull extends TileState {
|
||||||
*/
|
*/
|
||||||
void setOwnerProfile(@Nullable PlayerProfile profile);
|
void setOwnerProfile(@Nullable PlayerProfile profile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the sound to play if the skull is placed on a note block.
|
||||||
|
* <br>
|
||||||
|
* <strong>Note:</strong> This only works for player heads. For other heads,
|
||||||
|
* see {@link org.bukkit.Instrument}.
|
||||||
|
*
|
||||||
|
* @return the key of the sound, or null
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public NamespacedKey getNoteBlockSound();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the sound to play if the skull is placed on a note block.
|
||||||
|
* <br>
|
||||||
|
* <strong>Note:</strong> This only works for player heads. For other heads,
|
||||||
|
* see {@link org.bukkit.Instrument}.
|
||||||
|
*
|
||||||
|
* @param noteBlockSound the key of the sound to be played, or null
|
||||||
|
*/
|
||||||
|
public void setNoteBlockSound(@Nullable NamespacedKey noteBlockSound);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the rotation of the skull in the world (or facing direction if this
|
* Gets the rotation of the skull in the world (or facing direction if this
|
||||||
* is a wall mounted skull).
|
* is a wall mounted skull).
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package org.bukkit.inventory.meta;
|
package org.bukkit.inventory.meta;
|
||||||
|
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.profile.PlayerProfile;
|
import org.bukkit.profile.PlayerProfile;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
@ -79,6 +80,27 @@ public interface SkullMeta extends ItemMeta {
|
||||||
*/
|
*/
|
||||||
void setOwnerProfile(@Nullable PlayerProfile profile);
|
void setOwnerProfile(@Nullable PlayerProfile profile);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the sound to play if the skull is placed on a note block.
|
||||||
|
* <br>
|
||||||
|
* <strong>Note:</strong> This only works for player heads. For other heads,
|
||||||
|
* see {@link org.bukkit.Instrument}.
|
||||||
|
*
|
||||||
|
* @param noteBlockSound the key of the sound to be played, or null
|
||||||
|
*/
|
||||||
|
void setNoteBlockSound(@Nullable NamespacedKey noteBlockSound);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the sound to play if the skull is placed on a note block.
|
||||||
|
* <br>
|
||||||
|
* <strong>Note:</strong> This only works for player heads. For other heads,
|
||||||
|
* see {@link org.bukkit.Instrument}.
|
||||||
|
*
|
||||||
|
* @return the key of the sound, or null
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
NamespacedKey getNoteBlockSound();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@NotNull
|
@NotNull
|
||||||
SkullMeta clone();
|
SkullMeta clone();
|
||||||
|
|
|
@ -8,6 +8,10 @@ public class InstrumentTest {
|
||||||
@Test
|
@Test
|
||||||
public void getByType() {
|
public void getByType() {
|
||||||
for (Instrument instrument : Instrument.values()) {
|
for (Instrument instrument : Instrument.values()) {
|
||||||
|
if (instrument.getType() < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
assertThat(Instrument.getByType(instrument.getType()), is(instrument));
|
assertThat(Instrument.getByType(instrument.getType()), is(instrument));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue