diff options
author | Jake Potrebic <[email protected]> | 2024-09-26 14:20:09 -0700 |
---|---|---|
committer | Jake Potrebic <[email protected]> | 2024-09-26 14:20:09 -0700 |
commit | 20ec62255da0374efed5026600321f715ad94282 (patch) | |
tree | ad901e58067d54c0873d71f1644a308142b7013d | |
parent | 1bc02e6b23bf18ba43054bf978769411bd96a04d (diff) | |
download | Paper-20ec62255da0374efed5026600321f715ad94282.tar.gz Paper-20ec62255da0374efed5026600321f715ad94282.zip |
use correct types for preloading CraftRegistry
also add a check in CraftRegistryEntry constructor to
make sure preload class isn't in net.minecraft package
-rw-r--r-- | patches/server/0471-Add-RegistryAccess-for-managing-Registries.patch | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/patches/server/0471-Add-RegistryAccess-for-managing-Registries.patch b/patches/server/0471-Add-RegistryAccess-for-managing-Registries.patch index 0469174819..18d4a70174 100644 --- a/patches/server/0471-Add-RegistryAccess-for-managing-Registries.patch +++ b/patches/server/0471-Add-RegistryAccess-for-managing-Registries.patch @@ -12,7 +12,7 @@ public net.minecraft.server.RegistryLayer STATIC_ACCESS diff --git a/src/main/java/io/papermc/paper/registry/PaperRegistries.java b/src/main/java/io/papermc/paper/registry/PaperRegistries.java new file mode 100644 -index 0000000000000000000000000000000000000000..c92ce42398a9bfd00eb4e05972289c521ee255cf +index 0000000000000000000000000000000000000000..633b01431750d4b40159a57bf25fb35c6670ff1b --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/PaperRegistries.java @@ -0,0 +1,146 @@ @@ -28,8 +28,6 @@ index 0000000000000000000000000000000000000000..c92ce42398a9bfd00eb4e05972289c52 +import net.minecraft.core.Registry; +import net.minecraft.core.registries.Registries; +import net.minecraft.resources.ResourceKey; -+import net.minecraft.world.item.enchantment.Enchantment; -+import net.minecraft.world.level.levelgen.structure.Structure; +import org.bukkit.GameEvent; +import org.bukkit.JukeboxSong; +import org.bukkit.Keyed; @@ -58,11 +56,13 @@ index 0000000000000000000000000000000000000000..c92ce42398a9bfd00eb4e05972289c52 +import org.bukkit.craftbukkit.potion.CraftPotionEffectType; +import org.bukkit.craftbukkit.util.CraftNamespacedKey; +import org.bukkit.damage.DamageType; ++import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Cat; +import org.bukkit.entity.Frog; +import org.bukkit.entity.Villager; +import org.bukkit.entity.Wolf; +import org.bukkit.entity.memory.MemoryKey; ++import org.bukkit.generator.structure.Structure; +import org.bukkit.generator.structure.StructureType; +import org.bukkit.inventory.ItemType; +import org.bukkit.inventory.MenuType; @@ -416,12 +416,13 @@ index 0000000000000000000000000000000000000000..ceb217dbbb84e8bd51365dd47bf91971 +} diff --git a/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java b/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java new file mode 100644 -index 0000000000000000000000000000000000000000..568984894a5463ccfa68bb6944b409ab0a2d7ad7 +index 0000000000000000000000000000000000000000..9bb4aa926978f117901c9f99c45a6862a1d5ce30 --- /dev/null +++ b/src/main/java/io/papermc/paper/registry/entry/CraftRegistryEntry.java -@@ -0,0 +1,49 @@ +@@ -0,0 +1,51 @@ +package io.papermc.paper.registry.entry; + ++import com.google.common.base.Preconditions; +import io.papermc.paper.registry.RegistryHolder; +import io.papermc.paper.registry.RegistryKey; +import java.util.function.BiFunction; @@ -450,6 +451,7 @@ index 0000000000000000000000000000000000000000..568984894a5463ccfa68bb6944b409ab + final BiFunction<NamespacedKey, M, B> minecraftToBukkit + ) { + super(mcKey, apiKey); ++ Preconditions.checkArgument(!classToPreload.getPackageName().startsWith("net.minecraft"), classToPreload + " should not be in the net.minecraft package as the class-to-preload"); + this.classToPreload = classToPreload; + this.minecraftToBukkit = minecraftToBukkit; + } |