Merge branch 'master' into enums-to-registers

# Conflicts:
#	src/main/java/org/bukkit/Bukkit.java
#	src/main/java/org/bukkit/Material.java
#	src/main/java/org/bukkit/Particle.java
#	src/main/java/org/bukkit/Registry.java
#	src/main/java/org/bukkit/Server.java
#	src/main/java/org/bukkit/Sound.java
#	src/main/java/org/bukkit/Tag.java
#	src/main/java/org/bukkit/block/banner/PatternType.java
#	src/main/java/org/bukkit/enchantments/Enchantment.java
#	src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java
#	src/main/java/org/bukkit/entity/Cat.java
#	src/main/java/org/bukkit/entity/EntityType.java
#	src/main/java/org/bukkit/inventory/ItemFactory.java
#	src/main/java/org/bukkit/potion/PotionEffectType.java
#	src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java
This commit is contained in:
DerFrZocker 2023-12-09 07:56:58 +01:00
commit 6ec538a00f
No known key found for this signature in database
GPG key ID: 713F71FFFE1DDF91
56 changed files with 2609 additions and 337 deletions

1
.gitignore vendored
View file

@ -3,6 +3,7 @@
/.project /.project
/.settings /.settings
/.checkstyle /.checkstyle
/.factorypath
# netbeans # netbeans
/nbproject /nbproject

View file

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

View file

@ -36,6 +36,7 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.help.HelpMap; import org.bukkit.help.HelpMap;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemCraftResult;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Merchant; import org.bukkit.inventory.Merchant;
@ -944,6 +945,58 @@ public final class Bukkit {
return server.getCraftingRecipe(craftingMatrix, world); return server.getCraftingRecipe(craftingMatrix, world);
} }
/**
* Get the crafted item using the list of {@link ItemStack} provided.
*
* <p>The list is formatted as a crafting matrix where the index follow
* the pattern below:</p>
*
* <pre>
* [ 0 1 2 ]
* [ 3 4 5 ]
* [ 6 7 8 ]
* </pre>
*
* <p>The {@link World} and {@link Player} arguments are required to fulfill the Bukkit Crafting
* events.</p>
*
* <p>Calls {@link org.bukkit.event.inventory.PrepareItemCraftEvent} to imitate the {@link Player}
* initiating the crafting event.</p>
*
* @param craftingMatrix list of items to be crafted from.
* Must not contain more than 9 items.
* @param world The world the crafting takes place in.
* @param player The player to imitate the crafting event on.
* @return resulting {@link ItemCraftResult} containing the resulting item, matrix and any overflow items.
*/
@NotNull
public static ItemCraftResult craftItemResult(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player) {
return server.craftItemResult(craftingMatrix, world, player);
}
/**
* Get the crafted item using the list of {@link ItemStack} provided.
*
* <p>The list is formatted as a crafting matrix where the index follow
* the pattern below:</p>
*
* <pre>
* [ 0 1 2 ]
* [ 3 4 5 ]
* [ 6 7 8 ]
* </pre>
*
* @param craftingMatrix list of items to be crafted from.
* Must not contain more than 9 items.
* @param world The world the crafting takes place in.
* @return resulting {@link ItemCraftResult} containing the resulting item, matrix and any overflow items.
*/
@NotNull
public static ItemCraftResult craftItemResult(@NotNull ItemStack[] craftingMatrix, @NotNull World world) {
return server.craftItemResult(craftingMatrix, world);
}
/** /**
* Get the crafted item using the list of {@link ItemStack} provided. * Get the crafted item using the list of {@link ItemStack} provided.
* *
@ -974,6 +1027,29 @@ public final class Bukkit {
return server.craftItem(craftingMatrix, world, player); return server.craftItem(craftingMatrix, world, player);
} }
/**
* Get the crafted item using the list of {@link ItemStack} provided.
*
* <p>The list is formatted as a crafting matrix where the index follow
* the pattern below:</p>
*
* <pre>
* [ 0 1 2 ]
* [ 3 4 5 ]
* [ 6 7 8 ]
* </pre>
*
* @param craftingMatrix list of items to be crafted from.
* Must not contain more than 9 items.
* @param world The world the crafting takes place in.
* @return the {@link ItemStack} resulting from the given crafting matrix, if no recipe is found
* an ItemStack of {@link Material#AIR} is returned.
*/
@NotNull
public static ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world) {
return server.craftItem(craftingMatrix, world);
}
/** /**
* Get an iterator through the list of crafting recipes. * Get an iterator through the list of crafting recipes.
* *
@ -1864,7 +1940,7 @@ public final class Bukkit {
* @return new data instance * @return new data instance
*/ */
@NotNull @NotNull
public static <B extends BlockData> B createBlockData(@NotNull BlockType<B> blockType, @Nullable Consumer<B> consumer) { public static <B extends BlockData> B createBlockData(@NotNull BlockType<B> blockType, @Nullable Consumer<? super B> consumer) {
return server.createBlockData(blockType, consumer); return server.createBlockData(blockType, consumer);
} }

View file

@ -1,25 +1,37 @@
package org.bukkit; package org.bukkit;
import com.google.common.base.Preconditions;
import org.bukkit.entity.Ageable; import org.bukkit.entity.Ageable;
import org.bukkit.entity.ArmorStand; import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Cat; import org.bukkit.entity.Cat;
import org.bukkit.entity.Dolphin; import org.bukkit.entity.Dolphin;
import org.bukkit.entity.Egg;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EvokerFangs;
import org.bukkit.entity.Firework; import org.bukkit.entity.Firework;
import org.bukkit.entity.Fox; import org.bukkit.entity.Fox;
import org.bukkit.entity.Goat;
import org.bukkit.entity.Guardian; import org.bukkit.entity.Guardian;
import org.bukkit.entity.Hoglin;
import org.bukkit.entity.IronGolem; import org.bukkit.entity.IronGolem;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Rabbit; import org.bukkit.entity.Rabbit;
import org.bukkit.entity.Ravager; import org.bukkit.entity.Ravager;
import org.bukkit.entity.Sheep;
import org.bukkit.entity.Sniffer;
import org.bukkit.entity.Snowball;
import org.bukkit.entity.Squid; import org.bukkit.entity.Squid;
import org.bukkit.entity.Tameable; import org.bukkit.entity.Tameable;
import org.bukkit.entity.TippedArrow; import org.bukkit.entity.TippedArrow;
import org.bukkit.entity.Villager; import org.bukkit.entity.Villager;
import org.bukkit.entity.Warden;
import org.bukkit.entity.Witch; import org.bukkit.entity.Witch;
import org.bukkit.entity.Wolf; import org.bukkit.entity.Wolf;
import org.bukkit.entity.Zoglin;
import org.bukkit.entity.ZombieVillager; import org.bukkit.entity.ZombieVillager;
import org.bukkit.entity.minecart.ExplosiveMinecart;
import org.bukkit.entity.minecart.SpawnerMinecart;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@ -35,6 +47,11 @@ public enum EntityEffect {
* Rabbit jumping. * Rabbit jumping.
*/ */
RABBIT_JUMP(1, Rabbit.class), RABBIT_JUMP(1, Rabbit.class),
/**
* Resets a spawner minecart's delay to 200. Does not effect actual spawning
* delay, only the speed at which the entity in the spawner spins
*/
RESET_SPAWNER_MINECART_DELAY(1, SpawnerMinecart.class),
/** /**
* When mobs get hurt. * When mobs get hurt.
* *
@ -47,35 +64,86 @@ public enum EntityEffect {
* <p> * <p>
* <b>This will cause client-glitches!</b> * <b>This will cause client-glitches!</b>
* *
* @deprecated although this effect may trigger other events on non-living * @deprecated split into individual effects
* entities, it's only supported usage is on living ones. * @see #EGG_BREAK
* @see #SNOWBALL_BREAK
* @see #ENTITY_DEATH
*/ */
@Deprecated @Deprecated
DEATH(3, Entity.class), DEATH(3, Entity.class),
// PAIL - SPIGOT-3641 duplicate /**
// GOLEM_ATTACK(4, IronGolem.class), * Spawns the egg breaking particles
*/
EGG_BREAK(3, Egg.class),
/**
* Spawns the snowball breaking particles
*/
SNOWBALL_BREAK(3, Snowball.class),
/**
* Plays the entity death sound and animation
* <p>
* <b>This will cause client-glitches!</b>
*/
ENTITY_DEATH(3, LivingEntity.class),
/**
* Plays the fang attack animation
*/
FANG_ATTACK(4, EvokerFangs.class),
/**
* Plays the hoglin attack animation
*/
HOGLIN_ATTACK(4, Hoglin.class),
/**
* Plays the iron golem attack animation
*/
IRON_GOLEN_ATTACK(4, IronGolem.class),
/**
* Plays the ravager attack animation
*/
RAVAGER_ATTACK(4, Ravager.class),
/**
* Plays the warden attack animation
*/
WARDEN_ATTACK(4, Warden.class),
/**
* Plays the zoglin attack animation
*/
ZOGLIN_ATTACK(4, Zoglin.class),
// 5 - unused // 5 - unused
/** /**
* The smoke when taming a wolf fails. * The smoke when taming an entity fails.
*/ */
WOLF_SMOKE(6, Tameable.class), WOLF_SMOKE(6, Tameable.class),
/** /**
* The hearts when taming a wolf succeeds. * The hearts when taming an entity succeeds.
*/ */
WOLF_HEARTS(7, Wolf.class), WOLF_HEARTS(7, Tameable.class),
/** /**
* When a wolf shakes (after being wet). * When a wolf shakes (after being wet).
*
* @see EntityEffect#WOLF_SHAKE_STOP
*/ */
WOLF_SHAKE(8, Wolf.class), WOLF_SHAKE(8, Wolf.class),
// 9 - unused // 9 - unused
/** /**
* When an entity eats a LONG_GRASS block. * When an entity eats a LONG_GRASS block.
* *
* @deprecated although this effect may trigger other events on non-living * @deprecated split into individual effects
* entities, it's only supported usage is on living ones. * @see #SHEEP_EAT_GRASS
* @see #TNT_MINECART_IGNITE
*/ */
@Deprecated @Deprecated
SHEEP_EAT(10, Entity.class), SHEEP_EAT(10, Entity.class),
/**
* Plays the sheep eating grass animation
*/
SHEEP_EAT_GRASS(10, Sheep.class),
/**
* Causes the TNT minecart to ignite, does not play the ignition sound
* <p>
* <b>This will cause client-glitches!</b>
*/
TNT_MINECART_IGNITE(10, ExplosiveMinecart.class),
/** /**
* When an Iron Golem gives a rose. * When an Iron Golem gives a rose.
*/ */
@ -213,7 +281,57 @@ public enum EntityEffect {
/** /**
* Entity breaks item in boot slot * Entity breaks item in boot slot
*/ */
BREAK_EQUIPMENT_BOOTS(52, LivingEntity.class); BREAK_EQUIPMENT_BOOTS(52, LivingEntity.class),
/**
* Spawns honey block slide particles at the entity's feet
*/
HONEY_BLOCK_SLIDE_PARTICLES(53, Entity.class),
/**
* Spawns honey block fall particles at the entity's feet
*/
HONEY_BLOCK_FALL_PARTICLES(54, LivingEntity.class),
/**
* Entity swaps the items in their hand and offhand
*/
SWAP_HAND_ITEMS(55, LivingEntity.class),
/**
* Stops a wolf that is currently shaking
*
* @see EntityEffect#WOLF_SHAKE
*/
WOLF_SHAKE_STOP(56, Wolf.class),
// 57 - unused
/**
* Goat lowers its head for ramming
*
* @see #GOAT_RAISE_HEAD
*/
GOAT_LOWER_HEAD(58, Goat.class),
/**
* Goat raises its head
*
* @see #GOAT_LOWER_HEAD
*/
GOAT_RAISE_HEAD(59, Goat.class),
/**
* Spawns death smoke particles
*/
SPAWN_DEATH_SMOKE(60, LivingEntity.class),
/**
* Warden shakes its tendrils
*/
WARDEN_TENDRIL_SHAKE(61, Warden.class),
/**
* Warden performs sonic attack animation <br>
* Does not play the sound or fire the beam
*/
WARDEN_SONIC_ATTACK(62, Warden.class),
/**
* Plays sniffer digging sound <br>
* Sniffer must have a target and be in {@link Sniffer.State#SEARCHING} or
* {@link Sniffer.State#DIGGING}
*/
SNIFFER_DIG(63, Sniffer.class);
private final byte data; private final byte data;
private final Class<? extends Entity> applicable; private final Class<? extends Entity> applicable;
@ -224,7 +342,7 @@ public enum EntityEffect {
} }
/** /**
* Gets the data value of this EntityEffect * Gets the data value of this EntityEffect, may not be unique.
* *
* @return The data value * @return The data value
* @deprecated Magic value * @deprecated Magic value
@ -243,4 +361,28 @@ public enum EntityEffect {
public Class<? extends Entity> getApplicable() { public Class<? extends Entity> getApplicable() {
return applicable; return applicable;
} }
/**
* Checks if this effect is applicable to the given entity.
*
* @param entity the entity to check
* @return true if applicable
*/
public boolean isApplicableTo(@NotNull Entity entity) {
Preconditions.checkArgument(entity != null, "Entity cannot be null");
return isApplicableTo(entity.getClass());
}
/**
* Checks if this effect is applicable to the given entity class.
*
* @param clazz the entity class to check
* @return true if applicable
*/
public boolean isApplicableTo(@NotNull Class<? extends Entity> clazz) {
Preconditions.checkArgument(clazz != null, "Class cannot be null");
return applicable.isAssignableFrom(clazz);
}
} }

View file

@ -27,4 +27,7 @@ public interface FeatureFlag extends Keyed {
@MinecraftExperimental @MinecraftExperimental
public static final FeatureFlag TRADE_REBALANCE = Bukkit.getUnsafe().getFeatureFlag(NamespacedKey.minecraft("trade_rebalance")); public static final FeatureFlag TRADE_REBALANCE = Bukkit.getUnsafe().getFeatureFlag(NamespacedKey.minecraft("trade_rebalance"));
@MinecraftExperimental
public static final FeatureFlag UPDATE_121 = Bukkit.getUnsafe().getFeatureFlag(NamespacedKey.minecraft("update_1_21"));
} }

View file

@ -61,6 +61,11 @@ public final class GameRule<T> {
*/ */
public static final GameRule<Boolean> DO_MOB_LOOT = new GameRule<>("doMobLoot", Boolean.class); public static final GameRule<Boolean> DO_MOB_LOOT = new GameRule<>("doMobLoot", Boolean.class);
/**
* Whether projectiles can break blocks.
*/
public static final GameRule<Boolean> PROJECTILES_CAN_BREAK_BLOCKS = new GameRule<>("projectilesCanBreakBlocks", Boolean.class);
/** /**
* Whether mobs should naturally spawn. * Whether mobs should naturally spawn.
*/ */
@ -243,6 +248,12 @@ public final class GameRule<T> {
*/ */
public static final GameRule<Integer> MAX_COMMAND_CHAIN_LENGTH = new GameRule<>("maxCommandChainLength", Integer.class); public static final GameRule<Integer> MAX_COMMAND_CHAIN_LENGTH = new GameRule<>("maxCommandChainLength", Integer.class);
/**
* Determines the number of different commands/functions which execute
* commands can fork into.
*/
public static final GameRule<Integer> MAX_COMMAND_FORK_COUNT = new GameRule<>("maxCommandForkCount", Integer.class);
/** /**
* Determines the maximum number of blocks which a command can modify. * Determines the maximum number of blocks which a command can modify.
*/ */
@ -255,6 +266,18 @@ public final class GameRule<T> {
public static final GameRule<Integer> PLAYERS_SLEEPING_PERCENTAGE = new GameRule<>("playersSleepingPercentage", Integer.class); public static final GameRule<Integer> PLAYERS_SLEEPING_PERCENTAGE = new GameRule<>("playersSleepingPercentage", Integer.class);
public static final GameRule<Integer> SNOW_ACCUMULATION_HEIGHT = new GameRule<>("snowAccumulationHeight", Integer.class); public static final GameRule<Integer> SNOW_ACCUMULATION_HEIGHT = new GameRule<>("snowAccumulationHeight", Integer.class);
/**
* The amount of time a player must stand in a nether portal before the
* portal activates.
*/
public static final GameRule<Integer> PLAYERS_NETHER_PORTAL_DEFAULT_DELAY = new GameRule<>("playersNetherPortalDefaultDelay", Integer.class);
/**
* The amount of time a player in creative mode must stand in a nether
* portal before the portal activates.
*/
public static final GameRule<Integer> PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = new GameRule<>("playersNetherPortalCreativeDelay", Integer.class);
// All GameRules instantiated above this for organizational purposes // All GameRules instantiated above this for organizational purposes
private final String name; private final String name;
private final Class<T> type; private final Class<T> type;

View file

@ -9,110 +9,123 @@ public enum Instrument {
/** /**
* Piano is the standard instrument for a note block. * Piano is the standard instrument for a note block.
*/ */
PIANO(0x0), PIANO(0x0, Sound.BLOCK_NOTE_BLOCK_HARP),
/** /**
* Bass drum is normally played when a note block is on top of a * Bass drum is normally played when a note block is on top of a
* stone-like block. * stone-like block.
*/ */
BASS_DRUM(0x1), BASS_DRUM(0x1, Sound.BLOCK_NOTE_BLOCK_BASEDRUM),
/** /**
* Snare drum is normally played when a note block is on top of a sandy * Snare drum is normally played when a note block is on top of a sandy
* block. * block.
*/ */
SNARE_DRUM(0x2), SNARE_DRUM(0x2, Sound.BLOCK_NOTE_BLOCK_SNARE),
/** /**
* Sticks are normally played when a note block is on top of a glass * Sticks are normally played when a note block is on top of a glass
* block. * block.
*/ */
STICKS(0x3), STICKS(0x3, Sound.BLOCK_NOTE_BLOCK_HAT),
/** /**
* Bass guitar is normally played when a note block is on top of a wooden * Bass guitar is normally played when a note block is on top of a wooden
* block. * block.
*/ */
BASS_GUITAR(0x4), BASS_GUITAR(0x4, Sound.BLOCK_NOTE_BLOCK_BASS),
/** /**
* Flute is normally played when a note block is on top of a clay block. * Flute is normally played when a note block is on top of a clay block.
*/ */
FLUTE(0x5), FLUTE(0x5, Sound.BLOCK_NOTE_BLOCK_FLUTE),
/** /**
* Bell is normally played when a note block is on top of a gold block. * Bell is normally played when a note block is on top of a gold block.
*/ */
BELL(0x6), BELL(0x6, Sound.BLOCK_NOTE_BLOCK_BELL),
/** /**
* Guitar is normally played when a note block is on top of a woolen block. * Guitar is normally played when a note block is on top of a woolen block.
*/ */
GUITAR(0x7), GUITAR(0x7, Sound.BLOCK_NOTE_BLOCK_GUITAR),
/** /**
* Chime is normally played when a note block is on top of a packed ice * Chime is normally played when a note block is on top of a packed ice
* block. * block.
*/ */
CHIME(0x8), CHIME(0x8, Sound.BLOCK_NOTE_BLOCK_CHIME),
/** /**
* Xylophone is normally played when a note block is on top of a bone block. * Xylophone is normally played when a note block is on top of a bone block.
*/ */
XYLOPHONE(0x9), XYLOPHONE(0x9, Sound.BLOCK_NOTE_BLOCK_XYLOPHONE),
/** /**
* Iron Xylophone is normally played when a note block is on top of a iron block. * Iron Xylophone is normally played when a note block is on top of a iron block.
*/ */
IRON_XYLOPHONE(0xA), IRON_XYLOPHONE(0xA, Sound.BLOCK_NOTE_BLOCK_IRON_XYLOPHONE),
/** /**
* Cow Bell is normally played when a note block is on top of a soul sand block. * Cow Bell is normally played when a note block is on top of a soul sand block.
*/ */
COW_BELL(0xB), COW_BELL(0xB, Sound.BLOCK_NOTE_BLOCK_COW_BELL),
/** /**
* Didgeridoo is normally played when a note block is on top of a pumpkin block. * Didgeridoo is normally played when a note block is on top of a pumpkin block.
*/ */
DIDGERIDOO(0xC), DIDGERIDOO(0xC, Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO),
/** /**
* Bit is normally played when a note block is on top of a emerald block. * Bit is normally played when a note block is on top of a emerald block.
*/ */
BIT(0xD), BIT(0xD, Sound.BLOCK_NOTE_BLOCK_BIT),
/** /**
* Banjo is normally played when a note block is on top of a hay block. * Banjo is normally played when a note block is on top of a hay block.
*/ */
BANJO(0xE), BANJO(0xE, Sound.BLOCK_NOTE_BLOCK_BANJO),
/** /**
* Pling is normally played when a note block is on top of a glowstone block. * Pling is normally played when a note block is on top of a glowstone block.
*/ */
PLING(0xF), PLING(0xF, Sound.BLOCK_NOTE_BLOCK_PLING),
/** /**
* Zombie is normally played when a Zombie Head is on top of the note block. * Zombie is normally played when a Zombie Head is on top of the note block.
*/ */
ZOMBIE, ZOMBIE(Sound.BLOCK_NOTE_BLOCK_IMITATE_ZOMBIE),
/** /**
* Skeleton is normally played when a Skeleton Head is on top of the note block. * Skeleton is normally played when a Skeleton Head is on top of the note block.
*/ */
SKELETON, SKELETON(Sound.BLOCK_NOTE_BLOCK_IMITATE_SKELETON),
/** /**
* Creeper is normally played when a Creeper Head is on top of the note block. * Creeper is normally played when a Creeper Head is on top of the note block.
*/ */
CREEPER, CREEPER(Sound.BLOCK_NOTE_BLOCK_IMITATE_CREEPER),
/** /**
* Dragon is normally played when a Dragon Head is on top of the note block. * Dragon is normally played when a Dragon Head is on top of the note block.
*/ */
DRAGON, DRAGON(Sound.BLOCK_NOTE_BLOCK_IMITATE_ENDER_DRAGON),
/** /**
* Wither Skeleton is normally played when a Wither Skeleton Head is on top of the note block. * Wither Skeleton is normally played when a Wither Skeleton Head is on top of the note block.
*/ */
WITHER_SKELETON, WITHER_SKELETON(Sound.BLOCK_NOTE_BLOCK_IMITATE_WITHER_SKELETON),
/** /**
* Piglin is normally played when a Piglin Head is on top of the note block. * Piglin is normally played when a Piglin Head is on top of the note block.
*/ */
PIGLIN, PIGLIN(Sound.BLOCK_NOTE_BLOCK_IMITATE_PIGLIN),
/** /**
* Custom Sound is normally played when a Player Head with the required data is on top of the note block. * Custom Sound is normally played when a Player Head with the required data is on top of the note block.
*/ */
CUSTOM_HEAD; CUSTOM_HEAD(null);
private final byte type; private final byte type;
private final Sound sound;
private static final Map<Byte, Instrument> BY_DATA = Maps.newHashMap(); private static final Map<Byte, Instrument> BY_DATA = Maps.newHashMap();
private Instrument() { private Instrument(final Sound sound) {
this(-1); this(-1, sound);
} }
private Instrument(final int type) { private Instrument(final int type, final Sound sound) {
this.type = (byte) type; this.type = (byte) type;
this.sound = sound;
}
/**
* Gets the sound associated with this instrument. <br>
* Will be null for {@link Instrument#CUSTOM_HEAD}
*
* @return the sound or null
*/
@Nullable
public Sound getSound() {
return this.sound;
} }
/** /**

File diff suppressed because it is too large Load diff

View file

@ -118,6 +118,14 @@ public class Note {
} }
} }
private static final float[] pitchArray = new float[25];
static {
for (int i = 0; i <= 24; i++) {
// See https://minecraft.wiki/w/Note_Block#Notes
pitchArray[i] = (float) Math.pow(2, (i - 12) / 12f);
}
}
private final byte note; private final byte note;
/** /**
@ -254,6 +262,16 @@ public class Note {
return Tone.getById(note).isSharped(note); return Tone.getById(note).isSharped(note);
} }
/**
* Gets the pitch of this note. This is the value used with
* {@link World#playSound} or the /playsound command.
*
* @return the pitch
*/
public float getPitch() {
return pitchArray[this.note];
}
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;

View file

@ -120,6 +120,16 @@ public abstract class Particle<D> extends OldEnum<Particle<D>> implements Keyed
public static final Particle<Integer> SHRIEK = getParticle("shriek"); public static final Particle<Integer> SHRIEK = getParticle("shriek");
public static final Particle<Void> CHERRY_LEAVES = getParticle("cherry_leaves"); public static final Particle<Void> CHERRY_LEAVES = getParticle("cherry_leaves");
public static final Particle<Void> EGG_CRACK = getParticle("egg_crack"); public static final Particle<Void> EGG_CRACK = getParticle("egg_crack");
public static final Particle<Void> DUST_PLUME = getParticle("dust_plume");
public static final Particle<Void> WHITE_SMOKE = getParticle("white_smoke");
@MinecraftExperimental
public static final Particle<Void> GUST = getParticle("gust");
@MinecraftExperimental
public static final Particle<Void> GUST_EMITTER = getParticle("gust_emitter");
@MinecraftExperimental
public static final Particle<Void> GUST_DUST = getParticle("gust_dust");
@MinecraftExperimental
public static final Particle<Void> TRIAL_SPAWNER_DETECTION = getParticle("trial_spawner_detection");
/** /**
* Uses {@link BlockData} as DataType * Uses {@link BlockData} as DataType
*/ */

View file

@ -183,7 +183,7 @@ public interface RegionAccessor {
* @param stateConsumer The consumer which should get called for every block which gets changed * @param stateConsumer The consumer which should get called for every block which gets changed
* @return true if the tree was created successfully, otherwise false * @return true if the tree was created successfully, otherwise false
*/ */
boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer<BlockState> stateConsumer); boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer<? super BlockState> stateConsumer);
/** /**
* Creates a tree at the given {@link Location} * Creates a tree at the given {@link Location}
@ -203,7 +203,7 @@ public interface RegionAccessor {
* @param statePredicate The predicate which should get used to test if a block should be set or not. * @param statePredicate The predicate which should get used to test if a block should be set or not.
* @return true if the tree was created successfully, otherwise false * @return true if the tree was created successfully, otherwise false
*/ */
boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate<BlockState> statePredicate); boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate<? super BlockState> statePredicate);
/** /**
* Creates a entity at the given {@link Location} * Creates a entity at the given {@link Location}
@ -282,6 +282,24 @@ public interface RegionAccessor {
@NotNull @NotNull
Collection<Entity> getEntitiesByClasses(@NotNull Class<?>... classes); Collection<Entity> getEntitiesByClasses(@NotNull Class<?>... classes);
/**
* Creates an entity of a specific class at the given {@link Location} but
* does not spawn it in the world.
* <p>
* <b>Note:</b> The created entity keeps a reference to the world it was
* created in, care should be taken that the entity does not outlive the
* world instance as this will lead to memory leaks.
*
* @param <T> the class of the {@link Entity} to create
* @param location the {@link Location} to create the entity at
* @param clazz the class of the {@link Entity} to spawn
* @return an instance of the created {@link Entity}
* @see #addEntity(Entity)
* @see Entity#createSnapshot()
*/
@NotNull
<T extends Entity> T createEntity(@NotNull Location location, @NotNull Class<T> clazz);
/** /**
* Spawn an entity of a specific class at the given {@link Location} * Spawn an entity of a specific class at the given {@link Location}
* *
@ -312,7 +330,7 @@ public interface RegionAccessor {
* {@link Entity} requested cannot be spawned * {@link Entity} requested cannot be spawned
*/ */
@NotNull @NotNull
<T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, @Nullable Consumer<T> function) throws IllegalArgumentException; <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, @Nullable Consumer<? super T> function) throws IllegalArgumentException;
/** /**
* Creates a new entity at the given {@link Location} with the supplied * Creates a new entity at the given {@link Location} with the supplied
@ -350,7 +368,7 @@ public interface RegionAccessor {
* @throws IllegalArgumentException if either the world or clazz parameter are null. * @throws IllegalArgumentException if either the world or clazz parameter are null.
*/ */
@NotNull @NotNull
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, boolean randomizeData, @Nullable Consumer<T> function) throws IllegalArgumentException; public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, boolean randomizeData, @Nullable Consumer<? super T> function) throws IllegalArgumentException;
/** /**
* Gets the highest non-empty (impassable) coordinate at the given * Gets the highest non-empty (impassable) coordinate at the given
@ -396,4 +414,15 @@ public interface RegionAccessor {
* {@link HeightMap} * {@link HeightMap}
*/ */
public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap); public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap);
/**
* Spawns a previously created entity in the world. <br>
* The provided entity must not have already been spawned in a world.
*
* @param <T> the generic type of the entity that is being added.
* @param entity the entity to add
* @return the entity now in the world
*/
@NotNull
public <T extends Entity> T addEntity(@NotNull T entity);
} }

View file

@ -79,6 +79,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @see Attribute * @see Attribute
*/ */
Registry<Attribute> ATTRIBUTE = Objects.requireNonNull(Bukkit.getRegistry(Attribute.class), "No registry present for Attribute. This is a bug."); Registry<Attribute> ATTRIBUTE = Objects.requireNonNull(Bukkit.getRegistry(Attribute.class), "No registry present for Attribute. This is a bug.");
/**
* Server banner patterns.
*
* @see PatternType
*/
Registry<PatternType> BANNER_PATTERN = Objects.requireNonNull(Bukkit.getRegistry(PatternType.class), "No registry present for PatternType. This is a bug.");
/** /**
* Server biomes. * Server biomes.
* *
@ -91,12 +97,6 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @see BlockType * @see BlockType
*/ */
Registry<BlockType<?>> BLOCK = Objects.requireNonNull(Bukkit.getRegistry(BlockType.class), "No registry present for BlockType. This is a bug."); Registry<BlockType<?>> BLOCK = Objects.requireNonNull(Bukkit.getRegistry(BlockType.class), "No registry present for BlockType. This is a bug.");
/**
* Server pattern types.
*
* @see PatternType
*/
Registry<PatternType> BANNER_PATTERN = Objects.requireNonNull(Bukkit.getRegistry(PatternType.class), "No registry present for PatternType. This is a bug.");
/** /**
* Custom boss bars. * Custom boss bars.
* *
@ -128,7 +128,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* *
* @see Cat.Type * @see Cat.Type
*/ */
Registry<Cat.Type> CAT_TYPE = Objects.requireNonNull(Bukkit.getRegistry(Cat.Type.class), "No registry present for Cat Type. This is a bug."); Registry<Cat.Type> CAT_VARIANT = Objects.requireNonNull(Bukkit.getRegistry(Cat.Type.class), "No registry present for Cat Type. This is a bug.");
/** /**
* Server enchantments. * Server enchantments.
* *
@ -167,6 +167,12 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
*/ */
@Deprecated @Deprecated
Registry<Material> MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy()); Registry<Material> MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy());
/**
* Server mob effects.
*
* @see PotionEffectType
*/
Registry<PotionEffectType> EFFECT = Objects.requireNonNull(Bukkit.getRegistry(PotionEffectType.class), "No registry present for PotionEffectType. This is a bug.");
/** /**
* Server particles. * Server particles.
* *
@ -272,13 +278,6 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
* @see GameEvent * @see GameEvent
*/ */
Registry<GameEvent> GAME_EVENT = Objects.requireNonNull(Bukkit.getRegistry(GameEvent.class), "No registry present for GameEvent. This is a bug."); Registry<GameEvent> GAME_EVENT = Objects.requireNonNull(Bukkit.getRegistry(GameEvent.class), "No registry present for GameEvent. This is a bug.");
/**
* Server potion effect types.
*
* @see PotionEffectType
*/
Registry<PotionEffectType> POTION_EFFECT_TYPE = Objects.requireNonNull(Bukkit.getRegistry(PotionEffectType.class), "No registry present for Potion Effect Type. This is a bug.");
/** /**
* Get the object by its key. * Get the object by its key.
* *

View file

@ -36,6 +36,7 @@ import org.bukkit.generator.ChunkGenerator;
import org.bukkit.help.HelpMap; import org.bukkit.help.HelpMap;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemCraftResult;
import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Merchant; import org.bukkit.inventory.Merchant;
@ -836,6 +837,74 @@ public interface Server extends PluginMessageRecipient {
@NotNull @NotNull
public ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player); public ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player);
/**
* Get the crafted item using the list of {@link ItemStack} provided.
*
* <p>The list is formatted as a crafting matrix where the index follow
* the pattern below:</p>
*
* <pre>
* [ 0 1 2 ]
* [ 3 4 5 ]
* [ 6 7 8 ]
* </pre>
*
* @param craftingMatrix list of items to be crafted from.
* Must not contain more than 9 items.
* @param world The world the crafting takes place in.
* @return the {@link ItemStack} resulting from the given crafting matrix, if no recipe is found
* an ItemStack of {@link Material#AIR} is returned.
*/
@NotNull
public ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world);
/**
* Get the crafted item using the list of {@link ItemStack} provided.
*
* <p>The list is formatted as a crafting matrix where the index follow
* the pattern below:</p>
*
* <pre>
* [ 0 1 2 ]
* [ 3 4 5 ]
* [ 6 7 8 ]
* </pre>
*
* <p>The {@link World} and {@link Player} arguments are required to fulfill the Bukkit Crafting
* events.</p>
*
* <p>Calls {@link org.bukkit.event.inventory.PrepareItemCraftEvent} to imitate the {@link Player}
* initiating the crafting event.</p>
*
* @param craftingMatrix list of items to be crafted from.
* Must not contain more than 9 items.
* @param world The world the crafting takes place in.
* @param player The player to imitate the crafting event on.
* @return resulting {@link ItemCraftResult} containing the resulting item, matrix and any overflow items.
*/
@NotNull
public ItemCraftResult craftItemResult(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player);
/**
* Get the crafted item using the list of {@link ItemStack} provided.
*
* <p>The list is formatted as a crafting matrix where the index follow
* the pattern below:</p>
*
* <pre>
* [ 0 1 2 ]
* [ 3 4 5 ]
* [ 6 7 8 ]
* </pre>
*
* @param craftingMatrix list of items to be crafted from.
* Must not contain more than 9 items.
* @param world The world the crafting takes place in.
* @return resulting {@link ItemCraftResult} containing the resulting item, matrix and any overflow items.
*/
@NotNull
public ItemCraftResult craftItemResult(@NotNull ItemStack[] craftingMatrix, @NotNull World world);
/** /**
* Get an iterator through the list of crafting recipes. * Get an iterator through the list of crafting recipes.
* *
@ -1583,7 +1652,7 @@ public interface Server extends PluginMessageRecipient {
* @return new data instance * @return new data instance
*/ */
@NotNull @NotNull
public <B extends BlockData> B createBlockData(@NotNull BlockType<B> blockType, @Nullable Consumer<B> consumer); public <B extends BlockData> B createBlockData(@NotNull BlockType<B> blockType, @Nullable Consumer<? super B> consumer);
/** /**
* Creates a new {@link BlockData} instance with block type and properties * Creates a new {@link BlockData} instance with block type and properties

View file

@ -181,6 +181,15 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound ITEM_BOTTLE_EMPTY = getSound("item.bottle.empty"); public static final Sound ITEM_BOTTLE_EMPTY = getSound("item.bottle.empty");
public static final Sound ITEM_BOTTLE_FILL = getSound("item.bottle.fill"); public static final Sound ITEM_BOTTLE_FILL = getSound("item.bottle.fill");
public static final Sound ITEM_BOTTLE_FILL_DRAGONBREATH = getSound("item.bottle.fill_dragonbreath"); public static final Sound ITEM_BOTTLE_FILL_DRAGONBREATH = getSound("item.bottle.fill_dragonbreath");
public static final Sound ENTITY_BREEZE_INHALE = getSound("entity.breeze.inhale");
public static final Sound ENTITY_BREEZE_IDLE_GROUND = getSound("entity.breeze.idle_ground");
public static final Sound ENTITY_BREEZE_IDLE_AIR = getSound("entity.breeze.idle_air");
public static final Sound ENTITY_BREEZE_SHOOT = getSound("entity.breeze.shoot");
public static final Sound ENTITY_BREEZE_JUMP = getSound("entity.breeze.jump");
public static final Sound ENTITY_BREEZE_LAND = getSound("entity.breeze.land");
public static final Sound ENTITY_BREEZE_SLIDE = getSound("entity.breeze.slide");
public static final Sound ENTITY_BREEZE_DEATH = getSound("entity.breeze.death");
public static final Sound ENTITY_BREEZE_HURT = getSound("entity.breeze.hurt");
public static final Sound BLOCK_BREWING_STAND_BREW = getSound("block.brewing_stand.brew"); public static final Sound BLOCK_BREWING_STAND_BREW = getSound("block.brewing_stand.brew");
public static final Sound ITEM_BRUSH_BRUSHING_GENERIC = getSound("item.brush.brushing.generic"); public static final Sound ITEM_BRUSH_BRUSHING_GENERIC = getSound("item.brush.brushing.generic");
public static final Sound ITEM_BRUSH_BRUSHING_SAND = getSound("item.brush.brushing.sand"); public static final Sound ITEM_BRUSH_BRUSHING_SAND = getSound("item.brush.brushing.sand");
@ -316,11 +325,27 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound BLOCK_CONDUIT_AMBIENT_SHORT = getSound("block.conduit.ambient.short"); public static final Sound BLOCK_CONDUIT_AMBIENT_SHORT = getSound("block.conduit.ambient.short");
public static final Sound BLOCK_CONDUIT_ATTACK_TARGET = getSound("block.conduit.attack.target"); public static final Sound BLOCK_CONDUIT_ATTACK_TARGET = getSound("block.conduit.attack.target");
public static final Sound BLOCK_CONDUIT_DEACTIVATE = getSound("block.conduit.deactivate"); public static final Sound BLOCK_CONDUIT_DEACTIVATE = getSound("block.conduit.deactivate");
public static final Sound BLOCK_COPPER_BULB_BREAK = getSound("block.copper_bulb.break");
public static final Sound BLOCK_COPPER_BULB_STEP = getSound("block.copper_bulb.step");
public static final Sound BLOCK_COPPER_BULB_PLACE = getSound("block.copper_bulb.place");
public static final Sound BLOCK_COPPER_BULB_HIT = getSound("block.copper_bulb.hit");
public static final Sound BLOCK_COPPER_BULB_FALL = getSound("block.copper_bulb.fall");
public static final Sound BLOCK_COPPER_BULB_TURN_ON = getSound("block.copper_bulb.turn_on");
public static final Sound BLOCK_COPPER_BULB_TURN_OFF = getSound("block.copper_bulb.turn_off");
public static final Sound BLOCK_COPPER_BREAK = getSound("block.copper.break"); public static final Sound BLOCK_COPPER_BREAK = getSound("block.copper.break");
public static final Sound BLOCK_COPPER_STEP = getSound("block.copper.step"); public static final Sound BLOCK_COPPER_STEP = getSound("block.copper.step");
public static final Sound BLOCK_COPPER_PLACE = getSound("block.copper.place"); public static final Sound BLOCK_COPPER_PLACE = getSound("block.copper.place");
public static final Sound BLOCK_COPPER_HIT = getSound("block.copper.hit"); public static final Sound BLOCK_COPPER_HIT = getSound("block.copper.hit");
public static final Sound BLOCK_COPPER_FALL = getSound("block.copper.fall"); public static final Sound BLOCK_COPPER_FALL = getSound("block.copper.fall");
public static final Sound BLOCK_COPPER_DOOR_CLOSE = getSound("block.copper_door.close");
public static final Sound BLOCK_COPPER_DOOR_OPEN = getSound("block.copper_door.open");
public static final Sound BLOCK_COPPER_GRATE_BREAK = getSound("block.copper_grate.break");
public static final Sound BLOCK_COPPER_GRATE_STEP = getSound("block.copper_grate.step");
public static final Sound BLOCK_COPPER_GRATE_PLACE = getSound("block.copper_grate.place");
public static final Sound BLOCK_COPPER_GRATE_HIT = getSound("block.copper_grate.hit");
public static final Sound BLOCK_COPPER_GRATE_FALL = getSound("block.copper_grate.fall");
public static final Sound BLOCK_COPPER_TRAPDOOR_CLOSE = getSound("block.copper_trapdoor.close");
public static final Sound BLOCK_COPPER_TRAPDOOR_OPEN = getSound("block.copper_trapdoor.open");
public static final Sound BLOCK_CORAL_BLOCK_BREAK = getSound("block.coral_block.break"); public static final Sound BLOCK_CORAL_BLOCK_BREAK = getSound("block.coral_block.break");
public static final Sound BLOCK_CORAL_BLOCK_FALL = getSound("block.coral_block.fall"); public static final Sound BLOCK_CORAL_BLOCK_FALL = getSound("block.coral_block.fall");
public static final Sound BLOCK_CORAL_BLOCK_HIT = getSound("block.coral_block.hit"); public static final Sound BLOCK_CORAL_BLOCK_HIT = getSound("block.coral_block.hit");
@ -331,6 +356,8 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound ENTITY_COW_HURT = getSound("entity.cow.hurt"); public static final Sound ENTITY_COW_HURT = getSound("entity.cow.hurt");
public static final Sound ENTITY_COW_MILK = getSound("entity.cow.milk"); public static final Sound ENTITY_COW_MILK = getSound("entity.cow.milk");
public static final Sound ENTITY_COW_STEP = getSound("entity.cow.step"); public static final Sound ENTITY_COW_STEP = getSound("entity.cow.step");
public static final Sound BLOCK_CRAFTER_CRAFT = getSound("block.crafter.craft");
public static final Sound BLOCK_CRAFTER_FAIL = getSound("block.crafter.fail");
public static final Sound ENTITY_CREEPER_DEATH = getSound("entity.creeper.death"); public static final Sound ENTITY_CREEPER_DEATH = getSound("entity.creeper.death");
public static final Sound ENTITY_CREEPER_HURT = getSound("entity.creeper.hurt"); public static final Sound ENTITY_CREEPER_HURT = getSound("entity.creeper.hurt");
public static final Sound ENTITY_CREEPER_PRIMED = getSound("entity.creeper.primed"); public static final Sound ENTITY_CREEPER_PRIMED = getSound("entity.creeper.primed");
@ -347,6 +374,8 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound BLOCK_DECORATED_POT_BREAK = getSound("block.decorated_pot.break"); public static final Sound BLOCK_DECORATED_POT_BREAK = getSound("block.decorated_pot.break");
public static final Sound BLOCK_DECORATED_POT_FALL = getSound("block.decorated_pot.fall"); public static final Sound BLOCK_DECORATED_POT_FALL = getSound("block.decorated_pot.fall");
public static final Sound BLOCK_DECORATED_POT_HIT = getSound("block.decorated_pot.hit"); public static final Sound BLOCK_DECORATED_POT_HIT = getSound("block.decorated_pot.hit");
public static final Sound BLOCK_DECORATED_POT_INSERT = getSound("block.decorated_pot.insert");
public static final Sound BLOCK_DECORATED_POT_INSERT_FAIL = getSound("block.decorated_pot.insert_fail");
public static final Sound BLOCK_DECORATED_POT_STEP = getSound("block.decorated_pot.step"); public static final Sound BLOCK_DECORATED_POT_STEP = getSound("block.decorated_pot.step");
public static final Sound BLOCK_DECORATED_POT_PLACE = getSound("block.decorated_pot.place"); public static final Sound BLOCK_DECORATED_POT_PLACE = getSound("block.decorated_pot.place");
public static final Sound BLOCK_DECORATED_POT_SHATTER = getSound("block.decorated_pot.shatter"); public static final Sound BLOCK_DECORATED_POT_SHATTER = getSound("block.decorated_pot.shatter");
@ -624,6 +653,17 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_FALL = getSound("block.bamboo_wood_hanging_sign.fall"); public static final Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_FALL = getSound("block.bamboo_wood_hanging_sign.fall");
public static final Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_HIT = getSound("block.bamboo_wood_hanging_sign.hit"); public static final Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_HIT = getSound("block.bamboo_wood_hanging_sign.hit");
public static final Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_PLACE = getSound("block.bamboo_wood_hanging_sign.place"); public static final Sound BLOCK_BAMBOO_WOOD_HANGING_SIGN_PLACE = getSound("block.bamboo_wood_hanging_sign.place");
public static final Sound BLOCK_TRIAL_SPAWNER_BREAK = getSound("block.trial_spawner.break");
public static final Sound BLOCK_TRIAL_SPAWNER_STEP = getSound("block.trial_spawner.step");
public static final Sound BLOCK_TRIAL_SPAWNER_PLACE = getSound("block.trial_spawner.place");
public static final Sound BLOCK_TRIAL_SPAWNER_HIT = getSound("block.trial_spawner.hit");
public static final Sound BLOCK_TRIAL_SPAWNER_FALL = getSound("block.trial_spawner.fall");
public static final Sound BLOCK_TRIAL_SPAWNER_SPAWN_MOB = getSound("block.trial_spawner.spawn_mob");
public static final Sound BLOCK_TRIAL_SPAWNER_DETECT_PLAYER = getSound("block.trial_spawner.detect_player");
public static final Sound BLOCK_TRIAL_SPAWNER_AMBIENT = getSound("block.trial_spawner.ambient");
public static final Sound BLOCK_TRIAL_SPAWNER_OPEN_SHUTTER = getSound("block.trial_spawner.open_shutter");
public static final Sound BLOCK_TRIAL_SPAWNER_CLOSE_SHUTTER = getSound("block.trial_spawner.close_shutter");
public static final Sound BLOCK_TRIAL_SPAWNER_EJECT_ITEM = getSound("block.trial_spawner.eject_item");
public static final Sound ITEM_HOE_TILL = getSound("item.hoe.till"); public static final Sound ITEM_HOE_TILL = getSound("item.hoe.till");
public static final Sound ENTITY_HOGLIN_AMBIENT = getSound("entity.hoglin.ambient"); public static final Sound ENTITY_HOGLIN_AMBIENT = getSound("entity.hoglin.ambient");
public static final Sound ENTITY_HOGLIN_ANGRY = getSound("entity.hoglin.angry"); public static final Sound ENTITY_HOGLIN_ANGRY = getSound("entity.hoglin.angry");
@ -958,6 +998,7 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound ENTITY_PARROT_FLY = getSound("entity.parrot.fly"); public static final Sound ENTITY_PARROT_FLY = getSound("entity.parrot.fly");
public static final Sound ENTITY_PARROT_HURT = getSound("entity.parrot.hurt"); public static final Sound ENTITY_PARROT_HURT = getSound("entity.parrot.hurt");
public static final Sound ENTITY_PARROT_IMITATE_BLAZE = getSound("entity.parrot.imitate.blaze"); public static final Sound ENTITY_PARROT_IMITATE_BLAZE = getSound("entity.parrot.imitate.blaze");
public static final Sound ENTITY_PARROT_IMITATE_BREEZE = getSound("entity.parrot.imitate.breeze");
public static final Sound ENTITY_PARROT_IMITATE_CREEPER = getSound("entity.parrot.imitate.creeper"); public static final Sound ENTITY_PARROT_IMITATE_CREEPER = getSound("entity.parrot.imitate.creeper");
public static final Sound ENTITY_PARROT_IMITATE_DROWNED = getSound("entity.parrot.imitate.drowned"); public static final Sound ENTITY_PARROT_IMITATE_DROWNED = getSound("entity.parrot.imitate.drowned");
public static final Sound ENTITY_PARROT_IMITATE_ELDER_GUARDIAN = getSound("entity.parrot.imitate.elder_guardian"); public static final Sound ENTITY_PARROT_IMITATE_ELDER_GUARDIAN = getSound("entity.parrot.imitate.elder_guardian");
@ -1044,6 +1085,7 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound ENTITY_PLAYER_SPLASH = getSound("entity.player.splash"); public static final Sound ENTITY_PLAYER_SPLASH = getSound("entity.player.splash");
public static final Sound ENTITY_PLAYER_SPLASH_HIGH_SPEED = getSound("entity.player.splash.high_speed"); public static final Sound ENTITY_PLAYER_SPLASH_HIGH_SPEED = getSound("entity.player.splash.high_speed");
public static final Sound ENTITY_PLAYER_SWIM = getSound("entity.player.swim"); public static final Sound ENTITY_PLAYER_SWIM = getSound("entity.player.swim");
public static final Sound ENTITY_PLAYER_TELEPORT = getSound("entity.player.teleport");
public static final Sound ENTITY_POLAR_BEAR_AMBIENT = getSound("entity.polar_bear.ambient"); public static final Sound ENTITY_POLAR_BEAR_AMBIENT = getSound("entity.polar_bear.ambient");
public static final Sound ENTITY_POLAR_BEAR_AMBIENT_BABY = getSound("entity.polar_bear.ambient_baby"); public static final Sound ENTITY_POLAR_BEAR_AMBIENT_BABY = getSound("entity.polar_bear.ambient_baby");
public static final Sound ENTITY_POLAR_BEAR_DEATH = getSound("entity.polar_bear.death"); public static final Sound ENTITY_POLAR_BEAR_DEATH = getSound("entity.polar_bear.death");
@ -1329,6 +1371,16 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound BLOCK_TUFF_PLACE = getSound("block.tuff.place"); public static final Sound BLOCK_TUFF_PLACE = getSound("block.tuff.place");
public static final Sound BLOCK_TUFF_HIT = getSound("block.tuff.hit"); public static final Sound BLOCK_TUFF_HIT = getSound("block.tuff.hit");
public static final Sound BLOCK_TUFF_FALL = getSound("block.tuff.fall"); public static final Sound BLOCK_TUFF_FALL = getSound("block.tuff.fall");
public static final Sound BLOCK_TUFF_BRICKS_BREAK = getSound("block.tuff_bricks.break");
public static final Sound BLOCK_TUFF_BRICKS_FALL = getSound("block.tuff_bricks.fall");
public static final Sound BLOCK_TUFF_BRICKS_HIT = getSound("block.tuff_bricks.hit");
public static final Sound BLOCK_TUFF_BRICKS_PLACE = getSound("block.tuff_bricks.place");
public static final Sound BLOCK_TUFF_BRICKS_STEP = getSound("block.tuff_bricks.step");
public static final Sound BLOCK_POLISHED_TUFF_BREAK = getSound("block.polished_tuff.break");
public static final Sound BLOCK_POLISHED_TUFF_FALL = getSound("block.polished_tuff.fall");
public static final Sound BLOCK_POLISHED_TUFF_HIT = getSound("block.polished_tuff.hit");
public static final Sound BLOCK_POLISHED_TUFF_PLACE = getSound("block.polished_tuff.place");
public static final Sound BLOCK_POLISHED_TUFF_STEP = getSound("block.polished_tuff.step");
public static final Sound ENTITY_TURTLE_AMBIENT_LAND = getSound("entity.turtle.ambient_land"); public static final Sound ENTITY_TURTLE_AMBIENT_LAND = getSound("entity.turtle.ambient_land");
public static final Sound ENTITY_TURTLE_DEATH = getSound("entity.turtle.death"); public static final Sound ENTITY_TURTLE_DEATH = getSound("entity.turtle.death");
public static final Sound ENTITY_TURTLE_DEATH_BABY = getSound("entity.turtle.death_baby"); public static final Sound ENTITY_TURTLE_DEATH_BABY = getSound("entity.turtle.death_baby");
@ -1414,6 +1466,7 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound ENTITY_WARDEN_SONIC_CHARGE = getSound("entity.warden.sonic_charge"); public static final Sound ENTITY_WARDEN_SONIC_CHARGE = getSound("entity.warden.sonic_charge");
public static final Sound ENTITY_WARDEN_STEP = getSound("entity.warden.step"); public static final Sound ENTITY_WARDEN_STEP = getSound("entity.warden.step");
public static final Sound ENTITY_WARDEN_TENDRIL_CLICKS = getSound("entity.warden.tendril_clicks"); public static final Sound ENTITY_WARDEN_TENDRIL_CLICKS = getSound("entity.warden.tendril_clicks");
public static final Sound BLOCK_HANGING_SIGN_WAXED_INTERACT_FAIL = getSound("block.hanging_sign.waxed_interact_fail");
public static final Sound BLOCK_SIGN_WAXED_INTERACT_FAIL = getSound("block.sign.waxed_interact_fail"); public static final Sound BLOCK_SIGN_WAXED_INTERACT_FAIL = getSound("block.sign.waxed_interact_fail");
public static final Sound BLOCK_WATER_AMBIENT = getSound("block.water.ambient"); public static final Sound BLOCK_WATER_AMBIENT = getSound("block.water.ambient");
public static final Sound WEATHER_RAIN = getSound("weather.rain"); public static final Sound WEATHER_RAIN = getSound("weather.rain");
@ -1428,6 +1481,7 @@ public abstract class Sound extends OldEnum<Sound> implements Keyed {
public static final Sound BLOCK_WET_SPONGE_HIT = getSound("block.wet_sponge.hit"); public static final Sound BLOCK_WET_SPONGE_HIT = getSound("block.wet_sponge.hit");
public static final Sound BLOCK_WET_SPONGE_PLACE = getSound("block.wet_sponge.place"); public static final Sound BLOCK_WET_SPONGE_PLACE = getSound("block.wet_sponge.place");
public static final Sound BLOCK_WET_SPONGE_STEP = getSound("block.wet_sponge.step"); public static final Sound BLOCK_WET_SPONGE_STEP = getSound("block.wet_sponge.step");
public static final Sound ENTITY_GENERIC_WIND_BURST = getSound("entity.generic.wind_burst");
public static final Sound ENTITY_WITCH_AMBIENT = getSound("entity.witch.ambient"); public static final Sound ENTITY_WITCH_AMBIENT = getSound("entity.witch.ambient");
public static final Sound ENTITY_WITCH_CELEBRATE = getSound("entity.witch.celebrate"); public static final Sound ENTITY_WITCH_CELEBRATE = getSound("entity.witch.celebrate");
public static final Sound ENTITY_WITCH_DEATH = getSound("entity.witch.death"); public static final Sound ENTITY_WITCH_DEATH = getSound("entity.witch.death");

View file

@ -964,6 +964,18 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla tag representing entities which are not controlled by their mount. * Vanilla tag representing entities which are not controlled by their mount.
*/ */
Tag<EntityType<?>> ENTITY_TYPES_NON_CONTROLLING_RIDER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("non_controlling_rider"), EntityType.class); Tag<EntityType<?>> ENTITY_TYPES_NON_CONTROLLING_RIDER = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("non_controlling_rider"), EntityType.class);
/**
* Vanilla tag representing entities which deflect arrows.
*/
Tag<EntityType<?>> ENTITY_TYPES_DEFLECTS_ARROWS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_arrows"), EntityType.class);
/**
* Vanilla tag representing entities which deflect tridents.
*/
Tag<EntityType<?>> ENTITY_TYPES_DEFLECTS_TRIDENTS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_tridents"), EntityType.class);
/**
* Vanilla tag representing entities which can turn in boats.
*/
Tag<EntityType<?>> ENTITY_TYPES_CAN_TURN_IN_BOATS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("can_turn_in_boats"), EntityType.class);
/** /**
* Returns whether or not this tag has an entry for the specified item. * Returns whether or not this tag has an entry for the specified item.

View file

@ -454,7 +454,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @return ItemDrop entity created as a result of this method * @return ItemDrop entity created as a result of this method
*/ */
@NotNull @NotNull
public Item dropItem(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer<Item> function); public Item dropItem(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer<? super Item> function);
/** /**
* Drops an item at the specified {@link Location} with a random offset * Drops an item at the specified {@link Location} with a random offset
@ -476,7 +476,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @return ItemDrop entity created as a result of this method * @return ItemDrop entity created as a result of this method
*/ */
@NotNull @NotNull
public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer<Item> function); public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer<? super Item> function);
/** /**
* Creates an {@link Arrow} entity at the given {@link Location} * Creates an {@link Arrow} entity at the given {@link Location}
@ -642,7 +642,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* non-null collection. * non-null collection.
*/ */
@NotNull @NotNull
public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z, @Nullable Predicate<Entity> filter); public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z, @Nullable Predicate<? super Entity> filter);
/** /**
* Returns a list of entities within the given bounding box. * Returns a list of entities within the given bounding box.
@ -672,7 +672,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* be a non-null collection * be a non-null collection
*/ */
@NotNull @NotNull
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox boundingBox, @Nullable Predicate<Entity> filter); public Collection<Entity> getNearbyEntities(@NotNull BoundingBox boundingBox, @Nullable Predicate<? super Entity> filter);
/** /**
* Performs a ray trace that checks for entity collisions. * Performs a ray trace that checks for entity collisions.
@ -680,6 +680,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* This may not consider entities in currently unloaded chunks. Some * This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the maximum * implementations may impose artificial restrictions on the maximum
* distance. * distance.
* <p>
* <b>Note:</b> Due to display entities having a zero size hitbox, this method will not detect them.
* To detect display entities use {@link #rayTraceEntities(Location, Vector, double, double)} with a positive raySize
* *
* @param start the start position * @param start the start position
* @param direction the ray direction * @param direction the ray direction
@ -702,7 +705,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param direction the ray direction * @param direction the ray direction
* @param maxDistance the maximum distance * @param maxDistance the maximum distance
* @param raySize entity bounding boxes will be uniformly expanded (or * @param raySize entity bounding boxes will be uniformly expanded (or
* shrinked) by this value before doing collision checks * shrunk) by this value before doing collision checks
* @return the closest ray trace hit result, or <code>null</code> if there * @return the closest ray trace hit result, or <code>null</code> if there
* is no hit * is no hit
* @see #rayTraceEntities(Location, Vector, double, double, Predicate) * @see #rayTraceEntities(Location, Vector, double, double, Predicate)
@ -716,6 +719,9 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* This may not consider entities in currently unloaded chunks. Some * This may not consider entities in currently unloaded chunks. Some
* implementations may impose artificial restrictions on the maximum * implementations may impose artificial restrictions on the maximum
* distance. * distance.
* <p>
* <b>Note:</b> Due to display entities having a zero size hitbox, this method will not detect them.
* To detect display entities use {@link #rayTraceEntities(Location, Vector, double, double, Predicate)} with a positive raySize
* *
* @param start the start position * @param start the start position
* @param direction the ray direction * @param direction the ray direction
@ -727,7 +733,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @see #rayTraceEntities(Location, Vector, double, double, Predicate) * @see #rayTraceEntities(Location, Vector, double, double, Predicate)
*/ */
@Nullable @Nullable
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, @Nullable Predicate<Entity> filter); public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, @Nullable Predicate<? super Entity> filter);
/** /**
* Performs a ray trace that checks for entity collisions. * Performs a ray trace that checks for entity collisions.
@ -740,14 +746,14 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param direction the ray direction * @param direction the ray direction
* @param maxDistance the maximum distance * @param maxDistance the maximum distance
* @param raySize entity bounding boxes will be uniformly expanded (or * @param raySize entity bounding boxes will be uniformly expanded (or
* shrinked) by this value before doing collision checks * shrunk) by this value before doing collision checks
* @param filter only entities that fulfill this predicate are considered, * @param filter only entities that fulfill this predicate are considered,
* or <code>null</code> to consider all entities * or <code>null</code> to consider all entities
* @return the closest ray trace hit result, or <code>null</code> if there * @return the closest ray trace hit result, or <code>null</code> if there
* is no hit * is no hit
*/ */
@Nullable @Nullable
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, @Nullable Predicate<Entity> filter); public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, @Nullable Predicate<? super Entity> filter);
/** /**
* Performs a ray trace that checks for block collisions using the blocks' * Performs a ray trace that checks for block collisions using the blocks'
@ -836,14 +842,14 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
* @param ignorePassableBlocks whether to ignore passable but collidable * @param ignorePassableBlocks whether to ignore passable but collidable
* blocks (ex. tall grass, signs, fluids, ..) * blocks (ex. tall grass, signs, fluids, ..)
* @param raySize entity bounding boxes will be uniformly expanded (or * @param raySize entity bounding boxes will be uniformly expanded (or
* shrinked) by this value before doing collision checks * shrunk) by this value before doing collision checks
* @param filter only entities that fulfill this predicate are considered, * @param filter only entities that fulfill this predicate are considered,
* or <code>null</code> to consider all entities * or <code>null</code> to consider all entities
* @return the closest ray trace hit result with either a block or an * @return the closest ray trace hit result with either a block or an
* entity, or <code>null</code> if there is no hit * entity, or <code>null</code> if there is no hit
*/ */
@Nullable @Nullable
public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, @Nullable Predicate<Entity> filter); public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, @Nullable Predicate<? super Entity> filter);
/** /**
* Gets the default spawn {@link Location} of this world * Gets the default spawn {@link Location} of this world
@ -2083,6 +2089,18 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*/ */
void setSpawnLimit(@NotNull SpawnCategory spawnCategory, int limit); void setSpawnLimit(@NotNull SpawnCategory spawnCategory, int limit);
/**
* Play a note at the provided Location in the World. <br>
* This <i>will</i> work with cake.
* <p>
* This method will fail silently when called with {@link Instrument#CUSTOM_HEAD}.
*
* @param loc The location to play the note
* @param instrument The instrument
* @param note The note
*/
void playNote(@NotNull Location loc, @NotNull Instrument instrument, @NotNull Note note);
/** /**
* Play a Sound at the provided Location in the World. * Play a Sound at the provided Location in the World.
* <p> * <p>
@ -2137,6 +2155,38 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*/ */
void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch); void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch);
/**
* Play a Sound at the provided Location in the World. For sounds with multiple
* variations passing the same seed will always play the same variation.
* <p>
* This function will fail silently if Location or Sound are null.
*
* @param location The location to play the sound
* @param sound The sound to play
* @param category the category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
* @param seed The seed for the sound
*/
void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, long seed);
/**
* Play a Sound at the provided Location in the World. For sounds with multiple
* variations passing the same seed will always play the same variation.
* <p>
* This function will fail silently if Location or Sound are null. No sound will
* be heard by the players if their clients do not have the respective sound for
* the value passed.
*
* @param location The location to play the sound
* @param sound The internal sound name to play
* @param category the category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
* @param seed The seed for the sound
*/
void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch, long seed);
/** /**
* Play a Sound at the location of the provided entity in the World. * Play a Sound at the location of the provided entity in the World.
* <p> * <p>
@ -2187,6 +2237,38 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient
*/ */
void playSound(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch); void playSound(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch);
/**
* Play a Sound at the location of the provided entity in the World. For sounds
* with multiple variations passing the same seed will always play the same
* variation.
* <p>
* This function will fail silently if Entity or Sound are null.
*
* @param entity The entity to play the sound
* @param sound The sound to play
* @param category The category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
* @param seed The seed for the sound
*/
void playSound(@NotNull Entity entity, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, long seed);
/**
* Play a Sound at the location of the provided entity in the World. For sounds
* with multiple variations passing the same seed will always play the same
* variation.
* <p>
* This function will fail silently if Entity or Sound are null.
*
* @param entity The entity to play the sound
* @param sound The sound to play
* @param category The category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
* @param seed The seed for the sound
*/
void playSound(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch, long seed);
/** /**
* Get an array containing the names of all the {@link GameRule}s. * Get an array containing the names of all the {@link GameRule}s.
* *

View file

@ -44,6 +44,7 @@ import org.bukkit.block.data.type.ChiseledBookshelf;
import org.bukkit.block.data.type.Cocoa; import org.bukkit.block.data.type.Cocoa;
import org.bukkit.block.data.type.CommandBlock; import org.bukkit.block.data.type.CommandBlock;
import org.bukkit.block.data.type.Comparator; import org.bukkit.block.data.type.Comparator;
import org.bukkit.block.data.type.CopperBulb;
import org.bukkit.block.data.type.CoralWallFan; import org.bukkit.block.data.type.CoralWallFan;
import org.bukkit.block.data.type.DaylightDetector; import org.bukkit.block.data.type.DaylightDetector;
import org.bukkit.block.data.type.DecoratedPot; import org.bukkit.block.data.type.DecoratedPot;
@ -478,7 +479,7 @@ public interface BlockType<B extends BlockData> extends Keyed, Translatable {
*/ */
BlockType<Piston> STICKY_PISTON = getBlockType("sticky_piston"); BlockType<Piston> STICKY_PISTON = getBlockType("sticky_piston");
BlockType<BlockData> COBWEB = getBlockType("cobweb"); BlockType<BlockData> COBWEB = getBlockType("cobweb");
BlockType<BlockData> GRASS = getBlockType("grass"); BlockType<BlockData> SHORT_GRASS = getBlockType("short_grass");
BlockType<BlockData> FERN = getBlockType("fern"); BlockType<BlockData> FERN = getBlockType("fern");
BlockType<BlockData> DEAD_BUSH = getBlockType("dead_bush"); BlockType<BlockData> DEAD_BUSH = getBlockType("dead_bush");
BlockType<BlockData> SEAGRASS = getBlockType("seagrass"); BlockType<BlockData> SEAGRASS = getBlockType("seagrass");
@ -850,7 +851,6 @@ public interface BlockType<B extends BlockData> extends Keyed, Translatable {
* BlockData: {@link Fence} * BlockData: {@link Fence}
*/ */
BlockType<Fence> OAK_FENCE = getBlockType("oak_fence"); BlockType<Fence> OAK_FENCE = getBlockType("oak_fence");
BlockType<BlockData> PUMPKIN = getBlockType("pumpkin");
BlockType<BlockData> NETHERRACK = getBlockType("netherrack"); BlockType<BlockData> NETHERRACK = getBlockType("netherrack");
BlockType<BlockData> SOUL_SAND = getBlockType("soul_sand"); BlockType<BlockData> SOUL_SAND = getBlockType("soul_sand");
BlockType<BlockData> SOUL_SOIL = getBlockType("soul_soil"); BlockType<BlockData> SOUL_SOIL = getBlockType("soul_soil");
@ -976,6 +976,7 @@ public interface BlockType<B extends BlockData> extends Keyed, Translatable {
* BlockData: {@link Fence} * BlockData: {@link Fence}
*/ */
BlockType<Fence> GLASS_PANE = getBlockType("glass_pane"); BlockType<Fence> GLASS_PANE = getBlockType("glass_pane");
BlockType<BlockData> PUMPKIN = getBlockType("pumpkin");
BlockType<BlockData> MELON = getBlockType("melon"); BlockType<BlockData> MELON = getBlockType("melon");
/** /**
* BlockData: {@link Directional} * BlockData: {@link Directional}
@ -1398,7 +1399,10 @@ public interface BlockType<B extends BlockData> extends Keyed, Translatable {
*/ */
BlockType<Stairs> BAMBOO_MOSAIC_STAIRS = getBlockType("bamboo_mosaic_stairs"); BlockType<Stairs> BAMBOO_MOSAIC_STAIRS = getBlockType("bamboo_mosaic_stairs");
BlockType<BlockData> SLIME_BLOCK = getBlockType("slime_block"); BlockType<BlockData> SLIME_BLOCK = getBlockType("slime_block");
BlockType<BlockData> BARRIER = getBlockType("barrier"); /**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> BARRIER = getBlockType("barrier");
/** /**
* BlockData: {@link Light} * BlockData: {@link Light}
*/ */
@ -2804,6 +2808,46 @@ public interface BlockType<B extends BlockData> extends Keyed, Translatable {
*/ */
BlockType<AmethystCluster> SMALL_AMETHYST_BUD = getBlockType("small_amethyst_bud"); BlockType<AmethystCluster> SMALL_AMETHYST_BUD = getBlockType("small_amethyst_bud");
BlockType<BlockData> TUFF = getBlockType("tuff"); BlockType<BlockData> TUFF = getBlockType("tuff");
/**
* BlockData: {@link Slab}
*/
BlockType<Slab> TUFF_SLAB = getBlockType("tuff_slab");
/**
* BlockData: {@link Stairs}
*/
BlockType<Stairs> TUFF_STAIRS = getBlockType("tuff_stairs");
/**
* BlockData: {@link Wall}
*/
BlockType<Wall> TUFF_WALL = getBlockType("tuff_wall");
BlockType<BlockData> POLISHED_TUFF = getBlockType("polished_tuff");
/**
* BlockData: {@link Slab}
*/
BlockType<Slab> POLISHED_TUFF_SLAB = getBlockType("polished_tuff_slab");
/**
* BlockData: {@link Stairs}
*/
BlockType<Stairs> POLISHED_TUFF_STAIRS = getBlockType("polished_tuff_stairs");
/**
* BlockData: {@link Wall}
*/
BlockType<Wall> POLISHED_TUFF_WALL = getBlockType("polished_tuff_wall");
BlockType<BlockData> CHISELED_TUFF = getBlockType("chiseled_tuff");
BlockType<BlockData> TUFF_BRICKS = getBlockType("tuff_bricks");
/**
* BlockData: {@link Slab}
*/
BlockType<Slab> TUFF_BRICK_SLAB = getBlockType("tuff_brick_slab");
/**
* BlockData: {@link Stairs}
*/
BlockType<Stairs> TUFF_BRICK_STAIRS = getBlockType("tuff_brick_stairs");
/**
* BlockData: {@link Wall}
*/
BlockType<Wall> TUFF_BRICK_WALL = getBlockType("tuff_brick_wall");
BlockType<BlockData> CHISELED_TUFF_BRICKS = getBlockType("chiseled_tuff_bricks");
BlockType<BlockData> CALCITE = getBlockType("calcite"); BlockType<BlockData> CALCITE = getBlockType("calcite");
BlockType<BlockData> TINTED_GLASS = getBlockType("tinted_glass"); BlockType<BlockData> TINTED_GLASS = getBlockType("tinted_glass");
BlockType<BlockData> POWDER_SNOW = getBlockType("powder_snow"); BlockType<BlockData> POWDER_SNOW = getBlockType("powder_snow");
@ -2828,16 +2872,24 @@ public interface BlockType<B extends BlockData> extends Keyed, Translatable {
* BlockData: {@link SculkShrieker} * BlockData: {@link SculkShrieker}
*/ */
BlockType<SculkShrieker> SCULK_SHRIEKER = getBlockType("sculk_shrieker"); BlockType<SculkShrieker> SCULK_SHRIEKER = getBlockType("sculk_shrieker");
BlockType<BlockData> OXIDIZED_COPPER = getBlockType("oxidized_copper");
BlockType<BlockData> WEATHERED_COPPER = getBlockType("weathered_copper");
BlockType<BlockData> EXPOSED_COPPER = getBlockType("exposed_copper");
BlockType<BlockData> COPPER_BLOCK = getBlockType("copper_block"); BlockType<BlockData> COPPER_BLOCK = getBlockType("copper_block");
BlockType<BlockData> EXPOSED_COPPER = getBlockType("exposed_copper");
BlockType<BlockData> WEATHERED_COPPER = getBlockType("weathered_copper");
BlockType<BlockData> OXIDIZED_COPPER = getBlockType("oxidized_copper");
BlockType<BlockData> COPPER_ORE = getBlockType("copper_ore"); BlockType<BlockData> COPPER_ORE = getBlockType("copper_ore");
BlockType<BlockData> DEEPSLATE_COPPER_ORE = getBlockType("deepslate_copper_ore"); BlockType<BlockData> DEEPSLATE_COPPER_ORE = getBlockType("deepslate_copper_ore");
BlockType<BlockData> OXIDIZED_CUT_COPPER = getBlockType("oxidized_cut_copper"); BlockType<BlockData> OXIDIZED_CUT_COPPER = getBlockType("oxidized_cut_copper");
BlockType<BlockData> WEATHERED_CUT_COPPER = getBlockType("weathered_cut_copper"); BlockType<BlockData> WEATHERED_CUT_COPPER = getBlockType("weathered_cut_copper");
BlockType<BlockData> EXPOSED_CUT_COPPER = getBlockType("exposed_cut_copper"); BlockType<BlockData> EXPOSED_CUT_COPPER = getBlockType("exposed_cut_copper");
BlockType<BlockData> CUT_COPPER = getBlockType("cut_copper"); BlockType<BlockData> CUT_COPPER = getBlockType("cut_copper");
BlockType<BlockData> OXIDIZED_CHISELED_COPPER = getBlockType("oxidized_chiseled_copper");
BlockType<BlockData> WEATHERED_CHISELED_COPPER = getBlockType("weathered_chiseled_copper");
BlockType<BlockData> EXPOSED_CHISELED_COPPER = getBlockType("exposed_chiseled_copper");
BlockType<BlockData> CHISELED_COPPER = getBlockType("chiseled_copper");
BlockType<BlockData> WAXED_OXIDIZED_CHISELED_COPPER = getBlockType("waxed_oxidized_chiseled_copper");
BlockType<BlockData> WAXED_WEATHERED_CHISELED_COPPER = getBlockType("waxed_weathered_chiseled_copper");
BlockType<BlockData> WAXED_EXPOSED_CHISELED_COPPER = getBlockType("waxed_exposed_chiseled_copper");
BlockType<BlockData> WAXED_CHISELED_COPPER = getBlockType("waxed_chiseled_copper");
/** /**
* BlockData: {@link Stairs} * BlockData: {@link Stairs}
*/ */
@ -2910,6 +2962,134 @@ public interface BlockType<B extends BlockData> extends Keyed, Translatable {
* BlockData: {@link Slab} * BlockData: {@link Slab}
*/ */
BlockType<Slab> WAXED_CUT_COPPER_SLAB = getBlockType("waxed_cut_copper_slab"); BlockType<Slab> WAXED_CUT_COPPER_SLAB = getBlockType("waxed_cut_copper_slab");
/**
* BlockData: {@link Door}
*/
BlockType<Door> COPPER_DOOR = getBlockType("copper_door");
/**
* BlockData: {@link Door}
*/
BlockType<Door> EXPOSED_COPPER_DOOR = getBlockType("exposed_copper_door");
/**
* BlockData: {@link Door}
*/
BlockType<Door> OXIDIZED_COPPER_DOOR = getBlockType("oxidized_copper_door");
/**
* BlockData: {@link Door}
*/
BlockType<Door> WEATHERED_COPPER_DOOR = getBlockType("weathered_copper_door");
/**
* BlockData: {@link Door}
*/
BlockType<Door> WAXED_COPPER_DOOR = getBlockType("waxed_copper_door");
/**
* BlockData: {@link Door}
*/
BlockType<Door> WAXED_EXPOSED_COPPER_DOOR = getBlockType("waxed_exposed_copper_door");
/**
* BlockData: {@link Door}
*/
BlockType<Door> WAXED_OXIDIZED_COPPER_DOOR = getBlockType("waxed_oxidized_copper_door");
/**
* BlockData: {@link Door}
*/
BlockType<Door> WAXED_WEATHERED_COPPER_DOOR = getBlockType("waxed_weathered_copper_door");
/**
* BlockData: {@link TrapDoor}
*/
BlockType<TrapDoor> COPPER_TRAPDOOR = getBlockType("copper_trapdoor");
/**
* BlockData: {@link TrapDoor}
*/
BlockType<TrapDoor> EXPOSED_COPPER_TRAPDOOR = getBlockType("exposed_copper_trapdoor");
/**
* BlockData: {@link TrapDoor}
*/
BlockType<TrapDoor> OXIDIZED_COPPER_TRAPDOOR = getBlockType("oxidized_copper_trapdoor");
/**
* BlockData: {@link TrapDoor}
*/
BlockType<TrapDoor> WEATHERED_COPPER_TRAPDOOR = getBlockType("weathered_copper_trapdoor");
/**
* BlockData: {@link TrapDoor}
*/
BlockType<TrapDoor> WAXED_COPPER_TRAPDOOR = getBlockType("waxed_copper_trapdoor");
/**
* BlockData: {@link TrapDoor}
*/
BlockType<TrapDoor> WAXED_EXPOSED_COPPER_TRAPDOOR = getBlockType("waxed_exposed_copper_trapdoor");
/**
* BlockData: {@link TrapDoor}
*/
BlockType<TrapDoor> WAXED_OXIDIZED_COPPER_TRAPDOOR = getBlockType("waxed_oxidized_copper_trapdoor");
/**
* BlockData: {@link TrapDoor}
*/
BlockType<TrapDoor> WAXED_WEATHERED_COPPER_TRAPDOOR = getBlockType("waxed_weathered_copper_trapdoor");
/**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> COPPER_GRATE = getBlockType("copper_grate");
/**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> EXPOSED_COPPER_GRATE = getBlockType("exposed_copper_grate");
/**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> WEATHERED_COPPER_GRATE = getBlockType("weathered_copper_grate");
/**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> OXIDIZED_COPPER_GRATE = getBlockType("oxidized_copper_grate");
/**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> WAXED_COPPER_GRATE = getBlockType("waxed_copper_grate");
/**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> WAXED_EXPOSED_COPPER_GRATE = getBlockType("waxed_exposed_copper_grate");
/**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> WAXED_WEATHERED_COPPER_GRATE = getBlockType("waxed_weathered_copper_grate");
/**
* BlockData: {@link Waterlogged}
*/
BlockType<Waterlogged> WAXED_OXIDIZED_COPPER_GRATE = getBlockType("waxed_oxidized_copper_grate");
/**
* BlockData: {@link CopperBulb}
*/
BlockType<CopperBulb> COPPER_BULB = getBlockType("copper_bulb");
/**
* BlockData: {@link CopperBulb}
*/
BlockType<CopperBulb> EXPOSED_COPPER_BULB = getBlockType("exposed_copper_bulb");
/**
* BlockData: {@link CopperBulb}
*/
BlockType<CopperBulb> WEATHERED_COPPER_BULB = getBlockType("weathered_copper_bulb");
/**
* BlockData: {@link CopperBulb}
*/
BlockType<CopperBulb> OXIDIZED_COPPER_BULB = getBlockType("oxidized_copper_bulb");
/**
* BlockData: {@link CopperBulb}
*/
BlockType<CopperBulb> WAXED_COPPER_BULB = getBlockType("waxed_copper_bulb");
/**
* BlockData: {@link CopperBulb}
*/
BlockType<CopperBulb> WAXED_EXPOSED_COPPER_BULB = getBlockType("waxed_exposed_copper_bulb");
/**
* BlockData: {@link CopperBulb}
*/
BlockType<CopperBulb> WAXED_WEATHERED_COPPER_BULB = getBlockType("waxed_weathered_copper_bulb");
/**
* BlockData: {@link CopperBulb}
*/
BlockType<CopperBulb> WAXED_OXIDIZED_COPPER_BULB = getBlockType("waxed_oxidized_copper_bulb");
/** /**
* BlockData: {@link LightningRod} * BlockData: {@link LightningRod}
*/ */
@ -3041,6 +3221,14 @@ public interface BlockType<B extends BlockData> extends Keyed, Translatable {
* BlockData: {@link DecoratedPot} * BlockData: {@link DecoratedPot}
*/ */
BlockType<DecoratedPot> DECORATED_POT = getBlockType("decorated_pot"); BlockType<DecoratedPot> DECORATED_POT = getBlockType("decorated_pot");
/**
* BlockData: {@link Crafter}
*/
BlockType<org.bukkit.block.data.type.Crafter> CRAFTER = getBlockType("crafter");
/**
* BlockData: {@link TrialSpawner}
*/
BlockType<org.bukkit.block.data.type.TrialSpawner> TRIAL_SPAWNER = getBlockType("trial_spawner");
//</editor-fold> //</editor-fold>
@NotNull @NotNull

View file

@ -0,0 +1,63 @@
package org.bukkit.block;
import org.bukkit.MinecraftExperimental;
import org.bukkit.loot.Lootable;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents a captured state of a crafter.
*/
@ApiStatus.Experimental
@MinecraftExperimental
public interface Crafter extends Container, Lootable {
/**
* Gets the number of ticks which this block will remain in the crafting
* state for.
*
* @return number of ticks remaining
* @see org.bukkit.block.data.type.Crafter#isCrafting()
*/
int getCraftingTicks();
/**
* Sets the number of ticks which this block will remain in the crafting
* state for.
*
* @param ticks number of ticks remaining
* @see org.bukkit.block.data.type.Crafter#isCrafting()
*/
void setCraftingTicks(int ticks);
/**
* Gets whether the slot at the specified index is disabled and will not
* have items placed in it.
*
* @param slot slot index
* @return disabled status
*/
boolean isSlotDisabled(int slot);
/**
* Sets whether the slot at the specified index is disabled and will not
* have items placed in it.
*
* @param slot slot index
* @param disabled disabled status
*/
void setSlotDisabled(int slot, boolean disabled);
/**
* Gets whether this Crafter is powered.
*
* @return powered status
*/
boolean isTriggered();
/**
* Sets whether this Crafter is powered.
*
* @param triggered powered status
*/
void setTriggered(boolean triggered);
}

View file

@ -1,6 +1,12 @@
package org.bukkit.block; package org.bukkit.block;
import java.util.Collection;
import java.util.List;
import org.bukkit.block.spawner.SpawnRule;
import org.bukkit.block.spawner.SpawnerEntry;
import org.bukkit.entity.EntitySnapshot;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
/** /**
@ -17,7 +23,8 @@ public interface CreatureSpawner extends TileState {
public EntityType<?> getSpawnedType(); public EntityType<?> getSpawnedType();
/** /**
* Set the spawner's creature type. * Set the spawner's creature type. <br>
* This will override any entities that have been added with {@link #addPotentialSpawn}
* *
* @param creatureType The creature type or null to clear. * @param creatureType The creature type or null to clear.
*/ */
@ -199,4 +206,75 @@ public interface CreatureSpawner extends TileState {
* @see #getSpawnRange() * @see #getSpawnRange()
*/ */
public void setSpawnRange(int spawnRange); public void setSpawnRange(int spawnRange);
/**
* Gets the {@link EntitySnapshot} that will be spawned by this spawner or null
* if no entities have been assigned to this spawner. <br>
* <p>
* All applicable data from the spawner will be copied, such as custom name,
* health, and velocity. <br>
*
* @return the entity snapshot or null if no entities have been assigned to this
* spawner.
*/
@Nullable
public EntitySnapshot getSpawnedEntity();
/**
* Sets the entity that will be spawned by this spawner. <br>
* This will override any previous entries that have been added with
* {@link #addPotentialSpawn}
* <p>
* All applicable data from the snapshot will be copied, such as custom name,
* health, and velocity. <br>
*
* @param snapshot the entity snapshot
*/
public void setSpawnedEntity(@NotNull EntitySnapshot snapshot);
/**
* Adds a new {@link EntitySnapshot} to the list of entities this spawner can
* spawn.
* <p>
* The weight will determine how often this entry is chosen to spawn, higher
* weighted entries will spawn more often than lower weighted ones. <br>
* The {@link SpawnRule} will determine under what conditions this entry can
* spawn, passing null will use the default conditions for the given entity.
*
* @param snapshot the snapshot that will be spawned
* @param weight the weight
* @param spawnRule the spawn rule for this entity, or null
*/
public void addPotentialSpawn(@NotNull EntitySnapshot snapshot, int weight, @Nullable SpawnRule spawnRule);
/**
* Adds a new {@link SpawnerEntry} to the list of entities this spawner can
* spawn. <br>
*
* @param spawnerEntry the spawner entry to use
* @see #addPotentialSpawn(EntitySnapshot, int, SpawnRule)
*/
public void addPotentialSpawn(@NotNull final SpawnerEntry spawnerEntry);
/**
* Sets the list of {@link SpawnerEntry} this spawner can spawn. <br>
* This will override any previous entries added with
* {@link #addPotentialSpawn}
*
* @param entries the list of entries
*/
public void setPotentialSpawns(@NotNull final Collection<SpawnerEntry> entries);
/**
* Gets a list of potential spawns from this spawner or an empty list if no
* entities have been assigned to this spawner. <br>
* Changes made to the returned list will not be reflected in the spawner unless
* applied with {@link #setPotentialSpawns}
*
* @return a list of potential spawns from this spawner, or an empty list if no
* entities have been assigned to this spawner
* @see #getSpawnedType()
*/
@NotNull
public List<SpawnerEntry> getPotentialSpawns();
} }

View file

@ -0,0 +1,12 @@
package org.bukkit.block;
import org.bukkit.MinecraftExperimental;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents a captured state of a trial spawner.
*/
@MinecraftExperimental
@ApiStatus.Experimental
public interface TrialSpawner extends TileState {
}

View file

@ -70,8 +70,11 @@ public abstract class PatternType extends OldEnum<PatternType> implements Keyed
* this pattern type * this pattern type
* *
* @return the pattern's identifier * @return the pattern's identifier
* @see #getKey
* @deprecated magic value
*/ */
@NotNull @NotNull
@Deprecated
public abstract String getIdentifier(); public abstract String getIdentifier();
/** /**
@ -80,9 +83,12 @@ public abstract class PatternType extends OldEnum<PatternType> implements Keyed
* *
* @param identifier the identifier * @param identifier the identifier
* @return the matched pattern type or null * @return the matched pattern type or null
* @see Registry#BANNER_PATTERN
* @deprecated magic value, use {@link Registry#get(NamespacedKey)} instead
*/ */
@Contract("null -> null") @Contract("null -> null")
@Nullable @Nullable
@Deprecated
public static PatternType getByIdentifier(@Nullable String identifier) { public static PatternType getByIdentifier(@Nullable String identifier) {
if (identifier == null) { if (identifier == null) {
return null; return null;

View file

@ -0,0 +1,11 @@
package org.bukkit.block.data.type;
import org.bukkit.MinecraftExperimental;
import org.bukkit.block.data.Lightable;
import org.bukkit.block.data.Powerable;
import org.jetbrains.annotations.ApiStatus;
@MinecraftExperimental
@ApiStatus.Experimental
public interface CopperBulb extends Lightable, Powerable {
}

View file

@ -0,0 +1,82 @@
package org.bukkit.block.data.type;
import org.bukkit.MinecraftExperimental;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.Powerable;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* 'orientation' is the direction the block is facing.
* <br>
* Similar to {@link Powerable}, 'triggered' indicates whether or not the
* dispenser is currently activated.
* <br>
* 'crafting' is whether crafter's mouth is open and top is glowing.
*/
@ApiStatus.Experimental
@MinecraftExperimental
public interface Crafter extends BlockData {
/**
* Gets the value of the 'crafting' property.
*
* @return the 'crafting' value
*/
boolean isCrafting();
/**
* Sets the value of the 'crafting' property.
*
* @param crafting the new 'crafting' value
*/
void setCrafting(boolean crafting);
/**
* Gets the value of the 'triggered' property.
*
* @return the 'triggered' value
*/
boolean isTriggered();
/**
* Sets the value of the 'triggered' property.
*
* @param triggered the new 'triggered' value
*/
void setTriggered(boolean triggered);
/**
* Gets the value of the 'orientation' property.
*
* @return the 'orientation' value
*/
@NotNull
Orientation getOrientation();
/**
* Sets the value of the 'orientation' property.
*
* @param orientation the new 'orientation' value
*/
void setOrientation(@NotNull Orientation orientation);
/**
* The directions the Crafter can be oriented.
*/
public enum Orientation {
DOWN_EAST,
DOWN_NORTH,
DOWN_SOUTH,
DOWN_WEST,
UP_EAST,
UP_NORTH,
UP_SOUTH,
UP_WEST,
WEST_UP,
EAST_UP,
NORTH_UP,
SOUTH_UP;
}
}

View file

@ -0,0 +1,39 @@
package org.bukkit.block.data.type;
import org.bukkit.MinecraftExperimental;
import org.bukkit.block.data.BlockData;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
/**
* 'trial_spawner_state' indicates the current operational phase of the spawner.
*/
@MinecraftExperimental
@ApiStatus.Experimental
public interface TrialSpawner extends BlockData {
/**
* Gets the value of the 'trial_spawner_state' property.
*
* @return the 'trial_spawner_state' value
*/
@NotNull
State getTrialSpawnerState();
/**
* Sets the value of the 'trial_spawner_state' property.
*
* @param state the new 'trial_spawner_state' value
*/
void setTrialSpawnerState(@NotNull State state);
public enum State {
INACTIVE,
WAITING_FOR_PLAYERS,
ACTIVE,
WAITING_FOR_REWARD_EJECTION,
EJECTING_REWARD,
COOLDOWN;
}
}

View file

@ -0,0 +1,219 @@
package org.bukkit.block.spawner;
import com.google.common.base.Preconditions;
import java.util.LinkedHashMap;
import java.util.Map;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.SerializableAs;
import org.jetbrains.annotations.NotNull;
/**
* Represents a spawn rule that controls what conditions an entity from a
* monster spawner can spawn.
*/
@SerializableAs("SpawnRule")
public class SpawnRule implements Cloneable, ConfigurationSerializable {
private int minBlockLight;
private int maxBlockLight;
private int minSkyLight;
private int maxSkyLight;
/**
* Constructs a new SpawnRule.
*
* @param minBlockLight The minimum (inclusive) block light required for
* spawning to succeed.
* @param maxBlockLight The maximum (inclusive) block light required for
* spawning to succeed.
* @param minSkyLight The minimum (inclusive) sky light required for
* spawning to succeed.
* @param maxSkyLight The maximum (inclusive) sky light required for
* spawning to succeed.
*/
public SpawnRule(int minBlockLight, int maxBlockLight, int minSkyLight, int maxSkyLight) {
Preconditions.checkArgument(minBlockLight <= maxBlockLight, "minBlockLight must be <= maxBlockLight (%s <= %s)", minBlockLight, maxBlockLight);
Preconditions.checkArgument(minSkyLight <= maxSkyLight, "minSkyLight must be <= maxSkyLight (%s <= %s)", minSkyLight, maxSkyLight);
Preconditions.checkArgument(minBlockLight >= 0, "minBlockLight must be >= 0 (given %s)", minBlockLight);
Preconditions.checkArgument(maxBlockLight >= 0, "maxBlockLight must be >= 0 (given %s)", maxBlockLight);
Preconditions.checkArgument(minSkyLight >= 0, "minSkyLight must be >= 0 (given %s)", minSkyLight);
Preconditions.checkArgument(maxSkyLight >= 0, "maxSkyLight must be >= 0 (given %s)", maxSkyLight);
this.minBlockLight = minBlockLight;
this.maxBlockLight = maxBlockLight;
this.minSkyLight = minSkyLight;
this.maxSkyLight = maxSkyLight;
}
/**
* Gets the minimum (inclusive) block light required for spawning to
* succeed.
*
* @return minimum block light
*/
public int getMinBlockLight() {
return minBlockLight;
}
/**
* Sets the minimum (inclusive) block light required for spawning to
* succeed.
*
* @param minBlockLight minimum block light
*/
public void setMinBlockLight(int minBlockLight) {
Preconditions.checkArgument(minBlockLight >= 0, "minBlockLight must be >= 0 (given %s)", minBlockLight);
Preconditions.checkArgument(minBlockLight <= maxBlockLight, "minBlockLight must be <= maxBlockLight (%s <= %s)", minBlockLight, maxBlockLight);
this.minBlockLight = minBlockLight;
}
/**
* Gets the maximum (inclusive) block light required for spawning to
* succeed.
*
* @return maximum block light
*/
public int getMaxBlockLight() {
return maxBlockLight;
}
/**
* Sets the maximum (inclusive) block light required for spawning to
* succeed.
*
* @param maxBlockLight maximum block light
*/
public void setMaxBlockLight(int maxBlockLight) {
Preconditions.checkArgument(maxBlockLight >= 0, "maxBlockLight must be >= 0 (given %s)", maxBlockLight);
this.maxBlockLight = maxBlockLight;
}
/**
* Gets the minimum (inclusive) sky light required for spawning to succeed.
*
* @return minimum sky light
*/
public int getMinSkyLight() {
return minSkyLight;
}
/**
* Sets the minimum (inclusive) sky light required for spawning to succeed.
*
* @param minSkyLight minimum sky light
*/
public void setMinSkyLight(int minSkyLight) {
Preconditions.checkArgument(minSkyLight >= 0, "minSkyLight must be >= 0 (given %s)", minSkyLight);
Preconditions.checkArgument(minSkyLight <= maxSkyLight, "minSkyLight must be <= maxSkyLight (%s <= %s)", minSkyLight, maxSkyLight);
this.minSkyLight = minSkyLight;
}
/**
* Gets the maximum (inclusive) sky light required for spawning to succeed.
*
* @return maximum sky light
*/
public int getMaxSkyLight() {
return maxSkyLight;
}
/**
* Sets the maximum (inclusive) sky light required for spawning to succeed.
*
* @param maxSkyLight maximum sky light
*/
public void setMaxSkyLight(int maxSkyLight) {
Preconditions.checkArgument(maxSkyLight >= 0, "maxSkyLight must be >= 0 (given %s)", maxSkyLight);
this.maxSkyLight = maxSkyLight;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof SpawnRule)) {
return false;
}
SpawnRule other = (SpawnRule) obj;
return minBlockLight == other.minBlockLight && maxBlockLight == other.maxBlockLight && minSkyLight == other.minSkyLight && maxSkyLight == other.maxSkyLight;
}
@Override
public int hashCode() {
int hash = minBlockLight;
hash = (hash << 4) + maxBlockLight;
hash = (hash << 4) + minSkyLight;
hash = (hash << 4) + maxSkyLight;
return hash;
}
@NotNull
@Override
public SpawnRule clone() {
try {
return (SpawnRule) super.clone();
} catch (CloneNotSupportedException e) {
throw new Error(e);
}
}
@Override
@NotNull
public Map<String, Object> serialize() {
Map<String, Object> result = new LinkedHashMap<>();
Map<String, Object> block = new LinkedHashMap<>();
Map<String, Object> sky = new LinkedHashMap<>();
block.put("min", getMinBlockLight());
block.put("max", getMaxBlockLight());
sky.put("min", getMinSkyLight());
sky.put("max", getMaxSkyLight());
result.put("block-light", block);
result.put("sky-light", sky);
return result;
}
@NotNull
public static SpawnRule deserialize(@NotNull Map<String, Object> args) {
int minBlock = 0;
int maxBlock = 0;
int minSky = 0;
int maxSky = 0;
Object block = args.get("block-light");
Object sky = args.get("sky-light");
if (block instanceof Map<?, ?>) {
Map<?, ?> blockMap = (Map<?, ?>) block;
if (blockMap.containsKey("min")) {
minBlock = (int) blockMap.get("min");
}
if (blockMap.containsKey("max")) {
maxBlock = (int) blockMap.get("max");
}
}
if (sky instanceof Map<?, ?>) {
Map<?, ?> skyMap = (Map<?, ?>) sky;
if (skyMap.containsKey("min")) {
minSky = (int) skyMap.get("min");
}
if (skyMap.containsKey("max")) {
maxSky = (int) skyMap.get("max");
}
}
return new SpawnRule(minBlock, maxBlock, minSky, maxSky);
}
}

View file

@ -0,0 +1,85 @@
package org.bukkit.block.spawner;
import com.google.common.base.Preconditions;
import org.bukkit.entity.EntitySnapshot;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a weighted spawn potential that can be added to a monster spawner.
*/
public class SpawnerEntry {
private EntitySnapshot snapshot;
private int spawnWeight;
private SpawnRule spawnRule;
public SpawnerEntry(@NotNull EntitySnapshot snapshot, int spawnWeight, @Nullable SpawnRule spawnRule) {
Preconditions.checkArgument(snapshot != null, "Snapshot cannot be null");
this.snapshot = snapshot;
this.spawnWeight = spawnWeight;
this.spawnRule = spawnRule;
}
/**
* Gets the {@link EntitySnapshot} for this SpawnerEntry.
*
* @return the snapshot
*/
@NotNull
public EntitySnapshot getSnapshot() {
return snapshot;
}
/**
* Sets the {@link EntitySnapshot} for this SpawnerEntry.
*
* @param snapshot the snapshot
*/
public void setSnapshot(@NotNull EntitySnapshot snapshot) {
Preconditions.checkArgument(snapshot != null, "Snapshot cannot be null");
this.snapshot = snapshot;
}
/**
* Gets the weight for this SpawnerEntry, when added to a spawner entries
* with higher weight will spawn more often.
*
* @return the weight
*/
public int getSpawnWeight() {
return spawnWeight;
}
/**
* Sets the weight for this SpawnerEntry, when added to a spawner entries
* with higher weight will spawn more often.
*
* @param spawnWeight the new spawn weight
*/
public void setSpawnWeight(int spawnWeight) {
this.spawnWeight = spawnWeight;
}
/**
* Gets a copy of the {@link SpawnRule} for this SpawnerEntry, or null if
* none has been set.
*
* @return a copy of the spawn rule or null
*/
@Nullable
public SpawnRule getSpawnRule() {
return spawnRule == null ? null : spawnRule.clone();
}
/**
* Sets the {@link SpawnRule} for this SpawnerEntry, null may be used to
* clear the current spawn rule.
*
* @param spawnRule the new spawn rule to use or null
*/
public void setSpawnRule(@Nullable SpawnRule spawnRule) {
this.spawnRule = spawnRule;
}
}

View file

@ -0,0 +1,4 @@
/**
* Classes relevant to mob spawners.
*/
package org.bukkit.block.spawner;

View file

@ -14,6 +14,7 @@ import org.bukkit.FireworkEffect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
import org.bukkit.block.banner.Pattern; import org.bukkit.block.banner.Pattern;
import org.bukkit.block.spawner.SpawnRule;
import org.bukkit.configuration.Configuration; import org.bukkit.configuration.Configuration;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -42,6 +43,7 @@ public class ConfigurationSerialization {
registerClass(Location.class); registerClass(Location.class);
registerClass(AttributeModifier.class); registerClass(AttributeModifier.class);
registerClass(BoundingBox.class); registerClass(BoundingBox.class);
registerClass(SpawnRule.class);
} }
protected ConfigurationSerialization(@NotNull Class<? extends ConfigurationSerializable> clazz) { protected ConfigurationSerialization(@NotNull Class<? extends ConfigurationSerializable> clazz) {

View file

@ -215,7 +215,9 @@ public abstract class Enchantment implements Keyed {
private static Enchantment getEnchantment(@NotNull String key) { private static Enchantment getEnchantment(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key); NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
Enchantment enchantment = Registry.ENCHANTMENT.get(namespacedKey); Enchantment enchantment = Registry.ENCHANTMENT.get(namespacedKey);
Preconditions.checkNotNull(enchantment, "No Enchantment found for %s. This is a bug.", namespacedKey); Preconditions.checkNotNull(enchantment, "No Enchantment found for %s. This is a bug.", namespacedKey);
return enchantment; return enchantment;
} }
@ -325,6 +327,7 @@ public abstract class Enchantment implements Keyed {
if (name == null) { if (name == null) {
return null; return null;
} }
name = convertLegacy(name); name = convertLegacy(name);
return getByKey(NamespacedKey.fromString(name.toLowerCase())); return getByKey(NamespacedKey.fromString(name.toLowerCase()));
} }
@ -341,35 +344,6 @@ public abstract class Enchantment implements Keyed {
return Lists.newArrayList(Registry.ENCHANTMENT).toArray(new Enchantment[0]); return Lists.newArrayList(Registry.ENCHANTMENT).toArray(new Enchantment[0]);
} }
/**
* Registers an enchantment with the given ID and object.
* <p>
* Generally not to be used from within a plugin.
*
* @param enchantment Enchantment to register
* @deprecated only for backwards compatibility, has no effect.
*/
@Deprecated
public static void registerEnchantment(@NotNull Enchantment enchantment) {}
/**
* Checks if this is accepting Enchantment registrations.
*
* @return True if the server Implementation may add enchantments
* @deprecated only for backwards compatibility, has no effect.
*/
@Deprecated
public static boolean isAcceptingRegistrations() {
return false;
}
/**
* Stops accepting any enchantment registrations
* @deprecated only for backwards compatibility, has no effect.
*/
@Deprecated
public static void stopAcceptingRegistrations() {}
private static String convertLegacy(String from) { private static String convertLegacy(String from) {
if (from == null) { if (from == null) {
return null; return null;

View file

@ -1,7 +1,5 @@
package org.bukkit.enchantments; package org.bukkit.enchantments;
import org.bukkit.NamespacedKey;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@ -9,8 +7,8 @@ import org.jetbrains.annotations.NotNull;
* @deprecated only for backwards compatibility, EnchantmentWrapper is no longer used. * @deprecated only for backwards compatibility, EnchantmentWrapper is no longer used.
*/ */
@Deprecated @Deprecated
public class EnchantmentWrapper extends Enchantment { public abstract class EnchantmentWrapper extends Enchantment {
public EnchantmentWrapper(@NotNull String name) { protected EnchantmentWrapper() {
} }
/** /**
@ -20,54 +18,6 @@ public class EnchantmentWrapper extends Enchantment {
*/ */
@NotNull @NotNull
public Enchantment getEnchantment() { public Enchantment getEnchantment() {
return Enchantment.getByKey(getKey()); return this;
}
@Override
public int getMaxLevel() {
return getEnchantment().getMaxLevel();
}
@Override
public int getStartLevel() {
return getEnchantment().getStartLevel();
}
@NotNull
@Override
public EnchantmentTarget getItemTarget() {
return getEnchantment().getItemTarget();
}
@Override
public boolean canEnchantItem(@NotNull ItemStack item) {
return getEnchantment().canEnchantItem(item);
}
@NotNull
@Override
public String getName() {
return getEnchantment().getName();
}
@Override
public boolean isTreasure() {
return getEnchantment().isTreasure();
}
@Override
public boolean isCursed() {
return getEnchantment().isCursed();
}
@Override
public boolean conflictsWith(@NotNull Enchantment other) {
return getEnchantment().conflictsWith(other);
}
@NotNull
@Override
public NamespacedKey getKey() {
return getEnchantment().getKey();
} }
} }

View file

@ -0,0 +1,12 @@
package org.bukkit.entity;
import org.bukkit.MinecraftExperimental;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents a Breeze. Whoosh!
*/
@MinecraftExperimental
@ApiStatus.Experimental
public interface Breeze extends Monster {
}

View file

@ -63,7 +63,7 @@ public interface Cat extends Tameable, Sittable {
@NotNull @NotNull
private static Type getType(@NotNull String key) { private static Type getType(@NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key); NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
Type type = Registry.CAT_TYPE.get(namespacedKey); Type type = Registry.CAT_VARIANT.get(namespacedKey);
Preconditions.checkNotNull(type, "No cat type found for %s. This is a bug.", namespacedKey); Preconditions.checkNotNull(type, "No cat type found for %s. This is a bug.", namespacedKey);
return type; return type;
} }
@ -76,7 +76,7 @@ public interface Cat extends Tameable, Sittable {
@NotNull @NotNull
@Deprecated @Deprecated
public static Type valueOf(@NotNull String name) { public static Type valueOf(@NotNull String name) {
Type type = Registry.CAT_TYPE.get(NamespacedKey.fromString(name.toLowerCase())); Type type = Registry.CAT_VARIANT.get(NamespacedKey.fromString(name.toLowerCase()));
Preconditions.checkArgument(type != null, "No cat type found with the name %s", name); Preconditions.checkArgument(type != null, "No cat type found with the name %s", name);
return type; return type;
} }
@ -88,7 +88,7 @@ public interface Cat extends Tameable, Sittable {
@NotNull @NotNull
@Deprecated @Deprecated
public static Type[] values() { public static Type[] values() {
return Lists.newArrayList(Registry.CAT_TYPE).toArray(new Type[0]); return Lists.newArrayList(Registry.CAT_VARIANT).toArray(new Type[0]);
} }
} }
} }

View file

@ -26,6 +26,9 @@ import org.jetbrains.annotations.Nullable;
/** /**
* Represents a base entity in the world * Represents a base entity in the world
* <p>
* Not all methods are guaranteed to work/may have side effects when
* {@link #isInWorld()} is false.
*/ */
public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder { public interface Entity extends Metadatable, CommandSender, Nameable, PersistentDataHolder {
@ -254,6 +257,8 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
/** /**
* Mark the entity's removal. * Mark the entity's removal.
*
* @throws UnsupportedOperationException if you try to remove a {@link Player} use {@link Player#kickPlayer(String)} in this case instead
*/ */
public void remove(); public void remove();
@ -265,8 +270,8 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
public boolean isDead(); public boolean isDead();
/** /**
* Returns false if the entity has died or been despawned for some other * Returns false if the entity has died, been despawned for some other
* reason. * reason, or has not been added to the world.
* *
* @return True if valid. * @return True if valid.
*/ */
@ -714,4 +719,43 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent
*/ */
@NotNull @NotNull
SpawnCategory getSpawnCategory(); SpawnCategory getSpawnCategory();
/**
* Checks if this entity has been spawned in a world. <br>
* Entities not spawned in a world will not tick, be sent to players, or be
* saved to the server files.
*
* @return whether the entity has been spawned in a world
*/
boolean isInWorld();
/**
* Crates an {@link EntitySnapshot} representing the current state of this entity.
*
* @return a snapshot representing this entity or null if one cannot be made
*/
@Nullable
@ApiStatus.Experimental
EntitySnapshot createSnapshot();
/**
* Creates a copy of this entity and all its data. Does not spawn the copy in
* the world. <br>
* <b>Note:</b> Players cannot be copied.
*
* @return a copy of this entity.
*/
@NotNull
@ApiStatus.Experimental
Entity copy();
/**
* Creates a copy of this entity and all its data. Spawns the copy at the given location. <br>
* <b>Note:</b> Players cannot be copied.
* @param to the location to copy to
* @return a copy of this entity.
*/
@NotNull
@ApiStatus.Experimental
Entity copy(@NotNull Location to);
} }

View file

@ -0,0 +1,39 @@
package org.bukkit.entity;
import org.bukkit.Location;
import org.bukkit.World;
import org.jetbrains.annotations.NotNull;
/**
* Represents an immutable copy of an entity's state. Can be used at any time to
* create an instance of the stored entity.
*/
public interface EntitySnapshot {
/**
* Creates an entity using this template. Does not spawn the copy in the world.
* <br>
*
* @param world the world to create the entity in
* @return a copy of this entity.
*/
@NotNull
Entity createEntity(@NotNull World world);
/**
* Creates an entity using this template and spawns it at the provided location.
*
* @param to the location to copy to
* @return the new entity.
*/
@NotNull
Entity createEntity(@NotNull Location to);
/**
* Gets the type of entity this template holds.
*
* @return the type
*/
@NotNull
EntityType getEntityType();
}

View file

@ -7,6 +7,7 @@ import com.google.common.collect.Lists;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Keyed; import org.bukkit.Keyed;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.MinecraftExperimental;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Registry; import org.bukkit.Registry;
import org.bukkit.Translatable; import org.bukkit.Translatable;
@ -21,6 +22,7 @@ import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.OldEnum; import org.bukkit.util.OldEnum;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -288,6 +290,12 @@ public abstract class EntityType<E extends Entity> extends OldEnum<EntityType<E>
public static final EntityType<ItemDisplay> ITEM_DISPLAY = getEntityType("item_display"); public static final EntityType<ItemDisplay> ITEM_DISPLAY = getEntityType("item_display");
public static final EntityType<Sniffer> SNIFFER = getEntityType("sniffer"); public static final EntityType<Sniffer> SNIFFER = getEntityType("sniffer");
public static final EntityType<TextDisplay> TEXT_DISPLAY = getEntityType("text_display"); public static final EntityType<TextDisplay> TEXT_DISPLAY = getEntityType("text_display");
@MinecraftExperimental
@ApiStatus.Experimental
public static final EntityType<Breeze> BREEZE = getEntityType("breeze");
@MinecraftExperimental
@ApiStatus.Experimental
public static final EntityType<WindCharge> WIND_CHARGE = getEntityType("wind_charge");
/** /**
* A fishing line and bobber. * A fishing line and bobber.
*/ */

View file

@ -21,4 +21,18 @@ public interface EvokerFangs extends Entity {
* @param owner the {@link LivingEntity} which summoned the fangs * @param owner the {@link LivingEntity} which summoned the fangs
*/ */
void setOwner(@Nullable LivingEntity owner); void setOwner(@Nullable LivingEntity owner);
/**
* Get the delay in ticks until the fang attacks.
*
* @return the delay
*/
int getAttackDelay();
/**
* Set the delay in ticks until the fang attacks.
*
* @param delay the delay, must be positive
*/
void setAttackDelay(int delay);
} }

View file

@ -7,6 +7,7 @@ import java.time.Instant;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.UUID;
import org.bukkit.BanEntry; import org.bukkit.BanEntry;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -391,11 +392,10 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
public void setBedSpawnLocation(@Nullable Location location, boolean force); public void setBedSpawnLocation(@Nullable Location location, boolean force);
/** /**
* Play a note for a player at a location. This requires a note block * Play a note for the player at a location. <br>
* at the particular location (as far as the client is concerned). This * This <i>will</i> work with cake.
* will not work without a note block. This will not work with cake.
* *
* @param loc The location of a note block. * @param loc The location to play the note
* @param instrument The instrument ID. * @param instrument The instrument ID.
* @param note The note ID. * @param note The note ID.
* @deprecated Magic value * @deprecated Magic value
@ -404,11 +404,11 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
public void playNote(@NotNull Location loc, byte instrument, byte note); public void playNote(@NotNull Location loc, byte instrument, byte note);
/** /**
* Play a note for a player at a location. This requires a note block * Play a note for the player at a location. <br>
* at the particular location (as far as the client is concerned). This * This <i>will</i> work with cake.
* will not work without a note block. This will not work with cake. * <p>
* * This method will fail silently when called with {@link Instrument#CUSTOM_HEAD}.
* @param loc The location of a note block * @param loc The location to play the note
* @param instrument The instrument * @param instrument The instrument
* @param note The note * @param note The note
*/ */
@ -469,6 +469,38 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
*/ */
public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch); public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch);
/**
* Play a sound for a player at the location. For sounds with multiple
* variations passing the same seed will always play the same variation.
* <p>
* This function will fail silently if Location or Sound are null.
*
* @param location The location to play the sound
* @param sound The sound to play
* @param category The category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
* @param seed The seed for the sound
*/
public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, long seed);
/**
* Play a sound for a player at the location. For sounds with multiple
* variations passing the same seed will always play the same variation.
* <p>
* This function will fail silently if Location or Sound are null. No sound
* will be heard by the player if their client does not have the respective
* sound for the value passed.
*
* @param location The location to play the sound
* @param sound The internal sound name to play
* @param category The category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
* @param seed The seed for the sound
*/
public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch, long seed);
/** /**
* Play a sound for a player at the location of the entity. * Play a sound for a player at the location of the entity.
* <p> * <p>
@ -519,6 +551,36 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
*/ */
public void playSound(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch); public void playSound(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch);
/**
* Play a sound for a player at the location of the entity. For sounds with
* multiple variations passing the same seed will always play the same variation.
* <p>
* This function will fail silently if Entity or Sound are null.
*
* @param entity The entity to play the sound
* @param sound The sound to play
* @param category The category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
* @param seed The seed for the sound
*/
public void playSound(@NotNull Entity entity, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch, long seed);
/**
* Play a sound for a player at the location of the entity. For sounds with
* multiple variations passing the same seed will always play the same variation.
* <p>
* This function will fail silently if Entity or Sound are null.
*
* @param entity The entity to play the sound
* @param sound The sound to play
* @param category The category of the sound
* @param volume The volume of the sound
* @param pitch The pitch of the sound
* @param seed The seed for the sound
*/
public void playSound(@NotNull Entity entity, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch, long seed);
/** /**
* Stop the specified sound from playing. * Stop the specified sound from playing.
* *
@ -1452,6 +1514,53 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM
*/ */
public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force); public void setResourcePack(@NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force);
/**
* Request that the player's client download and switch resource packs.
* <p>
* The player's client will download the new resource pack asynchronously
* in the background, and will automatically switch to it once the
* download is complete. If the client has downloaded and cached a
* resource pack with the same hash in the past it will not download but
* directly apply the cached pack. If the hash is null and the client has
* downloaded and cached the same resource pack in the past, it will
* perform a file size check against the response content to determine if
* the resource pack has changed and needs to be downloaded again. When
* this request is sent for the very first time from a given server, the
* client will first display a confirmation GUI to the player before
* proceeding with the download.
* <p>
* Notes:
* <ul>
* <li>Players can disable server resources on their client, in which
* case this method will have no affect on them. Use the
* {@link PlayerResourcePackStatusEvent} to figure out whether or not
* the player loaded the pack!
* <li>There is no concept of resetting resource packs back to default
* within Minecraft, so players will have to relog to do so or you
* have to send an empty pack.
* <li>The request is sent with empty string as the hash when the hash is
* not provided. This might result in newer versions not loading the
* pack correctly.
* </ul>
*
* @param id Unique resource pack ID.
* @param url The URL from which the client will download the resource
* pack. The string must contain only US-ASCII characters and should
* be encoded as per RFC 1738.
* @param hash The sha1 hash sum of the resource pack file which is used
* to apply a cached version of the pack directly without downloading
* if it is available. Hast to be 20 bytes long!
* @param prompt The optional custom prompt message to be shown to client.
* @param force If true, the client will be disconnected from the server
* when it declines to use the resource pack.
* @throws IllegalArgumentException Thrown if the URL is null.
* @throws IllegalArgumentException Thrown if the URL is too long. The
* length restriction is an implementation specific arbitrary value.
* @throws IllegalArgumentException Thrown if the hash is not 20 bytes
* long.
*/
public void setResourcePack(@NotNull UUID id, @NotNull String url, @Nullable byte[] hash, @Nullable String prompt, boolean force);
/** /**
* Gets the Scoreboard displayed to this player * Gets the Scoreboard displayed to this player
* *

View file

@ -65,5 +65,17 @@ public enum Pose {
/** /**
* Entity is digging. * Entity is digging.
*/ */
DIGGING; DIGGING,
/**
* Entity is sliding.
*/
SLIDING,
/**
* Entity is shooting.
*/
SHOOTING,
/**
* Entity is inhaling.
*/
INHALING;
} }

View file

@ -0,0 +1,12 @@
package org.bukkit.entity;
import org.bukkit.MinecraftExperimental;
import org.jetbrains.annotations.ApiStatus;
/**
* Represents a Wind Charge.
*/
@MinecraftExperimental
@ApiStatus.Experimental
public interface WindCharge extends Fireball {
}

View file

@ -1,8 +1,12 @@
package org.bukkit.event.entity; package org.bukkit.event.entity;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ThrownExpBottle; import org.bukkit.entity.ThrownExpBottle;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* Called when a ThrownExpBottle hits and releases experience. * Called when a ThrownExpBottle hits and releases experience.
@ -12,8 +16,13 @@ public class ExpBottleEvent extends ProjectileHitEvent {
private int exp; private int exp;
private boolean showEffect = true; private boolean showEffect = true;
@Deprecated
public ExpBottleEvent(@NotNull final ThrownExpBottle bottle, final int exp) { public ExpBottleEvent(@NotNull final ThrownExpBottle bottle, final int exp) {
super(bottle); this(bottle, null, null, null, exp);
}
public ExpBottleEvent(@NotNull final ThrownExpBottle bottle, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace, final int exp) {
super(bottle, hitEntity, hitBlock, hitFace);
this.exp = exp; this.exp = exp;
} }

View file

@ -1,10 +1,14 @@
package org.bukkit.event.entity; package org.bukkit.event.entity;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.AreaEffectCloud; import org.bukkit.entity.AreaEffectCloud;
import org.bukkit.entity.Entity;
import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* Called when a splash potion hits an area * Called when a splash potion hits an area
@ -14,8 +18,13 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca
private boolean cancelled; private boolean cancelled;
private final AreaEffectCloud entity; private final AreaEffectCloud entity;
@Deprecated
public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final AreaEffectCloud entity) { public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final AreaEffectCloud entity) {
super(potion); this(potion, null, null, null, entity);
}
public LingeringPotionSplashEvent(@NotNull final ThrownPotion potion, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace, @NotNull final AreaEffectCloud entity) {
super(potion, hitEntity, hitBlock, hitFace);
this.entity = entity; this.entity = entity;
} }

View file

@ -4,11 +4,15 @@ import com.google.common.base.Preconditions;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Map; import java.util.Map;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.ThrownPotion; import org.bukkit.entity.ThrownPotion;
import org.bukkit.event.Cancellable; import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* Called when a splash potion hits an area * Called when a splash potion hits an area
@ -18,9 +22,13 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable
private boolean cancelled; private boolean cancelled;
private final Map<LivingEntity, Double> affectedEntities; private final Map<LivingEntity, Double> affectedEntities;
@Deprecated
public PotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final Map<LivingEntity, Double> affectedEntities) { public PotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final Map<LivingEntity, Double> affectedEntities) {
super(potion); this(potion, null, null, null, affectedEntities);
}
public PotionSplashEvent(@NotNull final ThrownPotion potion, @Nullable Entity hitEntity, @Nullable Block hitBlock, @Nullable BlockFace hitFace, @NotNull final Map<LivingEntity, Double> affectedEntities) {
super(potion, hitEntity, hitBlock, hitFace);
this.affectedEntities = affectedEntities; this.affectedEntities = affectedEntities;
} }

View file

@ -1,6 +1,8 @@
package org.bukkit.event.inventory; package org.bukkit.event.inventory;
import org.bukkit.MinecraftExperimental;
import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
@ -142,6 +144,12 @@ public enum InventoryType {
* Pseudo jukebox inventory with 1 slot of undefined type. * Pseudo jukebox inventory with 1 slot of undefined type.
*/ */
JUKEBOX(1, "Jukebox", false), JUKEBOX(1, "Jukebox", false),
/**
* A crafter inventory, with 9 CRAFTING slots.
*/
@MinecraftExperimental
@ApiStatus.Experimental
CRAFTER(9, "Crafter"),
/** /**
* The new smithing inventory, with 3 CRAFTING slots and 1 RESULT slot. * The new smithing inventory, with 3 CRAFTING slots and 1 RESULT slot.
* *

View file

@ -0,0 +1,87 @@
package org.bukkit.event.player;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
/**
* Called when a player changes recipe book settings.
*/
public class PlayerRecipeBookSettingsChangeEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList();
private final RecipeBookType recipeBookType;
private final boolean open;
private final boolean filtering;
public PlayerRecipeBookSettingsChangeEvent(@NotNull final Player player, @NotNull final RecipeBookType recipeBookType, final boolean open, final boolean filtering) {
super(player);
this.recipeBookType = recipeBookType;
this.open = open;
this.filtering = filtering;
}
/**
* Gets the type of recipe book the player is changing the settings for.
*
* @return the type of recipe book
*/
@NotNull
public RecipeBookType getRecipeBookType() {
return recipeBookType;
}
/**
* Checks if the recipe book is being opened or closed.
*
* @return true if opening
*/
public boolean isOpen() {
return open;
}
/**
* Checks if the recipe book filter is being enabled or disabled.
*
* @return true if enabling
*/
public boolean isFiltering() {
return filtering;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
/**
* Enum representing the various types of recipe book.
* <br>
* Different types of recipe book are shown in different GUIs.
*/
public enum RecipeBookType {
/**
* Recipe book seen in crafting table and player inventory.
*/
CRAFTING,
/**
* Recipe book seen in furnace.
*/
FURNACE,
/**
* Recipe book seen in blast furnace.
*/
BLAST_FURNACE,
/**
* Recipe book seen in smoker.
*/
SMOKER;
}
}

View file

@ -1,5 +1,6 @@
package org.bukkit.event.player; package org.bukkit.event.player;
import java.util.UUID;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -11,13 +12,25 @@ import org.jetbrains.annotations.NotNull;
public class PlayerResourcePackStatusEvent extends PlayerEvent { public class PlayerResourcePackStatusEvent extends PlayerEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final UUID id;
private final Status status; private final Status status;
public PlayerResourcePackStatusEvent(@NotNull final Player who, @NotNull Status resourcePackStatus) { public PlayerResourcePackStatusEvent(@NotNull final Player who, @NotNull UUID id, @NotNull Status resourcePackStatus) {
super(who); super(who);
this.id = id;
this.status = resourcePackStatus; this.status = resourcePackStatus;
} }
/**
* Gets the unique ID of this pack.
*
* @return unique resource pack ID.
*/
@NotNull
public UUID getID() {
return id;
}
/** /**
* Gets the status of this pack. * Gets the status of this pack.
* *
@ -60,6 +73,22 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent {
/** /**
* The client accepted the pack and is beginning a download of it. * The client accepted the pack and is beginning a download of it.
*/ */
ACCEPTED; ACCEPTED,
/**
* The client successfully downloaded the pack.
*/
DOWNLOADED,
/**
* The pack URL was invalid.
*/
INVALID_URL,
/**
* The client was unable to reload the pack.
*/
FAILED_RELOAD,
/**
* The pack was discarded by the client.
*/
DISCARDED;
} }
} }

View file

@ -1,6 +1,7 @@
package org.bukkit.generator.structure; package org.bukkit.generator.structure;
import org.bukkit.Keyed; import org.bukkit.Keyed;
import org.bukkit.MinecraftExperimental;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.Registry; import org.bukkit.Registry;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -47,6 +48,8 @@ public abstract class Structure implements Keyed {
public static final Structure RUINED_PORTAL_NETHER = getStructure("ruined_portal_nether"); public static final Structure RUINED_PORTAL_NETHER = getStructure("ruined_portal_nether");
public static final Structure ANCIENT_CITY = getStructure("ancient_city"); public static final Structure ANCIENT_CITY = getStructure("ancient_city");
public static final Structure TRAIL_RUINS = getStructure("trail_ruins"); public static final Structure TRAIL_RUINS = getStructure("trail_ruins");
@MinecraftExperimental
public static final Structure TRIAL_CHAMBERS = getStructure("trial_chambers");
private static Structure getStructure(String name) { private static Structure getStructure(String name) {
return Registry.STRUCTURE.get(NamespacedKey.minecraft(name)); return Registry.STRUCTURE.get(NamespacedKey.minecraft(name));

View file

@ -0,0 +1,11 @@
package org.bukkit.inventory;
import org.bukkit.MinecraftExperimental;
import org.jetbrains.annotations.ApiStatus;
/**
* Interface to the inventory of a Crafter.
*/
@ApiStatus.Experimental
@MinecraftExperimental
public interface CrafterInventory extends Inventory { }

View file

@ -0,0 +1,38 @@
package org.bukkit.inventory;
import java.util.List;
import org.jetbrains.annotations.NotNull;
/**
* Container class containing the results of a Crafting event.
* <br>
* This class makes no guarantees about the nature or mutability of the returned
* values.
*/
public interface ItemCraftResult {
/**
* The resulting {@link ItemStack} that was crafted.
*
* @return {@link ItemStack} that was crafted.
*/
@NotNull
public ItemStack getResult();
/**
* Gets the resulting matrix from the crafting operation.
*
* @return resulting matrix
*/
@NotNull
public ItemStack[] getResultingMatrix();
/**
* Gets the overflowed items for items that don't fit back into the crafting
* matrix.
*
* @return overflow items
*/
@NotNull
public List<ItemStack> getOverflowItems();
}

View file

@ -2,7 +2,9 @@ package org.bukkit.inventory;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
@ -171,4 +173,47 @@ public interface ItemFactory {
*/ */
@Nullable @Nullable
ItemType getSpawnEgg(@NotNull EntityType<?> type); ItemType getSpawnEgg(@NotNull EntityType<?> type);
/**
* Enchants the given item at the provided level.
* <br>
* If an item that is air is passed through an error is thrown.
*
* @param entity the entity to use as a source of randomness
* @param item the item to enchant
* @param level the level to use, which is the level in the enchantment table
* @param allowTreasures allows treasure enchants, e.g. mending, if true.
* @return the modified ItemStack, or a copy if the ItemStack cannot be enchanted directly
*/
@NotNull
ItemStack enchantItem(@NotNull final Entity entity, @NotNull final ItemStack item, final int level, final boolean allowTreasures);
/**
* Enchants the given item at the provided level.
* <br>
* If an item that is air is passed through an error is thrown.
*
* @param world the world to use as a source of randomness
* @param item the item to enchant
* @param level the level to use, which is the level in the enchantment table
* @param allowTreasures allow the treasure enchants, e.g. mending, if true.
* @return the modified ItemStack, or a copy if the ItemStack cannot be
* enchanted directly
*/
@NotNull
ItemStack enchantItem(@NotNull final World world, @NotNull final ItemStack item, final int level, final boolean allowTreasures);
/**
* Enchants the given item at the provided level.
* <br>
* If an item that is air is passed through an error is thrown.
*
* @param item the item to enchant
* @param level the level to use, which is the level in the enchantment table
* @param allowTreasures allow treasure enchantments, e.g. mending, if true.
* @return the modified ItemStack, or a copy if the ItemStack cannot be
* enchanted directly
*/
@NotNull
ItemStack enchantItem(@NotNull final ItemStack item, final int level, final boolean allowTreasures);
} }

View file

@ -28,6 +28,19 @@ public interface ItemType extends Keyed, Translatable {
ItemType POLISHED_DEEPSLATE = getItemType("polished_deepslate"); ItemType POLISHED_DEEPSLATE = getItemType("polished_deepslate");
ItemType CALCITE = getItemType("calcite"); ItemType CALCITE = getItemType("calcite");
ItemType TUFF = getItemType("tuff"); ItemType TUFF = getItemType("tuff");
ItemType TUFF_SLAB = getItemType("tuff_slab");
ItemType TUFF_STAIRS = getItemType("tuff_stairs");
ItemType TUFF_WALL = getItemType("tuff_wall");
ItemType CHISELED_TUFF = getItemType("chiseled_tuff");
ItemType POLISHED_TUFF = getItemType("polished_tuff");
ItemType POLISHED_TUFF_SLAB = getItemType("polished_tuff_slab");
ItemType POLISHED_TUFF_STAIRS = getItemType("polished_tuff_stairs");
ItemType POLISHED_TUFF_WALL = getItemType("polished_tuff_wall");
ItemType TUFF_BRICKS = getItemType("tuff_bricks");
ItemType TUFF_BRICK_SLAB = getItemType("tuff_brick_slab");
ItemType TUFF_BRICK_STAIRS = getItemType("tuff_brick_stairs");
ItemType TUFF_BRICK_WALL = getItemType("tuff_brick_wall");
ItemType CHISELED_TUFF_BRICKS = getItemType("chiseled_tuff_bricks");
ItemType DRIPSTONE_BLOCK = getItemType("dripstone_block"); ItemType DRIPSTONE_BLOCK = getItemType("dripstone_block");
ItemType GRASS_BLOCK = getItemType("grass_block"); ItemType GRASS_BLOCK = getItemType("grass_block");
ItemType DIRT = getItemType("dirt"); ItemType DIRT = getItemType("dirt");
@ -97,6 +110,10 @@ public interface ItemType extends Keyed, Translatable {
ItemType EXPOSED_COPPER = getItemType("exposed_copper"); ItemType EXPOSED_COPPER = getItemType("exposed_copper");
ItemType WEATHERED_COPPER = getItemType("weathered_copper"); ItemType WEATHERED_COPPER = getItemType("weathered_copper");
ItemType OXIDIZED_COPPER = getItemType("oxidized_copper"); ItemType OXIDIZED_COPPER = getItemType("oxidized_copper");
ItemType CHISELED_COPPER = getItemType("chiseled_copper");
ItemType EXPOSED_CHISELED_COPPER = getItemType("exposed_chiseled_copper");
ItemType WEATHERED_CHISELED_COPPER = getItemType("weathered_chiseled_copper");
ItemType OXIDIZED_CHISELED_COPPER = getItemType("oxidized_chiseled_copper");
ItemType CUT_COPPER = getItemType("cut_copper"); ItemType CUT_COPPER = getItemType("cut_copper");
ItemType EXPOSED_CUT_COPPER = getItemType("exposed_cut_copper"); ItemType EXPOSED_CUT_COPPER = getItemType("exposed_cut_copper");
ItemType WEATHERED_CUT_COPPER = getItemType("weathered_cut_copper"); ItemType WEATHERED_CUT_COPPER = getItemType("weathered_cut_copper");
@ -113,6 +130,10 @@ public interface ItemType extends Keyed, Translatable {
ItemType WAXED_EXPOSED_COPPER = getItemType("waxed_exposed_copper"); ItemType WAXED_EXPOSED_COPPER = getItemType("waxed_exposed_copper");
ItemType WAXED_WEATHERED_COPPER = getItemType("waxed_weathered_copper"); ItemType WAXED_WEATHERED_COPPER = getItemType("waxed_weathered_copper");
ItemType WAXED_OXIDIZED_COPPER = getItemType("waxed_oxidized_copper"); ItemType WAXED_OXIDIZED_COPPER = getItemType("waxed_oxidized_copper");
ItemType WAXED_CHISELED_COPPER = getItemType("waxed_chiseled_copper");
ItemType WAXED_EXPOSED_CHISELED_COPPER = getItemType("waxed_exposed_chiseled_copper");
ItemType WAXED_WEATHERED_CHISELED_COPPER = getItemType("waxed_weathered_chiseled_copper");
ItemType WAXED_OXIDIZED_CHISELED_COPPER = getItemType("waxed_oxidized_chiseled_copper");
ItemType WAXED_CUT_COPPER = getItemType("waxed_cut_copper"); ItemType WAXED_CUT_COPPER = getItemType("waxed_cut_copper");
ItemType WAXED_EXPOSED_CUT_COPPER = getItemType("waxed_exposed_cut_copper"); ItemType WAXED_EXPOSED_CUT_COPPER = getItemType("waxed_exposed_cut_copper");
ItemType WAXED_WEATHERED_CUT_COPPER = getItemType("waxed_weathered_cut_copper"); ItemType WAXED_WEATHERED_CUT_COPPER = getItemType("waxed_weathered_cut_copper");
@ -188,7 +209,7 @@ public interface ItemType extends Keyed, Translatable {
ItemType CHISELED_SANDSTONE = getItemType("chiseled_sandstone"); ItemType CHISELED_SANDSTONE = getItemType("chiseled_sandstone");
ItemType CUT_SANDSTONE = getItemType("cut_sandstone"); ItemType CUT_SANDSTONE = getItemType("cut_sandstone");
ItemType COBWEB = getItemType("cobweb"); ItemType COBWEB = getItemType("cobweb");
ItemType GRASS = getItemType("grass"); ItemType SHORT_GRASS = getItemType("short_grass");
ItemType FERN = getItemType("fern"); ItemType FERN = getItemType("fern");
ItemType AZALEA = getItemType("azalea"); ItemType AZALEA = getItemType("azalea");
ItemType FLOWERING_AZALEA = getItemType("flowering_azalea"); ItemType FLOWERING_AZALEA = getItemType("flowering_azalea");
@ -715,6 +736,14 @@ public interface ItemType extends Keyed, Translatable {
ItemType BAMBOO_DOOR = getItemType("bamboo_door"); ItemType BAMBOO_DOOR = getItemType("bamboo_door");
ItemType CRIMSON_DOOR = getItemType("crimson_door"); ItemType CRIMSON_DOOR = getItemType("crimson_door");
ItemType WARPED_DOOR = getItemType("warped_door"); ItemType WARPED_DOOR = getItemType("warped_door");
ItemType COPPER_DOOR = getItemType("copper_door");
ItemType EXPOSED_COPPER_DOOR = getItemType("exposed_copper_door");
ItemType WEATHERED_COPPER_DOOR = getItemType("weathered_copper_door");
ItemType OXIDIZED_COPPER_DOOR = getItemType("oxidized_copper_door");
ItemType WAXED_COPPER_DOOR = getItemType("waxed_copper_door");
ItemType WAXED_EXPOSED_COPPER_DOOR = getItemType("waxed_exposed_copper_door");
ItemType WAXED_WEATHERED_COPPER_DOOR = getItemType("waxed_weathered_copper_door");
ItemType WAXED_OXIDIZED_COPPER_DOOR = getItemType("waxed_oxidized_copper_door");
ItemType IRON_TRAPDOOR = getItemType("iron_trapdoor"); ItemType IRON_TRAPDOOR = getItemType("iron_trapdoor");
ItemType OAK_TRAPDOOR = getItemType("oak_trapdoor"); ItemType OAK_TRAPDOOR = getItemType("oak_trapdoor");
ItemType SPRUCE_TRAPDOOR = getItemType("spruce_trapdoor"); ItemType SPRUCE_TRAPDOOR = getItemType("spruce_trapdoor");
@ -727,6 +756,14 @@ public interface ItemType extends Keyed, Translatable {
ItemType BAMBOO_TRAPDOOR = getItemType("bamboo_trapdoor"); ItemType BAMBOO_TRAPDOOR = getItemType("bamboo_trapdoor");
ItemType CRIMSON_TRAPDOOR = getItemType("crimson_trapdoor"); ItemType CRIMSON_TRAPDOOR = getItemType("crimson_trapdoor");
ItemType WARPED_TRAPDOOR = getItemType("warped_trapdoor"); ItemType WARPED_TRAPDOOR = getItemType("warped_trapdoor");
ItemType COPPER_TRAPDOOR = getItemType("copper_trapdoor");
ItemType EXPOSED_COPPER_TRAPDOOR = getItemType("exposed_copper_trapdoor");
ItemType WEATHERED_COPPER_TRAPDOOR = getItemType("weathered_copper_trapdoor");
ItemType OXIDIZED_COPPER_TRAPDOOR = getItemType("oxidized_copper_trapdoor");
ItemType WAXED_COPPER_TRAPDOOR = getItemType("waxed_copper_trapdoor");
ItemType WAXED_EXPOSED_COPPER_TRAPDOOR = getItemType("waxed_exposed_copper_trapdoor");
ItemType WAXED_WEATHERED_COPPER_TRAPDOOR = getItemType("waxed_weathered_copper_trapdoor");
ItemType WAXED_OXIDIZED_COPPER_TRAPDOOR = getItemType("waxed_oxidized_copper_trapdoor");
ItemType OAK_FENCE_GATE = getItemType("oak_fence_gate"); ItemType OAK_FENCE_GATE = getItemType("oak_fence_gate");
ItemType SPRUCE_FENCE_GATE = getItemType("spruce_fence_gate"); ItemType SPRUCE_FENCE_GATE = getItemType("spruce_fence_gate");
ItemType BIRCH_FENCE_GATE = getItemType("birch_fence_gate"); ItemType BIRCH_FENCE_GATE = getItemType("birch_fence_gate");
@ -956,6 +993,7 @@ public interface ItemType extends Keyed, Translatable {
ItemType RED_BED = getItemType("red_bed"); ItemType RED_BED = getItemType("red_bed");
ItemType BLACK_BED = getItemType("black_bed"); ItemType BLACK_BED = getItemType("black_bed");
ItemType COOKIE = getItemType("cookie"); ItemType COOKIE = getItemType("cookie");
ItemType CRAFTER = getItemType("crafter");
ItemType FILLED_MAP = getItemType("filled_map"); ItemType FILLED_MAP = getItemType("filled_map");
ItemType SHEARS = getItemType("shears"); ItemType SHEARS = getItemType("shears");
ItemType MELON_SLICE = getItemType("melon_slice"); ItemType MELON_SLICE = getItemType("melon_slice");
@ -987,6 +1025,7 @@ public interface ItemType extends Keyed, Translatable {
ItemType BAT_SPAWN_EGG = getItemType("bat_spawn_egg"); ItemType BAT_SPAWN_EGG = getItemType("bat_spawn_egg");
ItemType BEE_SPAWN_EGG = getItemType("bee_spawn_egg"); ItemType BEE_SPAWN_EGG = getItemType("bee_spawn_egg");
ItemType BLAZE_SPAWN_EGG = getItemType("blaze_spawn_egg"); ItemType BLAZE_SPAWN_EGG = getItemType("blaze_spawn_egg");
ItemType BREEZE_SPAWN_EGG = getItemType("breeze_spawn_egg");
ItemType CAT_SPAWN_EGG = getItemType("cat_spawn_egg"); ItemType CAT_SPAWN_EGG = getItemType("cat_spawn_egg");
ItemType CAMEL_SPAWN_EGG = getItemType("camel_spawn_egg"); ItemType CAMEL_SPAWN_EGG = getItemType("camel_spawn_egg");
ItemType CAVE_SPIDER_SPAWN_EGG = getItemType("cave_spider_spawn_egg"); ItemType CAVE_SPIDER_SPAWN_EGG = getItemType("cave_spider_spawn_egg");
@ -1270,6 +1309,24 @@ public interface ItemType extends Keyed, Translatable {
ItemType SHELTER_POTTERY_SHERD = getItemType("shelter_pottery_sherd"); ItemType SHELTER_POTTERY_SHERD = getItemType("shelter_pottery_sherd");
ItemType SKULL_POTTERY_SHERD = getItemType("skull_pottery_sherd"); ItemType SKULL_POTTERY_SHERD = getItemType("skull_pottery_sherd");
ItemType SNORT_POTTERY_SHERD = getItemType("snort_pottery_sherd"); ItemType SNORT_POTTERY_SHERD = getItemType("snort_pottery_sherd");
ItemType COPPER_GRATE = getItemType("copper_grate");
ItemType EXPOSED_COPPER_GRATE = getItemType("exposed_copper_grate");
ItemType WEATHERED_COPPER_GRATE = getItemType("weathered_copper_grate");
ItemType OXIDIZED_COPPER_GRATE = getItemType("oxidized_copper_grate");
ItemType WAXED_COPPER_GRATE = getItemType("waxed_copper_grate");
ItemType WAXED_EXPOSED_COPPER_GRATE = getItemType("waxed_exposed_copper_grate");
ItemType WAXED_WEATHERED_COPPER_GRATE = getItemType("waxed_weathered_copper_grate");
ItemType WAXED_OXIDIZED_COPPER_GRATE = getItemType("waxed_oxidized_copper_grate");
ItemType COPPER_BULB = getItemType("copper_bulb");
ItemType EXPOSED_COPPER_BULB = getItemType("exposed_copper_bulb");
ItemType WEATHERED_COPPER_BULB = getItemType("weathered_copper_bulb");
ItemType OXIDIZED_COPPER_BULB = getItemType("oxidized_copper_bulb");
ItemType WAXED_COPPER_BULB = getItemType("waxed_copper_bulb");
ItemType WAXED_EXPOSED_COPPER_BULB = getItemType("waxed_exposed_copper_bulb");
ItemType WAXED_WEATHERED_COPPER_BULB = getItemType("waxed_weathered_copper_bulb");
ItemType WAXED_OXIDIZED_COPPER_BULB = getItemType("waxed_oxidized_copper_bulb");
ItemType TRIAL_SPAWNER = getItemType("trial_spawner");
ItemType TRIAL_KEY = getItemType("trial_key");
//</editor-fold> //</editor-fold>
@NotNull @NotNull

View file

@ -1,8 +1,10 @@
package org.bukkit.inventory.meta; package org.bukkit.inventory.meta;
import org.bukkit.entity.EntitySnapshot;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/** /**
* Represents a spawn egg and it's spawned type. * Represents a spawn egg and it's spawned type.
@ -30,6 +32,28 @@ public interface SpawnEggMeta extends ItemMeta {
@Contract("_ -> fail") @Contract("_ -> fail")
void setSpawnedType(EntityType<?> type); void setSpawnedType(EntityType<?> type);
/**
* Gets the {@link EntitySnapshot} that will be spawned by this spawn egg or null if no entity
* has been set. <br>
* <p>
* All applicable data from the egg will be copied, such as custom name, health,
* and velocity. <br>
*
* @return the entity snapshot or null if no entity has been set
*/
@Nullable
EntitySnapshot getSpawnedEntity();
/**
* Sets the {@link EntitySnapshot} that will be spawned by this spawn egg. <br>
* <p>
* All applicable data from the entity will be copied, such as custom name,
* health, and velocity. <br>
*
* @param snapshot the snapshot
*/
void setSpawnedEntity(@NotNull EntitySnapshot snapshot);
@NotNull @NotNull
@Override @Override
SpawnEggMeta clone(); SpawnEggMeta clone();

View file

@ -2,6 +2,7 @@ package org.bukkit.loot;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Keyed; import org.bukkit.Keyed;
import org.bukkit.MinecraftExperimental;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -33,6 +34,26 @@ public enum LootTables implements Keyed {
ANCIENT_CITY("chests/ancient_city"), ANCIENT_CITY("chests/ancient_city"),
ANCIENT_CITY_ICE_BOX("chests/ancient_city_ice_box"), ANCIENT_CITY_ICE_BOX("chests/ancient_city_ice_box"),
RUINED_PORTAL("chests/ruined_portal"), RUINED_PORTAL("chests/ruined_portal"),
@MinecraftExperimental
TRIAL_CHAMBERS_REWARD("chests/trial_chambers/reward"),
@MinecraftExperimental
TRIAL_CHAMBERS_SUPPLY("chests/trial_chambers/supply"),
@MinecraftExperimental
TRIAL_CHAMBERS_CORRIDOR("chests/trial_chambers/corridor"),
@MinecraftExperimental
TRIAL_CHAMBERS_INTERSECTION("chests/trial_chambers/intersection"),
@MinecraftExperimental
TRIAL_CHAMBERS_INTERSECTION_BARREL("chests/trial_chambers/intersection_barrel"),
@MinecraftExperimental
TRIAL_CHAMBERS_ENTRANCE("chests/trial_chambers/entrance"),
@MinecraftExperimental
TRIAL_CHAMBERS_CORRIDOR_DISPENSER("dispensers/trial_chambers/corridor"),
@MinecraftExperimental
TRIAL_CHAMBERS_CHAMBER_DISPENSER("dispensers/trial_chambers/chamber"),
@MinecraftExperimental
TRIAL_CHAMBERS_WATER_DISPENSER("dispensers/trial_chambers/water"),
@MinecraftExperimental
TRIAL_CHAMBERS_CORRIDOR_POT("pots/trial_chambers/corridor"),
SHIPWRECK_MAP("chests/shipwreck_map"), SHIPWRECK_MAP("chests/shipwreck_map"),
SHIPWRECK_SUPPLY("chests/shipwreck_supply"), SHIPWRECK_SUPPLY("chests/shipwreck_supply"),
SHIPWRECK_TREASURE("chests/shipwreck_treasure"), SHIPWRECK_TREASURE("chests/shipwreck_treasure"),
@ -157,6 +178,9 @@ public enum LootTables implements Keyed {
WEAPONSMITH_GIFT("gameplay/hero_of_the_village/weaponsmith_gift"), WEAPONSMITH_GIFT("gameplay/hero_of_the_village/weaponsmith_gift"),
SNIFFER_DIGGING("gameplay/sniffer_digging"), SNIFFER_DIGGING("gameplay/sniffer_digging"),
PIGLIN_BARTERING("gameplay/piglin_bartering"), PIGLIN_BARTERING("gameplay/piglin_bartering"),
// Spawners
TRIAL_CHAMBER_KEY("spawners/trial_chamber/key"),
RIAL_CHAMBER_CONSUMABLES("spawners/trial_chamber/consumables"),
// Archaeology // Archaeology
DESERT_WELL_ARCHAEOLOGY("archaeology/desert_well"), DESERT_WELL_ARCHAEOLOGY("archaeology/desert_well"),
DESERT_PYRAMID_ARCHAEOLOGY("archaeology/desert_pyramid"), DESERT_PYRAMID_ARCHAEOLOGY("archaeology/desert_pyramid"),

View file

@ -21,15 +21,15 @@ public interface PersistentDataContainer {
* *
* @param key the key this value will be stored under * @param key the key this value will be stored under
* @param type the type this tag uses * @param type the type this tag uses
* @param value the value stored in the tag * @param value the value to store in the tag
* @param <T> the generic java type of the tag value * @param <T> the generic java type of the tag value
* @param <Z> the generic type of the object to store * @param <Z> the generic type of the object to store
* *
* @throws NullPointerException if the key is null * @throws IllegalArgumentException if the key is null
* @throws NullPointerException if the type is null * @throws IllegalArgumentException if the type is null
* @throws NullPointerException if the value is null. Removing a tag should * @throws IllegalArgumentException if the value is null. Removing a tag should
* be done using {@link #remove(NamespacedKey)} * be done using {@link #remove(NamespacedKey)}
* @throws IllegalArgumentException if no suitable adapter will be found for * @throws IllegalArgumentException if no suitable adapter was found for
* the {@link PersistentDataType#getPrimitiveType()} * the {@link PersistentDataType#getPrimitiveType()}
*/ */
<T, Z> void set(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type, @NotNull Z value); <T, Z> void set(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type, @NotNull Z value);
@ -38,7 +38,7 @@ public interface PersistentDataContainer {
* Returns if the persistent metadata provider has metadata registered * Returns if the persistent metadata provider has metadata registered
* matching the provided parameters. * matching the provided parameters.
* <p> * <p>
* This method will only return if the found value has the same primitive * This method will only return true if the found value has the same primitive
* data type as the provided key. * data type as the provided key.
* <p> * <p>
* Storing a value using a custom {@link PersistentDataType} implementation * Storing a value using a custom {@link PersistentDataType} implementation
@ -49,22 +49,41 @@ public interface PersistentDataContainer {
* bytes long. * bytes long.
* <p> * <p>
* This method is only usable for custom object keys. Overwriting existing * This method is only usable for custom object keys. Overwriting existing
* tags, like the the display name, will not work as the values are stored * tags, like the display name, will not work as the values are stored
* using your namespace. * using your namespace.
* *
* @param key the key the value is stored under * @param key the key the value is stored under
* @param type the type which primitive storage type has to match the value * @param type the type the primative stored value has to match
* @param <T> the generic type of the stored primitive * @param <T> the generic type of the stored primitive
* @param <Z> the generic type of the eventually created complex object * @param <Z> the generic type of the eventually created complex object
* *
* @return if a value * @return if a value with the provided key and type exists
* *
* @throws NullPointerException if the key to look up is null * @throws IllegalArgumentException if the key to look up is null
* @throws NullPointerException if the type to cast the found object to is * @throws IllegalArgumentException if the type to cast the found object to is
* null * null
*/ */
<T, Z> boolean has(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type); <T, Z> boolean has(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type);
/**
* Returns if the persistent metadata provider has metadata registered matching
* the provided parameters.
* <p>
* This method will return true as long as a value with the given key exists,
* regardless of its type.
* <p>
* This method is only usable for custom object keys. Overwriting existing tags,
* like the display name, will not work as the values are stored using your
* namespace.
*
* @param key the key the value is stored under
*
* @return if a value with the provided key exists
*
* @throws IllegalArgumentException if the key to look up is null
*/
boolean has(@NotNull NamespacedKey key);
/** /**
* Returns the metadata value that is stored on the * Returns the metadata value that is stored on the
* {@link PersistentDataHolder} instance. * {@link PersistentDataHolder} instance.
@ -77,12 +96,12 @@ public interface PersistentDataContainer {
* @return the value or {@code null} if no value was mapped under the given * @return the value or {@code null} if no value was mapped under the given
* value * value
* *
* @throws NullPointerException if the key to look up is null * @throws IllegalArgumentException if the key to look up is null
* @throws NullPointerException if the type to cast the found object to is * @throws IllegalArgumentException if the type to cast the found object to is
* null * null
* @throws IllegalArgumentException if the value exists under the given key, * @throws IllegalArgumentException if a value exists under the given key,
* but cannot be access using the given type * but cannot be accessed using the given type
* @throws IllegalArgumentException if no suitable adapter will be found for * @throws IllegalArgumentException if no suitable adapter was found for
* the {@link * the {@link
* PersistentDataType#getPrimitiveType()} * PersistentDataType#getPrimitiveType()}
*/ */
@ -102,21 +121,21 @@ public interface PersistentDataContainer {
* @param <Z> the generic type of the eventually created complex object * @param <Z> the generic type of the eventually created complex object
* *
* @return the value or the default value if no value was mapped under the * @return the value or the default value if no value was mapped under the
* given value * given key
* *
* @throws NullPointerException if the key to look up is null * @throws IllegalArgumentException if the key to look up is null
* @throws NullPointerException if the type to cast the found object to is * @throws IllegalArgumentException if the type to cast the found object to is
* null * null
* @throws IllegalArgumentException if the value exists under the given key, * @throws IllegalArgumentException if a value exists under the given key,
* but cannot be access using the given type * but cannot be accessed using the given type
* @throws IllegalArgumentException if no suitable adapter will be found for * @throws IllegalArgumentException if no suitable adapter was found for
* the {@link PersistentDataType#getPrimitiveType()} * the {@link PersistentDataType#getPrimitiveType()}
*/ */
@NotNull @NotNull
<T, Z> Z getOrDefault(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type, @NotNull Z defaultValue); <T, Z> Z getOrDefault(@NotNull NamespacedKey key, @NotNull PersistentDataType<T, Z> type, @NotNull Z defaultValue);
/** /**
* Get a set of keys present on this {@link PersistentDataContainer} * Get the set of keys present on this {@link PersistentDataContainer}
* instance. * instance.
* *
* Any changes made to the returned set will not be reflected on the * Any changes made to the returned set will not be reflected on the
@ -130,9 +149,9 @@ public interface PersistentDataContainer {
/** /**
* Removes a custom key from the {@link PersistentDataHolder} instance. * Removes a custom key from the {@link PersistentDataHolder} instance.
* *
* @param key the key * @param key the key to remove
* *
* @throws NullPointerException if the provided key is null * @throws IllegalArgumentException if the provided key is null
*/ */
void remove(@NotNull NamespacedKey key); void remove(@NotNull NamespacedKey key);
@ -144,6 +163,20 @@ public interface PersistentDataContainer {
*/ */
boolean isEmpty(); boolean isEmpty();
/**
* Copies all values from this {@link PersistentDataContainer} to the provided
* container.
* <p>
* This method only copies custom object keys. Existing tags, like the display
* name, will not be copied as the values are stored using your namespace.
*
* @param other the container to copy to
* @param replace whether to replace any matching values in the target container
*
* @throws IllegalArgumentException if the other container is null
*/
void copyTo(@NotNull PersistentDataContainer other, boolean replace);
/** /**
* Returns the adapter context this tag container uses. * Returns the adapter context this tag container uses.
* *

View file

@ -16,7 +16,7 @@ import org.jetbrains.annotations.Nullable;
* Represents a type of potion and its effect on an entity. * Represents a type of potion and its effect on an entity.
*/ */
public abstract class PotionEffectType implements Keyed { public abstract class PotionEffectType implements Keyed {
protected static final BiMap<Integer, PotionEffectType> ID_MAP = HashBiMap.create(); private static final BiMap<Integer, PotionEffectType> ID_MAP = HashBiMap.create();
/** /**
* Increases movement speed. * Increases movement speed.
@ -182,6 +182,7 @@ public abstract class PotionEffectType implements Keyed {
* \o/. * \o/.
*/ */
public static final PotionEffectType HERO_OF_THE_VILLAGE = getPotionEffectType(32, "hero_of_the_village"); public static final PotionEffectType HERO_OF_THE_VILLAGE = getPotionEffectType(32, "hero_of_the_village");
/** /**
* Causes the player's vision to dim occasionally. * Causes the player's vision to dim occasionally.
*/ */
@ -190,7 +191,7 @@ public abstract class PotionEffectType implements Keyed {
@NotNull @NotNull
private static PotionEffectType getPotionEffectType(int typeId, @NotNull String key) { private static PotionEffectType getPotionEffectType(int typeId, @NotNull String key) {
NamespacedKey namespacedKey = NamespacedKey.minecraft(key); NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
PotionEffectType potionEffectType = Registry.POTION_EFFECT_TYPE.get(namespacedKey); PotionEffectType potionEffectType = Registry.EFFECT.get(namespacedKey);
Preconditions.checkNotNull(potionEffectType, "No PotionEffectType found for %s. This is a bug.", namespacedKey); Preconditions.checkNotNull(potionEffectType, "No PotionEffectType found for %s. This is a bug.", namespacedKey);
if (typeId > 0) { if (typeId > 0) {
ID_MAP.put(typeId, potionEffectType); ID_MAP.put(typeId, potionEffectType);
@ -264,7 +265,11 @@ public abstract class PotionEffectType implements Keyed {
@Nullable @Nullable
@Deprecated @Deprecated
public static PotionEffectType getByKey(@Nullable NamespacedKey key) { public static PotionEffectType getByKey(@Nullable NamespacedKey key) {
return Registry.POTION_EFFECT_TYPE.get(key); if (key == null) {
return null;
}
return Registry.EFFECT.get(key);
} }
/** /**
@ -283,7 +288,7 @@ public abstract class PotionEffectType implements Keyed {
return type; return type;
} }
for (PotionEffectType other : Registry.POTION_EFFECT_TYPE) { for (PotionEffectType other : Registry.EFFECT) {
if (other.getId() == id) { if (other.getId() == id) {
ID_MAP.put(id, other); ID_MAP.put(id, other);
return other; return other;
@ -305,7 +310,7 @@ public abstract class PotionEffectType implements Keyed {
public static PotionEffectType getByName(@NotNull String name) { public static PotionEffectType getByName(@NotNull String name) {
Preconditions.checkArgument(name != null, "name cannot be null"); Preconditions.checkArgument(name != null, "name cannot be null");
name = convertLegacy(name); name = convertLegacy(name);
return Registry.POTION_EFFECT_TYPE.get(NamespacedKey.fromString(name.toLowerCase(java.util.Locale.ENGLISH))); return Registry.EFFECT.get(NamespacedKey.fromString(name.toLowerCase(java.util.Locale.ENGLISH)));
} }
/** /**
@ -315,27 +320,9 @@ public abstract class PotionEffectType implements Keyed {
@NotNull @NotNull
@Deprecated @Deprecated
public static PotionEffectType[] values() { public static PotionEffectType[] values() {
return Lists.newArrayList(Registry.POTION_EFFECT_TYPE).toArray(new PotionEffectType[0]); return Lists.newArrayList(Registry.EFFECT).toArray(new PotionEffectType[0]);
} }
/**
* Registers an effect type with the given object.
* <p>
* Generally not to be used from within a plugin.
*
* @param type PotionType to register
* @deprecated only for backwards compatibility, has no effect.
*/
@Deprecated
public static void registerPotionEffectType(@NotNull PotionEffectType type) {}
/**
* Stops accepting any effect type registrations.
* @deprecated only for backwards compatibility, has no effect.
*/
@Deprecated
public static void stopAcceptingRegistrations() {}
private static String convertLegacy(String from) { private static String convertLegacy(String from) {
if (from == null) { if (from == null) {
return null; return null;

View file

@ -1,30 +1,13 @@
package org.bukkit.potion; package org.bukkit.potion;
import org.bukkit.Color;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/** /**
* @deprecated only for backwards compatibility, PotionEffectTypeWrapper is no longer used. * @deprecated only for backwards compatibility, PotionEffectTypeWrapper is no longer used.
*/ */
@Deprecated @Deprecated
public class PotionEffectTypeWrapper extends PotionEffectType { public abstract class PotionEffectTypeWrapper extends PotionEffectType {
protected PotionEffectTypeWrapper(int id) {} protected PotionEffectTypeWrapper() {
@Override
public double getDurationModifier() {
return getType().getDurationModifier();
}
@Override
public int getId() {
return getType().getId();
}
@NotNull
@Override
public String getName() {
return getType().getName();
} }
/** /**
@ -34,29 +17,6 @@ public class PotionEffectTypeWrapper extends PotionEffectType {
*/ */
@NotNull @NotNull
public PotionEffectType getType() { public PotionEffectType getType() {
return PotionEffectType.getByKey(getKey()); return this;
}
@NotNull
@Override
public PotionEffect createEffect(int duration, int amplifier) {
return getType().createEffect(duration, amplifier);
}
@Override
public boolean isInstant() {
return getType().isInstant();
}
@NotNull
@Override
public Color getColor() {
return getType().getColor();
}
@NotNull
@Override
public NamespacedKey getKey() {
return getType().getKey();
} }
} }

View file

@ -227,7 +227,7 @@ public interface BukkitScheduler {
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public void runTask(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task) throws IllegalArgumentException; public void runTask(@NotNull Plugin plugin, @NotNull Consumer<? super BukkitTask> task) throws IllegalArgumentException;
/** /**
* @param plugin the reference to the plugin scheduling task * @param plugin the reference to the plugin scheduling task
@ -267,7 +267,7 @@ public interface BukkitScheduler {
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public void runTaskAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task) throws IllegalArgumentException; public void runTaskAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<? super BukkitTask> task) throws IllegalArgumentException;
/** /**
* @param plugin the reference to the plugin scheduling task * @param plugin the reference to the plugin scheduling task
@ -305,7 +305,7 @@ public interface BukkitScheduler {
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public void runTaskLater(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay) throws IllegalArgumentException; public void runTaskLater(@NotNull Plugin plugin, @NotNull Consumer<? super BukkitTask> task, long delay) throws IllegalArgumentException;
/** /**
* @param plugin the reference to the plugin scheduling task * @param plugin the reference to the plugin scheduling task
@ -350,7 +350,7 @@ public interface BukkitScheduler {
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public void runTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay) throws IllegalArgumentException; public void runTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<? super BukkitTask> task, long delay) throws IllegalArgumentException;
/** /**
* @param plugin the reference to the plugin scheduling task * @param plugin the reference to the plugin scheduling task
@ -391,7 +391,7 @@ public interface BukkitScheduler {
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public void runTaskTimer(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException; public void runTaskTimer(@NotNull Plugin plugin, @NotNull Consumer<? super BukkitTask> task, long delay, long period) throws IllegalArgumentException;
/** /**
* @param plugin the reference to the plugin scheduling task * @param plugin the reference to the plugin scheduling task
@ -441,7 +441,7 @@ public interface BukkitScheduler {
* @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if plugin is null
* @throws IllegalArgumentException if task is null * @throws IllegalArgumentException if task is null
*/ */
public void runTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<BukkitTask> task, long delay, long period) throws IllegalArgumentException; public void runTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull Consumer<? super BukkitTask> task, long delay, long period) throws IllegalArgumentException;
/** /**
* @param plugin the reference to the plugin scheduling task * @param plugin the reference to the plugin scheduling task