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>
<artifactId>bukkit</artifactId>
<version>1.21.2-R0.1-SNAPSHOT</version>
<version>1.21.3-R0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Bukkit</name>

View file

@ -1,77 +1,77 @@
package org.bukkit;
import com.google.common.base.Preconditions;
import com.google.common.collect.Maps;
import java.util.HashMap;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.packs.DataPack;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
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 {
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);
public interface Art extends OldEnum<Art>, Keyed {
private final int id, width, height;
private final NamespacedKey key;
private static final HashMap<String, Art> BY_NAME = Maps.newHashMap();
private static final HashMap<Integer, Art> BY_ID = Maps.newHashMap();
Art KEBAB = getArt("kebab");
Art AZTEC = getArt("aztec");
Art ALBAN = getArt("alban");
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) {
this.id = id;
this.width = width;
this.height = height;
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
@NotNull
private static Art getArt(@NotNull String key) {
return Registry.ART.getOrThrow(NamespacedKey.minecraft(key));
}
/**
@ -79,18 +79,14 @@ public enum Art implements Keyed {
*
* @return The width of the painting, in blocks
*/
public int getBlockWidth() {
return width;
}
int getBlockWidth();
/**
* Gets the height of the painting, in blocks
*
* @return The height of the painting, in blocks
*/
public int getBlockHeight() {
return height;
}
int getBlockHeight();
/**
* Get the ID of this painting.
@ -98,16 +94,8 @@ public enum Art implements Keyed {
* @return The ID of this painting
* @deprecated Magic value
*/
@Deprecated
public int getId() {
return id;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
@Deprecated(since = "1.6.2")
int getId();
/**
* Get a painting by its numeric ID
@ -116,31 +104,55 @@ public enum Art implements Keyed {
* @return The painting
* @deprecated Magic value
*/
@Deprecated
@Deprecated(since = "1.6.2")
@Nullable
public static Art getById(int id) {
return BY_ID.get(id);
static Art getById(int id) {
for (Art art : Registry.ART) {
if (id == art.getId()) {
return art;
}
}
return null;
}
/**
* Get a painting by its unique name
* <p>
* This ignores underscores and capitalization
* This ignores capitalization
*
* @param name The name
* @return The painting
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
*/
@Deprecated(since = "1.21.3")
@Nullable
public static Art getByName(@NotNull String name) {
static Art getByName(@NotNull String name) {
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()) {
BY_ID.put(art.id, art);
BY_NAME.put(art.toString().toLowerCase(Locale.ROOT), art);
}
/**
* @param name of the art.
* @return the art with the given name.
* @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();
}
/**
* 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.
*

View file

@ -1,39 +1,62 @@
package org.bukkit;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
/**
* Represents a fluid type.
*/
public enum Fluid implements Keyed {
public interface Fluid extends OldEnum<Fluid>, Keyed {
/**
* No fluid.
*/
Fluid EMPTY = getFluid("empty");
/**
* Stationary water.
*/
WATER,
Fluid WATER = getFluid("water");
/**
* Flowing water.
*/
FLOWING_WATER,
Fluid FLOWING_WATER = getFluid("flowing_water");
/**
* Stationary lava.
*/
LAVA,
Fluid LAVA = getFluid("lava");
/**
* Flowing lava.
*/
FLOWING_LAVA;
private final NamespacedKey key;
private Fluid() {
this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT));
}
Fluid FLOWING_LAVA = getFluid("flowing_lava");
@NotNull
@Override
public NamespacedKey getKey() {
return key;
private static Fluid getFluid(@NotNull String key) {
return Registry.FLUID.getOrThrow(NamespacedKey.minecraft(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
*/
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.
*
* @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.
*
@ -106,7 +106,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
*
* @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.
*
@ -243,7 +243,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
*
* @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.
*
@ -324,7 +324,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
*
* @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.
*

View file

@ -1565,6 +1565,24 @@ public interface Server extends PluginMessageRecipient {
*/
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.
*

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,7 @@
package org.bukkit;
import org.jetbrains.annotations.ApiStatus;
/**
* Tree and organic structure types.
*/
@ -101,4 +103,16 @@ public enum TreeType {
* Cherry tree
*/
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.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.damage.DamageEffect;
import org.bukkit.damage.DamageSource;
@ -99,6 +100,7 @@ public interface UnsafeValues {
String getTranslationKey(ItemStack itemStack);
@Deprecated(since = "1.21.3", forRemoval = true)
String getTranslationKey(Attribute attribute);
@Nullable
@ -134,6 +136,9 @@ public interface UnsafeValues {
@ApiStatus.Internal
<B extends Keyed> B get(Registry<B> registry, NamespacedKey key);
@ApiStatus.Internal
Biome getCustomBiome();
@ApiStatus.Internal
PoiType.Occupancy createOccupancy(String key);
}

View file

@ -1,160 +1,175 @@
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.Keyed;
import org.bukkit.NamespacedKey;
import org.bukkit.Registry;
import org.bukkit.Translatable;
import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.NotNull;
/**
* 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.
*/
GENERIC_MAX_HEALTH("max_health"),
Attribute MAX_HEALTH = getAttribute("max_health");
/**
* 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.
*/
GENERIC_KNOCKBACK_RESISTANCE("knockback_resistance"),
Attribute KNOCKBACK_RESISTANCE = getAttribute("knockback_resistance");
/**
* Movement speed of an Entity.
*/
GENERIC_MOVEMENT_SPEED("movement_speed"),
Attribute MOVEMENT_SPEED = getAttribute("movement_speed");
/**
* Flying speed of an Entity.
*/
GENERIC_FLYING_SPEED("flying_speed"),
Attribute FLYING_SPEED = getAttribute("flying_speed");
/**
* Attack damage of an Entity.
*/
GENERIC_ATTACK_DAMAGE("attack_damage"),
Attribute ATTACK_DAMAGE = getAttribute("attack_damage");
/**
* Attack knockback of an Entity.
*/
GENERIC_ATTACK_KNOCKBACK("attack_knockback"),
Attribute ATTACK_KNOCKBACK = getAttribute("attack_knockback");
/**
* Attack speed of an Entity.
*/
GENERIC_ATTACK_SPEED("attack_speed"),
Attribute ATTACK_SPEED = getAttribute("attack_speed");
/**
* Armor bonus of an Entity.
*/
GENERIC_ARMOR("armor"),
Attribute ARMOR = getAttribute("armor");
/**
* Armor durability bonus of an Entity.
*/
GENERIC_ARMOR_TOUGHNESS("armor_toughness"),
Attribute ARMOR_TOUGHNESS = getAttribute("armor_toughness");
/**
* 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.
*/
GENERIC_LUCK("luck"),
Attribute LUCK = getAttribute("luck");
/**
* 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.
*/
GENERIC_SAFE_FALL_DISTANCE("safe_fall_distance"),
Attribute SAFE_FALL_DISTANCE = getAttribute("safe_fall_distance");
/**
* The relative scale of an Entity.
*/
GENERIC_SCALE("scale"),
Attribute SCALE = getAttribute("scale");
/**
* 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.
*/
GENERIC_GRAVITY("gravity"),
Attribute GRAVITY = getAttribute("gravity");
/**
* 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.
*/
GENERIC_BURNING_TIME("burning_time"),
Attribute BURNING_TIME = getAttribute("burning_time");
/**
* 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.
*/
GENERIC_MOVEMENT_EFFICIENCY("movement_efficiency"),
Attribute MOVEMENT_EFFICIENCY = getAttribute("movement_efficiency");
/**
* Oxygen use underwater.
*/
GENERIC_OXYGEN_BONUS("oxygen_bonus"),
Attribute OXYGEN_BONUS = getAttribute("oxygen_bonus");
/**
* 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.
*/
GENERIC_TEMPT_RANGE("tempt_range"),
Attribute TEMPT_RANGE = getAttribute("tempt_range");
/**
* 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.
*/
PLAYER_ENTITY_INTERACTION_RANGE("entity_interaction_range"),
Attribute ENTITY_INTERACTION_RANGE = getAttribute("entity_interaction_range");
/**
* 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.
*/
PLAYER_MINING_EFFICIENCY("mining_efficiency"),
Attribute MINING_EFFICIENCY = getAttribute("mining_efficiency");
/**
* Sneaking speed.
*/
PLAYER_SNEAKING_SPEED("sneaking_speed"),
Attribute SNEAKING_SPEED = getAttribute("sneaking_speed");
/**
* Underwater mining speed.
*/
PLAYER_SUBMERGED_MINING_SPEED("submerged_mining_speed"),
Attribute SUBMERGED_MINING_SPEED = getAttribute("submerged_mining_speed");
/**
* Sweeping damage.
*/
PLAYER_SWEEPING_DAMAGE_RATIO("sweeping_damage_ratio"),
Attribute SWEEPING_DAMAGE_RATIO = getAttribute("sweeping_damage_ratio");
/**
* Chance of a zombie to spawn reinforcements.
*/
ZOMBIE_SPAWN_REINFORCEMENTS("spawn_reinforcements");
private final NamespacedKey key;
private Attribute(String key) {
this.key = NamespacedKey.minecraft(key);
}
Attribute SPAWN_REINFORCEMENTS = getAttribute("spawn_reinforcements");
@NotNull
@Override
public NamespacedKey getKey() {
return key;
private static Attribute getAttribute(@NotNull String key) {
return Registry.ATTRIBUTE.getOrThrow(NamespacedKey.minecraft(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
@Override
public String getTranslationKey() {
return Bukkit.getUnsafe().getTranslationKey(this);
@Deprecated(since = "1.21.3")
static Attribute valueOf(@NotNull String name) {
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;
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import java.util.Locale;
import org.bukkit.Bukkit;
import org.bukkit.FeatureFlag;
import org.bukkit.Keyed;
import org.bukkit.MinecraftExperimental;
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.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 {
OCEAN,
PLAINS,
DESERT,
WINDSWEPT_HILLS,
FOREST,
TAIGA,
SWAMP,
MANGROVE_SWAMP,
RIVER,
NETHER_WASTES,
THE_END,
FROZEN_OCEAN,
FROZEN_RIVER,
SNOWY_PLAINS,
MUSHROOM_FIELDS,
BEACH,
JUNGLE,
SPARSE_JUNGLE,
DEEP_OCEAN,
STONY_SHORE,
SNOWY_BEACH,
BIRCH_FOREST,
DARK_FOREST,
SNOWY_TAIGA,
OLD_GROWTH_PINE_TAIGA,
WINDSWEPT_FOREST,
SAVANNA,
SAVANNA_PLATEAU,
BADLANDS,
WOODED_BADLANDS,
SMALL_END_ISLANDS,
END_MIDLANDS,
END_HIGHLANDS,
END_BARRENS,
WARM_OCEAN,
LUKEWARM_OCEAN,
COLD_OCEAN,
DEEP_LUKEWARM_OCEAN,
DEEP_COLD_OCEAN,
DEEP_FROZEN_OCEAN,
THE_VOID,
SUNFLOWER_PLAINS,
WINDSWEPT_GRAVELLY_HILLS,
FLOWER_FOREST,
ICE_SPIKES,
OLD_GROWTH_BIRCH_FOREST,
OLD_GROWTH_SPRUCE_TAIGA,
WINDSWEPT_SAVANNA,
ERODED_BADLANDS,
BAMBOO_JUNGLE,
SOUL_SAND_VALLEY,
CRIMSON_FOREST,
WARPED_FOREST,
BASALT_DELTAS,
DRIPSTONE_CAVES,
LUSH_CAVES,
DEEP_DARK,
MEADOW,
GROVE,
SNOWY_SLOPES,
FROZEN_PEAKS,
JAGGED_PEAKS,
STONY_PEAKS,
CHERRY_GROVE,
public interface Biome extends OldEnum<Biome>, Keyed {
Biome OCEAN = getBiome("ocean");
Biome PLAINS = getBiome("plains");
Biome DESERT = getBiome("desert");
Biome WINDSWEPT_HILLS = getBiome("windswept_hills");
Biome FOREST = getBiome("forest");
Biome TAIGA = getBiome("taiga");
Biome SWAMP = getBiome("swamp");
Biome MANGROVE_SWAMP = getBiome("mangrove_swamp");
Biome RIVER = getBiome("river");
Biome NETHER_WASTES = getBiome("nether_wastes");
Biome THE_END = getBiome("the_end");
Biome FROZEN_OCEAN = getBiome("frozen_ocean");
Biome FROZEN_RIVER = getBiome("frozen_river");
Biome SNOWY_PLAINS = getBiome("snowy_plains");
Biome MUSHROOM_FIELDS = getBiome("mushroom_fields");
Biome BEACH = getBiome("beach");
Biome JUNGLE = getBiome("jungle");
Biome SPARSE_JUNGLE = getBiome("sparse_jungle");
Biome DEEP_OCEAN = getBiome("deep_ocean");
Biome STONY_SHORE = getBiome("stony_shore");
Biome SNOWY_BEACH = getBiome("snowy_beach");
Biome BIRCH_FOREST = getBiome("birch_forest");
Biome DARK_FOREST = getBiome("dark_forest");
Biome SNOWY_TAIGA = getBiome("snowy_taiga");
Biome OLD_GROWTH_PINE_TAIGA = getBiome("old_growth_pine_taiga");
Biome WINDSWEPT_FOREST = getBiome("windswept_forest");
Biome SAVANNA = getBiome("savanna");
Biome SAVANNA_PLATEAU = getBiome("savanna_plateau");
Biome BADLANDS = getBiome("badlands");
Biome WOODED_BADLANDS = getBiome("wooded_badlands");
Biome SMALL_END_ISLANDS = getBiome("small_end_islands");
Biome END_MIDLANDS = getBiome("end_midlands");
Biome END_HIGHLANDS = getBiome("end_highlands");
Biome END_BARRENS = getBiome("end_barrens");
Biome WARM_OCEAN = getBiome("warm_ocean");
Biome LUKEWARM_OCEAN = getBiome("lukewarm_ocean");
Biome COLD_OCEAN = getBiome("cold_ocean");
Biome DEEP_LUKEWARM_OCEAN = getBiome("deep_lukewarm_ocean");
Biome DEEP_COLD_OCEAN = getBiome("deep_cold_ocean");
Biome DEEP_FROZEN_OCEAN = getBiome("deep_frozen_ocean");
Biome THE_VOID = getBiome("the_void");
Biome SUNFLOWER_PLAINS = getBiome("sunflower_plains");
Biome WINDSWEPT_GRAVELLY_HILLS = getBiome("windswept_gravelly_hills");
Biome FLOWER_FOREST = getBiome("flower_forest");
Biome ICE_SPIKES = getBiome("ice_spikes");
Biome OLD_GROWTH_BIRCH_FOREST = getBiome("old_growth_birch_forest");
Biome OLD_GROWTH_SPRUCE_TAIGA = getBiome("old_growth_spruce_taiga");
Biome WINDSWEPT_SAVANNA = getBiome("windswept_savanna");
Biome ERODED_BADLANDS = getBiome("eroded_badlands");
Biome BAMBOO_JUNGLE = getBiome("bamboo_jungle");
Biome SOUL_SAND_VALLEY = getBiome("soul_sand_valley");
Biome CRIMSON_FOREST = getBiome("crimson_forest");
Biome WARPED_FOREST = getBiome("warped_forest");
Biome BASALT_DELTAS = getBiome("basalt_deltas");
Biome DRIPSTONE_CAVES = getBiome("dripstone_caves");
Biome LUSH_CAVES = getBiome("lush_caves");
Biome DEEP_DARK = getBiome("deep_dark");
Biome MEADOW = getBiome("meadow");
Biome GROVE = getBiome("grove");
Biome SNOWY_SLOPES = getBiome("snowy_slopes");
Biome FROZEN_PEAKS = getBiome("frozen_peaks");
Biome JAGGED_PEAKS = getBiome("jagged_peaks");
Biome STONY_PEAKS = getBiome("stony_peaks");
Biome CHERRY_GROVE = getBiome("cherry_grove");
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
PALE_GARDEN,
Biome PALE_GARDEN = Registry.BIOME.get(NamespacedKey.minecraft("pale_garden"));
/**
* Represents a custom Biome
*
* @deprecated Biome is no longer an enum, custom biomes will have their own biome instance.
*/
CUSTOM;
private final NamespacedKey key;
private Biome() {
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
}
@Deprecated(since = "1.21.3")
Biome CUSTOM = Bukkit.getUnsafe().getCustomBiome();
@NotNull
@Override
public NamespacedKey getKey() {
return key;
private static Biome getBiome(@NotNull String key) {
return Registry.BIOME.getOrThrow(NamespacedKey.minecraft(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
*/
@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();
/**
@ -23,6 +33,15 @@ public interface Vault extends Directional {
*
* @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);
/**

View file

@ -64,7 +64,7 @@ public interface Damageable extends Entity {
* Sets the entity's absorption amount.
* <p>
* 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.
*
* @param amount new absorption amount from 0
@ -77,7 +77,7 @@ public interface Damageable extends Entity {
* Gets the maximum health this entity has.
*
* @return Maximum health
* @deprecated use {@link Attribute#GENERIC_MAX_HEALTH}.
* @deprecated use {@link Attribute#MAX_HEALTH}.
*/
@Deprecated
double getMaxHealth();
@ -92,14 +92,14 @@ public interface Damageable extends Entity {
* {@link Wither}, etc...} will have their bar scaled accordingly.
*
* @param health amount of health to set the maximum to
* @deprecated use {@link Attribute#GENERIC_MAX_HEALTH}.
* @deprecated use {@link Attribute#MAX_HEALTH}.
*/
@Deprecated
void setMaxHealth(double health);
/**
* Resets the max health to the original amount.
* @deprecated use {@link Attribute#GENERIC_MAX_HEALTH}.
* @deprecated use {@link Attribute#MAX_HEALTH}.
*/
@Deprecated
void resetMaxHealth();

View file

@ -324,7 +324,11 @@ public enum EntityType implements Keyed, Translatable {
MANGROVE_CHEST_BOAT("mangrove_chest_boat", MangroveChestBoat.class, -1),
OAK_BOAT("oak_boat", OakBoat.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),
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
PALE_OAK_CHEST_BOAT("pale_oak_chest_boat", PaleOakChestBoat.class, -1),
SPRUCE_BOAT("spruce_boat", SpruceBoat.class, -1),
SPRUCE_CHEST_BOAT("spruce_chest_boat", SpruceChestBoat.class, -1),

View file

@ -31,19 +31,15 @@ public interface Minecart extends Vehicle {
* velocity.
*
* @return The max speed
* @see GameRule#MINECART_MAX_SPEED
*/
@Deprecated
public double getMaxSpeed();
/**
* 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
* @see GameRule#MINECART_MAX_SPEED
*/
@Deprecated
public void setMaxSpeed(double speed);
/**

View file

@ -13,6 +13,7 @@ import org.bukkit.BanEntry;
import org.bukkit.DyeColor;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.Input;
import org.bukkit.Instrument;
import org.bukkit.Location;
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
* other information into the username.dat file, in the world/player
* folder
* other information into the uuid.dat file, in the &lt;main
* world&gt;/playerdata folder.
*/
public void saveData();
/**
* Loads the players current location, health, inventory, motion, and
* other information from the username.dat file, in the world/player
* folder.
* other information from the uuid.dat file, in the &lt;main
* world&gt;/playerdata folder.
* <p>
* Note: This will overwrite the players current inventory, health,
* motion, etc, with the state from the saved dat file.
@ -503,6 +504,18 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
@ApiStatus.Experimental
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>
* This <i>will</i> work with cake.

View file

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

View file

@ -1,9 +1,13 @@
package org.bukkit.entity.boat;
import org.bukkit.MinecraftExperimental;
import org.bukkit.entity.ChestBoat;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents an pale oak chest boat.
*/
@ApiStatus.Experimental
@MinecraftExperimental(MinecraftExperimental.Requires.WINTER_DROP)
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>
* This value is based on factors such as the {@link Enchantment#KNOCKBACK}
* 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
*/

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 {
/**
* 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();
/**
* 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.

View file

@ -1,12 +1,11 @@
package org.bukkit.tag;
import java.util.Objects;
import org.bukkit.Bukkit;
import org.bukkit.NamespacedKey;
import org.bukkit.Tag;
import org.bukkit.damage.DamageType;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Vanilla {@link DamageType} {@link Tag tags}.
@ -32,7 +31,10 @@ public final class DamageTypeTags {
public static final Tag<DamageType> BYPASSES_INVULNERABILITY = getTag("bypasses_invulnerability");
/**
* 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");
/**
* Vanilla tag representing damage types which bypass effects.
@ -158,9 +160,9 @@ public final class DamageTypeTags {
@ApiStatus.Internal
public static final String REGISTRY_DAMAGE_TYPES = "damage_types";
@NotNull
@Nullable
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() {

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.hamcrest.CoreMatchers.*;
import org.bukkit.support.AbstractTestingBase;
import org.junit.jupiter.api.Test;
public class InstrumentTest {
public class InstrumentTest extends AbstractTestingBase {
@Test
public void getByType() {
for (Instrument instrument : Instrument.values()) {