From 5ba2f654ebfa6d3a9536c5502275a06842617c6c Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Thu, 2 Jun 2022 21:42:00 -0700 Subject: [PATCH] Fix some nullability things (#7275) --- .../api/Fix-Spigot-annotation-mistakes.patch | 9 ----- patches/server/Adventure.patch | 4 +-- patches/server/CB-fixes.patch | 33 ++++++++++++++++--- 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/patches/api/Fix-Spigot-annotation-mistakes.patch b/patches/api/Fix-Spigot-annotation-mistakes.patch index 5321f7cd61..c741329241 100644 --- a/patches/api/Fix-Spigot-annotation-mistakes.patch +++ b/patches/api/Fix-Spigot-annotation-mistakes.patch @@ -33,15 +33,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 public static ScoreboardManager getScoreboardManager() { return server.getScoreboardManager(); } -@@ -0,0 +0,0 @@ public final class Bukkit { - * @param clazz the class of the tag entries - * @return the tag or null - */ -- @Nullable -+ @UndefinedNullability // Paper - public static Tag getTag(@NotNull String registry, @NotNull NamespacedKey tag, @NotNull Class clazz) { - return server.getTag(registry, tag, clazz); - } diff --git a/src/main/java/org/bukkit/GrassSpecies.java b/src/main/java/org/bukkit/GrassSpecies.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/GrassSpecies.java diff --git a/patches/server/Adventure.patch b/patches/server/Adventure.patch index 261e63fdd1..e9b587dee0 100644 --- a/patches/server/Adventure.patch +++ b/patches/server/Adventure.patch @@ -1783,13 +1783,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 } + // Paper start - @Override ++ @Override + public net.kyori.adventure.text.Component shutdownMessage() { + String msg = getShutdownMessage(); + return msg != null ? net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(msg) : null; + } + // Paper end -+ @Override + @Override + @Deprecated // Paper public String getShutdownMessage() { return this.configuration.getString("settings.shutdown-message"); diff --git a/patches/server/CB-fixes.patch b/patches/server/CB-fixes.patch index e6f8c2f5a8..bae30828b4 100644 --- a/patches/server/CB-fixes.patch +++ b/patches/server/CB-fixes.patch @@ -1,16 +1,20 @@ From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: Spottedleaf +From: Jake Potrebic Date: Fri, 25 Feb 2022 07:14:48 -0800 Subject: [PATCH] CB fixes * Missing Level -> LevelStem generic in StructureCheck - Need to use the right for injectDatafixingContext + Need to use the right for injectDatafixingContext (Spottedleaf) -* Removed incorrect parent perm for `minecraft.debugstick.always` +* Removed incorrect parent perm for `minecraft.debugstick.always` (Machine_Maker) -* Fixed method signature of Marker#addPassenger +* Fixed method signature of Marker#addPassenger (Machine_Maker) -* Removed unneeded UOE in CustomWorldChunkManager (extends BiomeSource) +* Removed unneeded UOE in CustomWorldChunkManager (extends BiomeSource) (Machine_Maker) + +* Honor Server#getLootTable method contract (Machine_Maker) + +Co-authored-by: Spottedleaf diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 @@ -62,6 +66,25 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000 this.storageAccess = chunkIoWorker; this.registryAccess = registryManager; this.structureManager = structureManager; +diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 +--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java ++++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +@@ -0,0 +0,0 @@ public final class CraftServer implements Server { + Validate.notNull(key, "NamespacedKey cannot be null"); + + LootTables registry = this.getServer().getLootTables(); +- return new CraftLootTable(key, registry.get(CraftNamespacedKey.toMinecraft(key))); ++ // Paper start - honor method contract ++ final ResourceLocation lootTableKey = CraftNamespacedKey.toMinecraft(key); ++ if (!registry.getIds().contains(lootTableKey)) { ++ return null; ++ } ++ return new CraftLootTable(key, registry.get(lootTableKey)); ++ // Paper end + } + + @Override diff --git a/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java b/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644 --- a/src/main/java/org/bukkit/craftbukkit/generator/CustomWorldChunkManager.java