#1475: Add tests for Minecraft registry <-> Bukkit fields
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -279,6 +279,16 @@ public class CraftRegistry<B extends Keyed, M> implements Registry<B> {
|
||||
return bukkit;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public B getOrThrow(@NotNull NamespacedKey namespacedKey) {
|
||||
B object = get(namespacedKey);
|
||||
|
||||
Preconditions.checkArgument(object != null, "No registry entry found for key " + namespacedKey);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Stream<B> stream() {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.bukkit.craftbukkit.generator.structure;
|
||||
|
||||
import com.google.common.base.Suppliers;
|
||||
import java.util.function.Supplier;
|
||||
import net.minecraft.core.registries.Registries;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
@@ -20,12 +22,12 @@ public class CraftStructure extends Structure implements Handleable<net.minecraf
|
||||
|
||||
private final NamespacedKey key;
|
||||
private final net.minecraft.world.level.levelgen.structure.Structure structure;
|
||||
private final StructureType structureType;
|
||||
private final Supplier<StructureType> structureType;
|
||||
|
||||
public CraftStructure(NamespacedKey key, net.minecraft.world.level.levelgen.structure.Structure structure) {
|
||||
this.key = key;
|
||||
this.structure = structure;
|
||||
this.structureType = CraftStructureType.minecraftToBukkit(structure.type());
|
||||
this.structureType = Suppliers.memoize(() -> CraftStructureType.minecraftToBukkit(structure.type()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -35,7 +37,7 @@ public class CraftStructure extends Structure implements Handleable<net.minecraf
|
||||
|
||||
@Override
|
||||
public StructureType getStructureType() {
|
||||
return structureType;
|
||||
return structureType.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user