Updated Upstream (Bukkit/CraftBukkit) (#8270)

Upstream has released updates that appear to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
d43a1e72 SPIGOT-2450: Improve scoreboard criteria API, add missing DisplaySlots
9d6e4847 SPIGOT-7122: New Allay Methods from 1.19.1

CraftBukkit Changes:
c379a6b4e SPIGOT-2450: Improve scoreboard criteria API, add missing DisplaySlots
051fcced1 SPIGOT-7122: New Allay Methods from 1.19.1
This commit is contained in:
Nassim Jahnke 2022-08-09 09:18:08 +02:00
parent eb5b0d0edf
commit d4b4d5b95b
8 changed files with 154 additions and 64 deletions

View file

@ -18,7 +18,23 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public enum DisplaySlot {
- BELOW_NAME,
- PLAYER_LIST,
- SIDEBAR;
- SIDEBAR,
- SIDEBAR_BLACK,
- SIDEBAR_DARK_BLUE,
- SIDEBAR_DARK_GREEN,
- SIDEBAR_DARK_AQUA,
- SIDEBAR_DARK_RED,
- SIDEBAR_DARK_PURPLE,
- SIDEBAR_GOLD,
- SIDEBAR_GRAY,
- SIDEBAR_DARK_GRAY,
- SIDEBAR_BLUE,
- SIDEBAR_GREEN,
- SIDEBAR_AQUA,
- SIDEBAR_RED,
- SIDEBAR_LIGHT_PURPLE,
- SIDEBAR_YELLOW,
- SIDEBAR_WHITE;
+ // Paper start
+ BELOW_NAME("belowName"),
+ PLAYER_LIST("list"),

View file

@ -4288,8 +4288,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * characters.
+ * @throws IllegalArgumentException if an objective by that name already
+ * exists
+ * @deprecated use {@link #registerNewObjective(String, Criteria, net.kyori.adventure.text.Component)}
+ */
+ @NotNull
+ @Deprecated
+ Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @Nullable net.kyori.adventure.text.Component displayName) throws IllegalArgumentException;
+ /**
+ * Registers an Objective on this Scoreboard
@ -4309,18 +4311,57 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ * @throws IllegalArgumentException if renderType is null
+ * @throws IllegalArgumentException if an objective by that name already
+ * exists
+ * @deprecated use {@link #registerNewObjective(String, Criteria, net.kyori.adventure.text.Component, RenderType)}
+ */
+ @NotNull
+ @Deprecated
+ Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @Nullable net.kyori.adventure.text.Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
+ /**
+ * Registers an Objective on this Scoreboard
+ *
+ * @param name Name of the Objective
+ * @param criteria Criteria for the Objective
+ * @param displayName Name displayed to players for the Objective.
+ * @return The registered Objective
+ * @throws IllegalArgumentException if name is null
+ * @throws IllegalArgumentException if name is longer than 32767
+ * characters.
+ * @throws IllegalArgumentException if criteria is null
+ * @throws IllegalArgumentException if displayName is null
+ * @throws IllegalArgumentException if displayName is longer than 128
+ * characters.
+ * @throws IllegalArgumentException if an objective by that name already
+ * exists
+ */
+ @NotNull
+ Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @Nullable net.kyori.adventure.text.Component displayName) throws IllegalArgumentException;
+ /**
+ * Registers an Objective on this Scoreboard
+ *
+ * @param name Name of the Objective
+ * @param criteria Criteria for the Objective
+ * @param displayName Name displayed to players for the Objective.
+ * @param renderType Manner of rendering the Objective
+ * @return The registered Objective
+ * @throws IllegalArgumentException if name is null
+ * @throws IllegalArgumentException if name is longer than 32767
+ * characters.
+ * @throws IllegalArgumentException if criteria is null
+ * @throws IllegalArgumentException if displayName is null
+ * @throws IllegalArgumentException if displayName is longer than 128
+ * characters.
+ * @throws IllegalArgumentException if renderType is null
+ * @throws IllegalArgumentException if an objective by that name already
+ * exists
+ */
+ @NotNull
+ Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @Nullable net.kyori.adventure.text.Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
+ Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @Nullable net.kyori.adventure.text.Component displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
+ // Paper end
/**
* Registers an Objective on this Scoreboard
@@ -0,0 +0,0 @@ public interface Scoreboard {
* characters.
* @throws IllegalArgumentException if an objective by that name already
* exists
+ * @deprecated in favour of {@link #registerNewObjective(String, String, net.kyori.adventure.text.Component)}
* @deprecated use {@link #registerNewObjective(String, Criteria, String)}
*/
@NotNull
+ @Deprecated // Paper
@ -4328,15 +4369,34 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
/**
@@ -0,0 +0,0 @@ public interface Scoreboard {
* @throws IllegalArgumentException if renderType is null
* @throws IllegalArgumentException if an objective by that name already
* exists
+ * @deprecated in favour of {@link #registerNewObjective(String, String, net.kyori.adventure.text.Component, RenderType)}
* @deprecated use {@link #registerNewObjective(String, Criteria, String, RenderType)}
*/
@NotNull
+ @Deprecated // Paper
Objective registerNewObjective(@NotNull String name, @NotNull String criteria, @NotNull String displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
/**
@@ -0,0 +0,0 @@ public interface Scoreboard {
* characters.
* @throws IllegalArgumentException if an objective by that name already
* exists
+ * @deprecated in favour of {@link #registerNewObjective(String, Criteria, net.kyori.adventure.text.Component)}
*/
@NotNull
+ @Deprecated // Paper
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName) throws IllegalArgumentException;
/**
@@ -0,0 +0,0 @@ public interface Scoreboard {
* @throws IllegalArgumentException if renderType is null
* @throws IllegalArgumentException if an objective by that name already
* exists
+ * @deprecated in favour of {@link #registerNewObjective(String, Criteria, net.kyori.adventure.text.Component, RenderType)}
*/
@NotNull
+ @Deprecated // Paper
Objective registerNewObjective(@NotNull String name, @NotNull Criteria criteria, @NotNull String displayName, @NotNull RenderType renderType) throws IllegalArgumentException;
/**
diff --git a/src/main/java/org/bukkit/scoreboard/Team.java b/src/main/java/org/bukkit/scoreboard/Team.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644

View file

@ -12,13 +12,31 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
import org.bukkit.scoreboard.RenderType;
public final class CraftScoreboardTranslations {
- static final int MAX_DISPLAY_SLOT = 3;
- static final int MAX_DISPLAY_SLOT = 19;
+ static final int MAX_DISPLAY_SLOT = Scoreboard.getDisplaySlotNames().length; // Paper
+ @Deprecated // Paper
static ImmutableBiMap<DisplaySlot, String> SLOTS = ImmutableBiMap.of(
DisplaySlot.BELOW_NAME, "belowName",
DisplaySlot.PLAYER_LIST, "list",
@@ -0,0 +0,0 @@ public final class CraftScoreboardTranslations {
static final ImmutableBiMap<DisplaySlot, String> SLOTS = ImmutableBiMap.<DisplaySlot, String>builder()
.put(DisplaySlot.BELOW_NAME, "belowName")
.put(DisplaySlot.PLAYER_LIST, "list")
.put(DisplaySlot.SIDEBAR, "sidebar")
- .put(DisplaySlot.SIDEBAR_BLACK, "sidebar.team.black")
- .put(DisplaySlot.SIDEBAR_DARK_BLUE, "sidebar.team.dark_blue")
- .put(DisplaySlot.SIDEBAR_DARK_GREEN, "sidebar.team.dark_green")
- .put(DisplaySlot.SIDEBAR_DARK_AQUA, "sidebar.team.dark_aqua")
- .put(DisplaySlot.SIDEBAR_DARK_RED, "sidebar.team.dark_red")
- .put(DisplaySlot.SIDEBAR_DARK_PURPLE, "sidebar.team.dark_purple")
- .put(DisplaySlot.SIDEBAR_GOLD, "sidebar.team.gold")
- .put(DisplaySlot.SIDEBAR_GRAY, "sidebar.team.gray")
- .put(DisplaySlot.SIDEBAR_DARK_GRAY, "sidebar.team.dark_gray")
- .put(DisplaySlot.SIDEBAR_BLUE, "sidebar.team.blue")
- .put(DisplaySlot.SIDEBAR_GREEN, "sidebar.team.green")
- .put(DisplaySlot.SIDEBAR_AQUA, "sidebar.team.aqua")
- .put(DisplaySlot.SIDEBAR_RED, "sidebar.team.red")
- .put(DisplaySlot.SIDEBAR_LIGHT_PURPLE, "sidebar.team.light_purple")
- .put(DisplaySlot.SIDEBAR_YELLOW, "sidebar.team.yellow")
- .put(DisplaySlot.SIDEBAR_WHITE, "sidebar.team.white")
.buildOrThrow();
private CraftScoreboardTranslations() {}
public static DisplaySlot toBukkitSlot(int i) {
@ -31,6 +49,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
return Scoreboard.getDisplaySlotByName(CraftScoreboardTranslations.SLOTS.get(slot));
}
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
+++ b/src/main/java/org/bukkit/craftbukkit/util/Commodore.java
@@ -0,0 +0,0 @@ public class Commodore
desc = getOriginalOrRewrite( desc );
}
// Paper end
+ // Paper start - DisplaySlot
+ if (owner.equals("org/bukkit/scoreboard/DisplaySlot")) {
+ if (name.startsWith("SIDEBAR_") && !name.startsWith("SIDEBAR_TEAM_")) {
+ super.visitFieldInsn(opcode, owner, name.replace("SIDEBAR_", "SIDEBAR_TEAM_"), desc);
+ return;
+ }
+ }
+ // Paper end - DisplaySlot
if ( owner.equals( "org/bukkit/block/Biome" ) )
{
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..0000000000000000000000000000000000000000

View file

@ -4264,10 +4264,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper start
+ @Override
+ public CraftObjective registerNewObjective(String name, String criteria, net.kyori.adventure.text.Component displayName) {
+ return registerNewObjective(name, criteria, displayName, org.bukkit.scoreboard.RenderType.INTEGER);
+ return registerNewObjective(name, CraftCriteria.getFromBukkit(criteria), displayName, RenderType.INTEGER);
+ }
+ @Override
+ public CraftObjective registerNewObjective(String name, String criteria, net.kyori.adventure.text.Component displayName, RenderType renderType) {
+ return registerNewObjective(name, CraftCriteria.getFromBukkit(criteria), displayName, renderType);
+ }
+ @Override
+ public CraftObjective registerNewObjective(String name, Criteria criteria, net.kyori.adventure.text.Component displayName) throws IllegalArgumentException {
+ return registerNewObjective(name, criteria, displayName, RenderType.INTEGER);
+ }
+ @Override
+ public CraftObjective registerNewObjective(String name, Criteria criteria, net.kyori.adventure.text.Component displayName, RenderType renderType) throws IllegalArgumentException {
+ if (displayName == null) {
+ displayName = net.kyori.adventure.text.Component.empty();
+ }
@ -4277,8 +4285,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ Validate.notNull(renderType, "RenderType cannot be null");
+ Validate.isTrue(name.length() <= Short.MAX_VALUE, "The name '" + name + "' is longer than the limit of 32767 characters");
+ Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists");
+ CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
+ net.minecraft.world.scores.Objective objective = board.addObjective(name, craftCriteria.criteria, io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
+ net.minecraft.world.scores.Objective objective = board.addObjective(name, ((CraftCriteria) criteria).criteria, io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
+ return new CraftObjective(this, objective);
+ }
+ // Paper end
@ -4288,21 +4295,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
@Override
public CraftObjective registerNewObjective(String name, String criteria, String displayName, RenderType renderType) throws IllegalArgumentException {
public CraftObjective registerNewObjective(String name, Criteria criteria, String displayName, RenderType renderType) throws IllegalArgumentException {
- Validate.notNull(name, "Objective name cannot be null");
+ /*Validate.notNull(name, "Objective name cannot be null"); // Paper
Validate.notNull(criteria, "Criteria cannot be null");
Validate.notNull(displayName, "Display name cannot be null");
Validate.notNull(renderType, "RenderType cannot be null");
@@ -0,0 +0,0 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
net.minecraft.world.scores.Objective objective = this.board.addObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
- Validate.notNull(criteria, "Criteria cannot be null");
- Validate.notNull(displayName, "Display name cannot be null");
- Validate.notNull(renderType, "RenderType cannot be null");
- Validate.isTrue(name.length() <= Short.MAX_VALUE, "The name '" + name + "' is longer than the limit of 32767 characters");
- Validate.isTrue(displayName.length() <= 128, "The display name '" + displayName + "' is longer than the limit of 128 characters");
- Validate.isTrue(this.board.getObjective(name) == null, "An objective of name '" + name + "' already exists");
-
- net.minecraft.world.scores.Objective objective = this.board.addObjective(name, ((CraftCriteria) criteria).criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
- return new CraftObjective(this, objective);
+
+ CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
+ ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
+ return new CraftObjective(this, objective);*/ // Paper
+ return registerNewObjective(name, criteria, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(displayName), renderType); // Paper
}

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java
+++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java
@@ -0,0 +0,0 @@ final class CraftCriteria {
@@ -0,0 +0,0 @@ public final class CraftCriteria implements Criteria {
}
static CraftCriteria getFromNMS(Objective objective) {
@ -16,17 +16,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return java.util.Objects.requireNonNullElseGet(CraftCriteria.DEFAULTS.get(objective.getCriteria().getName()), () -> new CraftCriteria(objective.getCriteria())); // Paper
}
static CraftCriteria getFromBukkit(String name) {
@@ -0,0 +0,0 @@ final class CraftCriteria {
if (criteria != null) {
return criteria;
}
+ // Paper start - fix criteria defaults
+ var nmsCriteria = ObjectiveCriteria.byName(name);
+ if (nmsCriteria.isPresent()) {
+ return new CraftCriteria(nmsCriteria.get());
+ }
+ // Paper end
return new CraftCriteria(name);
}
public static CraftCriteria getFromBukkit(String name) {

View file

@ -26,31 +26,18 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
CraftScoreboard(Scoreboard board) {
this.board = board;
@@ -0,0 +0,0 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
Validate.notNull(renderType, "RenderType cannot be null");
Validate.isTrue(name.length() <= Short.MAX_VALUE, "The name '" + name + "' is longer than the limit of 32767 characters");
Validate.isTrue(board.getObjective(name) == null, "An objective of name '" + name + "' already exists");
CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
+ // Paper start - the block comment from the old registerNewObjective didnt cause a conflict when rebasing, so this block wasn't added to the adventure registerNewObjective
+ if (craftCriteria.criteria != net.minecraft.world.scores.criteria.ObjectiveCriteria.DUMMY && !registeredGlobally) {
+ if (((CraftCriteria) criteria).criteria != net.minecraft.world.scores.criteria.ObjectiveCriteria.DUMMY && !registeredGlobally) {
+ net.minecraft.server.MinecraftServer.getServer().server.getScoreboardManager().registerScoreboardForVanilla(this);
+ registeredGlobally = true;
+ }
+ // Paper end
net.minecraft.world.scores.Objective objective = board.addObjective(name, craftCriteria.criteria, io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
net.minecraft.world.scores.Objective objective = board.addObjective(name, ((CraftCriteria) criteria).criteria, io.papermc.paper.adventure.PaperAdventure.asVanilla(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
return new CraftObjective(this, objective);
}
@@ -0,0 +0,0 @@ public final class CraftScoreboard implements org.bukkit.scoreboard.Scoreboard {
net.minecraft.world.scores.Objective objective = this.board.addObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
CraftCriteria craftCriteria = CraftCriteria.getFromBukkit(criteria);
+ // Paper start
+ if (craftCriteria.criteria != net.minecraft.server.IScoreboardCriteria.DUMMY && !registeredGlobally) {
+ net.minecraft.server.MinecraftServer.getServer().server.getScoreboardManager().registerScoreboardForVanilla(this);
+ registeredGlobally = true;
+ }
+ // Paper end
ScoreboardObjective objective = board.registerObjective(name, craftCriteria.criteria, CraftChatMessage.fromStringOrNull(displayName), CraftScoreboardTranslations.fromBukkitRender(renderType));
return new CraftObjective(this, objective);*/ // Paper
return registerNewObjective(name, criteria, net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(displayName), renderType); // Paper
diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftScoreboardManager.java

@ -1 +1 @@
Subproject commit bf60995c031e1c046dfe1a322b94298426eb2f84
Subproject commit d43a1e722f50396694cfaaa96f6059ca533d7b45

@ -1 +1 @@
Subproject commit ec2b5d4cd1f039ef34be82c2d3954fb1a88bf3b5
Subproject commit c379a6b4e421561edd6e1a62e2e4410f48bf1ab1