From f6d4cdfc991f832fc07c631b3f6b41207a8607c7 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Fri, 22 Sep 2023 16:07:33 -0700 Subject: [PATCH] fixup display slots patch (#9746) --- ...d-missing-team-sidebar-display-slots.patch | 2 +- ...d-missing-team-sidebar-display-slots.patch | 35 ++++++++----------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/patches/api/Add-missing-team-sidebar-display-slots.patch b/patches/api/Add-missing-team-sidebar-display-slots.patch index 0618cf377f..ec7568d1b0 100644 --- a/patches/api/Add-missing-team-sidebar-display-slots.patch +++ b/patches/api/Add-missing-team-sidebar-display-slots.patch @@ -36,7 +36,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 - SIDEBAR_YELLOW, - SIDEBAR_WHITE; + // Paper start -+ BELOW_NAME("belowName"), ++ BELOW_NAME("below_name"), + PLAYER_LIST("list"), + SIDEBAR("sidebar"), + SIDEBAR_TEAM_BLACK(NamedTextColor.BLACK), diff --git a/patches/server/Add-missing-team-sidebar-display-slots.patch b/patches/server/Add-missing-team-sidebar-display-slots.patch index 9f840dde1b..1a6b8c6a95 100644 --- a/patches/server/Add-missing-team-sidebar-display-slots.patch +++ b/patches/server/Add-missing-team-sidebar-display-slots.patch @@ -5,19 +5,17 @@ Subject: [PATCH] Add missing team sidebar display slots == AT == public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations -public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations toBukkitSlot(I)Lorg/bukkit/scoreboard/DisplaySlot; -public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations fromBukkitSlot(Lorg/bukkit/scoreboard/DisplaySlot;)I +public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations toBukkitSlot(Lnet/minecraft/world/scores/DisplaySlot;)Lorg/bukkit/scoreboard/DisplaySlot; +public org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations fromBukkitSlot(Lorg/bukkit/scoreboard/DisplaySlot;)Lnet/minecraft/world/scores/DisplaySlot; diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java +++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java -@@ -0,0 +0,0 @@ import org.bukkit.scoreboard.DisplaySlot; - import org.bukkit.scoreboard.RenderType; +@@ -0,0 +0,0 @@ import org.bukkit.scoreboard.RenderType; public final class CraftScoreboardTranslations { -- static final int MAX_DISPLAY_SLOT = 19; -+ static final int MAX_DISPLAY_SLOT = net.minecraft.world.scores.DisplaySlot.values().length; // Paper // TODO - revisit this. + static final int MAX_DISPLAY_SLOT = 19; + @Deprecated // Paper static final ImmutableBiMap SLOTS = ImmutableBiMap.builder() .put(DisplaySlot.BELOW_NAME, "below_name") @@ -43,18 +41,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 private CraftScoreboardTranslations() {} - static DisplaySlot toBukkitSlot(net.minecraft.world.scores.DisplaySlot minecraft) { -+ if (true) return org.bukkit.scoreboard.DisplaySlot.NAMES.value(minecraft.getSerializedName()); // Paper + public static DisplaySlot toBukkitSlot(net.minecraft.world.scores.DisplaySlot minecraft) { ++ if (true) return DisplaySlot.NAMES.value(minecraft.getSerializedName()); // Paper return CraftScoreboardTranslations.SLOTS.inverse().get(minecraft.getSerializedName()); } -- static net.minecraft.world.scores.DisplaySlot fromBukkitSlot(DisplaySlot slot) { -- return net.minecraft.world.scores.DisplaySlot.CODEC.byName(CraftScoreboardTranslations.SLOTS.get(slot)); -+ public static net.minecraft.world.scores.DisplaySlot fromBukkitSlot(DisplaySlot slot) { // Paper - public for testing -+ return net.minecraft.world.scores.DisplaySlot.CODEC.byName(slot.getId()); // Paper + public static net.minecraft.world.scores.DisplaySlot fromBukkitSlot(DisplaySlot slot) { ++ if (true) return net.minecraft.world.scores.DisplaySlot.CODEC.byName(slot.getId()); // Paper + return net.minecraft.world.scores.DisplaySlot.CODEC.byName(CraftScoreboardTranslations.SLOTS.get(slot)); } - static RenderType toBukkitRender(ObjectiveCriteria.RenderType display) { diff --git a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java @@ -82,28 +78,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 @@ -0,0 +0,0 @@ +package io.papermc.paper.scoreboard; + -+import net.minecraft.world.scores.Scoreboard; +import org.bukkit.craftbukkit.scoreboard.CraftScoreboardTranslations; +import org.bukkit.scoreboard.DisplaySlot; +import org.junit.Test; + -+import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; + +public class DisplaySlotTest { + + @Test + public void testBukkitToMinecraftDisplaySlots() { -+ for (DisplaySlot value : DisplaySlot.values()) { -+ assertNotEquals(-1, CraftScoreboardTranslations.fromBukkitSlot(value)); ++ for (DisplaySlot bukkitSlot : DisplaySlot.values()) { ++ assertNotNull(CraftScoreboardTranslations.fromBukkitSlot(bukkitSlot)); + } + } + + @Test + public void testMinecraftToBukkitDisplaySlots() { -+ // TODO https://github.com/PaperMC/Paper/issues/9742 -+ /*for (String name : Scoreboard.getDisplaySlotNames()) { -+ assertNotNull(CraftScoreboardTranslations.toBukkitSlot(Scoreboard.getDisplaySlotByName(name))); -+ }*/ ++ for (net.minecraft.world.scores.DisplaySlot nmsSlot : net.minecraft.world.scores.DisplaySlot.values()) { ++ assertNotNull(CraftScoreboardTranslations.toBukkitSlot(nmsSlot)); ++ } + } +}