use correct types for preloading CraftRegistry

also add a check in CraftRegistryEntry constructor to
make sure preload class isn't in net.minecraft package
This commit is contained in:
Jake Potrebic 2024-09-26 14:20:09 -07:00
parent ee957a53ba
commit ae51e7b8ff

View file

@ -28,8 +28,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+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..00000000000000000000000000000000
+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;
@ -422,6 +422,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@
+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..00000000000000000000000000000000
+ 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;
+ }