aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0799-Fix-CraftCriteria-defaults-map.patch
diff options
context:
space:
mode:
authorstonar96 <[email protected]>2021-11-29 12:55:13 +0100
committerMiniDigger | Martin <[email protected]>2021-11-30 19:26:33 +0100
commit4ab59e13260e61cecc85c9f4c09ff70db0a4d08e (patch)
tree10135ffd5471a2fb513eb1dcd1f74c5ca658f305 /patches/server/0799-Fix-CraftCriteria-defaults-map.patch
parentebb727e6299d2f4a7d6ff537b8c280ecaaef64fa (diff)
downloadPaper-4ab59e13260e61cecc85c9f4c09ff70db0a4d08e.tar.gz
Paper-4ab59e13260e61cecc85c9f4c09ff70db0a4d08e.zip
Port Anti-Xray to 1.18 (#6947)
Diffstat (limited to 'patches/server/0799-Fix-CraftCriteria-defaults-map.patch')
-rw-r--r--patches/server/0799-Fix-CraftCriteria-defaults-map.patch32
1 files changed, 32 insertions, 0 deletions
diff --git a/patches/server/0799-Fix-CraftCriteria-defaults-map.patch b/patches/server/0799-Fix-CraftCriteria-defaults-map.patch
new file mode 100644
index 0000000000..11fce3ca24
--- /dev/null
+++ b/patches/server/0799-Fix-CraftCriteria-defaults-map.patch
@@ -0,0 +1,32 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jake Potrebic <[email protected]>
+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);
+ }
+