mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
#940: Create registry for banner pattern and cat type
By: Jishuna <joshl5324@gmail.com>
This commit is contained in:
parent
0c336e76ce
commit
460ea2aff9
3 changed files with 101 additions and 56 deletions
|
@ -12,8 +12,10 @@ import java.util.stream.StreamSupport;
|
|||
import org.bukkit.advancement.Advancement;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.banner.PatternType;
|
||||
import org.bukkit.boss.KeyedBossBar;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Cat;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Frog;
|
||||
import org.bukkit.entity.Villager;
|
||||
|
@ -75,6 +77,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
* @see Attribute
|
||||
*/
|
||||
Registry<Attribute> ATTRIBUTE = new SimpleRegistry<>(Attribute.class);
|
||||
/**
|
||||
* Server banner patterns.
|
||||
*
|
||||
* @see PatternType
|
||||
*/
|
||||
Registry<PatternType> BANNER_PATTERN = new SimpleRegistry<>(PatternType.class);
|
||||
/**
|
||||
* Server biomes.
|
||||
*
|
||||
|
@ -107,6 +115,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
return Bukkit.getBossBars();
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Server cat types.
|
||||
*
|
||||
* @see Cat.Type
|
||||
*/
|
||||
Registry<Cat.Type> CAT_VARIANT = new SimpleRegistry<>(Cat.Type.class);
|
||||
/**
|
||||
* Server enchantments.
|
||||
*
|
||||
|
|
|
@ -2,54 +2,58 @@ package org.bukkit.block.banner;
|
|||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.bukkit.Registry;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public enum PatternType {
|
||||
BASE("b"),
|
||||
SQUARE_BOTTOM_LEFT("bl"),
|
||||
SQUARE_BOTTOM_RIGHT("br"),
|
||||
SQUARE_TOP_LEFT("tl"),
|
||||
SQUARE_TOP_RIGHT("tr"),
|
||||
STRIPE_BOTTOM("bs"),
|
||||
STRIPE_TOP("ts"),
|
||||
STRIPE_LEFT("ls"),
|
||||
STRIPE_RIGHT("rs"),
|
||||
STRIPE_CENTER("cs"),
|
||||
STRIPE_MIDDLE("ms"),
|
||||
STRIPE_DOWNRIGHT("drs"),
|
||||
STRIPE_DOWNLEFT("dls"),
|
||||
STRIPE_SMALL("ss"),
|
||||
CROSS("cr"),
|
||||
STRAIGHT_CROSS("sc"),
|
||||
TRIANGLE_BOTTOM("bt"),
|
||||
TRIANGLE_TOP("tt"),
|
||||
TRIANGLES_BOTTOM("bts"),
|
||||
TRIANGLES_TOP("tts"),
|
||||
DIAGONAL_LEFT("ld"),
|
||||
DIAGONAL_RIGHT("rd"),
|
||||
DIAGONAL_LEFT_MIRROR("lud"),
|
||||
DIAGONAL_RIGHT_MIRROR("rud"),
|
||||
CIRCLE_MIDDLE("mc"),
|
||||
RHOMBUS_MIDDLE("mr"),
|
||||
HALF_VERTICAL("vh"),
|
||||
HALF_HORIZONTAL("hh"),
|
||||
HALF_VERTICAL_MIRROR("vhr"),
|
||||
HALF_HORIZONTAL_MIRROR("hhb"),
|
||||
BORDER("bo"),
|
||||
CURLY_BORDER("cbo"),
|
||||
CREEPER("cre"),
|
||||
GRADIENT("gra"),
|
||||
GRADIENT_UP("gru"),
|
||||
BRICKS("bri"),
|
||||
SKULL("sku"),
|
||||
FLOWER("flo"),
|
||||
MOJANG("moj"),
|
||||
GLOBE("glb"),
|
||||
PIGLIN("pig");
|
||||
public enum PatternType implements Keyed {
|
||||
BASE("b", "base"),
|
||||
SQUARE_BOTTOM_LEFT("bl", "square_bottom_left"),
|
||||
SQUARE_BOTTOM_RIGHT("br", "square_bottom_right"),
|
||||
SQUARE_TOP_LEFT("tl", "square_top_left"),
|
||||
SQUARE_TOP_RIGHT("tr", "square_top_right"),
|
||||
STRIPE_BOTTOM("bs", "stripe_bottom"),
|
||||
STRIPE_TOP("ts", "stripe_top"),
|
||||
STRIPE_LEFT("ls", "stripe_left"),
|
||||
STRIPE_RIGHT("rs", "stripe_right"),
|
||||
STRIPE_CENTER("cs", "stripe_center"),
|
||||
STRIPE_MIDDLE("ms", "stripe_middle"),
|
||||
STRIPE_DOWNRIGHT("drs", "stripe_downright"),
|
||||
STRIPE_DOWNLEFT("dls", "stripe_downleft"),
|
||||
STRIPE_SMALL("ss", "small_stripes"),
|
||||
CROSS("cr", "cross"),
|
||||
STRAIGHT_CROSS("sc", "straight_cross"),
|
||||
TRIANGLE_BOTTOM("bt", "triangle_bottom"),
|
||||
TRIANGLE_TOP("tt", "triangle_top"),
|
||||
TRIANGLES_BOTTOM("bts", "triangles_bottom"),
|
||||
TRIANGLES_TOP("tts", "triangles_top"),
|
||||
DIAGONAL_LEFT("ld", "diagonal_left"),
|
||||
DIAGONAL_RIGHT("rd", "diagonal_up_right"), //PAIL - Why are these keys swapped?
|
||||
DIAGONAL_LEFT_MIRROR("lud", "diagonal_up_left"),
|
||||
DIAGONAL_RIGHT_MIRROR("rud", "diagonal_right"), //PAIL - Why are these keys swapped?
|
||||
CIRCLE_MIDDLE("mc", "circle"),
|
||||
RHOMBUS_MIDDLE("mr", "rhombus"),
|
||||
HALF_VERTICAL("vh", "half_vertical"),
|
||||
HALF_HORIZONTAL("hh", "half_horizontal"),
|
||||
HALF_VERTICAL_MIRROR("vhr", "half_vertical_right"),
|
||||
HALF_HORIZONTAL_MIRROR("hhb", "half_horizontal_bottom"),
|
||||
BORDER("bo", "border"),
|
||||
CURLY_BORDER("cbo", "curly_border"),
|
||||
CREEPER("cre", "creeper"),
|
||||
GRADIENT("gra", "gradient"),
|
||||
GRADIENT_UP("gru", "gradient_up"),
|
||||
BRICKS("bri", "bricks"),
|
||||
SKULL("sku", "skull"),
|
||||
FLOWER("flo", "flower"),
|
||||
MOJANG("moj", "mojang"),
|
||||
GLOBE("glb", "globe"),
|
||||
PIGLIN("pig", "piglin");
|
||||
|
||||
private final String identifier;
|
||||
private final NamespacedKey key;
|
||||
private static final Map<String, PatternType> byString = new HashMap<String, PatternType>();
|
||||
|
||||
static {
|
||||
|
@ -58,8 +62,15 @@ public enum PatternType {
|
|||
}
|
||||
}
|
||||
|
||||
private PatternType(/*@NotNull*/ String key) {
|
||||
this.identifier = key;
|
||||
private PatternType(/*@NotNull*/ String identifier, String key) {
|
||||
this.identifier = identifier;
|
||||
this.key = NamespacedKey.minecraft(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,8 +78,11 @@ public enum PatternType {
|
|||
* this pattern type
|
||||
*
|
||||
* @return the pattern's identifier
|
||||
* @see #getKey
|
||||
* @deprecated magic value
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public String getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
|
@ -79,9 +93,12 @@ public enum PatternType {
|
|||
*
|
||||
* @param identifier the identifier
|
||||
* @return the matched pattern type or null
|
||||
* @see Registry#BANNER_PATTERN
|
||||
* @deprecated magic value, use {@link Registry#get(NamespacedKey)} instead
|
||||
*/
|
||||
@Contract("null -> null")
|
||||
@Nullable
|
||||
@Deprecated
|
||||
public static PatternType getByIdentifier(@Nullable String identifier) {
|
||||
return byString.get(identifier);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package org.bukkit.entity;
|
||||
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Keyed;
|
||||
import org.bukkit.NamespacedKey;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
|
@ -41,17 +43,29 @@ public interface Cat extends Tameable, Sittable {
|
|||
/**
|
||||
* Represents the various different cat types there are.
|
||||
*/
|
||||
public enum Type {
|
||||
TABBY,
|
||||
BLACK,
|
||||
RED,
|
||||
SIAMESE,
|
||||
BRITISH_SHORTHAIR,
|
||||
CALICO,
|
||||
PERSIAN,
|
||||
RAGDOLL,
|
||||
WHITE,
|
||||
JELLIE,
|
||||
ALL_BLACK;
|
||||
public enum Type implements Keyed {
|
||||
TABBY("tabby"),
|
||||
BLACK("black"),
|
||||
RED("red"),
|
||||
SIAMESE("siamese"),
|
||||
BRITISH_SHORTHAIR("british_shorthair"),
|
||||
CALICO("calico"),
|
||||
PERSIAN("persian"),
|
||||
RAGDOLL("ragdoll"),
|
||||
WHITE("white"),
|
||||
JELLIE("jellie"),
|
||||
ALL_BLACK("all_black");
|
||||
|
||||
private final NamespacedKey key;
|
||||
|
||||
private Type(String key) {
|
||||
this.key = NamespacedKey.minecraft(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public NamespacedKey getKey() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue