Skip to content

Commit

Permalink
fixup display slots patch (#9746)
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker authored Sep 22, 2023
1 parent 915bb92 commit 47aeab8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 26 deletions.
4 changes: 2 additions & 2 deletions patches/api/0313-Add-missing-team-sidebar-display-slots.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Subject: [PATCH] Add missing team sidebar display slots


diff --git a/src/main/java/org/bukkit/scoreboard/DisplaySlot.java b/src/main/java/org/bukkit/scoreboard/DisplaySlot.java
index 4959bec21d152a17fe4ca9d3f448aef482a05b5e..fe7d0a19f970ac5b4e0c4bef4ff7c4ceae60bb86 100644
index 4959bec21d152a17fe4ca9d3f448aef482a05b5e..21cd2ba659504c3a1eb95226539a5701d0c324db 100644
--- a/src/main/java/org/bukkit/scoreboard/DisplaySlot.java
+++ b/src/main/java/org/bukkit/scoreboard/DisplaySlot.java
@@ -1,26 +1,55 @@
Expand Down Expand Up @@ -36,7 +36,7 @@ index 4959bec21d152a17fe4ca9d3f448aef482a05b5e..fe7d0a19f970ac5b4e0c4bef4ff7c4ce
- SIDEBAR_YELLOW,
- SIDEBAR_WHITE;
+ // Paper start
+ BELOW_NAME("belowName"),
+ BELOW_NAME("below_name"),
+ PLAYER_LIST("list"),
+ SIDEBAR("sidebar"),
+ SIDEBAR_TEAM_BLACK(NamedTextColor.BLACK),
Expand Down
41 changes: 17 additions & 24 deletions patches/server/0657-Add-missing-team-sidebar-display-slots.patch
Original file line number Diff line number Diff line change
Expand Up @@ -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 808118a033ace90246318dcf6a3110cab353d09c..183496dfd40d6c89fb77758e5f8f66e8015fe182 100644
index 73c5ffff70605b32188a9bb5fb6c0ee04cb66efe..711d227f5ee6d63356a94a0567968da48e9f284c 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardTranslations.java
@@ -6,37 +6,23 @@ import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.RenderType;
@@ -7,35 +7,22 @@ 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<DisplaySlot, String> SLOTS = ImmutableBiMap.<DisplaySlot, String>builder()
.put(DisplaySlot.BELOW_NAME, "below_name")
Expand All @@ -43,18 +41,16 @@ index 808118a033ace90246318dcf6a3110cab353d09c..183496dfd40d6c89fb77758e5f8f66e8

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 fe5d3b60ad740b7f1cce040f9c8d96ac51245ef6..43ffc4180b1ef2d2000991ad58b0706141470d08 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
Expand All @@ -76,34 +72,31 @@ index fe5d3b60ad740b7f1cce040f9c8d96ac51245ef6..43ffc4180b1ef2d2000991ad58b07061
{
diff --git a/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..2d1d86eb58d7ec7246eb72029c09a53d0f775eb4
index 0000000000000000000000000000000000000000..9765f08707df27d1a46a1daa1cc2e2fc9cda3ffe
--- /dev/null
+++ b/src/test/java/io/papermc/paper/scoreboard/DisplaySlotTest.java
@@ -0,0 +1,27 @@
@@ -0,0 +1,24 @@
+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));
+ }
+ }
+}

0 comments on commit 47aeab8

Please sign in to comment.