mirror of
https://github.com/PaperMC/Paper.git
synced 2025-02-17 10:41:41 +01:00
#997: Change wolf variant from enum to interface
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
parent
4ba949cee7
commit
358a4da17e
2 changed files with 18 additions and 20 deletions
paper-api/src/main/java/org/bukkit
|
@ -271,7 +271,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
*
|
||||
* @see Wolf.Variant
|
||||
*/
|
||||
Registry<Wolf.Variant> WOLF_VARIANT = new SimpleRegistry<>(Wolf.Variant.class);
|
||||
Registry<Wolf.Variant> WOLF_VARIANT = Objects.requireNonNull(Bukkit.getRegistry(Wolf.Variant.class), "No registry present for Wolf Variant. This is a bug.");
|
||||
/**
|
||||
* Map cursor types.
|
||||
*
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package org.bukkit.entity;
|
||||
|
||||
import java.util.Locale;
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -89,27 +90,24 @@ public interface Wolf extends Tameable, Sittable {
|
|||
/**
|
||||
* Represents the variant of a wolf.
|
||||
*/
|
||||
public enum Variant implements Keyed {
|
||||
interface Variant extends Keyed {
|
||||
|
||||
PALE,
|
||||
SPOTTED,
|
||||
SNOWY,
|
||||
BLACK,
|
||||
ASHEN,
|
||||
RUSTY,
|
||||
WOODS,
|
||||
CHESTNUT,
|
||||
STRIPED;
|
||||
private final NamespacedKey key;
|
||||
|
||||
private Variant() {
|
||||
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
|
||||
}
|
||||
Variant PALE = getVariant("pale");
|
||||
Variant SPOTTED = getVariant("spotted");
|
||||
Variant SNOWY = getVariant("snowy");
|
||||
Variant BLACK = getVariant("black");
|
||||
Variant ASHEN = getVariant("ashen");
|
||||
Variant RUSTY = getVariant("rusty");
|
||||
Variant WOODS = getVariant("woods");
|
||||
Variant CHESTNUT = getVariant("chestnut");
|
||||
Variant STRIPED = getVariant("striped");
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue