From 9f48fadb5afb2088b4eafac4e482217b2206f596 Mon Sep 17 00:00:00 2001 From: Riley Park Date: Tue, 23 Feb 2021 15:45:26 -0800 Subject: [PATCH] Sound can implement Adventure's Sound.Type --- Spigot-API-Patches/Adventure.patch | 27 ++++++++++++++++++- .../Complete-resource-pack-API.patch | 2 +- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/Spigot-API-Patches/Adventure.patch b/Spigot-API-Patches/Adventure.patch index 16fd586549..c17370e7b1 100644 --- a/Spigot-API-Patches/Adventure.patch +++ b/Spigot-API-Patches/Adventure.patch @@ -575,6 +575,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public void broadcast(@NotNull net.md_5.bungee.api.chat.BaseComponent... components) { throw new UnsupportedOperationException("Not supported yet."); } +diff --git a/src/main/java/org/bukkit/Sound.java b/src/main/java/org/bukkit/Sound.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/Sound.java ++++ b/src/main/java/org/bukkit/Sound.java +@@ -0,0 +0,0 @@ import org.jetbrains.annotations.NotNull; + * guarantee values will not be removed from this Enum. As such, you should not + * depend on the ordinal values of this class. + */ +-public enum Sound implements Keyed { ++public enum Sound implements Keyed, net.kyori.adventure.sound.Sound.Type { // Paper - implement Sound.Type + + AMBIENT_BASALT_DELTAS_ADDITIONS("ambient.basalt_deltas.additions"), + AMBIENT_BASALT_DELTAS_LOOP("ambient.basalt_deltas.loop"), +@@ -0,0 +0,0 @@ public enum Sound implements Keyed { + public NamespacedKey getKey() { + return key; + } ++ ++ // Paper start ++ @Override ++ public net.kyori.adventure.key.@org.checkerframework.checker.nullness.qual.NonNull Key key() { ++ return this.key; ++ } ++ // Paper end + } diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/World.java @@ -1138,7 +1163,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 + @NotNull + @Override + default net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { -+ return net.kyori.adventure.text.event.HoverEvent.showEntity(this.getType().getKey(), this.getUniqueId(), this.displayName()); ++ return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.displayName()))); + } + // Paper end + diff --git a/Spigot-API-Patches/Complete-resource-pack-API.patch b/Spigot-API-Patches/Complete-resource-pack-API.patch index 1b8e6cc823..7e42da643e 100644 --- a/Spigot-API-Patches/Complete-resource-pack-API.patch +++ b/Spigot-API-Patches/Complete-resource-pack-API.patch @@ -20,7 +20,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 /** @@ -0,0 +0,0 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM default net.kyori.adventure.text.event.HoverEvent asHoverEvent(final @NotNull java.util.function.UnaryOperator op) { - return net.kyori.adventure.text.event.HoverEvent.showEntity(this.getType().getKey(), this.getUniqueId(), this.displayName()); + return net.kyori.adventure.text.event.HoverEvent.showEntity(op.apply(net.kyori.adventure.text.event.HoverEvent.ShowEntity.of(this.getType().getKey(), this.getUniqueId(), this.displayName()))); } + + /**