#1058: Add tests for Minecraft registry <-> Bukkit fields

By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
Bukkit/Spigot
2024-09-27 08:15:05 +10:00
parent 49d12d442a
commit 42cd6c82ff
21 changed files with 147 additions and 121 deletions

View File

@@ -64,11 +64,7 @@ public interface Cat extends Tameable, Sittable {
@NotNull
private static Type getType(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
Type type = Registry.CAT_VARIANT.get(namespacedKey);
Preconditions.checkNotNull(type, "No cat type found for %s. This is a bug.", namespacedKey);
return type;
return Registry.CAT_VARIANT.getOrThrow(NamespacedKey.minecraft(key));
}
/**

View File

@@ -65,11 +65,7 @@ public interface Frog extends Animals {
@NotNull
private static Variant getVariant(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
Variant variant = Registry.FROG_VARIANT.get(namespacedKey);
Preconditions.checkNotNull(variant, "No frog variant found for %s. This is a bug.", namespacedKey);
return variant;
return Registry.FROG_VARIANT.getOrThrow(NamespacedKey.minecraft(key));
}
/**

View File

@@ -134,11 +134,7 @@ public interface Villager extends AbstractVillager {
@NotNull
private static Type getType(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
Type type = Registry.VILLAGER_TYPE.get(namespacedKey);
Preconditions.checkNotNull(type, "No villager type found for %s. This is a bug.", namespacedKey);
return type;
return Registry.VILLAGER_TYPE.getOrThrow(NamespacedKey.minecraft(key));
}
/**
@@ -245,11 +241,7 @@ public interface Villager extends AbstractVillager {
@NotNull
private static Profession getProfession(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
Profession profession = Registry.VILLAGER_PROFESSION.get(namespacedKey);
Preconditions.checkNotNull(profession, "No villager profession found for %s. This is a bug.", namespacedKey);
return profession;
return Registry.VILLAGER_PROFESSION.getOrThrow(NamespacedKey.minecraft(key));
}
/**

View File

@@ -1,6 +1,5 @@
package org.bukkit.entity;
import com.google.common.base.Preconditions;
import org.bukkit.DyeColor;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
@@ -104,10 +103,7 @@ public interface Wolf extends Tameable, Sittable {
@NotNull
private static Variant getVariant(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
Variant variant = Registry.WOLF_VARIANT.get(namespacedKey);
Preconditions.checkNotNull(variant, "No Wolf Variant found for %s. This is a bug.", namespacedKey);
return variant;
return Registry.WOLF_VARIANT.getOrThrow(NamespacedKey.minecraft(key));
}
}
}