From fdd5c6542317e01b7f8e952d308d7273d32bd2d8 Mon Sep 17 00:00:00 2001 From: Jake Potrebic <15055071+Machine-Maker@users.noreply.github.com> Date: Tue, 5 Oct 2021 10:24:36 -0700 Subject: [PATCH] Fix CraftCriteria defaults map (#6723) --- .../0817-Fix-CraftCriteria-defaults-map.patch | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 patches/server/0817-Fix-CraftCriteria-defaults-map.patch diff --git a/patches/server/0817-Fix-CraftCriteria-defaults-map.patch b/patches/server/0817-Fix-CraftCriteria-defaults-map.patch new file mode 100644 index 0000000000..11fce3ca24 --- /dev/null +++ b/patches/server/0817-Fix-CraftCriteria-defaults-map.patch @@ -0,0 +1,32 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: Jake Potrebic +Date: Mon, 4 Oct 2021 22:31:51 -0700 +Subject: [PATCH] Fix CraftCriteria defaults map + + +diff --git a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java +index 22801e33fa15322c37cd11d73a40a43fa721a8e4..0cd63772871311fc0cb7111657cc9a9dac106167 100644 +--- a/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java ++++ b/src/main/java/org/bukkit/craftbukkit/scoreboard/CraftCriteria.java +@@ -37,7 +37,7 @@ final class CraftCriteria { + } + + static CraftCriteria getFromNMS(Objective objective) { +- return CraftCriteria.DEFAULTS.get(objective.getCriteria().getName()); ++ return java.util.Objects.requireNonNullElseGet(CraftCriteria.DEFAULTS.get(objective.getCriteria().getName()), () -> new CraftCriteria(objective.getCriteria())); // Paper + } + + static CraftCriteria getFromBukkit(String name) { +@@ -45,6 +45,12 @@ 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); + } +