Commits

Doc authored and md_5 committed 442838fdaef
#1053: Add MusicInstrument fields for description, range, duration and sound
No tags

src/main/java/org/bukkit/craftbukkit/CraftMusicInstrument.java

Modified
6 6 import com.mojang.datafixers.util.Pair;
7 7 import com.mojang.serialization.DataResult;
8 8 import com.mojang.serialization.JsonOps;
9 9 import net.minecraft.core.Holder;
10 10 import net.minecraft.core.registries.Registries;
11 11 import net.minecraft.resources.RegistryOps;
12 12 import net.minecraft.world.item.Instrument;
13 13 import org.bukkit.MusicInstrument;
14 14 import org.bukkit.NamespacedKey;
15 15 import org.bukkit.Registry;
16 +import org.bukkit.Sound;
17 +import org.bukkit.craftbukkit.util.CraftChatMessage;
16 18 import org.bukkit.craftbukkit.util.CraftNamespacedKey;
17 19 import org.bukkit.craftbukkit.util.HolderHandleable;
18 20 import org.jetbrains.annotations.NotNull;
19 21 import org.jetbrains.annotations.Nullable;
20 22
21 23 public class CraftMusicInstrument extends MusicInstrument implements HolderHandleable<Instrument> {
22 24
23 25 public static MusicInstrument minecraftToBukkit(Instrument minecraft) {
24 26 return CraftRegistry.minecraftToBukkit(minecraft, Registries.INSTRUMENT, Registry.INSTRUMENT);
25 27 }
83 85 @Override
84 86 public Instrument getHandle() {
85 87 return handle.value();
86 88 }
87 89
88 90 @Override
89 91 public Holder<Instrument> getHandleHolder() {
90 92 return handle;
91 93 }
92 94
95 + @Override
96 + public String getDescription() {
97 + return CraftChatMessage.fromComponent(this.getHandle().description());
98 + }
99 +
100 + @Override
101 + public float getDuration() {
102 + return this.getHandle().useDuration();
103 + }
104 +
105 + @Override
106 + public float getRange() {
107 + return this.getHandle().range();
108 + }
109 +
110 + @Override
111 + public Sound getSoundEvent() {
112 + return CraftSound.minecraftHolderToBukkit(this.getHandle().soundEvent());
113 + }
114 +
93 115 @NotNull
94 116 @Override
95 117 public NamespacedKey getKey() {
96 118 return getKeyOrThrow();
97 119 }
98 120
99 121 @Override
100 122 public boolean equals(Object o) {
101 123 if (this == o) {
102 124 return true;

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut