diff --git a/.gitignore b/.gitignore index 11038da2..5dd700a9 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /.project /.settings /.checkstyle +/.factorypath # netbeans /nbproject diff --git a/pom.xml b/pom.xml index d1d8a7a2..77005216 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ org.bukkit bukkit - 1.20.2-R0.1-SNAPSHOT + 1.20.4-R0.1-SNAPSHOT jar Bukkit diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java index db3142f0..a56d57ad 100644 --- a/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java @@ -36,6 +36,7 @@ import org.bukkit.generator.ChunkGenerator; import org.bukkit.help.HelpMap; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.ItemCraftResult; import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Merchant; @@ -944,6 +945,58 @@ public final class Bukkit { return server.getCraftingRecipe(craftingMatrix, world); } + /** + * Get the crafted item using the list of {@link ItemStack} provided. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + *

The {@link World} and {@link Player} arguments are required to fulfill the Bukkit Crafting + * events.

+ * + *

Calls {@link org.bukkit.event.inventory.PrepareItemCraftEvent} to imitate the {@link Player} + * initiating the crafting event.

+ * + * @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. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + * @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. * @@ -974,6 +1027,29 @@ public final class Bukkit { return server.craftItem(craftingMatrix, world, player); } + /** + * Get the crafted item using the list of {@link ItemStack} provided. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + * @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. * @@ -1864,7 +1940,7 @@ public final class Bukkit { * @return new data instance */ @NotNull - public static B createBlockData(@NotNull BlockType blockType, @Nullable Consumer consumer) { + public static B createBlockData(@NotNull BlockType blockType, @Nullable Consumer consumer) { return server.createBlockData(blockType, consumer); } diff --git a/src/main/java/org/bukkit/EntityEffect.java b/src/main/java/org/bukkit/EntityEffect.java index 1747b912..9db85b2f 100644 --- a/src/main/java/org/bukkit/EntityEffect.java +++ b/src/main/java/org/bukkit/EntityEffect.java @@ -1,25 +1,37 @@ package org.bukkit; +import com.google.common.base.Preconditions; import org.bukkit.entity.Ageable; import org.bukkit.entity.ArmorStand; import org.bukkit.entity.Cat; import org.bukkit.entity.Dolphin; +import org.bukkit.entity.Egg; import org.bukkit.entity.Entity; +import org.bukkit.entity.EvokerFangs; import org.bukkit.entity.Firework; import org.bukkit.entity.Fox; +import org.bukkit.entity.Goat; import org.bukkit.entity.Guardian; +import org.bukkit.entity.Hoglin; import org.bukkit.entity.IronGolem; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; import org.bukkit.entity.Rabbit; 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.Tameable; import org.bukkit.entity.TippedArrow; import org.bukkit.entity.Villager; +import org.bukkit.entity.Warden; import org.bukkit.entity.Witch; import org.bukkit.entity.Wolf; +import org.bukkit.entity.Zoglin; import org.bukkit.entity.ZombieVillager; +import org.bukkit.entity.minecart.ExplosiveMinecart; +import org.bukkit.entity.minecart.SpawnerMinecart; import org.jetbrains.annotations.NotNull; /** @@ -35,6 +47,11 @@ public enum EntityEffect { * Rabbit jumping. */ 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. * @@ -47,35 +64,86 @@ public enum EntityEffect { *

* This will cause client-glitches! * - * @deprecated although this effect may trigger other events on non-living - * entities, it's only supported usage is on living ones. + * @deprecated split into individual effects + * @see #EGG_BREAK + * @see #SNOWBALL_BREAK + * @see #ENTITY_DEATH */ @Deprecated 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 + *

+ * This will cause client-glitches! + */ + 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 /** - * The smoke when taming a wolf fails. + * The smoke when taming an entity fails. */ 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). + * + * @see EntityEffect#WOLF_SHAKE_STOP */ WOLF_SHAKE(8, Wolf.class), // 9 - unused /** * When an entity eats a LONG_GRASS block. * - * @deprecated although this effect may trigger other events on non-living - * entities, it's only supported usage is on living ones. + * @deprecated split into individual effects + * @see #SHEEP_EAT_GRASS + * @see #TNT_MINECART_IGNITE */ @Deprecated 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 + *

+ * This will cause client-glitches! + */ + TNT_MINECART_IGNITE(10, ExplosiveMinecart.class), /** * When an Iron Golem gives a rose. */ @@ -213,7 +281,57 @@ public enum EntityEffect { /** * 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
+ * Does not play the sound or fire the beam + */ + WARDEN_SONIC_ATTACK(62, Warden.class), + /** + * Plays sniffer digging sound
+ * 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 Class 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 * @deprecated Magic value @@ -243,4 +361,28 @@ public enum EntityEffect { public Class getApplicable() { 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 clazz) { + Preconditions.checkArgument(clazz != null, "Class cannot be null"); + + return applicable.isAssignableFrom(clazz); + } } diff --git a/src/main/java/org/bukkit/FeatureFlag.java b/src/main/java/org/bukkit/FeatureFlag.java index 1d93e26b..5269df59 100644 --- a/src/main/java/org/bukkit/FeatureFlag.java +++ b/src/main/java/org/bukkit/FeatureFlag.java @@ -27,4 +27,7 @@ public interface FeatureFlag extends Keyed { @MinecraftExperimental 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")); } diff --git a/src/main/java/org/bukkit/GameRule.java b/src/main/java/org/bukkit/GameRule.java index 3ac563da..cca52670 100644 --- a/src/main/java/org/bukkit/GameRule.java +++ b/src/main/java/org/bukkit/GameRule.java @@ -61,6 +61,11 @@ public final class GameRule { */ public static final GameRule DO_MOB_LOOT = new GameRule<>("doMobLoot", Boolean.class); + /** + * Whether projectiles can break blocks. + */ + public static final GameRule PROJECTILES_CAN_BREAK_BLOCKS = new GameRule<>("projectilesCanBreakBlocks", Boolean.class); + /** * Whether mobs should naturally spawn. */ @@ -243,6 +248,12 @@ public final class GameRule { */ public static final GameRule 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 MAX_COMMAND_FORK_COUNT = new GameRule<>("maxCommandForkCount", Integer.class); + /** * Determines the maximum number of blocks which a command can modify. */ @@ -255,6 +266,18 @@ public final class GameRule { public static final GameRule PLAYERS_SLEEPING_PERCENTAGE = new GameRule<>("playersSleepingPercentage", Integer.class); public static final GameRule 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 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 PLAYERS_NETHER_PORTAL_CREATIVE_DELAY = new GameRule<>("playersNetherPortalCreativeDelay", Integer.class); + // All GameRules instantiated above this for organizational purposes private final String name; private final Class type; diff --git a/src/main/java/org/bukkit/Instrument.java b/src/main/java/org/bukkit/Instrument.java index de976be7..032d7b81 100644 --- a/src/main/java/org/bukkit/Instrument.java +++ b/src/main/java/org/bukkit/Instrument.java @@ -9,110 +9,123 @@ public enum Instrument { /** * 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 * 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 * 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 * 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 * 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(0x5), + FLUTE(0x5, Sound.BLOCK_NOTE_BLOCK_FLUTE), /** * 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(0x7), + GUITAR(0x7, Sound.BLOCK_NOTE_BLOCK_GUITAR), /** * Chime is normally played when a note block is on top of a packed ice * 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(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(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(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(0xC), + DIDGERIDOO(0xC, Sound.BLOCK_NOTE_BLOCK_DIDGERIDOO), /** * 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(0xE), + BANJO(0xE, Sound.BLOCK_NOTE_BLOCK_BANJO), /** * 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, + ZOMBIE(Sound.BLOCK_NOTE_BLOCK_IMITATE_ZOMBIE), /** * 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, + CREEPER(Sound.BLOCK_NOTE_BLOCK_IMITATE_CREEPER), /** * 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, + 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, + 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_HEAD; + CUSTOM_HEAD(null); private final byte type; + private final Sound sound; private static final Map BY_DATA = Maps.newHashMap(); - private Instrument() { - this(-1); + private Instrument(final Sound sound) { + this(-1, sound); } - private Instrument(final int type) { + private Instrument(final int type, final Sound sound) { this.type = (byte) type; + this.sound = sound; + } + + /** + * Gets the sound associated with this instrument.
+ * Will be null for {@link Instrument#CUSTOM_HEAD} + * + * @return the sound or null + */ + @Nullable + public Sound getSound() { + return this.sound; } /** diff --git a/src/main/java/org/bukkit/Material.java b/src/main/java/org/bukkit/Material.java index 05ff6ef3..b3e282fd 100644 --- a/src/main/java/org/bukkit/Material.java +++ b/src/main/java/org/bukkit/Material.java @@ -48,7 +48,9 @@ import org.bukkit.block.data.type.ChiseledBookshelf; import org.bukkit.block.data.type.Cocoa; import org.bukkit.block.data.type.CommandBlock; 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.Crafter; import org.bukkit.block.data.type.DaylightDetector; import org.bukkit.block.data.type.DecoratedPot; import org.bukkit.block.data.type.Dispenser; @@ -104,6 +106,7 @@ import org.bukkit.block.data.type.Switch; import org.bukkit.block.data.type.TNT; import org.bukkit.block.data.type.TechnicalPiston; import org.bukkit.block.data.type.TrapDoor; +import org.bukkit.block.data.type.TrialSpawner; import org.bukkit.block.data.type.Tripwire; import org.bukkit.block.data.type.TripwireHook; import org.bukkit.block.data.type.TurtleEgg; @@ -140,6 +143,59 @@ public enum Material implements Keyed, Translatable { POLISHED_DEEPSLATE(31772), CALCITE(20311), TUFF(24364), + /** + * BlockData: {@link Slab} + */ + @MinecraftExperimental + TUFF_SLAB(19305, Slab.class), + /** + * BlockData: {@link Stairs} + */ + @MinecraftExperimental + TUFF_STAIRS(11268, Stairs.class), + /** + * BlockData: {@link Wall} + */ + @MinecraftExperimental + TUFF_WALL(24395, Wall.class), + @MinecraftExperimental + CHISELED_TUFF(15831), + @MinecraftExperimental + POLISHED_TUFF(17801), + /** + * BlockData: {@link Slab} + */ + @MinecraftExperimental + POLISHED_TUFF_SLAB(31096, Slab.class), + /** + * BlockData: {@link Stairs} + */ + @MinecraftExperimental + POLISHED_TUFF_STAIRS(7964, Stairs.class), + /** + * BlockData: {@link Wall} + */ + @MinecraftExperimental + POLISHED_TUFF_WALL(28886, Wall.class), + @MinecraftExperimental + TUFF_BRICKS(26276), + /** + * BlockData: {@link Slab} + */ + @MinecraftExperimental + TUFF_BRICK_SLAB(11843, Slab.class), + /** + * BlockData: {@link Stairs} + */ + @MinecraftExperimental + TUFF_BRICK_STAIRS(30753, Stairs.class), + /** + * BlockData: {@link Wall} + */ + @MinecraftExperimental + TUFF_BRICK_WALL(11761, Wall.class), + @MinecraftExperimental + CHISELED_TUFF_BRICKS(8601), DRIPSTONE_BLOCK(26227), /** * BlockData: {@link Snowable} @@ -251,6 +307,14 @@ public enum Material implements Keyed, Translatable { EXPOSED_COPPER(28488), WEATHERED_COPPER(19699), OXIDIZED_COPPER(19490), + @MinecraftExperimental + CHISELED_COPPER(12143), + @MinecraftExperimental + EXPOSED_CHISELED_COPPER(4570), + @MinecraftExperimental + WEATHERED_CHISELED_COPPER(30876), + @MinecraftExperimental + OXIDIZED_CHISELED_COPPER(27719), CUT_COPPER(32519), EXPOSED_CUT_COPPER(18000), WEATHERED_CUT_COPPER(21158), @@ -291,6 +355,14 @@ public enum Material implements Keyed, Translatable { WAXED_EXPOSED_COPPER(27989), WAXED_WEATHERED_COPPER(5960), WAXED_OXIDIZED_COPPER(25626), + @MinecraftExperimental + WAXED_CHISELED_COPPER(7500), + @MinecraftExperimental + WAXED_EXPOSED_CHISELED_COPPER(30658), + @MinecraftExperimental + WAXED_WEATHERED_CHISELED_COPPER(5970), + @MinecraftExperimental + WAXED_OXIDIZED_CHISELED_COPPER(7735), WAXED_CUT_COPPER(11030), WAXED_EXPOSED_CUT_COPPER(30043), WAXED_WEATHERED_CUT_COPPER(13823), @@ -552,7 +624,7 @@ public enum Material implements Keyed, Translatable { CHISELED_SANDSTONE(31763), CUT_SANDSTONE(6118), COBWEB(9469), - GRASS(6155), + SHORT_GRASS(6155), FERN(15794), AZALEA(29386), FLOWERING_AZALEA(28270), @@ -771,7 +843,7 @@ public enum Material implements Keyed, Translatable { /** * BlockData: {@link DecoratedPot} */ - DECORATED_POT(8720, 1, DecoratedPot.class), + DECORATED_POT(8720, DecoratedPot.class), MOSSY_COBBLESTONE(21900), OBSIDIAN(32723), TORCH(6063), @@ -2027,6 +2099,46 @@ public enum Material implements Keyed, Translatable { * BlockData: {@link Door} */ WARPED_DOOR(15062, Door.class), + /** + * BlockData: {@link Door} + */ + @MinecraftExperimental + COPPER_DOOR(26809, Door.class), + /** + * BlockData: {@link Door} + */ + @MinecraftExperimental + EXPOSED_COPPER_DOOR(13236, Door.class), + /** + * BlockData: {@link Door} + */ + @MinecraftExperimental + WEATHERED_COPPER_DOOR(10208, Door.class), + /** + * BlockData: {@link Door} + */ + @MinecraftExperimental + OXIDIZED_COPPER_DOOR(5348, Door.class), + /** + * BlockData: {@link Door} + */ + @MinecraftExperimental + WAXED_COPPER_DOOR(9954, Door.class), + /** + * BlockData: {@link Door} + */ + @MinecraftExperimental + WAXED_EXPOSED_COPPER_DOOR(20748, Door.class), + /** + * BlockData: {@link Door} + */ + @MinecraftExperimental + WAXED_WEATHERED_COPPER_DOOR(25073, Door.class), + /** + * BlockData: {@link Door} + */ + @MinecraftExperimental + WAXED_OXIDIZED_COPPER_DOOR(23888, Door.class), /** * BlockData: {@link TrapDoor} */ @@ -2075,6 +2187,46 @@ public enum Material implements Keyed, Translatable { * BlockData: {@link TrapDoor} */ WARPED_TRAPDOOR(7708, TrapDoor.class), + /** + * BlockData: {@link TrapDoor} + */ + @MinecraftExperimental + COPPER_TRAPDOOR(12110, TrapDoor.class), + /** + * BlockData: {@link TrapDoor} + */ + @MinecraftExperimental + EXPOSED_COPPER_TRAPDOOR(19219, TrapDoor.class), + /** + * BlockData: {@link TrapDoor} + */ + @MinecraftExperimental + WEATHERED_COPPER_TRAPDOOR(28254, TrapDoor.class), + /** + * BlockData: {@link TrapDoor} + */ + @MinecraftExperimental + OXIDIZED_COPPER_TRAPDOOR(26518, TrapDoor.class), + /** + * BlockData: {@link TrapDoor} + */ + @MinecraftExperimental + WAXED_COPPER_TRAPDOOR(12626, TrapDoor.class), + /** + * BlockData: {@link TrapDoor} + */ + @MinecraftExperimental + WAXED_EXPOSED_COPPER_TRAPDOOR(11010, TrapDoor.class), + /** + * BlockData: {@link TrapDoor} + */ + @MinecraftExperimental + WAXED_WEATHERED_COPPER_TRAPDOOR(30709, TrapDoor.class), + /** + * BlockData: {@link TrapDoor} + */ + @MinecraftExperimental + WAXED_OXIDIZED_COPPER_TRAPDOOR(21450, TrapDoor.class), /** * BlockData: {@link Gate} */ @@ -2475,6 +2627,11 @@ public enum Material implements Keyed, Translatable { */ BLACK_BED(20490, 1, Bed.class), COOKIE(27431), + /** + * BlockData: {@link Crafter} + */ + @MinecraftExperimental + CRAFTER(25243, Crafter.class), FILLED_MAP(23504), SHEARS(27971, 1, 238), MELON_SLICE(5347), @@ -2512,6 +2669,8 @@ public enum Material implements Keyed, Translatable { BAT_SPAWN_EGG(14607), BEE_SPAWN_EGG(22924), BLAZE_SPAWN_EGG(4759), + @MinecraftExperimental + BREEZE_SPAWN_EGG(7580), CAT_SPAWN_EGG(29583), CAMEL_SPAWN_EGG(14760), CAVE_SPIDER_SPAWN_EGG(23341), @@ -3002,6 +3161,93 @@ public enum Material implements Keyed, Translatable { SHELTER_POTTERY_SHERD(28390), SKULL_POTTERY_SHERD(16980), SNORT_POTTERY_SHERD(15921), + /** + * BlockData: {@link Waterlogged} + */ + @MinecraftExperimental + COPPER_GRATE(16221, Waterlogged.class), + /** + * BlockData: {@link Waterlogged} + */ + @MinecraftExperimental + EXPOSED_COPPER_GRATE(7783, Waterlogged.class), + /** + * BlockData: {@link Waterlogged} + */ + @MinecraftExperimental + WEATHERED_COPPER_GRATE(24954, Waterlogged.class), + /** + * BlockData: {@link Waterlogged} + */ + @MinecraftExperimental + OXIDIZED_COPPER_GRATE(14122, Waterlogged.class), + /** + * BlockData: {@link Waterlogged} + */ + @MinecraftExperimental + WAXED_COPPER_GRATE(11230, Waterlogged.class), + /** + * BlockData: {@link Waterlogged} + */ + @MinecraftExperimental + WAXED_EXPOSED_COPPER_GRATE(20520, Waterlogged.class), + /** + * BlockData: {@link Waterlogged} + */ + @MinecraftExperimental + WAXED_WEATHERED_COPPER_GRATE(16533, Waterlogged.class), + /** + * BlockData: {@link Waterlogged} + */ + @MinecraftExperimental + WAXED_OXIDIZED_COPPER_GRATE(32010, Waterlogged.class), + /** + * BlockData: {@link CopperBulb} + */ + @MinecraftExperimental + COPPER_BULB(21370, CopperBulb.class), + /** + * BlockData: {@link CopperBulb} + */ + @MinecraftExperimental + EXPOSED_COPPER_BULB(11944, CopperBulb.class), + /** + * BlockData: {@link CopperBulb} + */ + @MinecraftExperimental + WEATHERED_COPPER_BULB(10800, CopperBulb.class), + /** + * BlockData: {@link CopperBulb} + */ + @MinecraftExperimental + OXIDIZED_COPPER_BULB(22421, CopperBulb.class), + /** + * BlockData: {@link CopperBulb} + */ + @MinecraftExperimental + WAXED_COPPER_BULB(23756, CopperBulb.class), + /** + * BlockData: {@link CopperBulb} + */ + @MinecraftExperimental + WAXED_EXPOSED_COPPER_BULB(5530, CopperBulb.class), + /** + * BlockData: {@link CopperBulb} + */ + @MinecraftExperimental + WAXED_WEATHERED_COPPER_BULB(13239, CopperBulb.class), + /** + * BlockData: {@link CopperBulb} + */ + @MinecraftExperimental + WAXED_OXIDIZED_COPPER_BULB(26892, CopperBulb.class), + /** + * BlockData: {@link TrialSpawner} + */ + @MinecraftExperimental + TRIAL_SPAWNER(19902, TrialSpawner.class), + @MinecraftExperimental + TRIAL_KEY(12725), /** * BlockData: {@link Levelled} */ @@ -4508,7 +4754,7 @@ public enum Material implements Keyed, Translatable { * @return new data instance */ @NotNull - public BlockData createBlockData(@Nullable Consumer consumer) { + public BlockData createBlockData(@Nullable Consumer consumer) { return Bukkit.createBlockData((BlockType) asBlockType(), consumer); } @@ -4757,6 +5003,7 @@ public enum Material implements Keyed, Translatable { case CHEST: case CHIPPED_ANVIL: case CHISELED_BOOKSHELF: + case CHISELED_COPPER: case CHISELED_DEEPSLATE: case CHISELED_NETHER_BRICKS: case CHISELED_POLISHED_BLACKSTONE: @@ -4764,6 +5011,8 @@ public enum Material implements Keyed, Translatable { case CHISELED_RED_SANDSTONE: case CHISELED_SANDSTONE: case CHISELED_STONE_BRICKS: + case CHISELED_TUFF: + case CHISELED_TUFF_BRICKS: case CHORUS_FLOWER: case CHORUS_PLANT: case CLAY: @@ -4785,13 +5034,18 @@ public enum Material implements Keyed, Translatable { case COMPOSTER: case CONDUIT: case COPPER_BLOCK: + case COPPER_BULB: + case COPPER_DOOR: + case COPPER_GRATE: case COPPER_ORE: + case COPPER_TRAPDOOR: case CORNFLOWER: case CRACKED_DEEPSLATE_BRICKS: case CRACKED_DEEPSLATE_TILES: case CRACKED_NETHER_BRICKS: case CRACKED_POLISHED_BLACKSTONE_BRICKS: case CRACKED_STONE_BRICKS: + case CRAFTER: case CRAFTING_TABLE: case CREEPER_HEAD: case CREEPER_WALL_HEAD: @@ -4926,7 +5180,12 @@ public enum Material implements Keyed, Translatable { case END_STONE_BRICK_SLAB: case END_STONE_BRICK_STAIRS: case END_STONE_BRICK_WALL: + case EXPOSED_CHISELED_COPPER: case EXPOSED_COPPER: + case EXPOSED_COPPER_BULB: + case EXPOSED_COPPER_DOOR: + case EXPOSED_COPPER_GRATE: + case EXPOSED_COPPER_TRAPDOOR: case EXPOSED_CUT_COPPER: case EXPOSED_CUT_COPPER_SLAB: case EXPOSED_CUT_COPPER_STAIRS: @@ -4955,7 +5214,6 @@ public enum Material implements Keyed, Translatable { case GRANITE_SLAB: case GRANITE_STAIRS: case GRANITE_WALL: - case GRASS: case GRASS_BLOCK: case GRAVEL: case GRAY_BANNER: @@ -5197,7 +5455,12 @@ public enum Material implements Keyed, Translatable { case ORANGE_WALL_BANNER: case ORANGE_WOOL: case OXEYE_DAISY: + case OXIDIZED_CHISELED_COPPER: case OXIDIZED_COPPER: + case OXIDIZED_COPPER_BULB: + case OXIDIZED_COPPER_DOOR: + case OXIDIZED_COPPER_GRATE: + case OXIDIZED_COPPER_TRAPDOOR: case OXIDIZED_CUT_COPPER: case OXIDIZED_CUT_COPPER_SLAB: case OXIDIZED_CUT_COPPER_STAIRS: @@ -5256,6 +5519,10 @@ public enum Material implements Keyed, Translatable { case POLISHED_GRANITE: case POLISHED_GRANITE_SLAB: case POLISHED_GRANITE_STAIRS: + case POLISHED_TUFF: + case POLISHED_TUFF_SLAB: + case POLISHED_TUFF_STAIRS: + case POLISHED_TUFF_WALL: case POPPY: case POTATOES: case POTTED_ACACIA_SAPLING: @@ -5383,6 +5650,7 @@ public enum Material implements Keyed, Translatable { case SEAGRASS: case SEA_LANTERN: case SEA_PICKLE: + case SHORT_GRASS: case SHROOMLIGHT: case SHULKER_BOX: case SKELETON_SKULL: @@ -5483,6 +5751,7 @@ public enum Material implements Keyed, Translatable { case TORCHFLOWER: case TORCHFLOWER_CROP: case TRAPPED_CHEST: + case TRIAL_SPAWNER: case TRIPWIRE: case TRIPWIRE_HOOK: case TUBE_CORAL: @@ -5490,6 +5759,13 @@ public enum Material implements Keyed, Translatable { case TUBE_CORAL_FAN: case TUBE_CORAL_WALL_FAN: case TUFF: + case TUFF_BRICKS: + case TUFF_BRICK_SLAB: + case TUFF_BRICK_STAIRS: + case TUFF_BRICK_WALL: + case TUFF_SLAB: + case TUFF_STAIRS: + case TUFF_WALL: case TURTLE_EGG: case TWISTING_VINES: case TWISTING_VINES_PLANT: @@ -5518,23 +5794,48 @@ public enum Material implements Keyed, Translatable { case WARPED_WART_BLOCK: case WATER: case WATER_CAULDRON: + case WAXED_CHISELED_COPPER: case WAXED_COPPER_BLOCK: + case WAXED_COPPER_BULB: + case WAXED_COPPER_DOOR: + case WAXED_COPPER_GRATE: + case WAXED_COPPER_TRAPDOOR: case WAXED_CUT_COPPER: case WAXED_CUT_COPPER_SLAB: case WAXED_CUT_COPPER_STAIRS: + case WAXED_EXPOSED_CHISELED_COPPER: case WAXED_EXPOSED_COPPER: + case WAXED_EXPOSED_COPPER_BULB: + case WAXED_EXPOSED_COPPER_DOOR: + case WAXED_EXPOSED_COPPER_GRATE: + case WAXED_EXPOSED_COPPER_TRAPDOOR: case WAXED_EXPOSED_CUT_COPPER: case WAXED_EXPOSED_CUT_COPPER_SLAB: case WAXED_EXPOSED_CUT_COPPER_STAIRS: + case WAXED_OXIDIZED_CHISELED_COPPER: case WAXED_OXIDIZED_COPPER: + case WAXED_OXIDIZED_COPPER_BULB: + case WAXED_OXIDIZED_COPPER_DOOR: + case WAXED_OXIDIZED_COPPER_GRATE: + case WAXED_OXIDIZED_COPPER_TRAPDOOR: case WAXED_OXIDIZED_CUT_COPPER: case WAXED_OXIDIZED_CUT_COPPER_SLAB: case WAXED_OXIDIZED_CUT_COPPER_STAIRS: + case WAXED_WEATHERED_CHISELED_COPPER: case WAXED_WEATHERED_COPPER: + case WAXED_WEATHERED_COPPER_BULB: + case WAXED_WEATHERED_COPPER_DOOR: + case WAXED_WEATHERED_COPPER_GRATE: + case WAXED_WEATHERED_COPPER_TRAPDOOR: case WAXED_WEATHERED_CUT_COPPER: case WAXED_WEATHERED_CUT_COPPER_SLAB: case WAXED_WEATHERED_CUT_COPPER_STAIRS: + case WEATHERED_CHISELED_COPPER: case WEATHERED_COPPER: + case WEATHERED_COPPER_BULB: + case WEATHERED_COPPER_DOOR: + case WEATHERED_COPPER_GRATE: + case WEATHERED_COPPER_TRAPDOOR: case WEATHERED_CUT_COPPER: case WEATHERED_CUT_COPPER_SLAB: case WEATHERED_CUT_COPPER_STAIRS: @@ -5946,6 +6247,7 @@ public enum Material implements Keyed, Translatable { case CHEST: case CHIPPED_ANVIL: case CHISELED_BOOKSHELF: + case CHISELED_COPPER: case CHISELED_DEEPSLATE: case CHISELED_NETHER_BRICKS: case CHISELED_POLISHED_BLACKSTONE: @@ -5953,6 +6255,8 @@ public enum Material implements Keyed, Translatable { case CHISELED_RED_SANDSTONE: case CHISELED_SANDSTONE: case CHISELED_STONE_BRICKS: + case CHISELED_TUFF: + case CHISELED_TUFF_BRICKS: case CLAY: case COAL_BLOCK: case COAL_ORE: @@ -5969,12 +6273,17 @@ public enum Material implements Keyed, Translatable { case COMPOSTER: case CONDUIT: case COPPER_BLOCK: + case COPPER_BULB: + case COPPER_DOOR: + case COPPER_GRATE: case COPPER_ORE: + case COPPER_TRAPDOOR: case CRACKED_DEEPSLATE_BRICKS: case CRACKED_DEEPSLATE_TILES: case CRACKED_NETHER_BRICKS: case CRACKED_POLISHED_BLACKSTONE_BRICKS: case CRACKED_STONE_BRICKS: + case CRAFTER: case CRAFTING_TABLE: case CRIMSON_DOOR: case CRIMSON_FENCE: @@ -6092,7 +6401,12 @@ public enum Material implements Keyed, Translatable { case END_STONE_BRICK_SLAB: case END_STONE_BRICK_STAIRS: case END_STONE_BRICK_WALL: + case EXPOSED_CHISELED_COPPER: case EXPOSED_COPPER: + case EXPOSED_COPPER_BULB: + case EXPOSED_COPPER_DOOR: + case EXPOSED_COPPER_GRATE: + case EXPOSED_COPPER_TRAPDOOR: case EXPOSED_CUT_COPPER: case EXPOSED_CUT_COPPER_SLAB: case EXPOSED_CUT_COPPER_STAIRS: @@ -6312,7 +6626,12 @@ public enum Material implements Keyed, Translatable { case ORANGE_TERRACOTTA: case ORANGE_WALL_BANNER: case ORANGE_WOOL: + case OXIDIZED_CHISELED_COPPER: case OXIDIZED_COPPER: + case OXIDIZED_COPPER_BULB: + case OXIDIZED_COPPER_DOOR: + case OXIDIZED_COPPER_GRATE: + case OXIDIZED_COPPER_TRAPDOOR: case OXIDIZED_CUT_COPPER: case OXIDIZED_CUT_COPPER_SLAB: case OXIDIZED_CUT_COPPER_STAIRS: @@ -6359,6 +6678,10 @@ public enum Material implements Keyed, Translatable { case POLISHED_GRANITE: case POLISHED_GRANITE_SLAB: case POLISHED_GRANITE_STAIRS: + case POLISHED_TUFF: + case POLISHED_TUFF_SLAB: + case POLISHED_TUFF_STAIRS: + case POLISHED_TUFF_WALL: case POWDER_SNOW_CAULDRON: case PRISMARINE: case PRISMARINE_BRICKS: @@ -6512,8 +6835,16 @@ public enum Material implements Keyed, Translatable { case TINTED_GLASS: case TNT: case TRAPPED_CHEST: + case TRIAL_SPAWNER: case TUBE_CORAL_BLOCK: case TUFF: + case TUFF_BRICKS: + case TUFF_BRICK_SLAB: + case TUFF_BRICK_STAIRS: + case TUFF_BRICK_WALL: + case TUFF_SLAB: + case TUFF_STAIRS: + case TUFF_WALL: case TURTLE_EGG: case VERDANT_FROGLIGHT: case WARPED_DOOR: @@ -6533,23 +6864,48 @@ public enum Material implements Keyed, Translatable { case WARPED_WALL_SIGN: case WARPED_WART_BLOCK: case WATER_CAULDRON: + case WAXED_CHISELED_COPPER: case WAXED_COPPER_BLOCK: + case WAXED_COPPER_BULB: + case WAXED_COPPER_DOOR: + case WAXED_COPPER_GRATE: + case WAXED_COPPER_TRAPDOOR: case WAXED_CUT_COPPER: case WAXED_CUT_COPPER_SLAB: case WAXED_CUT_COPPER_STAIRS: + case WAXED_EXPOSED_CHISELED_COPPER: case WAXED_EXPOSED_COPPER: + case WAXED_EXPOSED_COPPER_BULB: + case WAXED_EXPOSED_COPPER_DOOR: + case WAXED_EXPOSED_COPPER_GRATE: + case WAXED_EXPOSED_COPPER_TRAPDOOR: case WAXED_EXPOSED_CUT_COPPER: case WAXED_EXPOSED_CUT_COPPER_SLAB: case WAXED_EXPOSED_CUT_COPPER_STAIRS: + case WAXED_OXIDIZED_CHISELED_COPPER: case WAXED_OXIDIZED_COPPER: + case WAXED_OXIDIZED_COPPER_BULB: + case WAXED_OXIDIZED_COPPER_DOOR: + case WAXED_OXIDIZED_COPPER_GRATE: + case WAXED_OXIDIZED_COPPER_TRAPDOOR: case WAXED_OXIDIZED_CUT_COPPER: case WAXED_OXIDIZED_CUT_COPPER_SLAB: case WAXED_OXIDIZED_CUT_COPPER_STAIRS: + case WAXED_WEATHERED_CHISELED_COPPER: case WAXED_WEATHERED_COPPER: + case WAXED_WEATHERED_COPPER_BULB: + case WAXED_WEATHERED_COPPER_DOOR: + case WAXED_WEATHERED_COPPER_GRATE: + case WAXED_WEATHERED_COPPER_TRAPDOOR: case WAXED_WEATHERED_CUT_COPPER: case WAXED_WEATHERED_CUT_COPPER_SLAB: case WAXED_WEATHERED_CUT_COPPER_STAIRS: + case WEATHERED_CHISELED_COPPER: case WEATHERED_COPPER: + case WEATHERED_COPPER_BULB: + case WEATHERED_COPPER_DOOR: + case WEATHERED_COPPER_GRATE: + case WEATHERED_COPPER_TRAPDOOR: case WEATHERED_CUT_COPPER: case WEATHERED_CUT_COPPER_SLAB: case WEATHERED_CUT_COPPER_STAIRS: @@ -6858,7 +7214,6 @@ public enum Material implements Keyed, Translatable { case FERN: case FIRE: case FLOWER_POT: - case GRASS: case GRAY_CARPET: case GREEN_CARPET: case JUNGLE_BUTTON: @@ -6922,6 +7277,7 @@ public enum Material implements Keyed, Translatable { case RED_TULIP: case REPEATER: case ROSE_BUSH: + case SHORT_GRASS: case SKELETON_SKULL: case SKELETON_WALL_SKULL: case SNOW: @@ -7131,7 +7487,6 @@ public enum Material implements Keyed, Translatable { case FLETCHING_TABLE: case FLOWERING_AZALEA_LEAVES: case GLOW_LICHEN: - case GRASS: case GRAY_BANNER: case GRAY_BED: case GRAY_CARPET: @@ -7240,6 +7595,7 @@ public enum Material implements Keyed, Translatable { case RED_WALL_BANNER: case RED_WOOL: case ROSE_BUSH: + case SHORT_GRASS: case SMITHING_TABLE: case SOUL_CAMPFIRE: case SPRUCE_DOOR: @@ -7435,7 +7791,6 @@ public enum Material implements Keyed, Translatable { case FLOWERING_AZALEA: case FLOWERING_AZALEA_LEAVES: case GLOW_LICHEN: - case GRASS: case GRAY_CARPET: case GRAY_WOOL: case GREEN_CARPET: @@ -7497,6 +7852,7 @@ public enum Material implements Keyed, Translatable { case RED_WOOL: case ROSE_BUSH: case SCAFFOLDING: + case SHORT_GRASS: case SMALL_DRIPLEAF: case SPORE_BLOSSOM: case SPRUCE_FENCE: @@ -7987,6 +8343,7 @@ public enum Material implements Keyed, Translatable { case CHERRY_PLANKS: case CHERRY_WOOD: case CHISELED_BOOKSHELF: + case CHISELED_COPPER: case CHISELED_DEEPSLATE: case CHISELED_NETHER_BRICKS: case CHISELED_POLISHED_BLACKSTONE: @@ -7994,6 +8351,8 @@ public enum Material implements Keyed, Translatable { case CHISELED_RED_SANDSTONE: case CHISELED_SANDSTONE: case CHISELED_STONE_BRICKS: + case CHISELED_TUFF: + case CHISELED_TUFF_BRICKS: case CLAY: case COAL_BLOCK: case COAL_ORE: @@ -8008,6 +8367,7 @@ public enum Material implements Keyed, Translatable { case CRACKED_NETHER_BRICKS: case CRACKED_POLISHED_BLACKSTONE_BRICKS: case CRACKED_STONE_BRICKS: + case CRAFTER: case CRAFTING_TABLE: case CRIMSON_HYPHAE: case CRIMSON_NYLIUM: @@ -8055,6 +8415,7 @@ public enum Material implements Keyed, Translatable { case EMERALD_ORE: case END_STONE: case END_STONE_BRICKS: + case EXPOSED_CHISELED_COPPER: case EXPOSED_COPPER: case EXPOSED_CUT_COPPER: case FIRE_CORAL_BLOCK: @@ -8156,6 +8517,7 @@ public enum Material implements Keyed, Translatable { case ORANGE_SHULKER_BOX: case ORANGE_TERRACOTTA: case ORANGE_WOOL: + case OXIDIZED_CHISELED_COPPER: case OXIDIZED_COPPER: case OXIDIZED_CUT_COPPER: case PACKED_ICE: @@ -8175,6 +8537,7 @@ public enum Material implements Keyed, Translatable { case POLISHED_DEEPSLATE: case POLISHED_DIORITE: case POLISHED_GRANITE: + case POLISHED_TUFF: case PRISMARINE: case PRISMARINE_BRICKS: case PUMPKIN: @@ -8258,22 +8621,29 @@ public enum Material implements Keyed, Translatable { case SUSPICIOUS_SAND: case TARGET: case TERRACOTTA: + case TRIAL_SPAWNER: case TUBE_CORAL_BLOCK: case TUFF: + case TUFF_BRICKS: case VERDANT_FROGLIGHT: case WARPED_HYPHAE: case WARPED_NYLIUM: case WARPED_PLANKS: case WARPED_STEM: case WARPED_WART_BLOCK: + case WAXED_CHISELED_COPPER: case WAXED_COPPER_BLOCK: case WAXED_CUT_COPPER: + case WAXED_EXPOSED_CHISELED_COPPER: case WAXED_EXPOSED_COPPER: case WAXED_EXPOSED_CUT_COPPER: + case WAXED_OXIDIZED_CHISELED_COPPER: case WAXED_OXIDIZED_COPPER: case WAXED_OXIDIZED_CUT_COPPER: + case WAXED_WEATHERED_CHISELED_COPPER: case WAXED_WEATHERED_COPPER: case WAXED_WEATHERED_CUT_COPPER: + case WEATHERED_CHISELED_COPPER: case WEATHERED_COPPER: case WEATHERED_CUT_COPPER: case WET_SPONGE: @@ -8679,20 +9049,16 @@ public enum Material implements Keyed, Translatable { case ACACIA_FENCE_GATE: case ACACIA_HANGING_SIGN: case ACACIA_SIGN: - case ACACIA_STAIRS: case ACACIA_TRAPDOOR: case ACACIA_WALL_HANGING_SIGN: case ACACIA_WALL_SIGN: - case ANDESITE_STAIRS: case ANVIL: case BAMBOO_BUTTON: case BAMBOO_DOOR: case BAMBOO_FENCE: case BAMBOO_FENCE_GATE: case BAMBOO_HANGING_SIGN: - case BAMBOO_MOSAIC_STAIRS: case BAMBOO_SIGN: - case BAMBOO_STAIRS: case BAMBOO_TRAPDOOR: case BAMBOO_WALL_HANGING_SIGN: case BAMBOO_WALL_SIGN: @@ -8707,11 +9073,9 @@ public enum Material implements Keyed, Translatable { case BIRCH_FENCE_GATE: case BIRCH_HANGING_SIGN: case BIRCH_SIGN: - case BIRCH_STAIRS: case BIRCH_TRAPDOOR: case BIRCH_WALL_HANGING_SIGN: case BIRCH_WALL_SIGN: - case BLACKSTONE_STAIRS: case BLACK_BED: case BLACK_CANDLE: case BLACK_CANDLE_CAKE: @@ -8722,7 +9086,6 @@ public enum Material implements Keyed, Translatable { case BLUE_CANDLE_CAKE: case BLUE_SHULKER_BOX: case BREWING_STAND: - case BRICK_STAIRS: case BROWN_BED: case BROWN_CANDLE: case BROWN_CANDLE_CAKE: @@ -8742,18 +9105,18 @@ public enum Material implements Keyed, Translatable { case CHERRY_FENCE_GATE: case CHERRY_HANGING_SIGN: case CHERRY_SIGN: - case CHERRY_STAIRS: case CHERRY_TRAPDOOR: case CHERRY_WALL_HANGING_SIGN: case CHERRY_WALL_SIGN: case CHEST: case CHIPPED_ANVIL: case CHISELED_BOOKSHELF: - case COBBLED_DEEPSLATE_STAIRS: - case COBBLESTONE_STAIRS: case COMMAND_BLOCK: case COMPARATOR: case COMPOSTER: + case COPPER_DOOR: + case COPPER_TRAPDOOR: + case CRAFTER: case CRAFTING_TABLE: case CRIMSON_BUTTON: case CRIMSON_DOOR: @@ -8761,11 +9124,9 @@ public enum Material implements Keyed, Translatable { case CRIMSON_FENCE_GATE: case CRIMSON_HANGING_SIGN: case CRIMSON_SIGN: - case CRIMSON_STAIRS: case CRIMSON_TRAPDOOR: case CRIMSON_WALL_HANGING_SIGN: case CRIMSON_WALL_SIGN: - case CUT_COPPER_STAIRS: case CYAN_BED: case CYAN_CANDLE: case CYAN_CANDLE_CAKE: @@ -8777,27 +9138,22 @@ public enum Material implements Keyed, Translatable { case DARK_OAK_FENCE_GATE: case DARK_OAK_HANGING_SIGN: case DARK_OAK_SIGN: - case DARK_OAK_STAIRS: case DARK_OAK_TRAPDOOR: case DARK_OAK_WALL_HANGING_SIGN: case DARK_OAK_WALL_SIGN: - case DARK_PRISMARINE_STAIRS: case DAYLIGHT_DETECTOR: - case DEEPSLATE_BRICK_STAIRS: + case DECORATED_POT: case DEEPSLATE_REDSTONE_ORE: - case DEEPSLATE_TILE_STAIRS: - case DIORITE_STAIRS: case DISPENSER: case DRAGON_EGG: case DROPPER: case ENCHANTING_TABLE: case ENDER_CHEST: - case END_STONE_BRICK_STAIRS: - case EXPOSED_CUT_COPPER_STAIRS: + case EXPOSED_COPPER_DOOR: + case EXPOSED_COPPER_TRAPDOOR: case FLETCHING_TABLE: case FLOWER_POT: case FURNACE: - case GRANITE_STAIRS: case GRAY_BED: case GRAY_CANDLE: case GRAY_CANDLE_CAKE: @@ -8818,7 +9174,6 @@ public enum Material implements Keyed, Translatable { case JUNGLE_FENCE_GATE: case JUNGLE_HANGING_SIGN: case JUNGLE_SIGN: - case JUNGLE_STAIRS: case JUNGLE_TRAPDOOR: case JUNGLE_WALL_HANGING_SIGN: case JUNGLE_WALL_SIGN: @@ -8849,16 +9204,11 @@ public enum Material implements Keyed, Translatable { case MANGROVE_FENCE_GATE: case MANGROVE_HANGING_SIGN: case MANGROVE_SIGN: - case MANGROVE_STAIRS: case MANGROVE_TRAPDOOR: case MANGROVE_WALL_HANGING_SIGN: case MANGROVE_WALL_SIGN: - case MOSSY_COBBLESTONE_STAIRS: - case MOSSY_STONE_BRICK_STAIRS: case MOVING_PISTON: - case MUD_BRICK_STAIRS: case NETHER_BRICK_FENCE: - case NETHER_BRICK_STAIRS: case NOTE_BLOCK: case OAK_BUTTON: case OAK_DOOR: @@ -8866,7 +9216,6 @@ public enum Material implements Keyed, Translatable { case OAK_FENCE_GATE: case OAK_HANGING_SIGN: case OAK_SIGN: - case OAK_STAIRS: case OAK_TRAPDOOR: case OAK_WALL_HANGING_SIGN: case OAK_WALL_SIGN: @@ -8874,18 +9223,13 @@ public enum Material implements Keyed, Translatable { case ORANGE_CANDLE: case ORANGE_CANDLE_CAKE: case ORANGE_SHULKER_BOX: - case OXIDIZED_CUT_COPPER_STAIRS: + case OXIDIZED_COPPER_DOOR: + case OXIDIZED_COPPER_TRAPDOOR: case PINK_BED: case PINK_CANDLE: case PINK_CANDLE_CAKE: case PINK_SHULKER_BOX: - case POLISHED_ANDESITE_STAIRS: - case POLISHED_BLACKSTONE_BRICK_STAIRS: case POLISHED_BLACKSTONE_BUTTON: - case POLISHED_BLACKSTONE_STAIRS: - case POLISHED_DEEPSLATE_STAIRS: - case POLISHED_DIORITE_STAIRS: - case POLISHED_GRANITE_STAIRS: case POTTED_ACACIA_SAPLING: case POTTED_ALLIUM: case POTTED_AZALEA_BUSH: @@ -8921,33 +9265,23 @@ public enum Material implements Keyed, Translatable { case POTTED_WHITE_TULIP: case POTTED_WITHER_ROSE: case POWDER_SNOW_CAULDRON: - case PRISMARINE_BRICK_STAIRS: - case PRISMARINE_STAIRS: case PUMPKIN: case PURPLE_BED: case PURPLE_CANDLE: case PURPLE_CANDLE_CAKE: case PURPLE_SHULKER_BOX: - case PURPUR_STAIRS: - case QUARTZ_STAIRS: case REDSTONE_ORE: case REDSTONE_WIRE: case RED_BED: case RED_CANDLE: case RED_CANDLE_CAKE: - case RED_NETHER_BRICK_STAIRS: - case RED_SANDSTONE_STAIRS: case RED_SHULKER_BOX: case REPEATER: case REPEATING_COMMAND_BLOCK: case RESPAWN_ANCHOR: - case SANDSTONE_STAIRS: case SHULKER_BOX: case SMITHING_TABLE: case SMOKER: - case SMOOTH_QUARTZ_STAIRS: - case SMOOTH_RED_SANDSTONE_STAIRS: - case SMOOTH_SANDSTONE_STAIRS: case SOUL_CAMPFIRE: case SPRUCE_BUTTON: case SPRUCE_DOOR: @@ -8955,14 +9289,11 @@ public enum Material implements Keyed, Translatable { case SPRUCE_FENCE_GATE: case SPRUCE_HANGING_SIGN: case SPRUCE_SIGN: - case SPRUCE_STAIRS: case SPRUCE_TRAPDOOR: case SPRUCE_WALL_HANGING_SIGN: case SPRUCE_WALL_SIGN: case STONECUTTER: - case STONE_BRICK_STAIRS: case STONE_BUTTON: - case STONE_STAIRS: case STRUCTURE_BLOCK: case SWEET_BERRY_BUSH: case TNT: @@ -8973,16 +9304,20 @@ public enum Material implements Keyed, Translatable { case WARPED_FENCE_GATE: case WARPED_HANGING_SIGN: case WARPED_SIGN: - case WARPED_STAIRS: case WARPED_TRAPDOOR: case WARPED_WALL_HANGING_SIGN: case WARPED_WALL_SIGN: case WATER_CAULDRON: - case WAXED_CUT_COPPER_STAIRS: - case WAXED_EXPOSED_CUT_COPPER_STAIRS: - case WAXED_OXIDIZED_CUT_COPPER_STAIRS: - case WAXED_WEATHERED_CUT_COPPER_STAIRS: - case WEATHERED_CUT_COPPER_STAIRS: + case WAXED_COPPER_DOOR: + case WAXED_COPPER_TRAPDOOR: + case WAXED_EXPOSED_COPPER_DOOR: + case WAXED_EXPOSED_COPPER_TRAPDOOR: + case WAXED_OXIDIZED_COPPER_DOOR: + case WAXED_OXIDIZED_COPPER_TRAPDOOR: + case WAXED_WEATHERED_COPPER_DOOR: + case WAXED_WEATHERED_COPPER_TRAPDOOR: + case WEATHERED_COPPER_DOOR: + case WEATHERED_COPPER_TRAPDOOR: case WHITE_BED: case WHITE_CANDLE: case WHITE_CANDLE_CAKE: @@ -9456,8 +9791,11 @@ public enum Material implements Keyed, Translatable { case CHISELED_BOOKSHELF: case CHISELED_POLISHED_BLACKSTONE: case CHISELED_STONE_BRICKS: + case CHISELED_TUFF: + case CHISELED_TUFF_BRICKS: case CRACKED_POLISHED_BLACKSTONE_BRICKS: case CRACKED_STONE_BRICKS: + case CRAFTER: case DARK_PRISMARINE: case DARK_PRISMARINE_SLAB: case DARK_PRISMARINE_STAIRS: @@ -9504,6 +9842,10 @@ public enum Material implements Keyed, Translatable { case POLISHED_GRANITE: case POLISHED_GRANITE_SLAB: case POLISHED_GRANITE_STAIRS: + case POLISHED_TUFF: + case POLISHED_TUFF_SLAB: + case POLISHED_TUFF_STAIRS: + case POLISHED_TUFF_WALL: case PRISMARINE: case PRISMARINE_BRICKS: case PRISMARINE_BRICK_SLAB: @@ -9524,6 +9866,13 @@ public enum Material implements Keyed, Translatable { case STONE_STAIRS: case TUBE_CORAL_BLOCK: case TUFF: + case TUFF_BRICKS: + case TUFF_BRICK_SLAB: + case TUFF_BRICK_STAIRS: + case TUFF_BRICK_WALL: + case TUFF_SLAB: + case TUFF_STAIRS: + case TUFF_WALL: return 1.5F; case BLACK_CONCRETE: case BLUE_CONCRETE: @@ -9739,10 +10088,15 @@ public enum Material implements Keyed, Translatable { case BIRCH_TRAPDOOR: case CHERRY_DOOR: case CHERRY_TRAPDOOR: + case CHISELED_COPPER: case COAL_ORE: case CONDUIT: case COPPER_BLOCK: + case COPPER_BULB: + case COPPER_DOOR: + case COPPER_GRATE: case COPPER_ORE: + case COPPER_TRAPDOOR: case CRIMSON_DOOR: case CRIMSON_TRAPDOOR: case CUT_COPPER: @@ -9759,7 +10113,12 @@ public enum Material implements Keyed, Translatable { case END_STONE_BRICK_SLAB: case END_STONE_BRICK_STAIRS: case END_STONE_BRICK_WALL: + case EXPOSED_CHISELED_COPPER: case EXPOSED_COPPER: + case EXPOSED_COPPER_BULB: + case EXPOSED_COPPER_DOOR: + case EXPOSED_COPPER_GRATE: + case EXPOSED_COPPER_TRAPDOOR: case EXPOSED_CUT_COPPER: case EXPOSED_CUT_COPPER_SLAB: case EXPOSED_CUT_COPPER_STAIRS: @@ -9779,7 +10138,12 @@ public enum Material implements Keyed, Translatable { case OAK_DOOR: case OAK_TRAPDOOR: case OBSERVER: + case OXIDIZED_CHISELED_COPPER: case OXIDIZED_COPPER: + case OXIDIZED_COPPER_BULB: + case OXIDIZED_COPPER_DOOR: + case OXIDIZED_COPPER_GRATE: + case OXIDIZED_COPPER_TRAPDOOR: case OXIDIZED_CUT_COPPER: case OXIDIZED_CUT_COPPER_SLAB: case OXIDIZED_CUT_COPPER_STAIRS: @@ -9790,23 +10154,48 @@ public enum Material implements Keyed, Translatable { case SPRUCE_TRAPDOOR: case WARPED_DOOR: case WARPED_TRAPDOOR: + case WAXED_CHISELED_COPPER: case WAXED_COPPER_BLOCK: + case WAXED_COPPER_BULB: + case WAXED_COPPER_DOOR: + case WAXED_COPPER_GRATE: + case WAXED_COPPER_TRAPDOOR: case WAXED_CUT_COPPER: case WAXED_CUT_COPPER_SLAB: case WAXED_CUT_COPPER_STAIRS: + case WAXED_EXPOSED_CHISELED_COPPER: case WAXED_EXPOSED_COPPER: + case WAXED_EXPOSED_COPPER_BULB: + case WAXED_EXPOSED_COPPER_DOOR: + case WAXED_EXPOSED_COPPER_GRATE: + case WAXED_EXPOSED_COPPER_TRAPDOOR: case WAXED_EXPOSED_CUT_COPPER: case WAXED_EXPOSED_CUT_COPPER_SLAB: case WAXED_EXPOSED_CUT_COPPER_STAIRS: + case WAXED_OXIDIZED_CHISELED_COPPER: case WAXED_OXIDIZED_COPPER: + case WAXED_OXIDIZED_COPPER_BULB: + case WAXED_OXIDIZED_COPPER_DOOR: + case WAXED_OXIDIZED_COPPER_GRATE: + case WAXED_OXIDIZED_COPPER_TRAPDOOR: case WAXED_OXIDIZED_CUT_COPPER: case WAXED_OXIDIZED_CUT_COPPER_SLAB: case WAXED_OXIDIZED_CUT_COPPER_STAIRS: + case WAXED_WEATHERED_CHISELED_COPPER: case WAXED_WEATHERED_COPPER: + case WAXED_WEATHERED_COPPER_BULB: + case WAXED_WEATHERED_COPPER_DOOR: + case WAXED_WEATHERED_COPPER_GRATE: + case WAXED_WEATHERED_COPPER_TRAPDOOR: case WAXED_WEATHERED_CUT_COPPER: case WAXED_WEATHERED_CUT_COPPER_SLAB: case WAXED_WEATHERED_CUT_COPPER_STAIRS: + case WEATHERED_CHISELED_COPPER: case WEATHERED_COPPER: + case WEATHERED_COPPER_BULB: + case WEATHERED_COPPER_DOOR: + case WEATHERED_COPPER_GRATE: + case WEATHERED_COPPER_TRAPDOOR: case WEATHERED_CUT_COPPER: case WEATHERED_CUT_COPPER_SLAB: case WEATHERED_CUT_COPPER_STAIRS: @@ -9878,6 +10267,7 @@ public enum Material implements Keyed, Translatable { case NETHERITE_BLOCK: case OBSIDIAN: case RESPAWN_ANCHOR: + case TRIAL_SPAWNER: return 50.0F; case REINFORCED_DEEPSLATE: return 55.0F; @@ -10520,6 +10910,7 @@ public enum Material implements Keyed, Translatable { case WARPED_TRAPDOOR: return 3.0F; case BLAST_FURNACE: + case CRAFTER: case DISPENSER: case DROPPER: case FURNACE: @@ -10574,10 +10965,13 @@ public enum Material implements Keyed, Translatable { case BRICK_WALL: case BUBBLE_CORAL_BLOCK: case CHAIN: + case CHISELED_COPPER: case CHISELED_DEEPSLATE: case CHISELED_NETHER_BRICKS: case CHISELED_POLISHED_BLACKSTONE: case CHISELED_STONE_BRICKS: + case CHISELED_TUFF: + case CHISELED_TUFF_BRICKS: case COAL_BLOCK: case COBBLED_DEEPSLATE: case COBBLED_DEEPSLATE_SLAB: @@ -10588,6 +10982,10 @@ public enum Material implements Keyed, Translatable { case COBBLESTONE_STAIRS: case COBBLESTONE_WALL: case COPPER_BLOCK: + case COPPER_BULB: + case COPPER_DOOR: + case COPPER_GRATE: + case COPPER_TRAPDOOR: case CRACKED_DEEPSLATE_BRICKS: case CRACKED_DEEPSLATE_TILES: case CRACKED_NETHER_BRICKS: @@ -10621,7 +11019,12 @@ public enum Material implements Keyed, Translatable { case DIORITE_STAIRS: case DIORITE_WALL: case EMERALD_BLOCK: + case EXPOSED_CHISELED_COPPER: case EXPOSED_COPPER: + case EXPOSED_COPPER_BULB: + case EXPOSED_COPPER_DOOR: + case EXPOSED_COPPER_GRATE: + case EXPOSED_COPPER_TRAPDOOR: case EXPOSED_CUT_COPPER: case EXPOSED_CUT_COPPER_SLAB: case EXPOSED_CUT_COPPER_STAIRS: @@ -10651,7 +11054,12 @@ public enum Material implements Keyed, Translatable { case NETHER_BRICK_SLAB: case NETHER_BRICK_STAIRS: case NETHER_BRICK_WALL: + case OXIDIZED_CHISELED_COPPER: case OXIDIZED_COPPER: + case OXIDIZED_COPPER_BULB: + case OXIDIZED_COPPER_DOOR: + case OXIDIZED_COPPER_GRATE: + case OXIDIZED_COPPER_TRAPDOOR: case OXIDIZED_CUT_COPPER: case OXIDIZED_CUT_COPPER_SLAB: case OXIDIZED_CUT_COPPER_STAIRS: @@ -10677,6 +11085,10 @@ public enum Material implements Keyed, Translatable { case POLISHED_GRANITE: case POLISHED_GRANITE_SLAB: case POLISHED_GRANITE_STAIRS: + case POLISHED_TUFF: + case POLISHED_TUFF_SLAB: + case POLISHED_TUFF_STAIRS: + case POLISHED_TUFF_WALL: case PRISMARINE: case PRISMARINE_BRICKS: case PRISMARINE_BRICK_SLAB: @@ -10719,23 +11131,55 @@ public enum Material implements Keyed, Translatable { case STONE_STAIRS: case TUBE_CORAL_BLOCK: case TUFF: + case TUFF_BRICKS: + case TUFF_BRICK_SLAB: + case TUFF_BRICK_STAIRS: + case TUFF_BRICK_WALL: + case TUFF_SLAB: + case TUFF_STAIRS: + case TUFF_WALL: + case WAXED_CHISELED_COPPER: case WAXED_COPPER_BLOCK: + case WAXED_COPPER_BULB: + case WAXED_COPPER_DOOR: + case WAXED_COPPER_GRATE: + case WAXED_COPPER_TRAPDOOR: case WAXED_CUT_COPPER: case WAXED_CUT_COPPER_SLAB: case WAXED_CUT_COPPER_STAIRS: + case WAXED_EXPOSED_CHISELED_COPPER: case WAXED_EXPOSED_COPPER: + case WAXED_EXPOSED_COPPER_BULB: + case WAXED_EXPOSED_COPPER_DOOR: + case WAXED_EXPOSED_COPPER_GRATE: + case WAXED_EXPOSED_COPPER_TRAPDOOR: case WAXED_EXPOSED_CUT_COPPER: case WAXED_EXPOSED_CUT_COPPER_SLAB: case WAXED_EXPOSED_CUT_COPPER_STAIRS: + case WAXED_OXIDIZED_CHISELED_COPPER: case WAXED_OXIDIZED_COPPER: + case WAXED_OXIDIZED_COPPER_BULB: + case WAXED_OXIDIZED_COPPER_DOOR: + case WAXED_OXIDIZED_COPPER_GRATE: + case WAXED_OXIDIZED_COPPER_TRAPDOOR: case WAXED_OXIDIZED_CUT_COPPER: case WAXED_OXIDIZED_CUT_COPPER_SLAB: case WAXED_OXIDIZED_CUT_COPPER_STAIRS: + case WAXED_WEATHERED_CHISELED_COPPER: case WAXED_WEATHERED_COPPER: + case WAXED_WEATHERED_COPPER_BULB: + case WAXED_WEATHERED_COPPER_DOOR: + case WAXED_WEATHERED_COPPER_GRATE: + case WAXED_WEATHERED_COPPER_TRAPDOOR: case WAXED_WEATHERED_CUT_COPPER: case WAXED_WEATHERED_CUT_COPPER_SLAB: case WAXED_WEATHERED_CUT_COPPER_STAIRS: + case WEATHERED_CHISELED_COPPER: case WEATHERED_COPPER: + case WEATHERED_COPPER_BULB: + case WEATHERED_COPPER_DOOR: + case WEATHERED_COPPER_GRATE: + case WEATHERED_COPPER_TRAPDOOR: case WEATHERED_CUT_COPPER: case WEATHERED_CUT_COPPER_SLAB: case WEATHERED_CUT_COPPER_STAIRS: @@ -10747,6 +11191,8 @@ public enum Material implements Keyed, Translatable { case END_STONE_BRICK_STAIRS: case END_STONE_BRICK_WALL: return 9.0F; + case TRIAL_SPAWNER: + return 50.0F; case LAVA: case WATER: return 100.0F; diff --git a/src/main/java/org/bukkit/Note.java b/src/main/java/org/bukkit/Note.java index fc3da7ce..48aecc94 100644 --- a/src/main/java/org/bukkit/Note.java +++ b/src/main/java/org/bukkit/Note.java @@ -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; /** @@ -254,6 +262,16 @@ public class 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 public int hashCode() { final int prime = 31; diff --git a/src/main/java/org/bukkit/Particle.java b/src/main/java/org/bukkit/Particle.java index 9ce177d0..fc3035dd 100644 --- a/src/main/java/org/bukkit/Particle.java +++ b/src/main/java/org/bukkit/Particle.java @@ -120,6 +120,16 @@ public abstract class Particle extends OldEnum> implements Keyed public static final Particle SHRIEK = getParticle("shriek"); public static final Particle CHERRY_LEAVES = getParticle("cherry_leaves"); public static final Particle EGG_CRACK = getParticle("egg_crack"); + public static final Particle DUST_PLUME = getParticle("dust_plume"); + public static final Particle WHITE_SMOKE = getParticle("white_smoke"); + @MinecraftExperimental + public static final Particle GUST = getParticle("gust"); + @MinecraftExperimental + public static final Particle GUST_EMITTER = getParticle("gust_emitter"); + @MinecraftExperimental + public static final Particle GUST_DUST = getParticle("gust_dust"); + @MinecraftExperimental + public static final Particle TRIAL_SPAWNER_DETECTION = getParticle("trial_spawner_detection"); /** * Uses {@link BlockData} as DataType */ diff --git a/src/main/java/org/bukkit/RegionAccessor.java b/src/main/java/org/bukkit/RegionAccessor.java index 0f191a81..7a5d5952 100644 --- a/src/main/java/org/bukkit/RegionAccessor.java +++ b/src/main/java/org/bukkit/RegionAccessor.java @@ -183,7 +183,7 @@ public interface RegionAccessor { * @param stateConsumer The consumer which should get called for every block which gets changed * @return true if the tree was created successfully, otherwise false */ - boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer stateConsumer); + boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Consumer stateConsumer); /** * 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. * @return true if the tree was created successfully, otherwise false */ - boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate statePredicate); + boolean generateTree(@NotNull Location location, @NotNull Random random, @NotNull TreeType type, @Nullable Predicate statePredicate); /** * Creates a entity at the given {@link Location} @@ -282,6 +282,24 @@ public interface RegionAccessor { @NotNull Collection getEntitiesByClasses(@NotNull Class... classes); + /** + * Creates an entity of a specific class at the given {@link Location} but + * does not spawn it in the world. + *

+ * Note: 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 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 createEntity(@NotNull Location location, @NotNull Class clazz); + /** * 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 */ @NotNull - T spawn(@NotNull Location location, @NotNull Class clazz, @Nullable Consumer function) throws IllegalArgumentException; + T spawn(@NotNull Location location, @NotNull Class clazz, @Nullable Consumer function) throws IllegalArgumentException; /** * 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. */ @NotNull - public T spawn(@NotNull Location location, @NotNull Class clazz, boolean randomizeData, @Nullable Consumer function) throws IllegalArgumentException; + public T spawn(@NotNull Location location, @NotNull Class clazz, boolean randomizeData, @Nullable Consumer function) throws IllegalArgumentException; /** * Gets the highest non-empty (impassable) coordinate at the given @@ -396,4 +414,15 @@ public interface RegionAccessor { * {@link HeightMap} */ public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap); + + /** + * Spawns a previously created entity in the world.
+ * The provided entity must not have already been spawned in a world. + * + * @param 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 addEntity(@NotNull T entity); } diff --git a/src/main/java/org/bukkit/Registry.java b/src/main/java/org/bukkit/Registry.java index 8ef41bc6..396e8fe7 100644 --- a/src/main/java/org/bukkit/Registry.java +++ b/src/main/java/org/bukkit/Registry.java @@ -79,6 +79,12 @@ public interface Registry extends Iterable { * @see Attribute */ Registry ATTRIBUTE = Objects.requireNonNull(Bukkit.getRegistry(Attribute.class), "No registry present for Attribute. This is a bug."); + /** + * Server banner patterns. + * + * @see PatternType + */ + Registry BANNER_PATTERN = Objects.requireNonNull(Bukkit.getRegistry(PatternType.class), "No registry present for PatternType. This is a bug."); /** * Server biomes. * @@ -91,12 +97,6 @@ public interface Registry extends Iterable { * @see BlockType */ Registry> BLOCK = Objects.requireNonNull(Bukkit.getRegistry(BlockType.class), "No registry present for BlockType. This is a bug."); - /** - * Server pattern types. - * - * @see PatternType - */ - Registry BANNER_PATTERN = Objects.requireNonNull(Bukkit.getRegistry(PatternType.class), "No registry present for PatternType. This is a bug."); /** * Custom boss bars. * @@ -128,7 +128,7 @@ public interface Registry extends Iterable { * * @see Cat.Type */ - Registry CAT_TYPE = Objects.requireNonNull(Bukkit.getRegistry(Cat.Type.class), "No registry present for Cat Type. This is a bug."); + Registry CAT_VARIANT = Objects.requireNonNull(Bukkit.getRegistry(Cat.Type.class), "No registry present for Cat Type. This is a bug."); /** * Server enchantments. * @@ -167,6 +167,12 @@ public interface Registry extends Iterable { */ @Deprecated Registry MATERIAL = new SimpleRegistry<>(Material.class, (mat) -> !mat.isLegacy()); + /** + * Server mob effects. + * + * @see PotionEffectType + */ + Registry EFFECT = Objects.requireNonNull(Bukkit.getRegistry(PotionEffectType.class), "No registry present for PotionEffectType. This is a bug."); /** * Server particles. * @@ -272,13 +278,6 @@ public interface Registry extends Iterable { * @see GameEvent */ Registry GAME_EVENT = Objects.requireNonNull(Bukkit.getRegistry(GameEvent.class), "No registry present for GameEvent. This is a bug."); - /** - * Server potion effect types. - * - * @see PotionEffectType - */ - Registry 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. * diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java index 680f3988..7c1d96e0 100644 --- a/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java @@ -36,6 +36,7 @@ import org.bukkit.generator.ChunkGenerator; import org.bukkit.help.HelpMap; import org.bukkit.inventory.Inventory; import org.bukkit.inventory.InventoryHolder; +import org.bukkit.inventory.ItemCraftResult; import org.bukkit.inventory.ItemFactory; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.Merchant; @@ -836,6 +837,74 @@ public interface Server extends PluginMessageRecipient { @NotNull public ItemStack craftItem(@NotNull ItemStack[] craftingMatrix, @NotNull World world, @NotNull Player player); + /** + * Get the crafted item using the list of {@link ItemStack} provided. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + * @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. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + *

The {@link World} and {@link Player} arguments are required to fulfill the Bukkit Crafting + * events.

+ * + *

Calls {@link org.bukkit.event.inventory.PrepareItemCraftEvent} to imitate the {@link Player} + * initiating the crafting event.

+ * + * @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. + * + *

The list is formatted as a crafting matrix where the index follow + * the pattern below:

+ * + *
+     * [ 0 1 2 ]
+     * [ 3 4 5 ]
+     * [ 6 7 8 ]
+     * 
+ * + * @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. * @@ -1583,7 +1652,7 @@ public interface Server extends PluginMessageRecipient { * @return new data instance */ @NotNull - public B createBlockData(@NotNull BlockType blockType, @Nullable Consumer consumer); + public B createBlockData(@NotNull BlockType blockType, @Nullable Consumer consumer); /** * Creates a new {@link BlockData} instance with block type and properties diff --git a/src/main/java/org/bukkit/Sound.java b/src/main/java/org/bukkit/Sound.java index fe19ed17..098fbc97 100644 --- a/src/main/java/org/bukkit/Sound.java +++ b/src/main/java/org/bukkit/Sound.java @@ -181,6 +181,15 @@ public abstract class Sound extends OldEnum implements Keyed { 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_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 ITEM_BRUSH_BRUSHING_GENERIC = getSound("item.brush.brushing.generic"); public static final Sound ITEM_BRUSH_BRUSHING_SAND = getSound("item.brush.brushing.sand"); @@ -316,11 +325,27 @@ public abstract class Sound extends OldEnum implements Keyed { 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_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_STEP = getSound("block.copper.step"); 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_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_FALL = getSound("block.coral_block.fall"); public static final Sound BLOCK_CORAL_BLOCK_HIT = getSound("block.coral_block.hit"); @@ -331,6 +356,8 @@ public abstract class Sound extends OldEnum implements Keyed { 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_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_HURT = getSound("entity.creeper.hurt"); public static final Sound ENTITY_CREEPER_PRIMED = getSound("entity.creeper.primed"); @@ -347,6 +374,8 @@ public abstract class Sound extends OldEnum implements Keyed { 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_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_PLACE = getSound("block.decorated_pot.place"); public static final Sound BLOCK_DECORATED_POT_SHATTER = getSound("block.decorated_pot.shatter"); @@ -624,6 +653,17 @@ public abstract class Sound extends OldEnum 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_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_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 ENTITY_HOGLIN_AMBIENT = getSound("entity.hoglin.ambient"); public static final Sound ENTITY_HOGLIN_ANGRY = getSound("entity.hoglin.angry"); @@ -958,6 +998,7 @@ public abstract class Sound extends OldEnum implements Keyed { 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_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_DROWNED = getSound("entity.parrot.imitate.drowned"); 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 implements Keyed { 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_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_BABY = getSound("entity.polar_bear.ambient_baby"); public static final Sound ENTITY_POLAR_BEAR_DEATH = getSound("entity.polar_bear.death"); @@ -1329,6 +1371,16 @@ public abstract class Sound extends OldEnum implements Keyed { 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_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_DEATH = getSound("entity.turtle.death"); public static final Sound ENTITY_TURTLE_DEATH_BABY = getSound("entity.turtle.death_baby"); @@ -1414,6 +1466,7 @@ public abstract class Sound extends OldEnum implements Keyed { 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_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_WATER_AMBIENT = getSound("block.water.ambient"); public static final Sound WEATHER_RAIN = getSound("weather.rain"); @@ -1428,6 +1481,7 @@ public abstract class Sound extends OldEnum implements Keyed { 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_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_CELEBRATE = getSound("entity.witch.celebrate"); public static final Sound ENTITY_WITCH_DEATH = getSound("entity.witch.death"); diff --git a/src/main/java/org/bukkit/Tag.java b/src/main/java/org/bukkit/Tag.java index e13374f4..9a5f8196 100644 --- a/src/main/java/org/bukkit/Tag.java +++ b/src/main/java/org/bukkit/Tag.java @@ -964,6 +964,18 @@ public interface Tag extends Keyed { * Vanilla tag representing entities which are not controlled by their mount. */ Tag> 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> ENTITY_TYPES_DEFLECTS_ARROWS = Bukkit.getTag(REGISTRY_ENTITY_TYPES, NamespacedKey.minecraft("deflects_arrows"), EntityType.class); + /** + * Vanilla tag representing entities which deflect tridents. + */ + Tag> 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> 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. diff --git a/src/main/java/org/bukkit/World.java b/src/main/java/org/bukkit/World.java index 60261b28..1a290c43 100644 --- a/src/main/java/org/bukkit/World.java +++ b/src/main/java/org/bukkit/World.java @@ -454,7 +454,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * @return ItemDrop entity created as a result of this method */ @NotNull - public Item dropItem(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer function); + public Item dropItem(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer function); /** * 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 */ @NotNull - public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer function); + public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item, @Nullable Consumer function); /** * Creates an {@link Arrow} entity at the given {@link Location} @@ -642,7 +642,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * non-null collection. */ @NotNull - public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z, @Nullable Predicate filter); + public Collection getNearbyEntities(@NotNull Location location, double x, double y, double z, @Nullable Predicate filter); /** * 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 */ @NotNull - public Collection getNearbyEntities(@NotNull BoundingBox boundingBox, @Nullable Predicate filter); + public Collection getNearbyEntities(@NotNull BoundingBox boundingBox, @Nullable Predicate filter); /** * 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 * implementations may impose artificial restrictions on the maximum * distance. + *

+ * Note: 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 direction the ray direction @@ -702,7 +705,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * @param direction the ray direction * @param maxDistance the maximum distance * @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 null if there * is no hit * @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 * implementations may impose artificial restrictions on the maximum * distance. + *

+ * Note: 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 direction the ray direction @@ -727,7 +733,7 @@ public interface World extends RegionAccessor, WorldInfo, PluginMessageRecipient * @see #rayTraceEntities(Location, Vector, double, double, Predicate) */ @Nullable - public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, @Nullable Predicate filter); + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, @Nullable Predicate filter); /** * 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 maxDistance the maximum distance * @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, * or null to consider all entities * @return the closest ray trace hit result, or null if there * is no hit */ @Nullable - public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, @Nullable Predicate filter); + public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, @Nullable Predicate filter); /** * 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 * blocks (ex. tall grass, signs, fluids, ..) * @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, * or null to consider all entities * @return the closest ray trace hit result with either a block or an * entity, or null if there is no hit */ @Nullable - public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, @Nullable Predicate filter); + public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, @Nullable Predicate filter); /** * 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); + /** + * Play a note at the provided Location in the World.
+ * This will work with cake. + *

+ * 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. *

@@ -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); + /** + * 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. + *

+ * 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. + *

+ * 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. *

@@ -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); + /** + * 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. + *

+ * 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. + *

+ * 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. * diff --git a/src/main/java/org/bukkit/block/BlockType.java b/src/main/java/org/bukkit/block/BlockType.java index a7832251..5bb9b48c 100644 --- a/src/main/java/org/bukkit/block/BlockType.java +++ b/src/main/java/org/bukkit/block/BlockType.java @@ -44,6 +44,7 @@ import org.bukkit.block.data.type.ChiseledBookshelf; import org.bukkit.block.data.type.Cocoa; import org.bukkit.block.data.type.CommandBlock; 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.DaylightDetector; import org.bukkit.block.data.type.DecoratedPot; @@ -112,7 +113,7 @@ import org.jetbrains.annotations.Nullable; public interface BlockType extends Keyed, Translatable { // - BlockType AIR = getBlockType("air"); + BlockType AIR = getBlockType("air"); BlockType STONE = getBlockType("stone"); BlockType GRANITE = getBlockType("granite"); BlockType POLISHED_GRANITE = getBlockType("polished_granite"); @@ -478,7 +479,7 @@ public interface BlockType extends Keyed, Translatable { */ BlockType STICKY_PISTON = getBlockType("sticky_piston"); BlockType COBWEB = getBlockType("cobweb"); - BlockType GRASS = getBlockType("grass"); + BlockType SHORT_GRASS = getBlockType("short_grass"); BlockType FERN = getBlockType("fern"); BlockType DEAD_BUSH = getBlockType("dead_bush"); BlockType SEAGRASS = getBlockType("seagrass"); @@ -850,7 +851,6 @@ public interface BlockType extends Keyed, Translatable { * BlockData: {@link Fence} */ BlockType OAK_FENCE = getBlockType("oak_fence"); - BlockType PUMPKIN = getBlockType("pumpkin"); BlockType NETHERRACK = getBlockType("netherrack"); BlockType SOUL_SAND = getBlockType("soul_sand"); BlockType SOUL_SOIL = getBlockType("soul_soil"); @@ -976,6 +976,7 @@ public interface BlockType extends Keyed, Translatable { * BlockData: {@link Fence} */ BlockType GLASS_PANE = getBlockType("glass_pane"); + BlockType PUMPKIN = getBlockType("pumpkin"); BlockType MELON = getBlockType("melon"); /** * BlockData: {@link Directional} @@ -1398,7 +1399,10 @@ public interface BlockType extends Keyed, Translatable { */ BlockType BAMBOO_MOSAIC_STAIRS = getBlockType("bamboo_mosaic_stairs"); BlockType SLIME_BLOCK = getBlockType("slime_block"); - BlockType BARRIER = getBlockType("barrier"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType BARRIER = getBlockType("barrier"); /** * BlockData: {@link Light} */ @@ -2804,6 +2808,46 @@ public interface BlockType extends Keyed, Translatable { */ BlockType SMALL_AMETHYST_BUD = getBlockType("small_amethyst_bud"); BlockType TUFF = getBlockType("tuff"); + /** + * BlockData: {@link Slab} + */ + BlockType TUFF_SLAB = getBlockType("tuff_slab"); + /** + * BlockData: {@link Stairs} + */ + BlockType TUFF_STAIRS = getBlockType("tuff_stairs"); + /** + * BlockData: {@link Wall} + */ + BlockType TUFF_WALL = getBlockType("tuff_wall"); + BlockType POLISHED_TUFF = getBlockType("polished_tuff"); + /** + * BlockData: {@link Slab} + */ + BlockType POLISHED_TUFF_SLAB = getBlockType("polished_tuff_slab"); + /** + * BlockData: {@link Stairs} + */ + BlockType POLISHED_TUFF_STAIRS = getBlockType("polished_tuff_stairs"); + /** + * BlockData: {@link Wall} + */ + BlockType POLISHED_TUFF_WALL = getBlockType("polished_tuff_wall"); + BlockType CHISELED_TUFF = getBlockType("chiseled_tuff"); + BlockType TUFF_BRICKS = getBlockType("tuff_bricks"); + /** + * BlockData: {@link Slab} + */ + BlockType TUFF_BRICK_SLAB = getBlockType("tuff_brick_slab"); + /** + * BlockData: {@link Stairs} + */ + BlockType TUFF_BRICK_STAIRS = getBlockType("tuff_brick_stairs"); + /** + * BlockData: {@link Wall} + */ + BlockType TUFF_BRICK_WALL = getBlockType("tuff_brick_wall"); + BlockType CHISELED_TUFF_BRICKS = getBlockType("chiseled_tuff_bricks"); BlockType CALCITE = getBlockType("calcite"); BlockType TINTED_GLASS = getBlockType("tinted_glass"); BlockType POWDER_SNOW = getBlockType("powder_snow"); @@ -2828,16 +2872,24 @@ public interface BlockType extends Keyed, Translatable { * BlockData: {@link SculkShrieker} */ BlockType SCULK_SHRIEKER = getBlockType("sculk_shrieker"); - BlockType OXIDIZED_COPPER = getBlockType("oxidized_copper"); - BlockType WEATHERED_COPPER = getBlockType("weathered_copper"); - BlockType EXPOSED_COPPER = getBlockType("exposed_copper"); BlockType COPPER_BLOCK = getBlockType("copper_block"); + BlockType EXPOSED_COPPER = getBlockType("exposed_copper"); + BlockType WEATHERED_COPPER = getBlockType("weathered_copper"); + BlockType OXIDIZED_COPPER = getBlockType("oxidized_copper"); BlockType COPPER_ORE = getBlockType("copper_ore"); BlockType DEEPSLATE_COPPER_ORE = getBlockType("deepslate_copper_ore"); BlockType OXIDIZED_CUT_COPPER = getBlockType("oxidized_cut_copper"); BlockType WEATHERED_CUT_COPPER = getBlockType("weathered_cut_copper"); BlockType EXPOSED_CUT_COPPER = getBlockType("exposed_cut_copper"); BlockType CUT_COPPER = getBlockType("cut_copper"); + BlockType OXIDIZED_CHISELED_COPPER = getBlockType("oxidized_chiseled_copper"); + BlockType WEATHERED_CHISELED_COPPER = getBlockType("weathered_chiseled_copper"); + BlockType EXPOSED_CHISELED_COPPER = getBlockType("exposed_chiseled_copper"); + BlockType CHISELED_COPPER = getBlockType("chiseled_copper"); + BlockType WAXED_OXIDIZED_CHISELED_COPPER = getBlockType("waxed_oxidized_chiseled_copper"); + BlockType WAXED_WEATHERED_CHISELED_COPPER = getBlockType("waxed_weathered_chiseled_copper"); + BlockType WAXED_EXPOSED_CHISELED_COPPER = getBlockType("waxed_exposed_chiseled_copper"); + BlockType WAXED_CHISELED_COPPER = getBlockType("waxed_chiseled_copper"); /** * BlockData: {@link Stairs} */ @@ -2910,6 +2962,134 @@ public interface BlockType extends Keyed, Translatable { * BlockData: {@link Slab} */ BlockType WAXED_CUT_COPPER_SLAB = getBlockType("waxed_cut_copper_slab"); + /** + * BlockData: {@link Door} + */ + BlockType COPPER_DOOR = getBlockType("copper_door"); + /** + * BlockData: {@link Door} + */ + BlockType EXPOSED_COPPER_DOOR = getBlockType("exposed_copper_door"); + /** + * BlockData: {@link Door} + */ + BlockType OXIDIZED_COPPER_DOOR = getBlockType("oxidized_copper_door"); + /** + * BlockData: {@link Door} + */ + BlockType WEATHERED_COPPER_DOOR = getBlockType("weathered_copper_door"); + /** + * BlockData: {@link Door} + */ + BlockType WAXED_COPPER_DOOR = getBlockType("waxed_copper_door"); + /** + * BlockData: {@link Door} + */ + BlockType WAXED_EXPOSED_COPPER_DOOR = getBlockType("waxed_exposed_copper_door"); + /** + * BlockData: {@link Door} + */ + BlockType WAXED_OXIDIZED_COPPER_DOOR = getBlockType("waxed_oxidized_copper_door"); + /** + * BlockData: {@link Door} + */ + BlockType WAXED_WEATHERED_COPPER_DOOR = getBlockType("waxed_weathered_copper_door"); + /** + * BlockData: {@link TrapDoor} + */ + BlockType COPPER_TRAPDOOR = getBlockType("copper_trapdoor"); + /** + * BlockData: {@link TrapDoor} + */ + BlockType EXPOSED_COPPER_TRAPDOOR = getBlockType("exposed_copper_trapdoor"); + /** + * BlockData: {@link TrapDoor} + */ + BlockType OXIDIZED_COPPER_TRAPDOOR = getBlockType("oxidized_copper_trapdoor"); + /** + * BlockData: {@link TrapDoor} + */ + BlockType WEATHERED_COPPER_TRAPDOOR = getBlockType("weathered_copper_trapdoor"); + /** + * BlockData: {@link TrapDoor} + */ + BlockType WAXED_COPPER_TRAPDOOR = getBlockType("waxed_copper_trapdoor"); + /** + * BlockData: {@link TrapDoor} + */ + BlockType WAXED_EXPOSED_COPPER_TRAPDOOR = getBlockType("waxed_exposed_copper_trapdoor"); + /** + * BlockData: {@link TrapDoor} + */ + BlockType WAXED_OXIDIZED_COPPER_TRAPDOOR = getBlockType("waxed_oxidized_copper_trapdoor"); + /** + * BlockData: {@link TrapDoor} + */ + BlockType WAXED_WEATHERED_COPPER_TRAPDOOR = getBlockType("waxed_weathered_copper_trapdoor"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType COPPER_GRATE = getBlockType("copper_grate"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType EXPOSED_COPPER_GRATE = getBlockType("exposed_copper_grate"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType WEATHERED_COPPER_GRATE = getBlockType("weathered_copper_grate"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType OXIDIZED_COPPER_GRATE = getBlockType("oxidized_copper_grate"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType WAXED_COPPER_GRATE = getBlockType("waxed_copper_grate"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType WAXED_EXPOSED_COPPER_GRATE = getBlockType("waxed_exposed_copper_grate"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType WAXED_WEATHERED_COPPER_GRATE = getBlockType("waxed_weathered_copper_grate"); + /** + * BlockData: {@link Waterlogged} + */ + BlockType WAXED_OXIDIZED_COPPER_GRATE = getBlockType("waxed_oxidized_copper_grate"); + /** + * BlockData: {@link CopperBulb} + */ + BlockType COPPER_BULB = getBlockType("copper_bulb"); + /** + * BlockData: {@link CopperBulb} + */ + BlockType EXPOSED_COPPER_BULB = getBlockType("exposed_copper_bulb"); + /** + * BlockData: {@link CopperBulb} + */ + BlockType WEATHERED_COPPER_BULB = getBlockType("weathered_copper_bulb"); + /** + * BlockData: {@link CopperBulb} + */ + BlockType OXIDIZED_COPPER_BULB = getBlockType("oxidized_copper_bulb"); + /** + * BlockData: {@link CopperBulb} + */ + BlockType WAXED_COPPER_BULB = getBlockType("waxed_copper_bulb"); + /** + * BlockData: {@link CopperBulb} + */ + BlockType WAXED_EXPOSED_COPPER_BULB = getBlockType("waxed_exposed_copper_bulb"); + /** + * BlockData: {@link CopperBulb} + */ + BlockType WAXED_WEATHERED_COPPER_BULB = getBlockType("waxed_weathered_copper_bulb"); + /** + * BlockData: {@link CopperBulb} + */ + BlockType WAXED_OXIDIZED_COPPER_BULB = getBlockType("waxed_oxidized_copper_bulb"); /** * BlockData: {@link LightningRod} */ @@ -3041,6 +3221,14 @@ public interface BlockType extends Keyed, Translatable { * BlockData: {@link DecoratedPot} */ BlockType DECORATED_POT = getBlockType("decorated_pot"); + /** + * BlockData: {@link Crafter} + */ + BlockType CRAFTER = getBlockType("crafter"); + /** + * BlockData: {@link TrialSpawner} + */ + BlockType TRIAL_SPAWNER = getBlockType("trial_spawner"); // @NotNull diff --git a/src/main/java/org/bukkit/block/Crafter.java b/src/main/java/org/bukkit/block/Crafter.java new file mode 100644 index 00000000..fda6e896 --- /dev/null +++ b/src/main/java/org/bukkit/block/Crafter.java @@ -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); +} diff --git a/src/main/java/org/bukkit/block/CreatureSpawner.java b/src/main/java/org/bukkit/block/CreatureSpawner.java index 6586c8a8..91bb24c0 100644 --- a/src/main/java/org/bukkit/block/CreatureSpawner.java +++ b/src/main/java/org/bukkit/block/CreatureSpawner.java @@ -1,6 +1,12 @@ 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.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -17,7 +23,8 @@ public interface CreatureSpawner extends TileState { public EntityType getSpawnedType(); /** - * Set the spawner's creature type. + * Set the spawner's creature type.
+ * This will override any entities that have been added with {@link #addPotentialSpawn} * * @param creatureType The creature type or null to clear. */ @@ -199,4 +206,75 @@ public interface CreatureSpawner extends TileState { * @see #getSpawnRange() */ 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.
+ *

+ * All applicable data from the spawner will be copied, such as custom name, + * health, and velocity.
+ * + * @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.
+ * This will override any previous entries that have been added with + * {@link #addPotentialSpawn} + *

+ * All applicable data from the snapshot will be copied, such as custom name, + * health, and velocity.
+ * + * @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. + *

+ * The weight will determine how often this entry is chosen to spawn, higher + * weighted entries will spawn more often than lower weighted ones.
+ * 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.
+ * + * @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.
+ * This will override any previous entries added with + * {@link #addPotentialSpawn} + * + * @param entries the list of entries + */ + public void setPotentialSpawns(@NotNull final Collection entries); + + /** + * Gets a list of potential spawns from this spawner or an empty list if no + * entities have been assigned to this spawner.
+ * 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 getPotentialSpawns(); } diff --git a/src/main/java/org/bukkit/block/TrialSpawner.java b/src/main/java/org/bukkit/block/TrialSpawner.java new file mode 100644 index 00000000..66ce87d2 --- /dev/null +++ b/src/main/java/org/bukkit/block/TrialSpawner.java @@ -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 { +} diff --git a/src/main/java/org/bukkit/block/banner/PatternType.java b/src/main/java/org/bukkit/block/banner/PatternType.java index ff93d013..4da966f3 100644 --- a/src/main/java/org/bukkit/block/banner/PatternType.java +++ b/src/main/java/org/bukkit/block/banner/PatternType.java @@ -70,8 +70,11 @@ public abstract class PatternType extends OldEnum implements Keyed * this pattern type * * @return the pattern's identifier + * @see #getKey + * @deprecated magic value */ @NotNull + @Deprecated public abstract String getIdentifier(); /** @@ -80,9 +83,12 @@ public abstract class PatternType extends OldEnum implements Keyed * * @param identifier the identifier * @return the matched pattern type or null + * @see Registry#BANNER_PATTERN + * @deprecated magic value, use {@link Registry#get(NamespacedKey)} instead */ @Contract("null -> null") @Nullable + @Deprecated public static PatternType getByIdentifier(@Nullable String identifier) { if (identifier == null) { return null; diff --git a/src/main/java/org/bukkit/block/data/type/CopperBulb.java b/src/main/java/org/bukkit/block/data/type/CopperBulb.java new file mode 100644 index 00000000..2257f23c --- /dev/null +++ b/src/main/java/org/bukkit/block/data/type/CopperBulb.java @@ -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 { +} diff --git a/src/main/java/org/bukkit/block/data/type/Crafter.java b/src/main/java/org/bukkit/block/data/type/Crafter.java new file mode 100644 index 00000000..282188ff --- /dev/null +++ b/src/main/java/org/bukkit/block/data/type/Crafter.java @@ -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. + *
+ * Similar to {@link Powerable}, 'triggered' indicates whether or not the + * dispenser is currently activated. + *
+ * '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; + } +} diff --git a/src/main/java/org/bukkit/block/data/type/TrialSpawner.java b/src/main/java/org/bukkit/block/data/type/TrialSpawner.java new file mode 100644 index 00000000..2a205290 --- /dev/null +++ b/src/main/java/org/bukkit/block/data/type/TrialSpawner.java @@ -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; + } +} diff --git a/src/main/java/org/bukkit/block/spawner/SpawnRule.java b/src/main/java/org/bukkit/block/spawner/SpawnRule.java new file mode 100644 index 00000000..c15ce91a --- /dev/null +++ b/src/main/java/org/bukkit/block/spawner/SpawnRule.java @@ -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 serialize() { + Map result = new LinkedHashMap<>(); + Map block = new LinkedHashMap<>(); + Map 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 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); + } +} diff --git a/src/main/java/org/bukkit/block/spawner/SpawnerEntry.java b/src/main/java/org/bukkit/block/spawner/SpawnerEntry.java new file mode 100644 index 00000000..0043276a --- /dev/null +++ b/src/main/java/org/bukkit/block/spawner/SpawnerEntry.java @@ -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; + } +} diff --git a/src/main/java/org/bukkit/block/spawner/package-info.java b/src/main/java/org/bukkit/block/spawner/package-info.java new file mode 100644 index 00000000..9a8e7688 --- /dev/null +++ b/src/main/java/org/bukkit/block/spawner/package-info.java @@ -0,0 +1,4 @@ +/** + * Classes relevant to mob spawners. + */ +package org.bukkit.block.spawner; diff --git a/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java b/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java index 2c047062..a6497f42 100644 --- a/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java +++ b/src/main/java/org/bukkit/configuration/serialization/ConfigurationSerialization.java @@ -14,6 +14,7 @@ import org.bukkit.FireworkEffect; import org.bukkit.Location; import org.bukkit.attribute.AttributeModifier; import org.bukkit.block.banner.Pattern; +import org.bukkit.block.spawner.SpawnRule; import org.bukkit.configuration.Configuration; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; @@ -42,6 +43,7 @@ public class ConfigurationSerialization { registerClass(Location.class); registerClass(AttributeModifier.class); registerClass(BoundingBox.class); + registerClass(SpawnRule.class); } protected ConfigurationSerialization(@NotNull Class clazz) { diff --git a/src/main/java/org/bukkit/enchantments/Enchantment.java b/src/main/java/org/bukkit/enchantments/Enchantment.java index ed59e306..2bab22ec 100644 --- a/src/main/java/org/bukkit/enchantments/Enchantment.java +++ b/src/main/java/org/bukkit/enchantments/Enchantment.java @@ -215,7 +215,9 @@ public abstract class Enchantment implements Keyed { private static Enchantment getEnchantment(@NotNull String key) { NamespacedKey namespacedKey = NamespacedKey.minecraft(key); Enchantment enchantment = Registry.ENCHANTMENT.get(namespacedKey); + Preconditions.checkNotNull(enchantment, "No Enchantment found for %s. This is a bug.", namespacedKey); + return enchantment; } @@ -325,6 +327,7 @@ public abstract class Enchantment implements Keyed { if (name == null) { return null; } + name = convertLegacy(name); 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]); } - /** - * Registers an enchantment with the given ID and object. - *

- * 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) { if (from == null) { return null; diff --git a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java index 7fee01b0..7ad7bcf9 100644 --- a/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java +++ b/src/main/java/org/bukkit/enchantments/EnchantmentWrapper.java @@ -1,7 +1,5 @@ package org.bukkit.enchantments; -import org.bukkit.NamespacedKey; -import org.bukkit.inventory.ItemStack; 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 -public class EnchantmentWrapper extends Enchantment { - public EnchantmentWrapper(@NotNull String name) { +public abstract class EnchantmentWrapper extends Enchantment { + protected EnchantmentWrapper() { } /** @@ -20,54 +18,6 @@ public class EnchantmentWrapper extends Enchantment { */ @NotNull public Enchantment getEnchantment() { - return Enchantment.getByKey(getKey()); - } - - @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(); + return this; } } diff --git a/src/main/java/org/bukkit/entity/Breeze.java b/src/main/java/org/bukkit/entity/Breeze.java new file mode 100644 index 00000000..03d9e1f5 --- /dev/null +++ b/src/main/java/org/bukkit/entity/Breeze.java @@ -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 { +} diff --git a/src/main/java/org/bukkit/entity/Cat.java b/src/main/java/org/bukkit/entity/Cat.java index a541d961..981ce846 100644 --- a/src/main/java/org/bukkit/entity/Cat.java +++ b/src/main/java/org/bukkit/entity/Cat.java @@ -63,7 +63,7 @@ public interface Cat extends Tameable, Sittable { @NotNull private static Type getType(@NotNull String 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); return type; } @@ -76,7 +76,7 @@ public interface Cat extends Tameable, Sittable { @NotNull @Deprecated 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); return type; } @@ -88,7 +88,7 @@ public interface Cat extends Tameable, Sittable { @NotNull @Deprecated public static Type[] values() { - return Lists.newArrayList(Registry.CAT_TYPE).toArray(new Type[0]); + return Lists.newArrayList(Registry.CAT_VARIANT).toArray(new Type[0]); } } } diff --git a/src/main/java/org/bukkit/entity/Entity.java b/src/main/java/org/bukkit/entity/Entity.java index 26631b6d..8ecb97c5 100644 --- a/src/main/java/org/bukkit/entity/Entity.java +++ b/src/main/java/org/bukkit/entity/Entity.java @@ -26,6 +26,9 @@ import org.jetbrains.annotations.Nullable; /** * Represents a base entity in the world + *

+ * Not all methods are guaranteed to work/may have side effects when + * {@link #isInWorld()} is false. */ 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. + * + * @throws UnsupportedOperationException if you try to remove a {@link Player} use {@link Player#kickPlayer(String)} in this case instead */ public void remove(); @@ -265,8 +270,8 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent public boolean isDead(); /** - * Returns false if the entity has died or been despawned for some other - * reason. + * Returns false if the entity has died, been despawned for some other + * reason, or has not been added to the world. * * @return True if valid. */ @@ -714,4 +719,43 @@ public interface Entity extends Metadatable, CommandSender, Nameable, Persistent */ @NotNull SpawnCategory getSpawnCategory(); + + /** + * Checks if this entity has been spawned in a world.
+ * 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.
+ * Note: 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.
+ * Note: 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); } diff --git a/src/main/java/org/bukkit/entity/EntitySnapshot.java b/src/main/java/org/bukkit/entity/EntitySnapshot.java new file mode 100644 index 00000000..6f34486a --- /dev/null +++ b/src/main/java/org/bukkit/entity/EntitySnapshot.java @@ -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. + *
+ * + * @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(); +} diff --git a/src/main/java/org/bukkit/entity/EntityType.java b/src/main/java/org/bukkit/entity/EntityType.java index 855b4022..0042cefb 100644 --- a/src/main/java/org/bukkit/entity/EntityType.java +++ b/src/main/java/org/bukkit/entity/EntityType.java @@ -7,6 +7,7 @@ import com.google.common.collect.Lists; import org.bukkit.Bukkit; import org.bukkit.Keyed; import org.bukkit.Location; +import org.bukkit.MinecraftExperimental; import org.bukkit.NamespacedKey; import org.bukkit.Registry; import org.bukkit.Translatable; @@ -21,6 +22,7 @@ import org.bukkit.entity.minecart.StorageMinecart; import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffectType; import org.bukkit.util.OldEnum; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -288,6 +290,12 @@ public abstract class EntityType extends OldEnum public static final EntityType ITEM_DISPLAY = getEntityType("item_display"); public static final EntityType SNIFFER = getEntityType("sniffer"); public static final EntityType TEXT_DISPLAY = getEntityType("text_display"); + @MinecraftExperimental + @ApiStatus.Experimental + public static final EntityType BREEZE = getEntityType("breeze"); + @MinecraftExperimental + @ApiStatus.Experimental + public static final EntityType WIND_CHARGE = getEntityType("wind_charge"); /** * A fishing line and bobber. */ diff --git a/src/main/java/org/bukkit/entity/EvokerFangs.java b/src/main/java/org/bukkit/entity/EvokerFangs.java index 7cc1dcda..7d5f9ccb 100644 --- a/src/main/java/org/bukkit/entity/EvokerFangs.java +++ b/src/main/java/org/bukkit/entity/EvokerFangs.java @@ -21,4 +21,18 @@ public interface EvokerFangs extends Entity { * @param owner the {@link LivingEntity} which summoned the fangs */ 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); } diff --git a/src/main/java/org/bukkit/entity/Player.java b/src/main/java/org/bukkit/entity/Player.java index 11a16d98..5f62ace3 100644 --- a/src/main/java/org/bukkit/entity/Player.java +++ b/src/main/java/org/bukkit/entity/Player.java @@ -7,6 +7,7 @@ import java.time.Instant; import java.util.Collection; import java.util.Date; import java.util.Map; +import java.util.UUID; import org.bukkit.BanEntry; import org.bukkit.DyeColor; import org.bukkit.Effect; @@ -391,11 +392,10 @@ public interface Player extends HumanEntity, Conversable, OfflinePlayer, PluginM public void setBedSpawnLocation(@Nullable Location location, boolean force); /** - * Play a note for a player at a location. This requires a note block - * at the particular location (as far as the client is concerned). This - * will not work without a note block. This will not work with cake. + * Play a note for the player at a location.
+ * This will 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 note The note ID. * @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); /** - * Play a note for a player at a location. This requires a note block - * at the particular location (as far as the client is concerned). This - * will not work without a note block. This will not work with cake. - * - * @param loc The location of a note block + * Play a note for the player at a location.
+ * This will work with cake. + *

+ * 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 */ @@ -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); + /** + * Play a sound for a player at the location. For sounds with multiple + * variations passing the same seed will always play the same variation. + *

+ * 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. + *

+ * 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. *

@@ -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); + /** + * 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. + *

+ * 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. + *

+ * 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. * @@ -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); + /** + * Request that the player's client download and switch resource packs. + *

+ * 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. + *

+ * Notes: + *

    + *
  • 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! + *
  • 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. + *
  • 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. + *
+ * + * @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 * diff --git a/src/main/java/org/bukkit/entity/Pose.java b/src/main/java/org/bukkit/entity/Pose.java index 5122194a..d5e33844 100644 --- a/src/main/java/org/bukkit/entity/Pose.java +++ b/src/main/java/org/bukkit/entity/Pose.java @@ -65,5 +65,17 @@ public enum Pose { /** * Entity is digging. */ - DIGGING; + DIGGING, + /** + * Entity is sliding. + */ + SLIDING, + /** + * Entity is shooting. + */ + SHOOTING, + /** + * Entity is inhaling. + */ + INHALING; } diff --git a/src/main/java/org/bukkit/entity/WindCharge.java b/src/main/java/org/bukkit/entity/WindCharge.java new file mode 100644 index 00000000..9294de16 --- /dev/null +++ b/src/main/java/org/bukkit/entity/WindCharge.java @@ -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 { +} diff --git a/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java b/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java index 6417c2fd..997c86b0 100644 --- a/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java +++ b/src/main/java/org/bukkit/event/entity/ExpBottleEvent.java @@ -1,8 +1,12 @@ 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.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a ThrownExpBottle hits and releases experience. @@ -12,8 +16,13 @@ public class ExpBottleEvent extends ProjectileHitEvent { private int exp; private boolean showEffect = true; + @Deprecated 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; } diff --git a/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java b/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java index a10dab16..1584c6c4 100644 --- a/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java +++ b/src/main/java/org/bukkit/event/entity/LingeringPotionSplashEvent.java @@ -1,10 +1,14 @@ package org.bukkit.event.entity; +import org.bukkit.block.Block; +import org.bukkit.block.BlockFace; import org.bukkit.entity.AreaEffectCloud; +import org.bukkit.entity.Entity; import org.bukkit.entity.ThrownPotion; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a splash potion hits an area @@ -14,8 +18,13 @@ public class LingeringPotionSplashEvent extends ProjectileHitEvent implements Ca private boolean cancelled; private final AreaEffectCloud entity; + @Deprecated 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; } diff --git a/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java b/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java index 80f31a26..bc6ba6c4 100644 --- a/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java +++ b/src/main/java/org/bukkit/event/entity/PotionSplashEvent.java @@ -4,11 +4,15 @@ import com.google.common.base.Preconditions; import java.util.ArrayList; import java.util.Collection; 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.ThrownPotion; import org.bukkit.event.Cancellable; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Called when a splash potion hits an area @@ -18,9 +22,13 @@ public class PotionSplashEvent extends ProjectileHitEvent implements Cancellable private boolean cancelled; private final Map affectedEntities; + @Deprecated public PotionSplashEvent(@NotNull final ThrownPotion potion, @NotNull final Map 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 affectedEntities) { + super(potion, hitEntity, hitBlock, hitFace); this.affectedEntities = affectedEntities; } diff --git a/src/main/java/org/bukkit/event/inventory/InventoryType.java b/src/main/java/org/bukkit/event/inventory/InventoryType.java index ec9f58ea..a2e9bedc 100644 --- a/src/main/java/org/bukkit/event/inventory/InventoryType.java +++ b/src/main/java/org/bukkit/event/inventory/InventoryType.java @@ -1,6 +1,8 @@ package org.bukkit.event.inventory; +import org.bukkit.MinecraftExperimental; import org.bukkit.inventory.InventoryHolder; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NotNull; /** @@ -142,6 +144,12 @@ public enum InventoryType { * Pseudo jukebox inventory with 1 slot of undefined type. */ 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. * diff --git a/src/main/java/org/bukkit/event/player/PlayerRecipeBookSettingsChangeEvent.java b/src/main/java/org/bukkit/event/player/PlayerRecipeBookSettingsChangeEvent.java new file mode 100644 index 00000000..249f670f --- /dev/null +++ b/src/main/java/org/bukkit/event/player/PlayerRecipeBookSettingsChangeEvent.java @@ -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. + *
+ * 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; + } +} diff --git a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java index b9819565..e2c4f9a0 100644 --- a/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java +++ b/src/main/java/org/bukkit/event/player/PlayerResourcePackStatusEvent.java @@ -1,5 +1,6 @@ package org.bukkit.event.player; +import java.util.UUID; import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.jetbrains.annotations.NotNull; @@ -11,13 +12,25 @@ import org.jetbrains.annotations.NotNull; public class PlayerResourcePackStatusEvent extends PlayerEvent { private static final HandlerList handlers = new HandlerList(); + private final UUID id; 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); + this.id = id; 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. * @@ -60,6 +73,22 @@ public class PlayerResourcePackStatusEvent extends PlayerEvent { /** * 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; } } diff --git a/src/main/java/org/bukkit/generator/structure/Structure.java b/src/main/java/org/bukkit/generator/structure/Structure.java index ca310cfe..65d3d8fd 100644 --- a/src/main/java/org/bukkit/generator/structure/Structure.java +++ b/src/main/java/org/bukkit/generator/structure/Structure.java @@ -1,6 +1,7 @@ package org.bukkit.generator.structure; import org.bukkit.Keyed; +import org.bukkit.MinecraftExperimental; import org.bukkit.NamespacedKey; import org.bukkit.Registry; 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 ANCIENT_CITY = getStructure("ancient_city"); 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) { return Registry.STRUCTURE.get(NamespacedKey.minecraft(name)); diff --git a/src/main/java/org/bukkit/inventory/CrafterInventory.java b/src/main/java/org/bukkit/inventory/CrafterInventory.java new file mode 100644 index 00000000..7cdcd45e --- /dev/null +++ b/src/main/java/org/bukkit/inventory/CrafterInventory.java @@ -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 { } diff --git a/src/main/java/org/bukkit/inventory/ItemCraftResult.java b/src/main/java/org/bukkit/inventory/ItemCraftResult.java new file mode 100644 index 00000000..ebb4d19e --- /dev/null +++ b/src/main/java/org/bukkit/inventory/ItemCraftResult.java @@ -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. + *
+ * 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 getOverflowItems(); +} diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java index e05dd728..8951f92e 100644 --- a/src/main/java/org/bukkit/inventory/ItemFactory.java +++ b/src/main/java/org/bukkit/inventory/ItemFactory.java @@ -2,7 +2,9 @@ package org.bukkit.inventory; import org.bukkit.Color; import org.bukkit.Server; +import org.bukkit.World; import org.bukkit.enchantments.Enchantment; +import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.inventory.meta.BookMeta; import org.bukkit.inventory.meta.ItemMeta; @@ -171,4 +173,47 @@ public interface ItemFactory { */ @Nullable ItemType getSpawnEgg(@NotNull EntityType type); + + /** + * Enchants the given item at the provided level. + *
+ * 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. + *
+ * 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. + *
+ * 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); } diff --git a/src/main/java/org/bukkit/inventory/ItemType.java b/src/main/java/org/bukkit/inventory/ItemType.java index f008470f..1fc323a5 100644 --- a/src/main/java/org/bukkit/inventory/ItemType.java +++ b/src/main/java/org/bukkit/inventory/ItemType.java @@ -28,6 +28,19 @@ public interface ItemType extends Keyed, Translatable { ItemType POLISHED_DEEPSLATE = getItemType("polished_deepslate"); ItemType CALCITE = getItemType("calcite"); 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 GRASS_BLOCK = getItemType("grass_block"); ItemType DIRT = getItemType("dirt"); @@ -97,6 +110,10 @@ public interface ItemType extends Keyed, Translatable { ItemType EXPOSED_COPPER = getItemType("exposed_copper"); ItemType WEATHERED_COPPER = getItemType("weathered_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 EXPOSED_CUT_COPPER = getItemType("exposed_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_WEATHERED_COPPER = getItemType("waxed_weathered_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_EXPOSED_CUT_COPPER = getItemType("waxed_exposed_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 CUT_SANDSTONE = getItemType("cut_sandstone"); ItemType COBWEB = getItemType("cobweb"); - ItemType GRASS = getItemType("grass"); + ItemType SHORT_GRASS = getItemType("short_grass"); ItemType FERN = getItemType("fern"); ItemType AZALEA = getItemType("azalea"); ItemType FLOWERING_AZALEA = getItemType("flowering_azalea"); @@ -715,6 +736,14 @@ public interface ItemType extends Keyed, Translatable { ItemType BAMBOO_DOOR = getItemType("bamboo_door"); ItemType CRIMSON_DOOR = getItemType("crimson_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 OAK_TRAPDOOR = getItemType("oak_trapdoor"); ItemType SPRUCE_TRAPDOOR = getItemType("spruce_trapdoor"); @@ -727,6 +756,14 @@ public interface ItemType extends Keyed, Translatable { ItemType BAMBOO_TRAPDOOR = getItemType("bamboo_trapdoor"); ItemType CRIMSON_TRAPDOOR = getItemType("crimson_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 SPRUCE_FENCE_GATE = getItemType("spruce_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 BLACK_BED = getItemType("black_bed"); ItemType COOKIE = getItemType("cookie"); + ItemType CRAFTER = getItemType("crafter"); ItemType FILLED_MAP = getItemType("filled_map"); ItemType SHEARS = getItemType("shears"); 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 BEE_SPAWN_EGG = getItemType("bee_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 CAMEL_SPAWN_EGG = getItemType("camel_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 SKULL_POTTERY_SHERD = getItemType("skull_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"); // @NotNull diff --git a/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java b/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java index 28a7544d..db60ae90 100644 --- a/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java +++ b/src/main/java/org/bukkit/inventory/meta/SpawnEggMeta.java @@ -1,8 +1,10 @@ package org.bukkit.inventory.meta; +import org.bukkit.entity.EntitySnapshot; import org.bukkit.entity.EntityType; import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Represents a spawn egg and it's spawned type. @@ -30,6 +32,28 @@ public interface SpawnEggMeta extends ItemMeta { @Contract("_ -> fail") void setSpawnedType(EntityType type); + /** + * Gets the {@link EntitySnapshot} that will be spawned by this spawn egg or null if no entity + * has been set.
+ *

+ * All applicable data from the egg will be copied, such as custom name, health, + * and velocity.
+ * + * @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.
+ *

+ * All applicable data from the entity will be copied, such as custom name, + * health, and velocity.
+ * + * @param snapshot the snapshot + */ + void setSpawnedEntity(@NotNull EntitySnapshot snapshot); + @NotNull @Override SpawnEggMeta clone(); diff --git a/src/main/java/org/bukkit/loot/LootTables.java b/src/main/java/org/bukkit/loot/LootTables.java index 4e8479dc..d8721444 100644 --- a/src/main/java/org/bukkit/loot/LootTables.java +++ b/src/main/java/org/bukkit/loot/LootTables.java @@ -2,6 +2,7 @@ package org.bukkit.loot; import org.bukkit.Bukkit; import org.bukkit.Keyed; +import org.bukkit.MinecraftExperimental; import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; @@ -33,6 +34,26 @@ public enum LootTables implements Keyed { ANCIENT_CITY("chests/ancient_city"), ANCIENT_CITY_ICE_BOX("chests/ancient_city_ice_box"), 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_SUPPLY("chests/shipwreck_supply"), SHIPWRECK_TREASURE("chests/shipwreck_treasure"), @@ -157,6 +178,9 @@ public enum LootTables implements Keyed { WEAPONSMITH_GIFT("gameplay/hero_of_the_village/weaponsmith_gift"), SNIFFER_DIGGING("gameplay/sniffer_digging"), PIGLIN_BARTERING("gameplay/piglin_bartering"), + // Spawners + TRIAL_CHAMBER_KEY("spawners/trial_chamber/key"), + RIAL_CHAMBER_CONSUMABLES("spawners/trial_chamber/consumables"), // Archaeology DESERT_WELL_ARCHAEOLOGY("archaeology/desert_well"), DESERT_PYRAMID_ARCHAEOLOGY("archaeology/desert_pyramid"), diff --git a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java index bf2a957b..6c156faf 100644 --- a/src/main/java/org/bukkit/persistence/PersistentDataContainer.java +++ b/src/main/java/org/bukkit/persistence/PersistentDataContainer.java @@ -21,15 +21,15 @@ public interface PersistentDataContainer { * * @param key the key this value will be stored under * @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 the generic java type of the tag value * @param the generic type of the object to store * - * @throws NullPointerException if the key is null - * @throws NullPointerException if the type is null - * @throws NullPointerException if the value is null. Removing a tag should + * @throws IllegalArgumentException if the key is null + * @throws IllegalArgumentException if the type is null + * @throws IllegalArgumentException if the value is null. Removing a tag should * 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()} */ void set(@NotNull NamespacedKey key, @NotNull PersistentDataType type, @NotNull Z value); @@ -38,7 +38,7 @@ public interface PersistentDataContainer { * Returns if the persistent metadata provider has metadata registered * matching the provided parameters. *

- * 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. *

* Storing a value using a custom {@link PersistentDataType} implementation @@ -49,22 +49,41 @@ public interface PersistentDataContainer { * bytes long. *

* 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. * * @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 the generic type of the stored primitive * @param 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 NullPointerException if the type to cast the found object to is + * @throws IllegalArgumentException if the key to look up is null + * @throws IllegalArgumentException if the type to cast the found object to is * null */ boolean has(@NotNull NamespacedKey key, @NotNull PersistentDataType type); + /** + * Returns if the persistent metadata provider has metadata registered matching + * the provided parameters. + *

+ * This method will return true as long as a value with the given key exists, + * regardless of its type. + *

+ * 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 * {@link PersistentDataHolder} instance. @@ -77,12 +96,12 @@ public interface PersistentDataContainer { * @return the value or {@code null} if no value was mapped under the given * value * - * @throws NullPointerException if the key to look up is null - * @throws NullPointerException if the type to cast the found object to is + * @throws IllegalArgumentException if the key to look up is null + * @throws IllegalArgumentException if the type to cast the found object to is * null - * @throws IllegalArgumentException if the value exists under the given key, - * but cannot be access using the given type - * @throws IllegalArgumentException if no suitable adapter will be found for + * @throws IllegalArgumentException if a value exists under the given key, + * but cannot be accessed using the given type + * @throws IllegalArgumentException if no suitable adapter was found for * the {@link * PersistentDataType#getPrimitiveType()} */ @@ -102,21 +121,21 @@ public interface PersistentDataContainer { * @param the generic type of the eventually created complex object * * @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 NullPointerException if the type to cast the found object to is + * @throws IllegalArgumentException if the key to look up is null + * @throws IllegalArgumentException if the type to cast the found object to is * null - * @throws IllegalArgumentException if the value exists under the given key, - * but cannot be access using the given type - * @throws IllegalArgumentException if no suitable adapter will be found for + * @throws IllegalArgumentException if a value exists under the given key, + * but cannot be accessed using the given type + * @throws IllegalArgumentException if no suitable adapter was found for * the {@link PersistentDataType#getPrimitiveType()} */ @NotNull Z getOrDefault(@NotNull NamespacedKey key, @NotNull PersistentDataType 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. * * 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. * - * @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); @@ -144,6 +163,20 @@ public interface PersistentDataContainer { */ boolean isEmpty(); + /** + * Copies all values from this {@link PersistentDataContainer} to the provided + * container. + *

+ * 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. * diff --git a/src/main/java/org/bukkit/potion/PotionEffectType.java b/src/main/java/org/bukkit/potion/PotionEffectType.java index 26bd4303..23b3cc17 100644 --- a/src/main/java/org/bukkit/potion/PotionEffectType.java +++ b/src/main/java/org/bukkit/potion/PotionEffectType.java @@ -16,7 +16,7 @@ import org.jetbrains.annotations.Nullable; * Represents a type of potion and its effect on an entity. */ public abstract class PotionEffectType implements Keyed { - protected static final BiMap ID_MAP = HashBiMap.create(); + private static final BiMap ID_MAP = HashBiMap.create(); /** * Increases movement speed. @@ -182,6 +182,7 @@ public abstract class PotionEffectType implements Keyed { * \o/. */ public static final PotionEffectType HERO_OF_THE_VILLAGE = getPotionEffectType(32, "hero_of_the_village"); + /** * Causes the player's vision to dim occasionally. */ @@ -190,7 +191,7 @@ public abstract class PotionEffectType implements Keyed { @NotNull private static PotionEffectType getPotionEffectType(int typeId, @NotNull String 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); if (typeId > 0) { ID_MAP.put(typeId, potionEffectType); @@ -264,7 +265,11 @@ public abstract class PotionEffectType implements Keyed { @Nullable @Deprecated 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; } - for (PotionEffectType other : Registry.POTION_EFFECT_TYPE) { + for (PotionEffectType other : Registry.EFFECT) { if (other.getId() == id) { ID_MAP.put(id, other); return other; @@ -305,7 +310,7 @@ public abstract class PotionEffectType implements Keyed { public static PotionEffectType getByName(@NotNull String name) { Preconditions.checkArgument(name != null, "name cannot be null"); 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 @Deprecated 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. - *

- * 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) { if (from == null) { return null; diff --git a/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java b/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java index 0a2df03c..a613debb 100644 --- a/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java +++ b/src/main/java/org/bukkit/potion/PotionEffectTypeWrapper.java @@ -1,30 +1,13 @@ package org.bukkit.potion; -import org.bukkit.Color; -import org.bukkit.NamespacedKey; import org.jetbrains.annotations.NotNull; /** * @deprecated only for backwards compatibility, PotionEffectTypeWrapper is no longer used. */ @Deprecated -public class PotionEffectTypeWrapper extends PotionEffectType { - protected PotionEffectTypeWrapper(int id) {} - - @Override - public double getDurationModifier() { - return getType().getDurationModifier(); - } - - @Override - public int getId() { - return getType().getId(); - } - - @NotNull - @Override - public String getName() { - return getType().getName(); +public abstract class PotionEffectTypeWrapper extends PotionEffectType { + protected PotionEffectTypeWrapper() { } /** @@ -34,29 +17,6 @@ public class PotionEffectTypeWrapper extends PotionEffectType { */ @NotNull public PotionEffectType getType() { - return PotionEffectType.getByKey(getKey()); - } - - @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(); + return this; } } diff --git a/src/main/java/org/bukkit/scheduler/BukkitScheduler.java b/src/main/java/org/bukkit/scheduler/BukkitScheduler.java index 5aefb7f2..0368e912 100644 --- a/src/main/java/org/bukkit/scheduler/BukkitScheduler.java +++ b/src/main/java/org/bukkit/scheduler/BukkitScheduler.java @@ -227,7 +227,7 @@ public interface BukkitScheduler { * @throws IllegalArgumentException if plugin is null * @throws IllegalArgumentException if task is null */ - public void runTask(@NotNull Plugin plugin, @NotNull Consumer task) throws IllegalArgumentException; + public void runTask(@NotNull Plugin plugin, @NotNull Consumer task) throws IllegalArgumentException; /** * @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 task is null */ - public void runTaskAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task) throws IllegalArgumentException; + public void runTaskAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task) throws IllegalArgumentException; /** * @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 task is null */ - public void runTaskLater(@NotNull Plugin plugin, @NotNull Consumer task, long delay) throws IllegalArgumentException; + public void runTaskLater(@NotNull Plugin plugin, @NotNull Consumer task, long delay) throws IllegalArgumentException; /** * @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 task is null */ - public void runTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task, long delay) throws IllegalArgumentException; + public void runTaskLaterAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task, long delay) throws IllegalArgumentException; /** * @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 task is null */ - public void runTaskTimer(@NotNull Plugin plugin, @NotNull Consumer task, long delay, long period) throws IllegalArgumentException; + public void runTaskTimer(@NotNull Plugin plugin, @NotNull Consumer task, long delay, long period) throws IllegalArgumentException; /** * @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 task is null */ - public void runTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task, long delay, long period) throws IllegalArgumentException; + public void runTaskTimerAsynchronously(@NotNull Plugin plugin, @NotNull Consumer task, long delay, long period) throws IllegalArgumentException; /** * @param plugin the reference to the plugin scheduling task