mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-06 07:02:18 -07:00
#997: Change wolf variant from enum to interface
By: DerFrZocker <derrieple@gmail.com>
This commit is contained in:
@@ -271,7 +271,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||||||
*
|
*
|
||||||
* @see Wolf.Variant
|
* @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.
|
* Map cursor types.
|
||||||
*
|
*
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
package org.bukkit.entity;
|
package org.bukkit.entity;
|
||||||
|
|
||||||
import java.util.Locale;
|
import com.google.common.base.Preconditions;
|
||||||
import org.bukkit.DyeColor;
|
import org.bukkit.DyeColor;
|
||||||
import org.bukkit.Keyed;
|
import org.bukkit.Keyed;
|
||||||
import org.bukkit.NamespacedKey;
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Registry;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -89,27 +90,24 @@ public interface Wolf extends Tameable, Sittable {
|
|||||||
/**
|
/**
|
||||||
* Represents the variant of a wolf.
|
* Represents the variant of a wolf.
|
||||||
*/
|
*/
|
||||||
public enum Variant implements Keyed {
|
interface Variant extends Keyed {
|
||||||
|
|
||||||
PALE,
|
Variant PALE = getVariant("pale");
|
||||||
SPOTTED,
|
Variant SPOTTED = getVariant("spotted");
|
||||||
SNOWY,
|
Variant SNOWY = getVariant("snowy");
|
||||||
BLACK,
|
Variant BLACK = getVariant("black");
|
||||||
ASHEN,
|
Variant ASHEN = getVariant("ashen");
|
||||||
RUSTY,
|
Variant RUSTY = getVariant("rusty");
|
||||||
WOODS,
|
Variant WOODS = getVariant("woods");
|
||||||
CHESTNUT,
|
Variant CHESTNUT = getVariant("chestnut");
|
||||||
STRIPED;
|
Variant STRIPED = getVariant("striped");
|
||||||
private final NamespacedKey key;
|
|
||||||
|
|
||||||
private Variant() {
|
|
||||||
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
private static Variant getVariant(@NotNull String key) {
|
||||||
public NamespacedKey getKey() {
|
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
|
||||||
return key;
|
Variant variant = Registry.WOLF_VARIANT.get(namespacedKey);
|
||||||
|
Preconditions.checkNotNull(variant, "No Wolf Variant found for %s. This is a bug.", namespacedKey);
|
||||||
|
return variant;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user