Merge branch 'master' into new-api/poi

This commit is contained in:
Miles Holder 2024-11-14 08:54:17 -06:00
commit 8cb7e00677
No known key found for this signature in database
GPG key ID: B9CBACC92C5C094C
25 changed files with 2241 additions and 1950 deletions

View file

@ -5,7 +5,7 @@
<groupId>org.bukkit</groupId> <groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId> <artifactId>bukkit</artifactId>
<version>1.21.2-R0.1-SNAPSHOT</version> <version>1.21.3-R0.1-SNAPSHOT</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>Bukkit</name> <name>Bukkit</name>

View file

@ -1,77 +1,77 @@
package org.bukkit; package org.bukkit;
import com.google.common.base.Preconditions; import com.google.common.base.Preconditions;
import com.google.common.collect.Maps; import com.google.common.collect.Lists;
import java.util.HashMap;
import java.util.Locale; import java.util.Locale;
import org.bukkit.packs.DataPack;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
/** /**
* Represents the art on a painting * Represents the art on a painting.
* <p>
* The arts listed in this interface are present in the default server
* or can be enabled via a {@link FeatureFlag}.
* There may be additional arts present in the server, for example from a {@link DataPack}
* which can be accessed via {@link Registry#ART}.
*/ */
public enum Art implements Keyed { public interface Art extends OldEnum<Art>, Keyed {
KEBAB(0, 1, 1),
AZTEC(1, 1, 1),
ALBAN(2, 1, 1),
AZTEC2(3, 1, 1),
BOMB(4, 1, 1),
PLANT(5, 1, 1),
WASTELAND(6, 1, 1),
POOL(7, 2, 1),
COURBET(8, 2, 1),
SEA(9, 2, 1),
SUNSET(10, 2, 1),
CREEBET(11, 2, 1),
WANDERER(12, 1, 2),
GRAHAM(13, 1, 2),
MATCH(14, 2, 2),
BUST(15, 2, 2),
STAGE(16, 2, 2),
VOID(17, 2, 2),
SKULL_AND_ROSES(18, 2, 2),
WITHER(19, 2, 2),
FIGHTERS(20, 4, 2),
POINTER(21, 4, 4),
PIGSCENE(22, 4, 4),
BURNING_SKULL(23, 4, 4),
SKELETON(24, 4, 3),
DONKEY_KONG(25, 4, 3),
EARTH(26, 2, 2),
WIND(27, 2, 2),
WATER(28, 2, 2),
FIRE(29, 2, 2),
BAROQUE(30, 2, 2),
HUMBLE(31, 2, 2),
MEDITATIVE(32, 1, 1),
PRAIRIE_RIDE(33, 1, 2),
UNPACKED(34, 4, 4),
BACKYARD(35, 3, 4),
BOUQUET(36, 3, 3),
CAVEBIRD(37, 3, 3),
CHANGING(38, 4, 2),
COTAN(39, 3, 3),
ENDBOSS(40, 3, 3),
FERN(41, 3, 3),
FINDING(42, 4, 2),
LOWMIST(43, 4, 2),
ORB(44, 4, 4),
OWLEMONS(45, 3, 3),
PASSAGE(46, 4, 2),
POND(47, 3, 4),
SUNFLOWERS(48, 3, 3),
TIDES(49, 3, 3);
private final int id, width, height; Art KEBAB = getArt("kebab");
private final NamespacedKey key; Art AZTEC = getArt("aztec");
private static final HashMap<String, Art> BY_NAME = Maps.newHashMap(); Art ALBAN = getArt("alban");
private static final HashMap<Integer, Art> BY_ID = Maps.newHashMap(); Art AZTEC2 = getArt("aztec2");
Art BOMB = getArt("bomb");
Art PLANT = getArt("plant");
Art WASTELAND = getArt("wasteland");
Art POOL = getArt("pool");
Art COURBET = getArt("courbet");
Art SEA = getArt("sea");
Art SUNSET = getArt("sunset");
Art CREEBET = getArt("creebet");
Art WANDERER = getArt("wanderer");
Art GRAHAM = getArt("graham");
Art MATCH = getArt("match");
Art BUST = getArt("bust");
Art STAGE = getArt("stage");
Art VOID = getArt("void");
Art SKULL_AND_ROSES = getArt("skull_and_roses");
Art WITHER = getArt("wither");
Art FIGHTERS = getArt("fighters");
Art POINTER = getArt("pointer");
Art PIGSCENE = getArt("pigscene");
Art BURNING_SKULL = getArt("burning_skull");
Art SKELETON = getArt("skeleton");
Art DONKEY_KONG = getArt("donkey_kong");
Art EARTH = getArt("earth");
Art WIND = getArt("wind");
Art WATER = getArt("water");
Art FIRE = getArt("fire");
Art BAROQUE = getArt("baroque");
Art HUMBLE = getArt("humble");
Art MEDITATIVE = getArt("meditative");
Art PRAIRIE_RIDE = getArt("prairie_ride");
Art UNPACKED = getArt("unpacked");
Art BACKYARD = getArt("backyard");
Art BOUQUET = getArt("bouquet");
Art CAVEBIRD = getArt("cavebird");
Art CHANGING = getArt("changing");
Art COTAN = getArt("cotan");
Art ENDBOSS = getArt("endboss");
Art FERN = getArt("fern");
Art FINDING = getArt("finding");
Art LOWMIST = getArt("lowmist");
Art ORB = getArt("orb");
Art OWLEMONS = getArt("owlemons");
Art PASSAGE = getArt("passage");
Art POND = getArt("pond");
Art SUNFLOWERS = getArt("sunflowers");
Art TIDES = getArt("tides");
private Art(int id, int width, int height) { @NotNull
this.id = id; private static Art getArt(@NotNull String key) {
this.width = width; return Registry.ART.getOrThrow(NamespacedKey.minecraft(key));
this.height = height;
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
} }
/** /**
@ -79,18 +79,14 @@ public enum Art implements Keyed {
* *
* @return The width of the painting, in blocks * @return The width of the painting, in blocks
*/ */
public int getBlockWidth() { int getBlockWidth();
return width;
}
/** /**
* Gets the height of the painting, in blocks * Gets the height of the painting, in blocks
* *
* @return The height of the painting, in blocks * @return The height of the painting, in blocks
*/ */
public int getBlockHeight() { int getBlockHeight();
return height;
}
/** /**
* Get the ID of this painting. * Get the ID of this painting.
@ -98,16 +94,8 @@ public enum Art implements Keyed {
* @return The ID of this painting * @return The ID of this painting
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @Deprecated(since = "1.6.2")
public int getId() { int getId();
return id;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/** /**
* Get a painting by its numeric ID * Get a painting by its numeric ID
@ -116,31 +104,55 @@ public enum Art implements Keyed {
* @return The painting * @return The painting
* @deprecated Magic value * @deprecated Magic value
*/ */
@Deprecated @Deprecated(since = "1.6.2")
@Nullable @Nullable
public static Art getById(int id) { static Art getById(int id) {
return BY_ID.get(id); for (Art art : Registry.ART) {
if (id == art.getId()) {
return art;
}
}
return null;
} }
/** /**
* Get a painting by its unique name * Get a painting by its unique name
* <p> * <p>
* This ignores underscores and capitalization * This ignores capitalization
* *
* @param name The name * @param name The name
* @return The painting * @return The painting
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/ */
@Deprecated(since = "1.21.3")
@Nullable @Nullable
public static Art getByName(@NotNull String name) { static Art getByName(@NotNull String name) {
Preconditions.checkArgument(name != null, "Name cannot be null"); Preconditions.checkArgument(name != null, "Name cannot be null");
return BY_NAME.get(name.toLowerCase(Locale.ROOT)); return Bukkit.getUnsafe().get(Registry.ART, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
} }
static { /**
for (Art art : values()) { * @param name of the art.
BY_ID.put(art.id, art); * @return the art with the given name.
BY_NAME.put(art.toString().toLowerCase(Locale.ROOT), art); * @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Art valueOf(@NotNull String name) {
Art art = Bukkit.getUnsafe().get(Registry.ART, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(art != null, "No art found with the name %s", name);
return art;
} }
/**
* @return an array of all known arts.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Art[] values() {
return Lists.newArrayList(Registry.ART).toArray(new Art[0]);
} }
} }

View file

@ -1845,6 +1845,30 @@ public final class Bukkit {
return server.getIdleTimeout(); return server.getIdleTimeout();
} }
/**
* Gets the pause when empty threshold seconds. To save resources, the
* server will pause most functions after this time if there are no players
* online.
*
* @return the pause threshold in seconds
*/
public static int getPauseWhenEmptyTime() {
return server.getPauseWhenEmptyTime();
}
/**
* Sets the pause when empty threshold seconds. To save resources, the
* server will pause most functions after this time if there are no players
* online.
* <p>
* A value of less than 0 will disable the setting
*
* @param seconds the pause threshold in seconds
*/
public static void setPauseWhenEmptyTime(int seconds) {
server.setPauseWhenEmptyTime(seconds);
}
/** /**
* Create a ChunkData for use in a generator. * Create a ChunkData for use in a generator.
* *

View file

@ -1,39 +1,62 @@
package org.bukkit; package org.bukkit;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale; import java.util.Locale;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
* Represents a fluid type. * Represents a fluid type.
*/ */
public enum Fluid implements Keyed { public interface Fluid extends OldEnum<Fluid>, Keyed {
/**
* No fluid.
*/
Fluid EMPTY = getFluid("empty");
/** /**
* Stationary water. * Stationary water.
*/ */
WATER, Fluid WATER = getFluid("water");
/** /**
* Flowing water. * Flowing water.
*/ */
FLOWING_WATER, Fluid FLOWING_WATER = getFluid("flowing_water");
/** /**
* Stationary lava. * Stationary lava.
*/ */
LAVA, Fluid LAVA = getFluid("lava");
/** /**
* Flowing lava. * Flowing lava.
*/ */
FLOWING_LAVA; Fluid FLOWING_LAVA = getFluid("flowing_lava");
private final NamespacedKey key;
private Fluid() {
this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT));
}
@NotNull @NotNull
@Override private static Fluid getFluid(@NotNull String key) {
public NamespacedKey getKey() { return Registry.FLUID.getOrThrow(NamespacedKey.minecraft(key));
return key; }
/**
* @param name of the fluid.
* @return the fluid with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Fluid valueOf(@NotNull String name) {
Fluid fluid = Bukkit.getUnsafe().get(Registry.FLUID, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(fluid != null, "No fluid found with the name %s", name);
return fluid;
}
/**
* @return an array of all known fluids.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Fluid[] values() {
return Lists.newArrayList(Registry.FLUID).toArray(new Fluid[0]);
} }
} }

View file

@ -0,0 +1,59 @@
package org.bukkit;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents a movement input applied to an entity.
*/
@ApiStatus.Experimental
public interface Input {
/**
* Gets whether a forward input is applied.
*
* @return forward input
*/
boolean isForward();
/**
* Gets whether a backward input is applied.
*
* @return backward input
*/
boolean isBackward();
/**
* Gets whether a left input is applied.
*
* @return left input
*/
boolean isLeft();
/**
* Gets whether a right input is applied.
*
* @return right input
*/
boolean isRight();
/**
* Gets whether a jump input is applied.
*
* @return jump input
*/
boolean isJump();
/**
* Gets whether a sneak input is applied.
*
* @return sneak input
*/
boolean isSneak();
/**
* Gets whether a sprint input is applied.
*
* @return sprint input
*/
boolean isSprint();
}

View file

@ -88,13 +88,13 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* *
* @see Art * @see Art
*/ */
Registry<Art> ART = new SimpleRegistry<>(Art.class); Registry<Art> ART = Objects.requireNonNull(Bukkit.getRegistry(Art.class), "No registry present for Art. This is a bug.");
/** /**
* Attribute. * Attribute.
* *
* @see Attribute * @see Attribute
*/ */
Registry<Attribute> ATTRIBUTE = new SimpleRegistry<>(Attribute.class); Registry<Attribute> ATTRIBUTE = Objects.requireNonNull(Bukkit.getRegistry(Attribute.class), "No registry present for Attribute. This is a bug.");
/** /**
* Server banner patterns. * Server banner patterns.
* *
@ -106,7 +106,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* *
* @see Biome * @see Biome
*/ */
Registry<Biome> BIOME = new SimpleRegistry<>(Biome.class); Registry<Biome> BIOME = Objects.requireNonNull(Bukkit.getRegistry(Biome.class), "No registry present for Biome. This is a bug.");
/** /**
* Server block types. * Server block types.
* *
@ -243,7 +243,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* *
* @see Sound * @see Sound
*/ */
Registry<Sound> SOUNDS = new SimpleRegistry<>(Sound.class); Registry<Sound> SOUNDS = Objects.requireNonNull(Bukkit.getRegistry(Sound.class), "No registry present for Sound. This is a bug.");
/** /**
* Trim materials. * Trim materials.
* *
@ -324,7 +324,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* *
* @see Fluid * @see Fluid
*/ */
Registry<Fluid> FLUID = new SimpleRegistry<>(Fluid.class); Registry<Fluid> FLUID = Objects.requireNonNull(Bukkit.getRegistry(Fluid.class), "No registry present for Fluid. This is a bug.");
/** /**
* Frog variants. * Frog variants.
* *

View file

@ -1565,6 +1565,24 @@ public interface Server extends PluginMessageRecipient {
*/ */
public int getIdleTimeout(); public int getIdleTimeout();
/**
* Gets the pause when empty threshold seconds. To save resources, the
* pause most functions after this time if there are no players online.
*
* @return the pause threshold in seconds
*/
public int getPauseWhenEmptyTime();
/**
* Sets the pause when empty threshold seconds. To save resources, the
* pause most functions after this time if there are no players online.
* <p>
* A value of less than 0 will disable the setting
*
* @param seconds the pause threshold in seconds
*/
public void setPauseWhenEmptyTime(int seconds);
/** /**
* Create a ChunkData for use in a generator. * Create a ChunkData for use in a generator.
* *

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,7 @@
package org.bukkit; package org.bukkit;
import org.jetbrains.annotations.ApiStatus;
/** /**
* Tree and organic structure types. * Tree and organic structure types.
*/ */
@ -101,4 +103,16 @@ public enum TreeType {
* Cherry tree * Cherry tree
*/ */
CHERRY, CHERRY,
/**
* Pale oak tree
*/
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
PALE_OAK,
/**
* Pale oak tree with a creaking heart
*/
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
PALE_OAK_CREAKING,
} }

View file

@ -4,6 +4,7 @@ import com.google.common.collect.Multimap;
import org.bukkit.advancement.Advancement; import org.bukkit.advancement.Advancement;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData; import org.bukkit.block.data.BlockData;
import org.bukkit.damage.DamageEffect; import org.bukkit.damage.DamageEffect;
import org.bukkit.damage.DamageSource; import org.bukkit.damage.DamageSource;
@ -99,6 +100,7 @@ public interface UnsafeValues {
String getTranslationKey(ItemStack itemStack); String getTranslationKey(ItemStack itemStack);
@Deprecated(since = "1.21.3", forRemoval = true)
String getTranslationKey(Attribute attribute); String getTranslationKey(Attribute attribute);
@Nullable @Nullable
@ -134,6 +136,9 @@ public interface UnsafeValues {
@ApiStatus.Internal @ApiStatus.Internal
<B extends Keyed> B get(Registry<B> registry, NamespacedKey key); <B extends Keyed> B get(Registry<B> registry, NamespacedKey key);
@ApiStatus.Internal
Biome getCustomBiome();
@ApiStatus.Internal @ApiStatus.Internal
PoiType.Occupancy createOccupancy(String key); PoiType.Occupancy createOccupancy(String key);
} }

View file

@ -1,160 +1,175 @@
package org.bukkit.attribute; package org.bukkit.attribute;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Keyed; import org.bukkit.Keyed;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Translatable; import org.bukkit.Translatable;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
* Types of attributes which may be present on an {@link Attributable}. * Types of attributes which may be present on an {@link Attributable}.
*/ */
public enum Attribute implements Keyed, Translatable { public interface Attribute extends OldEnum<Attribute>, Keyed, Translatable {
/** /**
* Maximum health of an Entity. * Maximum health of an Entity.
*/ */
GENERIC_MAX_HEALTH("max_health"), Attribute MAX_HEALTH = getAttribute("max_health");
/** /**
* Range at which an Entity will follow others. * Range at which an Entity will follow others.
*/ */
GENERIC_FOLLOW_RANGE("follow_range"), Attribute FOLLOW_RANGE = getAttribute("follow_range");
/** /**
* Resistance of an Entity to knockback. * Resistance of an Entity to knockback.
*/ */
GENERIC_KNOCKBACK_RESISTANCE("knockback_resistance"), Attribute KNOCKBACK_RESISTANCE = getAttribute("knockback_resistance");
/** /**
* Movement speed of an Entity. * Movement speed of an Entity.
*/ */
GENERIC_MOVEMENT_SPEED("movement_speed"), Attribute MOVEMENT_SPEED = getAttribute("movement_speed");
/** /**
* Flying speed of an Entity. * Flying speed of an Entity.
*/ */
GENERIC_FLYING_SPEED("flying_speed"), Attribute FLYING_SPEED = getAttribute("flying_speed");
/** /**
* Attack damage of an Entity. * Attack damage of an Entity.
*/ */
GENERIC_ATTACK_DAMAGE("attack_damage"), Attribute ATTACK_DAMAGE = getAttribute("attack_damage");
/** /**
* Attack knockback of an Entity. * Attack knockback of an Entity.
*/ */
GENERIC_ATTACK_KNOCKBACK("attack_knockback"), Attribute ATTACK_KNOCKBACK = getAttribute("attack_knockback");
/** /**
* Attack speed of an Entity. * Attack speed of an Entity.
*/ */
GENERIC_ATTACK_SPEED("attack_speed"), Attribute ATTACK_SPEED = getAttribute("attack_speed");
/** /**
* Armor bonus of an Entity. * Armor bonus of an Entity.
*/ */
GENERIC_ARMOR("armor"), Attribute ARMOR = getAttribute("armor");
/** /**
* Armor durability bonus of an Entity. * Armor durability bonus of an Entity.
*/ */
GENERIC_ARMOR_TOUGHNESS("armor_toughness"), Attribute ARMOR_TOUGHNESS = getAttribute("armor_toughness");
/** /**
* The fall damage multiplier of an Entity. * The fall damage multiplier of an Entity.
*/ */
GENERIC_FALL_DAMAGE_MULTIPLIER("fall_damage_multiplier"), Attribute FALL_DAMAGE_MULTIPLIER = getAttribute("fall_damage_multiplier");
/** /**
* Luck bonus of an Entity. * Luck bonus of an Entity.
*/ */
GENERIC_LUCK("luck"), Attribute LUCK = getAttribute("luck");
/** /**
* Maximum absorption of an Entity. * Maximum absorption of an Entity.
*/ */
GENERIC_MAX_ABSORPTION("max_absorption"), Attribute MAX_ABSORPTION = getAttribute("max_absorption");
/** /**
* The distance which an Entity can fall without damage. * The distance which an Entity can fall without damage.
*/ */
GENERIC_SAFE_FALL_DISTANCE("safe_fall_distance"), Attribute SAFE_FALL_DISTANCE = getAttribute("safe_fall_distance");
/** /**
* The relative scale of an Entity. * The relative scale of an Entity.
*/ */
GENERIC_SCALE("scale"), Attribute SCALE = getAttribute("scale");
/** /**
* The height which an Entity can walk over. * The height which an Entity can walk over.
*/ */
GENERIC_STEP_HEIGHT("step_height"), Attribute STEP_HEIGHT = getAttribute("step_height");
/** /**
* The gravity applied to an Entity. * The gravity applied to an Entity.
*/ */
GENERIC_GRAVITY("gravity"), Attribute GRAVITY = getAttribute("gravity");
/** /**
* Strength with which an Entity will jump. * Strength with which an Entity will jump.
*/ */
GENERIC_JUMP_STRENGTH("jump_strength"), Attribute JUMP_STRENGTH = getAttribute("jump_strength");
/** /**
* How long an entity remains burning after ingition. * How long an entity remains burning after ingition.
*/ */
GENERIC_BURNING_TIME("burning_time"), Attribute BURNING_TIME = getAttribute("burning_time");
/** /**
* Resistance to knockback from explosions. * Resistance to knockback from explosions.
*/ */
GENERIC_EXPLOSION_KNOCKBACK_RESISTANCE("explosion_knockback_resistance"), Attribute EXPLOSION_KNOCKBACK_RESISTANCE = getAttribute("explosion_knockback_resistance");
/** /**
* Movement speed through difficult terrain. * Movement speed through difficult terrain.
*/ */
GENERIC_MOVEMENT_EFFICIENCY("movement_efficiency"), Attribute MOVEMENT_EFFICIENCY = getAttribute("movement_efficiency");
/** /**
* Oxygen use underwater. * Oxygen use underwater.
*/ */
GENERIC_OXYGEN_BONUS("oxygen_bonus"), Attribute OXYGEN_BONUS = getAttribute("oxygen_bonus");
/** /**
* Movement speed through water. * Movement speed through water.
*/ */
GENERIC_WATER_MOVEMENT_EFFICIENCY("water_movement_efficiency"), Attribute WATER_MOVEMENT_EFFICIENCY = getAttribute("water_movement_efficiency");
/** /**
* Range at which mobs will be tempted by items. * Range at which mobs will be tempted by items.
*/ */
GENERIC_TEMPT_RANGE("tempt_range"), Attribute TEMPT_RANGE = getAttribute("tempt_range");
/** /**
* The block reach distance of a Player. * The block reach distance of a Player.
*/ */
PLAYER_BLOCK_INTERACTION_RANGE("block_interaction_range"), Attribute BLOCK_INTERACTION_RANGE = getAttribute("block_interaction_range");
/** /**
* The entity reach distance of a Player. * The entity reach distance of a Player.
*/ */
PLAYER_ENTITY_INTERACTION_RANGE("entity_interaction_range"), Attribute ENTITY_INTERACTION_RANGE = getAttribute("entity_interaction_range");
/** /**
* Block break speed of a Player. * Block break speed of a Player.
*/ */
PLAYER_BLOCK_BREAK_SPEED("block_break_speed"), Attribute BLOCK_BREAK_SPEED = getAttribute("block_break_speed");
/** /**
* Mining speed for correct tools. * Mining speed for correct tools.
*/ */
PLAYER_MINING_EFFICIENCY("mining_efficiency"), Attribute MINING_EFFICIENCY = getAttribute("mining_efficiency");
/** /**
* Sneaking speed. * Sneaking speed.
*/ */
PLAYER_SNEAKING_SPEED("sneaking_speed"), Attribute SNEAKING_SPEED = getAttribute("sneaking_speed");
/** /**
* Underwater mining speed. * Underwater mining speed.
*/ */
PLAYER_SUBMERGED_MINING_SPEED("submerged_mining_speed"), Attribute SUBMERGED_MINING_SPEED = getAttribute("submerged_mining_speed");
/** /**
* Sweeping damage. * Sweeping damage.
*/ */
PLAYER_SWEEPING_DAMAGE_RATIO("sweeping_damage_ratio"), Attribute SWEEPING_DAMAGE_RATIO = getAttribute("sweeping_damage_ratio");
/** /**
* Chance of a zombie to spawn reinforcements. * Chance of a zombie to spawn reinforcements.
*/ */
ZOMBIE_SPAWN_REINFORCEMENTS("spawn_reinforcements"); Attribute SPAWN_REINFORCEMENTS = getAttribute("spawn_reinforcements");
private final NamespacedKey key;
private Attribute(String key) {
this.key = NamespacedKey.minecraft(key);
}
@NotNull @NotNull
@Override private static Attribute getAttribute(@NotNull String key) {
public NamespacedKey getKey() { return Registry.ATTRIBUTE.getOrThrow(NamespacedKey.minecraft(key));
return key;
} }
/**
* @param name of the attribute.
* @return the attribute with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull @NotNull
@Override @Deprecated(since = "1.21.3")
public String getTranslationKey() { static Attribute valueOf(@NotNull String name) {
return Bukkit.getUnsafe().getTranslationKey(this); Attribute attribute = Bukkit.getUnsafe().get(Registry.ATTRIBUTE, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(attribute != null, "No attribute found with the name %s", name);
return attribute;
}
/**
* @return an array of all known attributes.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Attribute[] values() {
return Lists.newArrayList(Registry.ATTRIBUTE).toArray(new Attribute[0]);
} }
} }

View file

@ -1,97 +1,134 @@
package org.bukkit.block; package org.bukkit.block;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale; import java.util.Locale;
import org.bukkit.Bukkit;
import org.bukkit.FeatureFlag;
import org.bukkit.Keyed; import org.bukkit.Keyed;
import org.bukkit.MinecraftExperimental; import org.bukkit.MinecraftExperimental;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.packs.DataPack;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
* Holds all accepted Biomes in the default server * Holds all accepted Biomes in the server.
* <p>
* The Biomes listed in this interface are present in the default server
* or can be enabled via a {@link FeatureFlag}.
* There may be additional biomes present in the server, for example from a {@link DataPack}
* which can be accessed via {@link Registry#BIOME}.
*/ */
public enum Biome implements Keyed { public interface Biome extends OldEnum<Biome>, Keyed {
OCEAN,
PLAINS, Biome OCEAN = getBiome("ocean");
DESERT, Biome PLAINS = getBiome("plains");
WINDSWEPT_HILLS, Biome DESERT = getBiome("desert");
FOREST, Biome WINDSWEPT_HILLS = getBiome("windswept_hills");
TAIGA, Biome FOREST = getBiome("forest");
SWAMP, Biome TAIGA = getBiome("taiga");
MANGROVE_SWAMP, Biome SWAMP = getBiome("swamp");
RIVER, Biome MANGROVE_SWAMP = getBiome("mangrove_swamp");
NETHER_WASTES, Biome RIVER = getBiome("river");
THE_END, Biome NETHER_WASTES = getBiome("nether_wastes");
FROZEN_OCEAN, Biome THE_END = getBiome("the_end");
FROZEN_RIVER, Biome FROZEN_OCEAN = getBiome("frozen_ocean");
SNOWY_PLAINS, Biome FROZEN_RIVER = getBiome("frozen_river");
MUSHROOM_FIELDS, Biome SNOWY_PLAINS = getBiome("snowy_plains");
BEACH, Biome MUSHROOM_FIELDS = getBiome("mushroom_fields");
JUNGLE, Biome BEACH = getBiome("beach");
SPARSE_JUNGLE, Biome JUNGLE = getBiome("jungle");
DEEP_OCEAN, Biome SPARSE_JUNGLE = getBiome("sparse_jungle");
STONY_SHORE, Biome DEEP_OCEAN = getBiome("deep_ocean");
SNOWY_BEACH, Biome STONY_SHORE = getBiome("stony_shore");
BIRCH_FOREST, Biome SNOWY_BEACH = getBiome("snowy_beach");
DARK_FOREST, Biome BIRCH_FOREST = getBiome("birch_forest");
SNOWY_TAIGA, Biome DARK_FOREST = getBiome("dark_forest");
OLD_GROWTH_PINE_TAIGA, Biome SNOWY_TAIGA = getBiome("snowy_taiga");
WINDSWEPT_FOREST, Biome OLD_GROWTH_PINE_TAIGA = getBiome("old_growth_pine_taiga");
SAVANNA, Biome WINDSWEPT_FOREST = getBiome("windswept_forest");
SAVANNA_PLATEAU, Biome SAVANNA = getBiome("savanna");
BADLANDS, Biome SAVANNA_PLATEAU = getBiome("savanna_plateau");
WOODED_BADLANDS, Biome BADLANDS = getBiome("badlands");
SMALL_END_ISLANDS, Biome WOODED_BADLANDS = getBiome("wooded_badlands");
END_MIDLANDS, Biome SMALL_END_ISLANDS = getBiome("small_end_islands");
END_HIGHLANDS, Biome END_MIDLANDS = getBiome("end_midlands");
END_BARRENS, Biome END_HIGHLANDS = getBiome("end_highlands");
WARM_OCEAN, Biome END_BARRENS = getBiome("end_barrens");
LUKEWARM_OCEAN, Biome WARM_OCEAN = getBiome("warm_ocean");
COLD_OCEAN, Biome LUKEWARM_OCEAN = getBiome("lukewarm_ocean");
DEEP_LUKEWARM_OCEAN, Biome COLD_OCEAN = getBiome("cold_ocean");
DEEP_COLD_OCEAN, Biome DEEP_LUKEWARM_OCEAN = getBiome("deep_lukewarm_ocean");
DEEP_FROZEN_OCEAN, Biome DEEP_COLD_OCEAN = getBiome("deep_cold_ocean");
THE_VOID, Biome DEEP_FROZEN_OCEAN = getBiome("deep_frozen_ocean");
SUNFLOWER_PLAINS, Biome THE_VOID = getBiome("the_void");
WINDSWEPT_GRAVELLY_HILLS, Biome SUNFLOWER_PLAINS = getBiome("sunflower_plains");
FLOWER_FOREST, Biome WINDSWEPT_GRAVELLY_HILLS = getBiome("windswept_gravelly_hills");
ICE_SPIKES, Biome FLOWER_FOREST = getBiome("flower_forest");
OLD_GROWTH_BIRCH_FOREST, Biome ICE_SPIKES = getBiome("ice_spikes");
OLD_GROWTH_SPRUCE_TAIGA, Biome OLD_GROWTH_BIRCH_FOREST = getBiome("old_growth_birch_forest");
WINDSWEPT_SAVANNA, Biome OLD_GROWTH_SPRUCE_TAIGA = getBiome("old_growth_spruce_taiga");
ERODED_BADLANDS, Biome WINDSWEPT_SAVANNA = getBiome("windswept_savanna");
BAMBOO_JUNGLE, Biome ERODED_BADLANDS = getBiome("eroded_badlands");
SOUL_SAND_VALLEY, Biome BAMBOO_JUNGLE = getBiome("bamboo_jungle");
CRIMSON_FOREST, Biome SOUL_SAND_VALLEY = getBiome("soul_sand_valley");
WARPED_FOREST, Biome CRIMSON_FOREST = getBiome("crimson_forest");
BASALT_DELTAS, Biome WARPED_FOREST = getBiome("warped_forest");
DRIPSTONE_CAVES, Biome BASALT_DELTAS = getBiome("basalt_deltas");
LUSH_CAVES, Biome DRIPSTONE_CAVES = getBiome("dripstone_caves");
DEEP_DARK, Biome LUSH_CAVES = getBiome("lush_caves");
MEADOW, Biome DEEP_DARK = getBiome("deep_dark");
GROVE, Biome MEADOW = getBiome("meadow");
SNOWY_SLOPES, Biome GROVE = getBiome("grove");
FROZEN_PEAKS, Biome SNOWY_SLOPES = getBiome("snowy_slopes");
JAGGED_PEAKS, Biome FROZEN_PEAKS = getBiome("frozen_peaks");
STONY_PEAKS, Biome JAGGED_PEAKS = getBiome("jagged_peaks");
CHERRY_GROVE, Biome STONY_PEAKS = getBiome("stony_peaks");
Biome CHERRY_GROVE = getBiome("cherry_grove");
@ApiStatus.Experimental @ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP) @MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
PALE_GARDEN, Biome PALE_GARDEN = Registry.BIOME.get(NamespacedKey.minecraft("pale_garden"));
/** /**
* Represents a custom Biome * Represents a custom Biome
*
* @deprecated Biome is no longer an enum, custom biomes will have their own biome instance.
*/ */
CUSTOM; @Deprecated(since = "1.21.3")
Biome CUSTOM = Bukkit.getUnsafe().getCustomBiome();
private final NamespacedKey key;
private Biome() {
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
}
@NotNull @NotNull
@Override private static Biome getBiome(@NotNull String key) {
public NamespacedKey getKey() { return Registry.BIOME.getOrThrow(NamespacedKey.minecraft(key));
return key; }
/**
* @param name of the biome.
* @return the biome with the given name.
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Biome valueOf(@NotNull String name) {
if ("CUSTOM".equals(name)) {
return Biome.CUSTOM;
}
Biome biome = Bukkit.getUnsafe().get(Registry.BIOME, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
Preconditions.checkArgument(biome != null, "No biome found with the name %s", name);
return biome;
}
/**
* @return an array of all known biomes.
* @deprecated use {@link Registry#iterator()}.
*/
@NotNull
@Deprecated(since = "1.21.3")
static Biome[] values() {
return Lists.newArrayList(Registry.BIOME).toArray(new Biome[0]);
} }
} }

View file

@ -16,6 +16,16 @@ public interface Vault extends Directional {
* @return the 'vault_state' value * @return the 'vault_state' value
*/ */
@NotNull @NotNull
State getVaultState();
/**
* Gets the value of the 'vault_state' property.
*
* @return the 'vault_state' value
* @deprecated see {@link #getVaultState()}
*/
@Deprecated(forRemoval = true)
@NotNull
State getTrialSpawnerState(); State getTrialSpawnerState();
/** /**
@ -23,6 +33,15 @@ public interface Vault extends Directional {
* *
* @param state the new 'vault_state' value * @param state the new 'vault_state' value
*/ */
void setVaultState(@NotNull State state);
/**
* Sets the value of the 'vault_state' property.
*
* @param state the new 'vault_state' value
* @deprecated see {@link #setVaultState(State)}
*/
@Deprecated(forRemoval = true)
void setTrialSpawnerState(@NotNull State state); void setTrialSpawnerState(@NotNull State state);
/** /**

View file

@ -64,7 +64,7 @@ public interface Damageable extends Entity {
* Sets the entity's absorption amount. * Sets the entity's absorption amount.
* <p> * <p>
* Note: The amount is capped to the value of * Note: The amount is capped to the value of
* {@link Attribute#GENERIC_MAX_ABSORPTION}. The effect of this method on * {@link Attribute#MAX_ABSORPTION}. The effect of this method on
* that attribute is currently unspecified and subject to change. * that attribute is currently unspecified and subject to change.
* *
* @param amount new absorption amount from 0 * @param amount new absorption amount from 0
@ -77,7 +77,7 @@ public interface Damageable extends Entity {
* Gets the maximum health this entity has. * Gets the maximum health this entity has.
* *
* @return Maximum health * @return Maximum health
* @deprecated use {@link Attribute#GENERIC_MAX_HEALTH}. * @deprecated use {@link Attribute#MAX_HEALTH}.
*/ */
@Deprecated @Deprecated
double getMaxHealth(); double getMaxHealth();
@ -92,14 +92,14 @@ public interface Damageable extends Entity {
* {@link Wither}, etc...} will have their bar scaled accordingly. * {@link Wither}, etc...} will have their bar scaled accordingly.
* *
* @param health amount of health to set the maximum to * @param health amount of health to set the maximum to
* @deprecated use {@link Attribute#GENERIC_MAX_HEALTH}. * @deprecated use {@link Attribute#MAX_HEALTH}.
*/ */
@Deprecated @Deprecated
void setMaxHealth(double health); void setMaxHealth(double health);
/** /**
* Resets the max health to the original amount. * Resets the max health to the original amount.
* @deprecated use {@link Attribute#GENERIC_MAX_HEALTH}. * @deprecated use {@link Attribute#MAX_HEALTH}.
*/ */
@Deprecated @Deprecated
void resetMaxHealth(); void resetMaxHealth();

View file

@ -324,7 +324,11 @@ public enum EntityType implements Keyed, Translatable {
MANGROVE_CHEST_BOAT("mangrove_chest_boat", MangroveChestBoat.class, -1), MANGROVE_CHEST_BOAT("mangrove_chest_boat", MangroveChestBoat.class, -1),
OAK_BOAT("oak_boat", OakBoat.class, -1), OAK_BOAT("oak_boat", OakBoat.class, -1),
OAK_CHEST_BOAT("oak_chest_boat", OakChestBoat.class, -1), OAK_CHEST_BOAT("oak_chest_boat", OakChestBoat.class, -1),
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
PALE_OAK_BOAT("pale_oak_boat", PaleOakBoat.class, -1), PALE_OAK_BOAT("pale_oak_boat", PaleOakBoat.class, -1),
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
PALE_OAK_CHEST_BOAT("pale_oak_chest_boat", PaleOakChestBoat.class, -1), PALE_OAK_CHEST_BOAT("pale_oak_chest_boat", PaleOakChestBoat.class, -1),
SPRUCE_BOAT("spruce_boat", SpruceBoat.class, -1), SPRUCE_BOAT("spruce_boat", SpruceBoat.class, -1),
SPRUCE_CHEST_BOAT("spruce_chest_boat", SpruceChestBoat.class, -1), SPRUCE_CHEST_BOAT("spruce_chest_boat", SpruceChestBoat.class, -1),

View file

@ -31,19 +31,15 @@ public interface Minecart extends Vehicle {
* velocity. * velocity.
* *
* @return The max speed * @return The max speed
* @see GameRule#MINECART_MAX_SPEED
*/ */
@Deprecated
public double getMaxSpeed(); public double getMaxSpeed();
/** /**
* Sets the maximum speed of a minecart. Must be nonnegative. Default is * Sets the maximum speed of a minecart. Must be nonnegative. Default is
* 0.4D. * 0.4D or {@link GameRule#MINECART_MAX_SPEED}.
* *
* @param speed The max speed * @param speed The max speed
* @see GameRule#MINECART_MAX_SPEED
*/ */
@Deprecated
public void setMaxSpeed(double speed); public void setMaxSpeed(double speed);
/** /**

View file

@ -13,6 +13,7 @@ import org.bukkit.BanEntry;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.Input;
import org.bukkit.Instrument; import org.bukkit.Instrument;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
@ -392,15 +393,15 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
/** /**
* Saves the players current location, health, inventory, motion, and * Saves the players current location, health, inventory, motion, and
* other information into the username.dat file, in the world/player * other information into the uuid.dat file, in the &lt;main
* folder * world&gt;/playerdata folder.
*/ */
public void saveData(); public void saveData();
/** /**
* Loads the players current location, health, inventory, motion, and * Loads the players current location, health, inventory, motion, and
* other information from the username.dat file, in the world/player * other information from the uuid.dat file, in the &lt;main
* folder. * world&gt;/playerdata folder.
* <p> * <p>
* Note: This will overwrite the players current inventory, health, * Note: This will overwrite the players current inventory, health,
* motion, etc, with the state from the saved dat file. * motion, etc, with the state from the saved dat file.
@ -503,6 +504,18 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@ApiStatus.Experimental @ApiStatus.Experimental
public Collection<EnderPearl> getEnderPearls(); public Collection<EnderPearl> getEnderPearls();
/**
* Gets the current movement input, as last provided by the player.
* <br>
* <b>Note: that this may not always be consistent with the current movement
* of the player.</b>
*
* @return current input
*/
@NotNull
@ApiStatus.Experimental
public Input getCurrentInput();
/** /**
* Play a note for the player at a location. <br> * Play a note for the player at a location. <br>
* This <i>will</i> work with cake. * This <i>will</i> work with cake.

View file

@ -1,9 +1,13 @@
package org.bukkit.entity.boat; package org.bukkit.entity.boat;
import org.bukkit.MinecraftExperimental;
import org.bukkit.entity.Boat; import org.bukkit.entity.Boat;
import org.jetbrains.annotations.ApiStatus;
/** /**
* Represents an pale oak boat. * Represents an pale oak boat.
*/ */
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
public interface PaleOakBoat extends Boat { public interface PaleOakBoat extends Boat {
} }

View file

@ -1,9 +1,13 @@
package org.bukkit.entity.boat; package org.bukkit.entity.boat;
import org.bukkit.MinecraftExperimental;
import org.bukkit.entity.ChestBoat; import org.bukkit.entity.ChestBoat;
import org.jetbrains.annotations.ApiStatus;
/** /**
* Represents an pale oak chest boat. * Represents an pale oak chest boat.
*/ */
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
public interface PaleOakChestBoat extends ChestBoat { public interface PaleOakChestBoat extends ChestBoat {
} }

View file

@ -50,7 +50,7 @@ public class EntityKnockbackEvent extends EntityEvent implements Cancellable {
* Gets the raw force of the knockback. <br> * Gets the raw force of the knockback. <br>
* This value is based on factors such as the {@link Enchantment#KNOCKBACK} * This value is based on factors such as the {@link Enchantment#KNOCKBACK}
* level of an attacker and the * level of an attacker and the
* {@link Attribute#GENERIC_KNOCKBACK_RESISTANCE} of the entity. * {@link Attribute#KNOCKBACK_RESISTANCE} of the entity.
* *
* @return the knockback force * @return the knockback force
*/ */

View file

@ -0,0 +1,45 @@
package org.bukkit.event.player;
import org.bukkit.Input;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* This event is called when a player sends updated input to the server.
*
* @see Player#getCurrentInput()
*/
@ApiStatus.Experimental
public class PlayerInputEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final Input input;
public PlayerInputEvent(@NotNull final Player player, @NotNull final Input input) {
super(player);
this.input = input;
}
/**
* Gets the new input received from this player.
*
* @return the new input
*/
@NotNull
public Input getInput() {
return input;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View file

@ -13,18 +13,20 @@ import org.jetbrains.annotations.Nullable;
public interface UseCooldownComponent extends ConfigurationSerializable { public interface UseCooldownComponent extends ConfigurationSerializable {
/** /**
* Gets the time in seconds it will take for this item to be eaten. * Gets the time in seconds it will take for an item in this cooldown group
* to be available to use again.
* *
* @return eat time * @return cooldown time
*/ */
float getCooldownSeconds(); float getCooldownSeconds();
/** /**
* Sets the time in seconds it will take for this item to be eaten. * Sets the time in seconds it will take for an item in this cooldown group
* to be available to use again.
* *
* @param eatSeconds new eat time, must be positive * @param cooldown new eat time, must be greater than 0
*/ */
void setCooldownSeconds(float eatSeconds); void setCooldownSeconds(float cooldown);
/** /**
* Gets the custom cooldown group to be used for similar items, if set. * Gets the custom cooldown group to be used for similar items, if set.

View file

@ -1,12 +1,11 @@
package org.bukkit.tag; package org.bukkit.tag;
import java.util.Objects;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Tag; import org.bukkit.Tag;
import org.bukkit.damage.DamageType; import org.bukkit.damage.DamageType;
import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable;
/** /**
* Vanilla {@link DamageType} {@link Tag tags}. * Vanilla {@link DamageType} {@link Tag tags}.
@ -32,7 +31,10 @@ public final class DamageTypeTags {
public static final Tag<DamageType> BYPASSES_INVULNERABILITY = getTag("bypasses_invulnerability"); public static final Tag<DamageType> BYPASSES_INVULNERABILITY = getTag("bypasses_invulnerability");
/** /**
* Vanilla tag representing damage types which bypass cooldowns. * Vanilla tag representing damage types which bypass cooldowns.
* <br>
* <b>Note:</b> this can be null unless a datapack add values to this tag because vanilla not has any values for this.
*/ */
@Nullable
public static final Tag<DamageType> BYPASSES_COOLDOWN = getTag("bypasses_cooldown"); public static final Tag<DamageType> BYPASSES_COOLDOWN = getTag("bypasses_cooldown");
/** /**
* Vanilla tag representing damage types which bypass effects. * Vanilla tag representing damage types which bypass effects.
@ -158,9 +160,9 @@ public final class DamageTypeTags {
@ApiStatus.Internal @ApiStatus.Internal
public static final String REGISTRY_DAMAGE_TYPES = "damage_types"; public static final String REGISTRY_DAMAGE_TYPES = "damage_types";
@NotNull @Nullable
private static Tag<DamageType> getTag(String key) { private static Tag<DamageType> getTag(String key) {
return Objects.requireNonNull(Bukkit.getTag(REGISTRY_DAMAGE_TYPES, NamespacedKey.minecraft(key), DamageType.class)); return Bukkit.getTag(REGISTRY_DAMAGE_TYPES, NamespacedKey.minecraft(key), DamageType.class);
} }
private DamageTypeTags() { private DamageTypeTags() {

View file

@ -1,44 +0,0 @@
package org.bukkit;
import static org.bukkit.support.MatcherAssert.*;
import static org.hamcrest.Matchers.*;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.jupiter.api.Test;
public class ArtTest {
@Test
public void getByNullName() {
assertThrows(IllegalArgumentException.class, () -> Art.getByName(null));
}
@Test
public void getById() {
for (Art art : Art.values()) {
assertThat(Art.getById(art.getId()), is(art));
}
}
@Test
public void getByName() {
for (Art art : Art.values()) {
assertThat(Art.getByName(art.toString()), is(art));
}
}
@Test
public void dimensionSanityCheck() {
for (Art art : Art.values()) {
assertThat(art.getBlockHeight(), is(greaterThan(0)));
assertThat(art.getBlockWidth(), is(greaterThan(0)));
}
}
@Test
public void getByNameWithMixedCase() {
Art subject = Art.values()[0];
String name = subject.toString().replace('E', 'e');
assertThat(Art.getByName(name), is(subject));
}
}

View file

@ -2,9 +2,10 @@ package org.bukkit;
import static org.bukkit.support.MatcherAssert.*; import static org.bukkit.support.MatcherAssert.*;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import org.bukkit.support.AbstractTestingBase;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
public class InstrumentTest { public class InstrumentTest extends AbstractTestingBase {
@Test @Test
public void getByType() { public void getByType() {
for (Instrument instrument : Instrument.values()) { for (Instrument instrument : Instrument.values()) {