Update to Minecraft 1.14-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
Bukkit/Spigot 2019-04-23 12:00:00 +10:00
parent 3c840f61b8
commit 30a442aef7
92 changed files with 2602 additions and 884 deletions

View File

@ -5,7 +5,7 @@
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.13.2-R0.1-SNAPSHOT</version>
<version>1.14-pre5-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Bukkit</name>
@ -57,12 +57,6 @@
<version>2.6</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
<scope>compile</scope>
</dependency>
<!-- bundled with Minecraft, should be kept in sync -->
<dependency>
<groupId>com.google.guava</groupId>

View File

@ -11,7 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents the art on a painting
*/
public enum Art {
public enum Art implements Keyed {
KEBAB(0, 1, 1),
AZTEC(1, 1, 1),
ALBAN(2, 1, 1),
@ -39,7 +39,8 @@ public enum Art {
SKELETON(24, 4, 3),
DONKEY_KONG(25, 4, 3);
private int id, width, height;
private final int id, width, height;
private final NamespacedKey key;
private static final HashMap<String, Art> BY_NAME = Maps.newHashMap();
private static final HashMap<Integer, Art> BY_ID = Maps.newHashMap();
@ -47,6 +48,7 @@ public enum Art {
this.id = id;
this.width = width;
this.height = height;
this.key = NamespacedKey.minecraft(name().toLowerCase(java.util.Locale.ENGLISH));
}
/**
@ -78,6 +80,12 @@ public enum Art {
return id;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* Get a painting by its numeric ID
*

View File

@ -192,31 +192,6 @@ public final class Bukkit {
return server.getIp();
}
/**
* Get the name of this server.
*
* @return the name of this server
* @deprecated not a standard server property
*/
@Deprecated
@NotNull
public static String getServerName() {
return server.getServerName();
}
/**
* Get an ID of this server. The ID is a simple generally alphanumeric ID
* that can be used for uniquely identifying this server.
*
* @return the ID of this server
* @deprecated not a standard server property
*/
@Deprecated
@NotNull
public static String getServerId() {
return server.getServerId();
}
/**
* Get world type (level-type setting) for default world.
*

View File

@ -104,18 +104,6 @@ public interface Chunk {
*/
boolean load();
/**
* Unloads and optionally saves the Chunk
*
* @param save Controls whether the chunk is saved
* @param safe Controls whether to unload the chunk when players are
* nearby
* @return true if the chunk has unloaded successfully, otherwise false
* @deprecated it is never safe to remove a chunk in use
*/
@Deprecated
boolean unload(boolean save, boolean safe);
/**
* Unloads and optionally saves the Chunk
*

View File

@ -51,7 +51,31 @@ public enum Instrument {
/**
* Xylophone is normally played when a note block is on top of a bone block.
*/
XYLOPHONE(0x9);
XYLOPHONE(0x9),
/**
* Iron Xylophone is normally played when a note block is on top of a iron block.
*/
IRON_XYLOPHONE(0xA),
/**
* Cow Bell is normally played when a note block is on top of a soul sand block.
*/
COW_BELL(0xB),
/**
* Didgeridoo is normally played when a note block is on top of a pumpkin block.
*/
DIDGERIDOO(0xC),
/**
* Bit is normally played when a note block is on top of a emerald block.
*/
BIT(0xD),
/**
* Banjo is normally played when a note block is on top of a hay block.
*/
BANJO(0xE),
/**
* Pling is normally played when a note block is on top of a glowstone block.
*/
PLING(0xF);
private final byte type;
private final static Map<Byte, Instrument> BY_DATA = Maps.newHashMap();

File diff suppressed because it is too large Load Diff

View File

@ -60,6 +60,14 @@ public enum Particle {
BUBBLE_COLUMN_UP,
NAUTILUS,
DOLPHIN,
SNEEZE,
CAMPFIRE_COSY_SMOKE,
CAMPFIRE_SIGNAL_SMOKE,
COMPOSTER,
FLASH,
FALLING_LAVA,
LANDING_LAVA,
FALLING_WATER,
// ----- Legacy Separator -----
LEGACY_BLOCK_CRACK(MaterialData.class),
LEGACY_BLOCK_DUST(MaterialData.class),

View File

@ -0,0 +1,155 @@
package org.bukkit;
import com.google.common.collect.ImmutableMap;
import java.util.Arrays;
import java.util.Iterator;
import java.util.Map;
import org.bukkit.advancement.Advancement;
import org.bukkit.block.Biome;
import org.bukkit.boss.KeyedBossBar;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.loot.LootTables;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a registry of Bukkit objects that may be retrieved by
* {@link NamespacedKey}.
*
* @param <T> type of item in the registry
*/
public interface Registry<T extends Keyed> extends Iterable<T> {
/**
* Server advancements.
*
* @see Bukkit#getAdvancement(org.bukkit.NamespacedKey)
* @see Bukkit#advancementIterator()
*/
Registry<Advancement> ADVANCEMENT = new Registry<Advancement>() {
@Nullable
@Override
public Advancement get(@NotNull NamespacedKey key) {
return Bukkit.getAdvancement(key);
}
@NotNull
@Override
public Iterator<Advancement> iterator() {
return Bukkit.advancementIterator();
}
};
/**
* Server art.
*
* @see Art
*/
Registry<Art> ART = new SimpleRegistry<>(Art.class);
/**
* Server biomes.
*
* @see Biome
*/
Registry<Biome> BIOME = new SimpleRegistry<>(Biome.class);
/**
* Custom boss bars.
*
* @see Bukkit#getBossBar(org.bukkit.NamespacedKey)
* @see Bukkit#getBossBars()
*/
Registry<KeyedBossBar> BOSS_BARS = new Registry<KeyedBossBar>() {
@Nullable
@Override
public KeyedBossBar get(@NotNull NamespacedKey key) {
return Bukkit.getBossBar(key);
}
@NotNull
@Override
public Iterator<KeyedBossBar> iterator() {
return Bukkit.getBossBars();
}
};
/**
* Server enchantments.
*
* @see Enchantment#getByKey(org.bukkit.NamespacedKey)
*/
Registry<Enchantment> ENCHANTMENT = new Registry<Enchantment>() {
@Nullable
@Override
public Enchantment get(@NotNull NamespacedKey key) {
return Enchantment.getByKey(key);
}
@NotNull
@Override
public Iterator<Enchantment> iterator() {
return Arrays.asList(Enchantment.values()).iterator();
}
};
/**
* Server entity types.
*
* @see EntityType
*/
Registry<EntityType> ENTITY_TYPE = new SimpleRegistry<>(EntityType.class);
/**
* Default server loot tables.
*
* @see LootTables
*/
Registry<LootTables> LOOT_TABLES = new SimpleRegistry<>(LootTables.class);
/**
* Server materials.
*
* @see Material
*/
Registry<Material> MATERIAL = new SimpleRegistry<>(Material.class);
/**
* Server statistics.
*
* @see Statistic
*/
Registry<Statistic> STATISTIC = new SimpleRegistry<>(Statistic.class);
/**
* Get the object by its key.
*
* @param key non-null key
* @return item or null if does not exist
*/
@Nullable
T get(@NotNull NamespacedKey key);
final static class SimpleRegistry<T extends Enum<T> & Keyed> implements Registry<T> {
private final Map<NamespacedKey, T> map;
protected SimpleRegistry(@NotNull Class<T> type) {
ImmutableMap.Builder<NamespacedKey, T> builder = ImmutableMap.builder();
for (T entry : type.getEnumConstants()) {
builder.put(entry.getKey(), entry);
}
map = builder.build();
}
@Nullable
@Override
public T get(@NotNull NamespacedKey key) {
return map.get(key);
}
@NotNull
@Override
public Iterator<T> iterator() {
return map.values().iterator();
}
}
}

View File

@ -161,27 +161,6 @@ public interface Server extends PluginMessageRecipient {
@NotNull
public String getIp();
/**
* Get the name of this server.
*
* @return the name of this server
* @deprecated not a standard server property
*/
@Deprecated
@NotNull
public String getServerName();
/**
* Get an ID of this server. The ID is a simple generally alphanumeric ID
* that can be used for uniquely identifying this server.
*
* @return the ID of this server
* @deprecated not a standard server property
*/
@Deprecated
@NotNull
public String getServerId();
/**
* Get world type (level-type setting) for default world.
*

View File

@ -24,22 +24,40 @@ public enum Sound {
BLOCK_ANVIL_PLACE,
BLOCK_ANVIL_STEP,
BLOCK_ANVIL_USE,
BLOCK_BAMBOO_BREAK,
BLOCK_BAMBOO_FALL,
BLOCK_BAMBOO_HIT,
BLOCK_BAMBOO_PLACE,
BLOCK_BAMBOO_SAPLING_BREAK,
BLOCK_BAMBOO_SAPLING_HIT,
BLOCK_BAMBOO_SAPLING_PLACE,
BLOCK_BAMBOO_STEP,
BLOCK_BARREL_CLOSE,
BLOCK_BARREL_OPEN,
BLOCK_BEACON_ACTIVATE,
BLOCK_BEACON_AMBIENT,
BLOCK_BEACON_DEACTIVATE,
BLOCK_BEACON_POWER_SELECT,
BLOCK_BELL_RESONATE,
BLOCK_BELL_USE,
BLOCK_BLASTFURNACE_FIRE_CRACKLE,
BLOCK_BREWING_STAND_BREW,
BLOCK_BUBBLE_COLUMN_BUBBLE_POP,
BLOCK_BUBBLE_COLUMN_UPWARDS_AMBIENT,
BLOCK_BUBBLE_COLUMN_UPWARDS_INSIDE,
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_AMBIENT,
BLOCK_BUBBLE_COLUMN_WHIRLPOOL_INSIDE,
BLOCK_CAMPFIRE_CRACKLE,
BLOCK_CHEST_CLOSE,
BLOCK_CHEST_LOCKED,
BLOCK_CHEST_OPEN,
BLOCK_CHORUS_FLOWER_DEATH,
BLOCK_CHORUS_FLOWER_GROW,
BLOCK_COMPARATOR_CLICK,
BLOCK_COMPOSTER_EMPTY,
BLOCK_COMPOSTER_FILL,
BLOCK_COMPOSTER_FILL_SUCCESS,
BLOCK_COMPOSTER_READY,
BLOCK_CONDUIT_ACTIVATE,
BLOCK_CONDUIT_AMBIENT,
BLOCK_CONDUIT_AMBIENT_SHORT,
@ -50,6 +68,7 @@ public enum Sound {
BLOCK_CORAL_BLOCK_HIT,
BLOCK_CORAL_BLOCK_PLACE,
BLOCK_CORAL_BLOCK_STEP,
BLOCK_CROP_BREAK,
BLOCK_DISPENSER_DISPENSE,
BLOCK_DISPENSER_FAIL,
BLOCK_DISPENSER_LAUNCH,
@ -79,6 +98,7 @@ public enum Sound {
BLOCK_GRAVEL_HIT,
BLOCK_GRAVEL_PLACE,
BLOCK_GRAVEL_STEP,
BLOCK_GRINDSTONE_USE,
BLOCK_IRON_DOOR_CLOSE,
BLOCK_IRON_DOOR_OPEN,
BLOCK_IRON_TRAPDOOR_CLOSE,
@ -88,6 +108,11 @@ public enum Sound {
BLOCK_LADDER_HIT,
BLOCK_LADDER_PLACE,
BLOCK_LADDER_STEP,
BLOCK_LANTERN_BREAK,
BLOCK_LANTERN_FALL,
BLOCK_LANTERN_HIT,
BLOCK_LANTERN_PLACE,
BLOCK_LANTERN_STEP,
BLOCK_LAVA_AMBIENT,
BLOCK_LAVA_EXTINGUISH,
BLOCK_LAVA_POP,
@ -100,14 +125,20 @@ public enum Sound {
BLOCK_METAL_PRESSURE_PLATE_CLICK_OFF,
BLOCK_METAL_PRESSURE_PLATE_CLICK_ON,
BLOCK_METAL_STEP,
BLOCK_NETHER_WART_BREAK,
BLOCK_NOTE_BLOCK_BANJO,
BLOCK_NOTE_BLOCK_BASEDRUM,
BLOCK_NOTE_BLOCK_BASS,
BLOCK_NOTE_BLOCK_BELL,
BLOCK_NOTE_BLOCK_BIT,
BLOCK_NOTE_BLOCK_CHIME,
BLOCK_NOTE_BLOCK_COW_BELL,
BLOCK_NOTE_BLOCK_DIDGERIDOO,
BLOCK_NOTE_BLOCK_FLUTE,
BLOCK_NOTE_BLOCK_GUITAR,
BLOCK_NOTE_BLOCK_HARP,
BLOCK_NOTE_BLOCK_HAT,
BLOCK_NOTE_BLOCK_IRON_XYLOPHONE,
BLOCK_NOTE_BLOCK_PLING,
BLOCK_NOTE_BLOCK_SNARE,
BLOCK_NOTE_BLOCK_XYLOPHONE,
@ -123,6 +154,11 @@ public enum Sound {
BLOCK_SAND_HIT,
BLOCK_SAND_PLACE,
BLOCK_SAND_STEP,
BLOCK_SCAFFOLDING_BREAK,
BLOCK_SCAFFOLDING_FALL,
BLOCK_SCAFFOLDING_HIT,
BLOCK_SCAFFOLDING_PLACE,
BLOCK_SCAFFOLDING_STEP,
BLOCK_SHULKER_BOX_CLOSE,
BLOCK_SHULKER_BOX_OPEN,
BLOCK_SLIME_BLOCK_BREAK,
@ -130,6 +166,7 @@ public enum Sound {
BLOCK_SLIME_BLOCK_HIT,
BLOCK_SLIME_BLOCK_PLACE,
BLOCK_SLIME_BLOCK_STEP,
BLOCK_SMOKER_SMOKE,
BLOCK_SNOW_BREAK,
BLOCK_SNOW_FALL,
BLOCK_SNOW_HIT,
@ -144,6 +181,8 @@ public enum Sound {
BLOCK_STONE_PRESSURE_PLATE_CLICK_OFF,
BLOCK_STONE_PRESSURE_PLATE_CLICK_ON,
BLOCK_STONE_STEP,
BLOCK_SWEET_BERRY_BUSH_BREAK,
BLOCK_SWEET_BERRY_BUSH_PLACE,
BLOCK_TRIPWIRE_ATTACH,
BLOCK_TRIPWIRE_CLICK_OFF,
BLOCK_TRIPWIRE_CLICK_ON,
@ -193,11 +232,14 @@ public enum Sound {
ENTITY_BOAT_PADDLE_LAND,
ENTITY_BOAT_PADDLE_WATER,
ENTITY_CAT_AMBIENT,
ENTITY_CAT_BEG_FOR_FOOD,
ENTITY_CAT_DEATH,
ENTITY_CAT_EAT,
ENTITY_CAT_HISS,
ENTITY_CAT_HURT,
ENTITY_CAT_PURR,
ENTITY_CAT_PURREOW,
ENTITY_CAT_STRAY_AMBIENT,
ENTITY_CHICKEN_AMBIENT,
ENTITY_CHICKEN_DEATH,
ENTITY_CHICKEN_EGG,
@ -270,6 +312,7 @@ public enum Sound {
ENTITY_ENDER_PEARL_THROW,
ENTITY_EVOKER_AMBIENT,
ENTITY_EVOKER_CAST_SPELL,
ENTITY_EVOKER_CELEBRATE,
ENTITY_EVOKER_DEATH,
ENTITY_EVOKER_FANGS_ATTACK,
ENTITY_EVOKER_HURT,
@ -290,6 +333,16 @@ public enum Sound {
ENTITY_FISHING_BOBBER_SPLASH,
ENTITY_FISHING_BOBBER_THROW,
ENTITY_FISH_SWIM,
ENTITY_FOX_AGGRO,
ENTITY_FOX_AMBIENT,
ENTITY_FOX_BITE,
ENTITY_FOX_DEATH,
ENTITY_FOX_EAT,
ENTITY_FOX_HURT,
ENTITY_FOX_SCREECH,
ENTITY_FOX_SLEEP,
ENTITY_FOX_SNIFF,
ENTITY_FOX_SPIT,
ENTITY_GENERIC_BIG_FALL,
ENTITY_GENERIC_BURN,
ENTITY_GENERIC_DEATH,
@ -380,13 +433,31 @@ public enum Sound {
ENTITY_MAGMA_CUBE_SQUISH_SMALL,
ENTITY_MINECART_INSIDE,
ENTITY_MINECART_RIDING,
ENTITY_MOOSHROOM_CONVERT,
ENTITY_MOOSHROOM_EAT,
ENTITY_MOOSHROOM_MILK,
ENTITY_MOOSHROOM_SHEAR,
ENTITY_MOOSHROOM_SUSPICIOUS_MILK,
ENTITY_MULE_AMBIENT,
ENTITY_MULE_CHEST,
ENTITY_MULE_DEATH,
ENTITY_MULE_HURT,
ENTITY_OCELOT_AMBIENT,
ENTITY_OCELOT_DEATH,
ENTITY_OCELOT_HURT,
ENTITY_PAINTING_BREAK,
ENTITY_PAINTING_PLACE,
ENTITY_PANDA_AGGRESSIVE_AMBIENT,
ENTITY_PANDA_AMBIENT,
ENTITY_PANDA_BITE,
ENTITY_PANDA_CANT_BREED,
ENTITY_PANDA_DEATH,
ENTITY_PANDA_EAT,
ENTITY_PANDA_HURT,
ENTITY_PANDA_PRE_SNEEZE,
ENTITY_PANDA_SNEEZE,
ENTITY_PANDA_STEP,
ENTITY_PANDA_WORRIED_AMBIENT,
ENTITY_PARROT_AMBIENT,
ENTITY_PARROT_DEATH,
ENTITY_PARROT_EAT,
@ -401,11 +472,15 @@ public enum Sound {
ENTITY_PARROT_IMITATE_ENDER_DRAGON,
ENTITY_PARROT_IMITATE_EVOKER,
ENTITY_PARROT_IMITATE_GHAST,
ENTITY_PARROT_IMITATE_GUARDIAN,
ENTITY_PARROT_IMITATE_HUSK,
ENTITY_PARROT_IMITATE_ILLUSIONER,
ENTITY_PARROT_IMITATE_MAGMA_CUBE,
ENTITY_PARROT_IMITATE_PANDA,
ENTITY_PARROT_IMITATE_PHANTOM,
ENTITY_PARROT_IMITATE_PILLAGER,
ENTITY_PARROT_IMITATE_POLAR_BEAR,
ENTITY_PARROT_IMITATE_RAVAGER,
ENTITY_PARROT_IMITATE_SHULKER,
ENTITY_PARROT_IMITATE_SILVERFISH,
ENTITY_PARROT_IMITATE_SKELETON,
@ -433,6 +508,10 @@ public enum Sound {
ENTITY_PIG_HURT,
ENTITY_PIG_SADDLE,
ENTITY_PIG_STEP,
ENTITY_PILLAGER_AMBIENT,
ENTITY_PILLAGER_CELEBRATE,
ENTITY_PILLAGER_DEATH,
ENTITY_PILLAGER_HURT,
ENTITY_PLAYER_ATTACK_CRIT,
ENTITY_PLAYER_ATTACK_KNOCKBACK,
ENTITY_PLAYER_ATTACK_NODAMAGE,
@ -446,6 +525,7 @@ public enum Sound {
ENTITY_PLAYER_HURT,
ENTITY_PLAYER_HURT_DROWN,
ENTITY_PLAYER_HURT_ON_FIRE,
ENTITY_PLAYER_HURT_SWEET_BERRY_BUSH,
ENTITY_PLAYER_LEVELUP,
ENTITY_PLAYER_SMALL_FALL,
ENTITY_PLAYER_SPLASH,
@ -469,6 +549,14 @@ public enum Sound {
ENTITY_RABBIT_DEATH,
ENTITY_RABBIT_HURT,
ENTITY_RABBIT_JUMP,
ENTITY_RAVAGER_AMBIENT,
ENTITY_RAVAGER_ATTACK,
ENTITY_RAVAGER_CELEBRATE,
ENTITY_RAVAGER_DEATH,
ENTITY_RAVAGER_HURT,
ENTITY_RAVAGER_ROAR,
ENTITY_RAVAGER_STEP,
ENTITY_RAVAGER_STUNNED,
ENTITY_SALMON_AMBIENT,
ENTITY_SALMON_DEATH,
ENTITY_SALMON_FLOP,
@ -555,15 +643,41 @@ public enum Sound {
ENTITY_VEX_DEATH,
ENTITY_VEX_HURT,
ENTITY_VILLAGER_AMBIENT,
ENTITY_VILLAGER_CELEBRATE,
ENTITY_VILLAGER_DEATH,
ENTITY_VILLAGER_HURT,
ENTITY_VILLAGER_NO,
ENTITY_VILLAGER_TRADE,
ENTITY_VILLAGER_WORK_ARMORER,
ENTITY_VILLAGER_WORK_BUTCHER,
ENTITY_VILLAGER_WORK_CARTOGRAPHER,
ENTITY_VILLAGER_WORK_CLERIC,
ENTITY_VILLAGER_WORK_FARMER,
ENTITY_VILLAGER_WORK_FISHERMAN,
ENTITY_VILLAGER_WORK_FLETCHER,
ENTITY_VILLAGER_WORK_LEATHERWORKER,
ENTITY_VILLAGER_WORK_LIBRARIAN,
ENTITY_VILLAGER_WORK_MASON,
ENTITY_VILLAGER_WORK_SHEPHERD,
ENTITY_VILLAGER_WORK_TOOLSMITH,
ENTITY_VILLAGER_WORK_WEAPONSMITH,
ENTITY_VILLAGER_YES,
ENTITY_VINDICATOR_AMBIENT,
ENTITY_VINDICATOR_CELEBRATE,
ENTITY_VINDICATOR_DEATH,
ENTITY_VINDICATOR_HURT,
ENTITY_WANDERING_TRADER_AMBIENT,
ENTITY_WANDERING_TRADER_DEATH,
ENTITY_WANDERING_TRADER_DISAPPEARED,
ENTITY_WANDERING_TRADER_DRINK_MILK,
ENTITY_WANDERING_TRADER_DRINK_POTION,
ENTITY_WANDERING_TRADER_HURT,
ENTITY_WANDERING_TRADER_NO,
ENTITY_WANDERING_TRADER_REAPPEARED,
ENTITY_WANDERING_TRADER_TRADE,
ENTITY_WANDERING_TRADER_YES,
ENTITY_WITCH_AMBIENT,
ENTITY_WITCH_CELEBRATE,
ENTITY_WITCH_DEATH,
ENTITY_WITCH_DRINK,
ENTITY_WITCH_HURT,
@ -610,6 +724,7 @@ public enum Sound {
ENTITY_ZOMBIE_VILLAGER_DEATH,
ENTITY_ZOMBIE_VILLAGER_HURT,
ENTITY_ZOMBIE_VILLAGER_STEP,
EVENT_RAID_HORN,
ITEM_ARMOR_EQUIP_CHAIN,
ITEM_ARMOR_EQUIP_DIAMOND,
ITEM_ARMOR_EQUIP_ELYTRA,
@ -619,6 +734,8 @@ public enum Sound {
ITEM_ARMOR_EQUIP_LEATHER,
ITEM_ARMOR_EQUIP_TURTLE,
ITEM_AXE_STRIP,
ITEM_BOOK_PAGE_TURN,
ITEM_BOOK_PUT,
ITEM_BOTTLE_EMPTY,
ITEM_BOTTLE_FILL,
ITEM_BOTTLE_FILL_DRAGONBREATH,
@ -629,13 +746,24 @@ public enum Sound {
ITEM_BUCKET_FILL_FISH,
ITEM_BUCKET_FILL_LAVA,
ITEM_CHORUS_FRUIT_TELEPORT,
ITEM_CROP_PLANT,
ITEM_CROSSBOW_HIT,
ITEM_CROSSBOW_LOADING_END,
ITEM_CROSSBOW_LOADING_MIDDLE,
ITEM_CROSSBOW_LOADING_START,
ITEM_CROSSBOW_QUICK_CHARGE_1,
ITEM_CROSSBOW_QUICK_CHARGE_2,
ITEM_CROSSBOW_QUICK_CHARGE_3,
ITEM_CROSSBOW_SHOOT,
ITEM_ELYTRA_FLYING,
ITEM_FIRECHARGE_USE,
ITEM_FLINTANDSTEEL_USE,
ITEM_HOE_TILL,
ITEM_NETHER_WART_PLANT,
ITEM_SHIELD_BLOCK,
ITEM_SHIELD_BREAK,
ITEM_SHOVEL_FLATTEN,
ITEM_SWEET_BERRIES_PICK_FROM_BUSH,
ITEM_TOTEM_USE,
ITEM_TRIDENT_HIT,
ITEM_TRIDENT_HIT_GROUND,
@ -666,6 +794,11 @@ public enum Sound {
MUSIC_NETHER,
MUSIC_UNDER_WATER,
UI_BUTTON_CLICK,
UI_CARTOGRAPHY_TABLE_TAKE_RESULT,
UI_LOOM_SELECT_PATTERN,
UI_LOOM_TAKE_RESULT,
UI_STONECUTTER_SELECT_RECIPE,
UI_STONECUTTER_TAKE_RESULT,
UI_TOAST_CHALLENGE_COMPLETE,
UI_TOAST_IN,
UI_TOAST_OUT,

View File

@ -1,11 +1,12 @@
package org.bukkit;
import java.util.Locale;
import org.jetbrains.annotations.NotNull;
/**
* Represents a countable statistic, which is tracked by the server.
*/
public enum Statistic {
public enum Statistic implements Keyed {
DAMAGE_DEALT,
DAMAGE_TAKEN,
DEATHS,
@ -74,9 +75,21 @@ public enum Statistic {
DAMAGE_BLOCKED_BY_SHIELD,
DAMAGE_ABSORBED,
DAMAGE_RESISTED,
CLEAN_SHULKER_BOX;
CLEAN_SHULKER_BOX,
OPEN_BARREL,
INTERACT_WITH_BLAST_FURNACE,
INTERACT_WITH_SMOKER,
INTERACT_WITH_LECTERN,
INTERACT_WITH_CAMPFIRE,
INTERACT_WITH_CARTOGRAPHY_TABLE,
INTERACT_WITH_LOOM,
INTERACT_WITH_STONECUTTER,
BELL_RING,
RAID_TRIGGER,
RAID_WIN;
private final Type type;
private final NamespacedKey key;
private Statistic() {
this(Type.UNTYPED);
@ -84,6 +97,7 @@ public enum Statistic {
private Statistic(/*@NotNull*/ Type type) {
this.type = type;
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
}
/**
@ -123,6 +137,12 @@ public enum Statistic {
return type == Type.BLOCK;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* The type of statistic.
*

View File

@ -31,7 +31,7 @@ public class StructureType {
* They are the only place where cave spider spawners and minecarts with
* chests can be found naturally.
*/
public static final StructureType MINESHAFT = register(new StructureType("Mineshaft", MapCursor.Type.RED_X));
public static final StructureType MINESHAFT = register(new StructureType("mineshaft", MapCursor.Type.RED_X));
/**
* Villages are naturally generating structures that form above ground.
@ -39,7 +39,7 @@ public class StructureType {
* They are usually generated in desert, plains, taiga, and savanna biomes
* and are a site for villager spawns, with whom the player can trade.
*/
public static final StructureType VILLAGE = register(new StructureType("Village", MapCursor.Type.MANSION));
public static final StructureType VILLAGE = register(new StructureType("village", MapCursor.Type.MANSION));
/**
* Nether fortresses are very large complexes that mainly consist of
@ -48,7 +48,7 @@ public class StructureType {
* They contain blaze spawners, nether wart farms, and loot chests. They are
* only generated in the nether dimension.
*/
public static final StructureType NETHER_FORTRESS = register(new StructureType("Fortress", MapCursor.Type.RED_X));
public static final StructureType NETHER_FORTRESS = register(new StructureType("fortress", MapCursor.Type.RED_X));
/**
* Strongholds are underground structures that consist of many rooms,
@ -56,7 +56,7 @@ public class StructureType {
* <br>
* They can be found using an {@link Material#ENDER_EYE}.
*/
public static final StructureType STRONGHOLD = register(new StructureType("Stronghold", MapCursor.Type.MANSION));
public static final StructureType STRONGHOLD = register(new StructureType("stronghold", MapCursor.Type.MANSION));
/**
* Jungle pyramids (also known as jungle temples) are found in jungles.
@ -65,7 +65,7 @@ public class StructureType {
* consist of three floors, with the bottom floor containing treasure
* chests.
*/
public static final StructureType JUNGLE_PYRAMID = register(new StructureType("Jungle_Pyramid", MapCursor.Type.RED_X));
public static final StructureType JUNGLE_PYRAMID = register(new StructureType("jungle_pyramid", MapCursor.Type.RED_X));
/**
* Ocean ruins are clusters of many different blocks that generate
@ -74,27 +74,27 @@ public class StructureType {
* They come in my different variations. The cold variants consist primarily
* of stone brick, and the warm variants consist of sandstone.
*/
public static final StructureType OCEAN_RUIN = register(new StructureType("Ocean_Ruin", MapCursor.Type.TEMPLE));
public static final StructureType OCEAN_RUIN = register(new StructureType("ocean_ruin", MapCursor.Type.TEMPLE));
/**
* Desert pyramids (also known as desert temples) are found in deserts.
* <br>
* They are usually composed of sandstone and stained terracotta.
*/
public static final StructureType DESERT_PYRAMID = register(new StructureType("Desert_Pyramid", MapCursor.Type.RED_X));
public static final StructureType DESERT_PYRAMID = register(new StructureType("desert_pyramid", MapCursor.Type.RED_X));
/**
* Igloos are structures that generate in snowy biomes.
* <br>
* They consist of the house, as well as a basement.
*/
public static final StructureType IGLOO = register(new StructureType("Igloo", MapCursor.Type.RED_X));
public static final StructureType IGLOO = register(new StructureType("igloo", MapCursor.Type.RED_X));
/**
* Swamp huts (also known as witch huts) generate in swamp biomes and have
* the ability to spawn witches.
*/
public static final StructureType SWAMP_HUT = register(new StructureType("Swamp_Hut", MapCursor.Type.RED_X));
public static final StructureType SWAMP_HUT = register(new StructureType("swamp_hut", MapCursor.Type.RED_X));
/**
* Ocean monuments are underwater structures.
@ -103,7 +103,7 @@ public class StructureType {
* lanterns. They are the only place guardians and elder guardians spawn
* naturally.
*/
public static final StructureType OCEAN_MONUMENT = register(new StructureType("Monument", MapCursor.Type.TEMPLE));
public static final StructureType OCEAN_MONUMENT = register(new StructureType("monument", MapCursor.Type.TEMPLE));
/**
* End Cities are tall castle-like structures that generate in the outer
@ -112,7 +112,7 @@ public class StructureType {
* They consist primarily of end stone bricks, purpur blocks, and end rods.
* They are the only place where shulkers can be found.
*/
public static final StructureType END_CITY = register(new StructureType("EndCity", MapCursor.Type.RED_X));
public static final StructureType END_CITY = register(new StructureType("endcity", MapCursor.Type.RED_X));
/**
* Mansions (also known as woodland mansions) are massive house structures
@ -121,13 +121,13 @@ public class StructureType {
* They are the only place where evokers, vindicators, and vexes spawn
* naturally (but only once)
*/
public static final StructureType WOODLAND_MANSION = register(new StructureType("Mansion", MapCursor.Type.MANSION));
public static final StructureType WOODLAND_MANSION = register(new StructureType("mansion", MapCursor.Type.MANSION));
/**
* Buried treasure consists of a single chest buried in the beach sand or
* gravel, with random loot in it.
*/
public static final StructureType BURIED_TREASURE = register(new StructureType("Buried_Treasure", MapCursor.Type.RED_X));
public static final StructureType BURIED_TREASURE = register(new StructureType("buried_treasure", MapCursor.Type.RED_X));
/**
* Shipwrecks are structures that generate on the floor of oceans or
@ -136,7 +136,12 @@ public class StructureType {
* They are made up of wood materials, and contain 1-3 loot chests. They can
* generate sideways, upside-down, or upright.
*/
public static final StructureType SHIPWRECK = register(new StructureType("Shipwreck", MapCursor.Type.RED_X));
public static final StructureType SHIPWRECK = register(new StructureType("shipwreck", MapCursor.Type.RED_X));
/**
* Pillager outposts may contain crossbows.
*/
public static final StructureType PILLAGER_OUTPOST = register(new StructureType("pillager_outpost", MapCursor.Type.RED_X));
/* ****************
* STRUCTURE TYPES REGISTERED ABOVE THIS

View File

@ -57,6 +57,10 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla block tag representing all wooden slabs.
*/
Tag<Material> WOODEN_SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_slabs"), Material.class);
/**
* Vanilla block tag representing all wooden fences.
*/
Tag<Material> WOODEN_FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wooden_fences"), Material.class);
/**
* Vanilla block tag representing all wooden pressure plates.
*/
@ -118,6 +122,10 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla block tag representing all slabs.
*/
Tag<Material> SLABS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("slabs"), Material.class);
/**
* Vanilla block tag representing all walls.
*/
Tag<Material> WALLS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("walls"), Material.class);
/**
* Vanilla block tag representing all damaged and undamaged anvils.
*/
@ -139,6 +147,18 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla block tag representing all empty and filled flower pots.
*/
Tag<Material> FLOWER_POTS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("flower_pots"), Material.class);
/**
* Vanilla block tag representing all small flowers.
*/
Tag<Material> SMALL_FLOWERS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("small_flowers"), Material.class);
/**
* Vanilla block tag representing all beds.
*/
Tag<Material> BEDS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("beds"), Material.class);
/**
* Vanilla block tag representing all fences.
*/
Tag<Material> FENCES = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("fences"), Material.class);
/**
* Vanilla block tag denoting blocks that enderman may pick up and hold.
*/
@ -175,6 +195,26 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla block tag representing all coral.
*/
Tag<Material> CORALS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("corals"), Material.class);
/**
* Vanilla block tag denoting all blocks bamboo may be planted on.
*/
Tag<Material> BAMBOO_PLANTABLE_ON = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("bamboo_plantable_on"), Material.class);
/**
* Vanilla block tag denoting dirt like blocks.
*/
Tag<Material> DIRT_LIKE = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("dirt_like"), Material.class);
/**
* Vanilla block tag representing all standing signs.
*/
Tag<Material> STANDING_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("standing_signs"), Material.class);
/**
* Vanilla block tag representing all wall signs.
*/
Tag<Material> WALL_SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("wall_signs"), Material.class);
/**
* Vanilla block tag representing all signs.
*/
Tag<Material> SIGNS = Bukkit.getTag(REGISTRY_BLOCKS, NamespacedKey.minecraft("signs"), Material.class);
/**
* Key for the built in item registry.
*/
@ -191,6 +231,18 @@ public interface Tag<T extends Keyed> extends Keyed {
* Vanilla item tag representing all fish items.
*/
Tag<Material> ITEMS_FISHES = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("fishes"), Material.class);
/**
* Vanilla item tag representing all music disc items.
*/
Tag<Material> ITEMS_MUSIC_DISCS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("music_discs"), Material.class);
/**
* Vanilla item tag representing all coal items.
*/
Tag<Material> ITEMS_COALS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("coals"), Material.class);
/**
* Vanilla item tag representing all arrow items.
*/
Tag<Material> ITEMS_ARROWS = Bukkit.getTag(REGISTRY_ITEMS, NamespacedKey.minecraft("arrows"), Material.class);
/**
* Returns whether or not this tag has an entry for the specified item.

View File

@ -1,100 +0,0 @@
package org.bukkit;
import org.jetbrains.annotations.NotNull;
/**
* The Travel Agent handles the creation and the research of Nether and End
* portals when Entities try to use one.
* <p>
* It is used in {@link org.bukkit.event.entity.EntityPortalEvent} and in
* {@link org.bukkit.event.player.PlayerPortalEvent} to help developers
* reproduce and/or modify Vanilla behaviour.
*/
public interface TravelAgent {
/**
* Set the Block radius to search in for available portals.
*
* @param radius the radius in which to search for a portal from the
* location
* @return this travel agent
*/
@NotNull
public TravelAgent setSearchRadius(int radius);
/**
* Gets the search radius value for finding an available portal.
*
* @return the currently set search radius
*/
public int getSearchRadius();
/**
* Sets the maximum radius from the given location to create a portal.
*
* @param radius the radius in which to create a portal from the location
* @return this travel agent
*/
@NotNull
public TravelAgent setCreationRadius(int radius);
/**
* Gets the maximum radius from the given location to create a portal.
*
* @return the currently set creation radius
*/
public int getCreationRadius();
/**
* Returns whether the TravelAgent will attempt to create a destination
* portal or not.
*
* @return whether the TravelAgent should create a destination portal or
* not
*/
public boolean getCanCreatePortal();
/**
* Sets whether the TravelAgent should attempt to create a destination
* portal or not.
*
* @param create Sets whether the TravelAgent should create a destination
* portal or not
*/
public void setCanCreatePortal(boolean create);
/**
* Attempt to find a portal near the given location, if a portal is not
* found it will attempt to create one.
*
* @param location the location where the search for a portal should begin
* @return the location of a portal which has been found or returns the
* location passed to the method if unsuccessful
* @see #createPortal(Location)
*/
@NotNull
public Location findOrCreate(@NotNull Location location);
/**
* Attempt to find a portal near the given location.
*
* @param location the desired location of the portal
* @return the location of the nearest portal to the location
*/
@NotNull
public Location findPortal(@NotNull Location location);
/**
* Attempt to create a portal near the given location.
* <p>
* In the case of a Nether portal teleportation, this will attempt to
* create a Nether portal.
* <p>
* In the case of an Ender portal teleportation, this will (re-)create the
* obsidian platform and clean blocks above it.
*
* @param location the desired location of the portal
* @return true if a portal was successfully created
*/
public boolean createPortal(@NotNull Location location);
}

View File

@ -28,6 +28,8 @@ public interface UnsafeValues {
BlockData fromLegacy(Material material, byte data);
Material getMaterial(String material, int version);
int getDataVersion();
ItemStack modifyItemStack(ItemStack stack, String arguments);

View File

@ -169,7 +169,11 @@ public interface World extends PluginMessageRecipient, Metadatable {
* @param z Z-coordinate of the chunk
* @return true if the chunk is loaded and in use by one or more players,
* otherwise false
* @deprecated This method was added to facilitate chunk garbage collection.
* As of the current Minecraft version chunks are now strictly managed and
* will not be loaded for more than 1 tick unless they are in use.
*/
@Deprecated
public boolean isChunkInUse(int x, int z);
/**
@ -199,8 +203,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
* <p>
* This method is analogous to {@link #unloadChunk(int, int, boolean,
* boolean)} where safe and save is true
* This method is analogous to {@link #unloadChunk(int, int, boolean)}
* where save is true.
*
* @param chunk the chunk to unload
* @return true if the chunk has unloaded successfully, otherwise false
@ -210,8 +214,8 @@ public interface World extends PluginMessageRecipient, Metadatable {
/**
* Safely unloads and saves the {@link Chunk} at the specified coordinates
* <p>
* This method is analogous to {@link #unloadChunk(int, int, boolean,
* boolean)} where safe and saveis true
* This method is analogous to {@link #unloadChunk(int, int, boolean)}
* where save is true.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
@ -221,10 +225,7 @@ public interface World extends PluginMessageRecipient, Metadatable {
/**
* Safely unloads and optionally saves the {@link Chunk} at the specified
* coordinates
* <p>
* This method is analogous to {@link #unloadChunk(int, int, boolean,
* boolean)} where save is true
* coordinates.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
@ -233,27 +234,9 @@ public interface World extends PluginMessageRecipient, Metadatable {
*/
public boolean unloadChunk(int x, int z, boolean save);
/**
* Unloads and optionally saves the {@link Chunk} at the specified
* coordinates
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param save Controls whether the chunk is saved
* @param safe Controls whether to unload the chunk when players are
* nearby
* @return true if the chunk has unloaded successfully, otherwise false
* @deprecated it is never safe to remove a chunk in use
*/
@Deprecated
public boolean unloadChunk(int x, int z, boolean save, boolean safe);
/**
* Safely queues the {@link Chunk} at the specified coordinates for
* unloading
* <p>
* This method is analogous to {@link #unloadChunkRequest(int, int,
* boolean)} where safe is true
* unloading.
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
@ -261,18 +244,6 @@ public interface World extends PluginMessageRecipient, Metadatable {
*/
public boolean unloadChunkRequest(int x, int z);
/**
* Queues the {@link Chunk} at the specified coordinates for unloading
*
* @param x X-coordinate of the chunk
* @param z Z-coordinate of the chunk
* @param safe Controls whether to queue the chunk when players are nearby
* @return Whether the chunk was actually queued
* @deprecated it is never safe to remove a chunk in use
*/
@Deprecated
public boolean unloadChunkRequest(int x, int z, boolean safe);
/**
* Regenerates the {@link Chunk} at the specified coordinates
*

View File

@ -0,0 +1,8 @@
package org.bukkit.block;
import org.bukkit.loot.Lootable;
/**
* Represents a captured state of a Barrel.
*/
public interface Barrel extends Container, Lootable { }

View File

@ -3,7 +3,6 @@ package org.bukkit.block;
import java.util.Collection;
import org.bukkit.Nameable;
import org.bukkit.entity.LivingEntity;
import org.bukkit.inventory.BeaconInventory;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
@ -12,15 +11,7 @@ import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a beacon.
*/
public interface Beacon extends Container, Nameable {
@NotNull
@Override
BeaconInventory getInventory();
@NotNull
@Override
BeaconInventory getSnapshotInventory();
public interface Beacon extends BlockState, Lockable, Nameable {
/**
* Returns the list of players within the beacon's range of effect.

View File

@ -0,0 +1,6 @@
package org.bukkit.block;
/**
* Represents a captured state of Bell.
*/
public interface Bell extends BlockState { }

View File

@ -1,9 +1,14 @@
package org.bukkit.block;
import java.util.Locale;
import org.bukkit.Keyed;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
/**
* Holds all accepted Biomes in the default server
*/
public enum Biome {
public enum Biome implements Keyed {
OCEAN,
PLAINS,
DESERT,
@ -76,5 +81,19 @@ public enum Biome {
SHATTERED_SAVANNA_PLATEAU,
ERODED_BADLANDS,
MODIFIED_WOODED_BADLANDS_PLATEAU,
MODIFIED_BADLANDS_PLATEAU
MODIFIED_BADLANDS_PLATEAU,
BAMBOO_JUNGLE,
BAMBOO_JUNGLE_HILLS;
private final NamespacedKey key;
private Biome() {
this.key = NamespacedKey.minecraft(name().toLowerCase(Locale.ROOT));
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
}

View File

@ -0,0 +1,6 @@
package org.bukkit.block;
/**
* Represents a captured state of a blast furnace.
*/
public interface BlastFurnace extends Furnace { }

View File

@ -1,13 +1,12 @@
package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.BrewerInventory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a brewing stand.
*/
public interface BrewingStand extends Container, Nameable {
public interface BrewingStand extends Container {
/**
* How much time is left in the brewing cycle.

View File

@ -0,0 +1,69 @@
package org.bukkit.block;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;
/**
* Represents a captured state of a campfire.
*/
public interface Campfire extends BlockState {
/**
* @see Inventory#getSize()
*
* @return The size of the inventory
*/
int getSize();
/**
* @see Inventory#getItem(int)
*
* @param index The index of the Slot's ItemStack to return
* @return The ItemStack in the slot
*/
@Nullable
ItemStack getItem(int index);
/**
* @see Inventory#setItem(int, org.bukkit.inventory.ItemStack)
*
* @param index The index where to put the ItemStack
* @param item The ItemStack to set
*/
void setItem(int index, @Nullable ItemStack item);
/**
* Get cook time.This is the amount of time the item has been cooking for.
*
* @param index
* @return Cook time
*/
int getCookTime(int index);
/**
* Set cook time.This is the amount of time the item has been cooking for.
*
* @param index
* @param cookTime Cook time
*/
void setCookTime(int index, int cookTime);
/**
* Get cook time total.This is the amount of time the item is required to
* cook for.
*
* @param index
* @return Cook time total
*/
int getCookTimeTotal(int index);
/**
* Set cook time.This is the amount of time the item is required to cook
* for.
*
* @param index
* @param cookTimeTotal Cook time total
*/
void setCookTimeTotal(int index, int cookTimeTotal);
}

View File

@ -1,6 +1,5 @@
package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.Inventory;
import org.bukkit.loot.Lootable;
import org.jetbrains.annotations.NotNull;
@ -8,7 +7,7 @@ import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a chest.
*/
public interface Chest extends Container, Nameable, Lootable {
public interface Chest extends Container, Lootable {
/**
* Gets the inventory of the chest block represented by this block state.

View File

@ -1,13 +1,14 @@
package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a container block.
*/
public interface Container extends BlockState, InventoryHolder, Lockable {
public interface Container extends BlockState, BlockInventoryHolder, Lockable, Nameable {
/**
* Gets the inventory of the block represented by this block state.

View File

@ -1,12 +1,11 @@
package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.loot.Lootable;
/**
* Represents a captured state of a dropper.
*/
public interface Dropper extends Container, Nameable, Lootable {
public interface Dropper extends Container, Lootable {
/**
* Tries to drop a randomly selected item from the dropper's inventory,

View File

@ -1,13 +1,12 @@
package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.inventory.FurnaceInventory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a furnace.
*/
public interface Furnace extends Container, Nameable {
public interface Furnace extends Container {
/**
* Get burn time.

View File

@ -1,9 +1,8 @@
package org.bukkit.block;
import org.bukkit.Nameable;
import org.bukkit.loot.Lootable;
/**
* Represents a captured state of a hopper.
*/
public interface Hopper extends Container, Nameable, Lootable { }
public interface Hopper extends Container, Lootable { }

View File

@ -0,0 +1,6 @@
package org.bukkit.block;
/**
* Represents a captured state of a jigsaw.
*/
public interface Jigsaw extends BlockState { }

View File

@ -0,0 +1,45 @@
package org.bukkit.block;
import org.bukkit.inventory.BlockInventoryHolder;
import org.bukkit.inventory.Inventory;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a lectern.
*/
public interface Lectern extends BlockState, BlockInventoryHolder {
/**
* Get the current lectern page.
*
* @return current page
*/
int getPage();
/**
* Set the current lectern page.
*
* If the page is greater than the number of pages of the book currently in
* the inventory, then behavior is undefined.
*
* @param page new page
*/
void setPage(int page);
/**
* @see Container#getInventory()
*
* @return inventory
*/
@NotNull
@Override
Inventory getInventory();
/**
* @see Container#getSnapshotInventory()
*
* @return snapshot inventory
*/
@NotNull
Inventory getSnapshotInventory();
}

View File

@ -1,14 +1,13 @@
package org.bukkit.block;
import org.bukkit.DyeColor;
import org.bukkit.Nameable;
import org.bukkit.loot.Lootable;
import org.jetbrains.annotations.NotNull;
/**
* Represents a captured state of a ShulkerBox.
*/
public interface ShulkerBox extends Container, Nameable, Lootable {
public interface ShulkerBox extends Container, Lootable {
/**
* Get the {@link DyeColor} corresponding to this ShulkerBox

View File

@ -0,0 +1,6 @@
package org.bukkit.block;
/**
* Represents a captured state of a smoker.
*/
public interface Smoker extends Furnace { }

View File

@ -0,0 +1,44 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Ageable;
import org.jetbrains.annotations.NotNull;
/**
* 'leaves' represents the size of the leaves on this bamboo block.
*/
public interface Bamboo extends Ageable, Sapling {
/**
* Gets the value of the 'leaves' property.
*
* @return the 'leaves' value
*/
@NotNull
Leaves getLeaves();
/**
* Sets the value of the 'leaves' property.
*
* @param leaves the new 'leaves' value
*/
void setLeaves(@NotNull Leaves leaves);
/**
* Bamboo leaf size.
*/
public enum Leaves {
/**
* No leaves.
*/
NONE,
/**
* Small leaves.
*/
SMALL,
/**
* Large leaves.
*/
LARGE;
}
}

View File

@ -0,0 +1,32 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Directional;
/**
* 'attachment' denotes how the bell is attached to its block.
*/
public interface Bell extends Directional {
/**
* What the bell is attached to.
*/
public enum Attachment {
/**
* Placed on floor.
*/
FLOOR,
/**
* Placed on ceiling.
*/
CEILING,
/**
* Placed on one wall.
*/
SINGLE_WALL,
/**
* Placed between two walls.
*/
DOUBLE_WALL;
}
}

View File

@ -0,0 +1,25 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Lightable;
import org.bukkit.block.data.Waterlogged;
/**
* 'signal_fire' denotes whether the fire is extra smokey due to having a hay
* bale placed beneath it.
*/
public interface Campfire extends Lightable, Waterlogged {
/**
* Gets the value of the 'signal_fire' property.
*
* @return the 'signal_fire' value
*/
boolean isSignalFire();
/**
* Sets the value of the 'signal_fire' property.
*
* @param signalFire the new 'signal_fire' value
*/
void setSignalFire(boolean signalFire);
}

View File

@ -0,0 +1,21 @@
package org.bukkit.block.data.type;
/**
* 'hanging' denotes whether the lantern is hanging from a block.
*/
public interface Lantern {
/**
* Gets the value of the 'hanging' property.
*
* @return the 'hanging' value
*/
boolean isHanging();
/**
* Sets the value of the 'hanging' property.
*
* @param hanging the new 'hanging' value
*/
void setHanging(boolean hanging);
}

View File

@ -0,0 +1,18 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Directional;
import org.bukkit.block.data.Powerable;
/**
* 'has_book' is a quick flag to check whether this lectern has a book inside
* it.
*/
public interface Lectern extends Directional, Powerable {
/**
* Gets the value of the 'has_book' property.
*
* @return the 'has_book' value
*/
boolean hasBook();
}

View File

@ -0,0 +1,49 @@
package org.bukkit.block.data.type;
import org.bukkit.block.data.Waterlogged;
/**
* 'bottom' indicates whether the scaffolding is floating or not.
* <br>
* 'distance' indicates the distance from a scaffolding block placed above a
* 'bottom' scaffold.
* <br>
* When 'distance' reaches {@link #getMaximumDistance()} the block will drop.
*/
public interface Scaffolding extends Waterlogged {
/**
* Gets the value of the 'bottom' property.
*
* @return the 'bottom' value
*/
boolean isBottom();
/**
* Sets the value of the 'bottom' property.
*
* @param bottom the new 'bottom' value
*/
void setBottom(boolean bottom);
/**
* Gets the value of the 'distance' property.
*
* @return the 'distance' value
*/
int getDistance();
/**
* Sets the value of the 'distance' property.
*
* @param distance the new 'distance' value
*/
void setDistance(int distance);
/**
* Gets the maximum allowed value of the 'distance' property.
*
* @return the maximum 'distance' value
*/
int getMaximumDistance();
}

View File

@ -44,8 +44,7 @@ public class VersionCommand extends BukkitCommand {
if (args.length == 0) {
sender.sendMessage("This server is running " + Bukkit.getName() + " version " + Bukkit.getVersion() + " (Implementing API version " + Bukkit.getBukkitVersion() + ")");
sender.sendMessage(ChatColor.YELLOW + "This is a final build for 1.13.2. Please see https://www.spigotmc.org/go/1.13.2 for details about upgrading.");
// sendVersion(sender);
sendVersion(sender);
} else {
StringBuilder name = new StringBuilder();

View File

@ -176,6 +176,21 @@ public abstract class Enchantment implements Keyed {
*/
public static final Enchantment CHANNELING = new EnchantmentWrapper("channeling");
/**
* Shoot multiple arrows from crossbows
*/
public static final Enchantment MULTISHOT = new EnchantmentWrapper("multishot");
/**
* Charges crossbows quickly
*/
public static final Enchantment QUICK_CHARGE = new EnchantmentWrapper("quick_charge");
/**
* Crossbow projectiles pierce entities
*/
public static final Enchantment PIERCING = new EnchantmentWrapper("piercing");
/**
* Allows mending the item using experience orbs
*/

View File

@ -191,6 +191,16 @@ public enum EnchantmentTarget {
public boolean includes(@NotNull Material item) {
return item.equals(Material.TRIDENT);
}
},
/**
* Allow the Enchantment to be placed on crossbows.
*/
CROSSBOW {
@Override
public boolean includes(@NotNull Material item) {
return item.equals(Material.CROSSBOW);
}
};
/**

View File

@ -0,0 +1,24 @@
package org.bukkit.entity;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.Merchant;
import org.jetbrains.annotations.NotNull;
/**
* Represents a villager NPC
*/
public interface AbstractVillager extends Ageable, NPC, InventoryHolder, Merchant {
/**
* Gets this villager's inventory.
* <br>
* Note that this inventory is not the Merchant inventory, rather, it is the
* items that a villager might have collected (from harvesting crops, etc.)
*
* {@inheritDoc}
*/
@NotNull
@Override
Inventory getInventory();
}

View File

@ -0,0 +1,41 @@
package org.bukkit.entity;
import org.jetbrains.annotations.NotNull;
/**
* Meow.
*/
public interface Cat extends Animals, Tameable, Sittable {
/**
* Gets the current type of this cat.
*
* @return Type of the cat.
*/
@NotNull
public Type getCatType();
/**
* Sets the current type of this cat.
*
* @param type New type of this cat.
*/
public void setCatType(@NotNull Type type);
/**
* Represents the various different cat types there are.
*/
public enum Type {
TABBY,
BLACK,
RED,
SIAMESE,
BRITISH_SHORTHAIR,
CALICO,
PERSIAN,
RAGDOLL,
WHITE,
JELLIE,
ALL_BLACK;
}
}

View File

@ -1,8 +1,10 @@
package org.bukkit.entity;
import com.google.common.base.Preconditions;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Keyed;
import org.bukkit.entity.minecart.CommandMinecart;
import org.bukkit.entity.minecart.HopperMinecart;
import org.bukkit.entity.minecart.SpawnerMinecart;
@ -12,12 +14,14 @@ import org.bukkit.entity.minecart.PoweredMinecart;
import org.bukkit.entity.minecart.StorageMinecart;
import org.bukkit.inventory.ItemStack;
import org.bukkit.Location;
import org.bukkit.NamespacedKey;
import org.bukkit.World;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
public enum EntityType {
public enum EntityType implements Keyed {
// These strings MUST match the strings in nms.EntityTypes and are case sensitive.
/**
@ -62,7 +66,7 @@ public enum EntityType {
/**
* An arrow projectile; may get stuck in the ground.
*/
ARROW("arrow", Arrow.class, 10),
ARROW("arrow", TippedArrow.class, 10),
/**
* A flying snowball.
*/
@ -86,7 +90,7 @@ public enum EntityType {
/**
* A flying splash potion.
*/
SPLASH_POTION("potion", SplashPotion.class, 16, false),
SPLASH_POTION("potion", ThrownPotion.class, 16, false),
/**
* A flying experience bottle.
*/
@ -116,7 +120,7 @@ public enum EntityType {
*/
HUSK("husk", Husk.class, 23),
/**
* Like {@link #TIPPED_ARROW} but causes the {@link PotionEffectType#GLOWING} effect on all team members.
* Like {@link #ARROW} but causes the {@link PotionEffectType#GLOWING} effect on all team members.
*/
SPECTRAL_ARROW("spectral_arrow", SpectralArrow.class, 24),
/**
@ -250,11 +254,13 @@ public enum EntityType {
TROPICAL_FISH("tropical_fish", TropicalFish.class, -1),
DROWNED("drowned", Drowned.class, -1),
DOLPHIN("dolphin", Dolphin.class, -1),
// These don't have an entity ID in nms.EntityTypes.
/**
* A flying lingering potion
*/
LINGERING_POTION(null, LingeringPotion.class, -1, false),
CAT("cat", Cat.class, -1),
PANDA("panda", Panda.class, -1),
PILLAGER("pillager", Pillager.class, -1),
RAVAGER("ravager", Ravager.class, -1),
TRADER_LLAMA("trader_llama", TraderLlama.class, -1),
WANDERING_TRADER("wandering_trader", WanderingTrader.class, -1),
FOX("fox", Fox.class, -1),
/**
* A fishing line and bobber.
*/
@ -265,23 +271,17 @@ public enum EntityType {
* Spawn with {@link World#strikeLightning(Location)}.
*/
LIGHTNING("lightning_bolt", LightningStrike.class, -1, false),
WEATHER(null, Weather.class, -1, false),
PLAYER("player", Player.class, -1, false),
COMPLEX_PART(null, ComplexEntityPart.class, -1, false),
/**
* Like {@link #ARROW} but tipped with a specific potion which is applied on
* contact.
*/
TIPPED_ARROW(null, TippedArrow.class, -1),
/**
* An unknown entity without an Entity Class
*/
UNKNOWN(null, null, -1, false);
private String name;
private Class<? extends Entity> clazz;
private short typeId;
private boolean independent, living;
private final String name;
private final Class<? extends Entity> clazz;
private final short typeId;
private final boolean independent, living;
private final NamespacedKey key;
private static final Map<String, EntityType> NAME_MAP = new HashMap<String, EntityType>();
private static final Map<Short, EntityType> ID_MAP = new HashMap<Short, EntityType>();
@ -320,9 +320,8 @@ public enum EntityType {
this.clazz = clazz;
this.typeId = (short) typeId;
this.independent = independent;
if (clazz != null) {
this.living = LivingEntity.class.isAssignableFrom(clazz);
}
this.living = clazz != null && LivingEntity.class.isAssignableFrom(clazz);
this.key = (name == null) ? null : NamespacedKey.minecraft(name);
}
/**
@ -336,6 +335,14 @@ public enum EntityType {
return name;
}
@NotNull
@Override
public NamespacedKey getKey() {
Preconditions.checkArgument(key != null, "EntityType doesn't have key! Is it UNKNOWN?");
return key;
}
@Nullable
public Class<? extends Entity> getEntityClass() {
return clazz;

View File

@ -0,0 +1,6 @@
package org.bukkit.entity;
/**
* What does the fox say?
*/
public interface Fox extends Animals {}

View File

@ -3,4 +3,4 @@ package org.bukkit.entity;
/**
* Represents a type of "Illager".
*/
public interface Illager extends Monster { }
public interface Illager extends Raider { }

View File

@ -3,7 +3,7 @@ package org.bukkit.entity;
/**
* Represents an instance of a lightning strike. May or may not do damage.
*/
public interface LightningStrike extends Weather {
public interface LightningStrike extends Entity {
/**
* Returns whether the strike is an effect that does no damage.

View File

@ -2,5 +2,7 @@ package org.bukkit.entity;
/**
* Represents a thrown lingering potion bottle
*
* @deprecated lingering status depends on only on the potion item.
*/
public interface LingeringPotion extends ThrownPotion { }

View File

@ -7,7 +7,7 @@ import org.jetbrains.annotations.Nullable;
/**
* A wild tameable cat
*/
public interface Ocelot extends Animals, Tameable, Sittable {
public interface Ocelot extends Animals {
/**
* Gets the current type of this cat.
@ -26,7 +26,10 @@ public interface Ocelot extends Animals, Tameable, Sittable {
/**
* Represents the various different cat types there are.
*
* @deprecated Cats are now a separate entity.
*/
@Deprecated
public enum Type {
WILD_OCELOT(0),
BLACK_CAT(1),

View File

@ -0,0 +1,66 @@
package org.bukkit.entity;
import org.jetbrains.annotations.NotNull;
/**
* Panda entity.
*/
public interface Panda extends Animals {
/**
* Gets this Panda's main gene.
*
* @return main gene
*/
@NotNull
Gene getMainGene();
/**
* Sets this Panda's main gene.
*
* @param gene main gene
*/
void setMainGene(@NotNull Gene gene);
/**
* Gets this Panda's hidden gene.
*
* @return hidden gene
*/
@NotNull
Gene getHiddenGene();
/**
* Sets this Panda's hidden gene.
*
* @param gene hidden gene
*/
void setHiddenGene(@NotNull Gene gene);
public enum Gene {
NORMAL(false),
LAZY(false),
WORRIED(false),
PLAYFUL(false),
BROWN(true),
WEAK(true),
AGGRESSIVE(false);
private final boolean recessive;
private Gene(boolean recessive) {
this.recessive = recessive;
}
/**
* Gets whether this gene is recessive, i.e. required in both parents to
* propagate to children.
*
* @return recessive status
*/
public boolean isRecessive() {
return recessive;
}
}
}

View File

@ -0,0 +1,8 @@
package org.bukkit.entity;
import org.bukkit.inventory.InventoryHolder;
/**
* Illager entity.
*/
public interface Pillager extends Illager, InventoryHolder { }

View File

@ -0,0 +1,36 @@
package org.bukkit.entity;
import org.bukkit.block.Block;
import org.jetbrains.annotations.Nullable;
public interface Raider extends Monster {
/**
* Gets the block the raider is targeting to patrol.
*
* @return target block or null
*/
@Nullable
Block getPatrolTarget();
/**
* Sets the block the raider is targeting to patrol.
*
* @param block target block or null. Must be in same world as the entity
*/
void setPatrolTarget(@Nullable Block block);
/**
* Gets whether this entity is a patrol leader.
*
* @return patrol leader status
*/
boolean isPatrolLeader();
/**
* Sets whether this entity is a patrol leader.
*
* @param leader patrol leader status
*/
void setPatrolLeader(boolean leader);
}

View File

@ -0,0 +1,6 @@
package org.bukkit.entity;
/**
* Illager beast.
*/
public interface Ravager extends Raider { }

View File

@ -2,5 +2,8 @@ package org.bukkit.entity;
/**
* Represents a thrown splash potion bottle
*
* @deprecated splash status depends on only on the potion item.
*/
@Deprecated
public interface SplashPotion extends ThrownPotion { }

View File

@ -0,0 +1,6 @@
package org.bukkit.entity;
/**
* Represents a trader Llama.
*/
public interface TraderLlama extends Llama { }

View File

@ -1,19 +1,11 @@
package org.bukkit.entity;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.LinkedListMultimap;
import com.google.common.collect.Multimap;
import java.util.List;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.Merchant;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* Represents a villager NPC
*/
public interface Villager extends Ageable, NPC, InventoryHolder, Merchant {
public interface Villager extends AbstractVillager {
/**
* Gets the current profession of this villager.
@ -30,243 +22,86 @@ public interface Villager extends Ageable, NPC, InventoryHolder, Merchant {
*/
public void setProfession(@NotNull Profession profession);
/**
* Get the current {@link Career} for this Villager.
*
* @return the {@link Career}
*/
@NotNull
public Career getCareer();
/**
* Set the new {@link Career} for this Villager.
* This method will reset the villager's trades to the new career.
*
* @param career the new career, or null to clear the career to a random one
* @throws IllegalArgumentException when the new {@link Career} cannot be
* used with this Villager's current {@link Profession}.
*/
public void setCareer(@Nullable Career career);
/**
* Set the new {@link Career} for this Villager.
*
* @param career the new career, or null to clear the career to a random one
* @param resetTrades true to reset this Villager's trades to the new
* career's (if any)
* @throws IllegalArgumentException when the new {@link Career} cannot be
* used with this Villager's current {@link Profession}.
*/
public void setCareer(@Nullable Career career, boolean resetTrades);
/**
* Gets this villager's inventory.
* <br>
* Note that this inventory is not the Merchant inventory, rather, it is the
* items that a villager might have collected (from harvesting crops, etc.)
*
* {@inheritDoc}
*/
@NotNull
@Override
Inventory getInventory();
/**
* Gets this villager's riches, the number of emeralds this villager has
* been given.
*
* @return the villager's riches
*/
int getRiches();
/**
* Sets this villager's riches.
*
* @see Villager#getRiches()
*
* @param riches the new riches
*/
void setRiches(int riches);
/**
* Represents the various different Villager professions there may be.
* Villagers have different trading options depending on their profession,
*/
public enum Profession {
NONE,
/**
* Normal. <b>Reserved for Zombies.</b>
* @deprecated Unused
*/
@Deprecated
NORMAL(true),
/**
* Farmer profession. Wears a brown robe.
*/
FARMER(false),
/**
* Librarian profession. Wears a white robe.
*/
LIBRARIAN(false),
/**
* Priest profession. Wears a purple robe.
*/
PRIEST(false),
/**
* Blacksmith profession. Wears a black apron.
*/
BLACKSMITH(false),
/**
* Butcher profession. Wears a white apron.
*/
BUTCHER(false),
/**
* Nitwit profession. Wears a green apron, cannot trade.
*/
NITWIT(false),
/**
* Husk. <b>Reserved for Zombies</b>
* @deprecated Unused
*/
@Deprecated
HUSK(true);
private final boolean zombie;
private Profession(boolean zombie) {
this.zombie = zombie;
}
/**
* Returns if this profession can only be used by zombies.
*
* @return zombie profession status
* @deprecated Unused
*/
@Deprecated
public boolean isZombie() {
return zombie;
}
/**
* Get an immutable list of {@link Career} belonging to this Profession.
*
* @return an immutable list of careers for this profession, or an empty
* map if this Profession has no careers.
*/
@NotNull
public List<Career> getCareers() {
return Career.getCareers(this);
}
}
/**
* The Career of this Villager.
* Each {@link Profession} has a set of careers it is applicable to. Each
* career dictates the trading options that are generated.
*/
public enum Career {
/*
NOTE: The Career entries are order-specific. They should be maintained in the numerical order they are used in the CB implementation.
(e.g. Farmer careers are 1,2,3,4 so Career should reflect that numerical order in their ordinal status)
*/
// Farmer careers
/**
* Farmers primarily trade for food-related items.
*/
FARMER(Profession.FARMER),
/**
* Fisherman primarily trade for fish, as well as possibly selling
* string and/or coal.
*/
FISHERMAN(Profession.FARMER),
/**
* Shepherds primarily trade for wool items, and shears.
*/
SHEPHERD(Profession.FARMER),
/**
* Fletchers primarily trade for string, bows, and arrows.
*/
FLETCHER(Profession.FARMER),
// Librarian careers
/**
* Librarians primarily trade for paper, books, and enchanted books.
*/
LIBRARIAN(Profession.LIBRARIAN),
/**
* Cartographers primarily trade for explorer maps and some paper.
*/
CARTOGRAPHER(Profession.LIBRARIAN),
// Priest careers
/**
* Clerics primarily trade for rotten flesh, gold ingot, redstone,
* lapis, ender pearl, glowstone, and bottle o' enchanting.
*/
CLERIC(Profession.PRIEST),
// Blacksmith careers
/**
* Armorer profession. Wears a black apron.
* Armorers primarily trade for iron armor, chainmail armor, and
* sometimes diamond armor.
*/
ARMORER(Profession.BLACKSMITH),
/**
* Weapon smiths primarily trade for iron and diamond weapons, sometimes
* enchanted.
*/
WEAPON_SMITH(Profession.BLACKSMITH),
/**
* Tool smiths primarily trade for iron and diamond tools.
*/
TOOL_SMITH(Profession.BLACKSMITH),
// Butcher careers
ARMORER,
/**
* Butcher profession. Wears a white apron.
* Butchers primarily trade for raw and cooked food.
*/
BUTCHER(Profession.BUTCHER),
BUTCHER,
/**
* Cartographer profession. Wears a white robe.
* Cartographers primarily trade for explorer maps and some paper.
*/
CARTOGRAPHER,
/**
* Cleric profession. Wears a purple robe.
* Clerics primarily trade for rotten flesh, gold ingot, redstone,
* lapis, ender pearl, glowstone, and bottle o' enchanting.
*/
CLERIC,
/**
* Farmer profession. Wears a brown robe.
* Farmers primarily trade for food-related items.
*/
FARMER,
/**
* Fisherman profession. Wears a brown robe.
* Fisherman primarily trade for fish, as well as possibly selling
* string and/or coal.
*/
FISHERMAN,
/**
* Fletcher profession. Wears a brown robe.
* Fletchers primarily trade for string, bows, and arrows.
*/
FLETCHER,
/**
* Leatherworker profession. Wears a white apron.
* Leatherworkers primarily trade for leather, and leather armor, as
* well as saddles.
*/
LEATHERWORKER(Profession.BUTCHER),
// Nitwit
LEATHERWORKER,
/**
* Librarian profession. Wears a white robe.
* Librarians primarily trade for paper, books, and enchanted books.
*/
LIBRARIAN,
/**
* Mason profession.
*/
MASON,
/**
* Nitwit profession. Wears a green apron, cannot trade.
* Nitwit villagers do not do anything. They do not have any trades by
* default.
*/
NITWIT(Profession.NITWIT);
private static final Multimap<Profession, Career> careerMap = LinkedListMultimap.create();
private final Profession profession;
private Career(/*@NotNull*/ Profession profession) {
this.profession = profession;
}
NITWIT,
/**
* Get the {@link Profession} this {@link Career} belongs to.
*
* @return the {@link Profession}.
* Sheperd profession. Wears a brown robe.
* Shepherds primarily trade for wool items, and shears.
*/
@NotNull
public Profession getProfession() {
return profession;
}
SHEPHERD,
/**
* Get an immutable list of {@link Career}s that can be used with a
* given {@link Profession}
*
* @param profession the profession to get careers for
* @return an immutable list of Careers that can be used by a
* profession, or an empty map if the profession was not found
* Toolsmith profession. Wears a black apron.
* Tool smiths primarily trade for iron and diamond tools.
*/
@NotNull
public static List<Career> getCareers(@NotNull Profession profession) {
return careerMap.containsKey(profession) ? ImmutableList.copyOf(careerMap.get(profession)) : ImmutableList.<Career>of();
}
static {
for (Career career : Career.values()) {
careerMap.put(career.profession, career);
}
}
TOOLSMITH,
/**
* Weaponsmith profession. Wears a black apron.
* Weapon smiths primarily trade for iron and diamond weapons, sometimes
* enchanted.
*/
WEAPONSMITH;
}
}

View File

@ -0,0 +1,6 @@
package org.bukkit.entity;
/**
* Represents a wandering trader NPC
*/
public interface WanderingTrader extends AbstractVillager { }

View File

@ -1,6 +0,0 @@
package org.bukkit.entity;
/**
* Represents a Weather related entity, such as a storm
*/
public interface Weather extends Entity {}

View File

@ -3,5 +3,5 @@ package org.bukkit.entity;
/**
* Represents a Witch
*/
public interface Witch extends Monster {
public interface Witch extends Raider {
}

View File

@ -0,0 +1,74 @@
package org.bukkit.event.block;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when an ItemStack is successfully cooked in a block.
*/
public class BlockCookEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final ItemStack source;
private ItemStack result;
private boolean cancelled;
public BlockCookEvent(@NotNull final Block block, @NotNull final ItemStack source, @NotNull final ItemStack result) {
super(block);
this.source = source;
this.result = result;
this.cancelled = false;
}
/**
* Gets the smelted ItemStack for this event
*
* @return smelting source ItemStack
*/
@NotNull
public ItemStack getSource() {
return source;
}
/**
* Gets the resultant ItemStack for this event
*
* @return smelting result ItemStack
*/
@NotNull
public ItemStack getResult() {
return result;
}
/**
* Sets the resultant ItemStack for this event
*
* @param result new result ItemStack
*/
public void setResult(@NotNull ItemStack result) {
this.result = result;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
}
}

View File

@ -1,7 +1,6 @@
package org.bukkit.event.entity;
import org.bukkit.Location;
import org.bukkit.TravelAgent;
import org.bukkit.entity.Entity;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
@ -15,63 +14,9 @@ import org.jetbrains.annotations.Nullable;
*/
public class EntityPortalEvent extends EntityTeleportEvent {
private static final HandlerList handlers = new HandlerList();
protected boolean useTravelAgent = true;
protected TravelAgent travelAgent;
public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) {
public EntityPortalEvent(@NotNull final Entity entity, @NotNull final Location from, @Nullable final Location to) {
super(entity, from, to);
this.travelAgent = pta;
}
/**
* Sets whether or not the Travel Agent will be used.
* <p>
* If this is set to true, the TravelAgent will try to find a Portal at
* the {@link #getTo()} Location, and will try to create one if there is
* none.
* <p>
* If this is set to false, the {@link #getEntity()} will only be
* teleported to the {@link #getTo()} Location.
*
* @param useTravelAgent whether to use the Travel Agent
*/
public void useTravelAgent(boolean useTravelAgent) {
this.useTravelAgent = useTravelAgent;
}
/**
* Gets whether or not the Travel Agent will be used.
* <p>
* If this is set to true, the TravelAgent will try to find a Portal at
* the {@link #getTo()} Location, and will try to create one if there is
* none.
* <p>
* If this is set to false, the {@link #getEntity()} will only be
* teleported to the {@link #getTo()} Location.
*
* @return whether to use the Travel Agent
*/
public boolean useTravelAgent() {
return useTravelAgent;
}
/**
* Gets the Travel Agent used (or not) in this event.
*
* @return the Travel Agent used (or not) in this event
*/
@NotNull
public TravelAgent getPortalTravelAgent() {
return this.travelAgent;
}
/**
* Sets the Travel Agent used (or not) in this event.
*
* @param travelAgent the Travel Agent used (or not) in this event
*/
public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) {
this.travelAgent = travelAgent;
}
@NotNull

View File

@ -2,7 +2,6 @@ package org.bukkit.event.entity;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Projectile;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.ItemStack;
@ -19,7 +18,7 @@ public class EntityShootBowEvent extends EntityEvent implements Cancellable {
private final float force;
private boolean cancelled;
public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Projectile projectile, final float force) {
public EntityShootBowEvent(@NotNull final LivingEntity shooter, @Nullable final ItemStack bow, @NotNull final Entity projectile, final float force) {
super(shooter);
this.bow = bow;
this.projectile = projectile;

View File

@ -151,6 +151,10 @@ public class EntityTargetEvent extends EntityEvent implements Cancellable {
* entity
*/
CLOSEST_ENTITY,
/**
* When a raiding entity selects the same target as one of its compatriots.
*/
FOLLOW_LEADER,
/**
* When another entity tempts this entity by having a desired item such
* as wheat in it's hand.

View File

@ -1,6 +1,6 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Villager;
import org.bukkit.entity.AbstractVillager;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.MerchantRecipe;
@ -16,7 +16,7 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl
//
private MerchantRecipe recipe;
public VillagerAcquireTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe) {
public VillagerAcquireTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe) {
super(what);
this.recipe = recipe;
}
@ -52,8 +52,8 @@ public class VillagerAcquireTradeEvent extends EntityEvent implements Cancellabl
@NotNull
@Override
public Villager getEntity() {
return (Villager) super.getEntity();
public AbstractVillager getEntity() {
return (AbstractVillager) super.getEntity();
}
@NotNull

View File

@ -1,6 +1,6 @@
package org.bukkit.event.entity;
import org.bukkit.entity.Villager;
import org.bukkit.entity.AbstractVillager;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.inventory.MerchantRecipe;
@ -20,7 +20,7 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
private MerchantRecipe recipe;
private int bonus;
public VillagerReplenishTradeEvent(@NotNull Villager what, @NotNull MerchantRecipe recipe, int bonus) {
public VillagerReplenishTradeEvent(@NotNull AbstractVillager what, @NotNull MerchantRecipe recipe, int bonus) {
super(what);
this.recipe = recipe;
this.bonus = bonus;
@ -77,8 +77,8 @@ public class VillagerReplenishTradeEvent extends EntityEvent implements Cancella
@NotNull
@Override
public Villager getEntity() {
return (Villager) super.getEntity();
public AbstractVillager getEntity() {
return (AbstractVillager) super.getEntity();
}
@NotNull

View File

@ -1,73 +1,16 @@
package org.bukkit.event.inventory;
import org.bukkit.block.Block;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockEvent;
import org.bukkit.event.block.BlockCookEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
/**
* Called when an ItemStack is successfully smelted in a furnace.
*/
public class FurnaceSmeltEvent extends BlockEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private final ItemStack source;
private ItemStack result;
private boolean cancelled;
public class FurnaceSmeltEvent extends BlockCookEvent {
public FurnaceSmeltEvent(@NotNull final Block furnace, @NotNull final ItemStack source, @NotNull final ItemStack result) {
super(furnace);
this.source = source;
this.result = result;
this.cancelled = false;
}
/**
* Gets the smelted ItemStack for this event
*
* @return smelting source ItemStack
*/
@NotNull
public ItemStack getSource() {
return source;
}
/**
* Gets the resultant ItemStack for this event
*
* @return smelting result ItemStack
*/
@NotNull
public ItemStack getResult() {
return result;
}
/**
* Sets the resultant ItemStack for this event
*
* @param result new result ItemStack
*/
public void setResult(@NotNull ItemStack result) {
this.result = result;
}
public boolean isCancelled() {
return cancelled;
}
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@NotNull
@Override
public HandlerList getHandlers() {
return handlers;
}
@NotNull
public static HandlerList getHandlerList() {
return handlers;
super(furnace, source, result);
}
}

View File

@ -92,6 +92,39 @@ public enum InventoryType {
* A shulker box inventory, with 27 slots of type CONTAINER.
*/
SHULKER_BOX(27, "Shulker Box"),
/**
* A barrel box inventory, with 27 slots of type CONTAINER.
*/
BARREL(27, "Barrel"),
/**
* A blast furnace inventory, with a RESULT slot, a CRAFTING slot, and a
* FUEL slot.
*/
BLAST_FURNACE(3, "Blast Furnace"),
/**
* A lectern inventory, with 1 BOOK slot.
*/
LECTERN(1, "Lectern", false),
/**
* A smoker inventory, with a RESULT slot, a CRAFTING slot, and a FUEL slot.
*/
SMOKER(3, "Smoker"),
/**
* Loom inventory, with 3 INPUT slots, and 1 RESULT slot.
*/
LOOM(4, "Loom"),
/**
* Cartography inventory with 2 INPUT slots, and 1 RESULT slot.
*/
CARTOGRAPHY(3, "Cartography Table"),
/**
* Grindstone inventory with 2 INPUT slots, and 1 RESULT slot.
*/
GRINDSTONE(3, "Repair & Disenchant"),
/**
* Stonecutter inventory with 1 INPUT slot, and 1 RESULT slot.
*/
STONECUTTER(2, "Stonecutter")
;
private final int size;

View File

@ -1,7 +1,6 @@
package org.bukkit.event.player;
import org.bukkit.Location;
import org.bukkit.TravelAgent;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
@ -15,68 +14,13 @@ import org.jetbrains.annotations.Nullable;
*/
public class PlayerPortalEvent extends PlayerTeleportEvent {
private static final HandlerList handlers = new HandlerList();
protected boolean useTravelAgent = true;
protected TravelAgent travelAgent;
public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to, @NotNull final TravelAgent pta) {
public PlayerPortalEvent(@NotNull final Player player, @NotNull final Location from, @Nullable final Location to) {
super(player, from, to);
this.travelAgent = pta;
}
public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TravelAgent pta, @NotNull TeleportCause cause) {
public PlayerPortalEvent(@NotNull Player player, @NotNull Location from, @Nullable Location to, @NotNull TeleportCause cause) {
super(player, from, to, cause);
this.travelAgent = pta;
}
/**
* Sets whether or not the Travel Agent will be used.
* <p>
* If this is set to true, the TravelAgent will try to find a Portal at
* the {@link #getTo()} Location, and will try to create one if there is
* none.
* <p>
* If this is set to false, the {@link #getPlayer()} will only be
* teleported to the {@link #getTo()} Location.
*
* @param useTravelAgent whether to use the Travel Agent
*/
public void useTravelAgent(boolean useTravelAgent) {
this.useTravelAgent = useTravelAgent;
}
/**
* Gets whether or not the Travel Agent will be used.
* <p>
* If this is set to true, the TravelAgent will try to find a Portal at
* the {@link #getTo()} Location, and will try to create one if there is
* none.
* <p>
* If this is set to false, the {@link #getPlayer()}} will only be
* teleported to the {@link #getTo()} Location.
*
* @return whether to use the Travel Agent
*/
public boolean useTravelAgent() {
return useTravelAgent && travelAgent != null;
}
/**
* Gets the Travel Agent used (or not) in this event.
*
* @return the Travel Agent used (or not) in this event
*/
@NotNull
public TravelAgent getPortalTravelAgent() {
return this.travelAgent;
}
/**
* Sets the Travel Agent used (or not) in this event.
*
* @param travelAgent the Travel Agent used (or not) in this event
*/
public void setPortalTravelAgent(@NotNull TravelAgent travelAgent) {
this.travelAgent = travelAgent;
}
@NotNull

View File

@ -6,4 +6,12 @@ import org.bukkit.event.Event;
* Miscellaneous server events
*/
public abstract class ServerEvent extends Event {
public ServerEvent() {
super();
}
public ServerEvent(boolean isAsync) {
super(isAsync);
}
}

View File

@ -23,6 +23,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
private int maxPlayers;
public ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int numPlayers, final int maxPlayers) {
super(true);
Validate.isTrue(numPlayers >= 0, "Cannot have negative number of players online", numPlayers);
this.address = address;
this.motd = motd;
@ -40,6 +41,7 @@ public class ServerListPingEvent extends ServerEvent implements Iterable<Player>
* @param maxPlayers the max number of players
*/
protected ServerListPingEvent(@NotNull final InetAddress address, @NotNull final String motd, final int maxPlayers) {
super(true);
this.numPlayers = MAGIC_PLAYER_COUNT;
this.address = address;
this.motd = motd;

View File

@ -0,0 +1,19 @@
package org.bukkit.inventory;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
/**
* Represents a campfire recipe.
*/
public class BlastingRecipe extends CookingRecipe<BlastingRecipe> {
public BlastingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) {
super(key, result, source, experience, cookingTime);
}
public BlastingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) {
super(key, result, input, experience, cookingTime);
}
}

View File

@ -0,0 +1,21 @@
package org.bukkit.inventory;
import org.bukkit.block.Block;
import org.jetbrains.annotations.NotNull;
/**
* Represents a block inventory holder - either a BlockState, or a regular
* Block.
*/
public interface BlockInventoryHolder extends InventoryHolder {
/**
* Gets the block associated with this holder.
*
* @return the block associated with this holder
* @throws IllegalStateException if the holder is a block state and is not
* placed
*/
@NotNull
Block getBlock();
}

View File

@ -0,0 +1,19 @@
package org.bukkit.inventory;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
/**
* Represents a campfire recipe.
*/
public class CampfireRecipe extends CookingRecipe<CampfireRecipe> {
public CampfireRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) {
super(key, result, source, experience, cookingTime);
}
public CampfireRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) {
super(key, result, input, experience, cookingTime);
}
}

View File

@ -0,0 +1,6 @@
package org.bukkit.inventory;
/**
* Interface to the inventory of a Cartography table.
*/
public interface CartographyInventory extends Inventory { }

View File

@ -0,0 +1,172 @@
package org.bukkit.inventory;
import com.google.common.base.Preconditions;
import java.util.Collections;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
/**
* Represents a cooking recipe.
* @param <T> type of recipe
*/
public abstract class CookingRecipe<T extends CookingRecipe> implements Recipe, Keyed {
private final NamespacedKey key;
private ItemStack output;
private RecipeChoice ingredient;
private float experience;
private int cookingTime;
private String group = "";
/**
* Create a cooking recipe to craft the specified ItemStack.
*
* @param key The unique recipe key
* @param result The item you want the recipe to create.
* @param source The input material.
* @param experience The experience given by this recipe
* @param cookingTime The cooking time (in ticks)
*/
public CookingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) {
this(key, result, new RecipeChoice.MaterialChoice(Collections.singletonList(source)), experience, cookingTime);
}
/**
* Create a cooking recipe to craft the specified ItemStack.
*
* @param key The unique recipe key
* @param result The item you want the recipe to create.
* @param input The input choices.
* @param experience The experience given by this recipe
* @param cookingTime The cooking time (in ticks)
*/
public CookingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) {
this.key = key;
this.output = new ItemStack(result);
this.ingredient = input;
this.experience = experience;
this.cookingTime = cookingTime;
}
/**
* Sets the input of this cooking recipe.
*
* @param input The input material.
* @return The changed recipe, so you can chain calls.
*/
@NotNull
public CookingRecipe setInput(@NotNull Material input) {
this.ingredient = new RecipeChoice.MaterialChoice(Collections.singletonList(input));
return this;
}
/**
* Get the input material.
*
* @return The input material.
*/
@NotNull
public ItemStack getInput() {
return this.ingredient.getItemStack();
}
/**
* Sets the input of this cooking recipe.
*
* @param input The input choice.
* @return The changed recipe, so you can chain calls.
*/
@NotNull
public T setInputChoice(@NotNull RecipeChoice input) {
this.ingredient = input;
return (T) this;
}
/**
* Get the input choice.
*
* @return The input choice.
*/
@NotNull
public RecipeChoice getInputChoice() {
return this.ingredient.clone();
}
/**
* Get the result of this recipe.
*
* @return The resulting stack.
*/
@NotNull
@Override
public ItemStack getResult() {
return output.clone();
}
/**
* Sets the experience given by this recipe.
*
* @param experience the experience level
*/
public void setExperience(float experience) {
this.experience = experience;
}
/**
* Get the experience given by this recipe.
*
* @return experience level
*/
public float getExperience() {
return experience;
}
/**
* Set the cooking time for this recipe in ticks.
*
* @param cookingTime new cooking time
*/
public void setCookingTime(int cookingTime) {
Preconditions.checkArgument(cookingTime >= 0, "cookingTime must be >= 0");
this.cookingTime = cookingTime;
}
/**
* Get the cooking time for this recipe in ticks.
*
* @return cooking time
*/
public int getCookingTime() {
return cookingTime;
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* Get the group of this recipe. Recipes with the same group may be grouped
* together when displayed in the client.
*
* @return recipe group. An empty string denotes no group. May not be null.
*/
@NotNull
public String getGroup() {
return group;
}
/**
* Set the group of this recipe. Recipes with the same group may be grouped
* together when displayed in the client.
*
* @param group recipe group. An empty string denotes no group. May not be
* null.
*/
public void setGroup(@NotNull String group) {
Preconditions.checkArgument(group != null, "group");
this.group = group;
}
}

View File

@ -1,23 +1,15 @@
package org.bukkit.inventory;
import com.google.common.base.Preconditions;
import java.util.Collections;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.material.MaterialData;
import org.jetbrains.annotations.NotNull;
/**
* Represents a smelting recipe.
* Represents a furnace recipe.
*/
public class FurnaceRecipe implements Recipe, Keyed {
private final NamespacedKey key;
private ItemStack output;
private RecipeChoice ingredient;
private float experience;
private int cookingTime;
private String group = "";
public class FurnaceRecipe extends CookingRecipe<FurnaceRecipe> {
@Deprecated
public FurnaceRecipe(@NotNull ItemStack result, @NotNull Material source) {
@ -67,11 +59,7 @@ public class FurnaceRecipe implements Recipe, Keyed {
* @param cookingTime The cooking time (in ticks)
*/
public FurnaceRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) {
this.key = key;
this.output = new ItemStack(result);
this.ingredient = input;
this.experience = experience;
this.cookingTime = cookingTime;
super(key, result, input, experience, cookingTime);
}
/**
@ -85,15 +73,10 @@ public class FurnaceRecipe implements Recipe, Keyed {
return setInput(input.getItemType(), input.getData());
}
/**
* Sets the input of this furnace recipe.
*
* @param input The input material.
* @return The changed recipe, so you can chain calls.
*/
@NotNull
@Override
public FurnaceRecipe setInput(@NotNull Material input) {
return setInput(input, 0);
return (FurnaceRecipe) super.setInput(input);
}
/**
@ -106,117 +89,13 @@ public class FurnaceRecipe implements Recipe, Keyed {
* @deprecated Magic value
*/
@Deprecated
@NotNull
public FurnaceRecipe setInput(@NotNull Material input, int data) {
this.ingredient = new RecipeChoice.MaterialChoice(Collections.singletonList(input));
return this;
}
/**
* Get the input material.
*
* @return The input material.
*/
@NotNull
public ItemStack getInput() {
return this.ingredient.getItemStack();
}
/**
* Sets the input of this furnace recipe.
*
* @param input The input choice.
* @return The changed recipe, so you can chain calls.
*/
@NotNull
public FurnaceRecipe setInputChoice(@NotNull RecipeChoice input) {
this.ingredient = input;
return this;
}
/**
* Get the input choice.
*
* @return The input choice.
*/
@NotNull
public RecipeChoice getInputChoice() {
return this.ingredient.clone();
}
/**
* Get the result of this recipe.
*
* @return The resulting stack.
*/
@NotNull
public ItemStack getResult() {
return output.clone();
}
/**
* Sets the experience given by this recipe.
*
* @param experience the experience level
*/
public void setExperience(float experience) {
this.experience = experience;
}
/**
* Get the experience given by this recipe.
*
* @return experience level
*/
public float getExperience() {
return experience;
}
/**
* Set the cooking time for this recipe in ticks.
*
* @param cookingTime new cooking time
*/
public void setCookingTime(int cookingTime) {
Preconditions.checkArgument(cookingTime >= 0, "cookingTime must be >= 0");
this.cookingTime = cookingTime;
}
/**
* Get the cooking time for this recipe in ticks.
*
* @return cooking time
*/
public int getCookingTime() {
return cookingTime;
return setInputChoice(new RecipeChoice.MaterialChoice(Collections.singletonList(input)));
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* Get the group of this recipe. Recipes with the same group may be grouped
* together when displayed in the client.
*
* @return recipe group. An empty string denotes no group. May not be null.
*/
@NotNull
public String getGroup() {
return group;
}
/**
* Set the group of this recipe. Recipes with the same group may be grouped
* together when displayed in the client.
*
* @param group recipe group. An empty string denotes no group. May not be
* null.
*/
public void setGroup(@NotNull String group) {
Preconditions.checkArgument(group != null, "group");
this.group = group;
public FurnaceRecipe setInputChoice(@NotNull RecipeChoice input) {
return (FurnaceRecipe) super.setInputChoice(input);
}
}

View File

@ -0,0 +1,6 @@
package org.bukkit.inventory;
/**
* Interface to the inventory of a Grindstone.
*/
public interface GrindstoneInventory extends Inventory { }

View File

@ -60,18 +60,6 @@ public interface Inventory extends Iterable<ItemStack> {
*/
public void setMaxStackSize(int size);
/**
* Returns the name of the inventory
*
* @return The String with the name of the inventory
* @deprecated different instances of the same inventory may have different names;
* it is not clear what this method is meant to return
* @see InventoryView#getTitle()
*/
@Deprecated
@NotNull
public String getName();
/**
* Returns the ItemStack found in the slot at the given index
*
@ -345,17 +333,6 @@ public interface Inventory extends Iterable<ItemStack> {
@NotNull
public List<HumanEntity> getViewers();
/**
* Returns the title of this inventory.
*
* @return A String with the title.
* @deprecated different instances of the same inventory may have different titles
* @see InventoryView#getTitle()
*/
@Deprecated
@NotNull
public String getTitle();
/**
* Returns what type of inventory this is.
*

View File

@ -427,7 +427,5 @@ public abstract class InventoryView {
* @return The title.
*/
@NotNull
public final String getTitle() {
return getTopInventory().getTitle();
}
public abstract String getTitle();
}

View File

@ -480,7 +480,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
damage = 0;
}
} else {
type = Material.getMaterial((String) args.get("type"));
type = Bukkit.getUnsafe().getMaterial((String) args.get("type"), version);
}
if (args.containsKey("amount")) {
@ -506,6 +506,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
} else if (args.containsKey("meta")) { // We cannot and will not have meta when enchantments (pre-ItemMeta) exist
Object raw = args.get("meta");
if (raw instanceof ItemMeta) {
((ItemMeta) raw).setVersion(version);
result.setItemMeta((ItemMeta) raw);
}
}

View File

@ -0,0 +1,14 @@
package org.bukkit.inventory;
import org.bukkit.block.Lectern;
import org.jetbrains.annotations.Nullable;
/**
* Interface to the inventory of a Lectern.
*/
public interface LecternInventory extends Inventory {
@Nullable
@Override
public Lectern getHolder();
}

View File

@ -0,0 +1,6 @@
package org.bukkit.inventory;
/**
* Interface to the inventory of a Loom.
*/
public interface LoomInventory extends Inventory { }

View File

@ -27,16 +27,24 @@ public class MerchantRecipe implements Recipe {
private int uses;
private int maxUses;
private boolean experienceReward;
private int villagerExperience;
private float priceMultiplier;
public MerchantRecipe(@NotNull ItemStack result, int maxUses) {
this(result, 0, maxUses, false);
}
public MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward) {
this(result, uses, maxUses, experienceReward, 0, 0.0F);
}
public MerchantRecipe(@NotNull ItemStack result, int uses, int maxUses, boolean experienceReward, int villagerExperience, float priceMultiplier) {
this.result = result;
this.uses = uses;
this.maxUses = maxUses;
this.experienceReward = experienceReward;
this.villagerExperience = villagerExperience;
this.priceMultiplier = priceMultiplier;
}
@NotNull
@ -111,20 +119,58 @@ public class MerchantRecipe implements Recipe {
}
/**
* Whether to reward experience for the trade.
* Whether to reward experience to the player for the trade.
*
* @return whether to reward experience for completing this trade
* @return whether to reward experience to the player for completing this
* trade
*/
public boolean hasExperienceReward() {
return experienceReward;
}
/**
* Set whether to reward experience for the trade.
* Set whether to reward experience to the player for the trade.
*
* @param flag whether to reward experience for completing this trade
* @param flag whether to reward experience to the player for completing
* this trade
*/
public void setExperienceReward(boolean flag) {
this.experienceReward = flag;
}
/**
* Gets the amount of experience the villager earns from this trade.
*
* @return villager experience
*/
public int getVillagerExperience() {
return villagerExperience;
}
/**
* Sets the amount of experience the villager earns from this trade.
*
* @param villagerExperience new experience amount
*/
public void setVillagerExperience(int villagerExperience) {
this.villagerExperience = villagerExperience;
}
/**
* Gets the additive price multiplier for the cost of this trade.
*
* @return price multiplier
*/
public float getPriceMultiplier() {
return priceMultiplier;
}
/**
* Sets the additive price multiplier for the cost of this trade.
*
* @param priceMultiplier new price multiplier
*/
public void setPriceMultiplier(float priceMultiplier) {
this.priceMultiplier = priceMultiplier;
}
}

View File

@ -0,0 +1,19 @@
package org.bukkit.inventory;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
/**
* Represents a campfire recipe.
*/
public class SmokingRecipe extends CookingRecipe<SmokingRecipe> {
public SmokingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source, float experience, int cookingTime) {
super(key, result, source, experience, cookingTime);
}
public SmokingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input, float experience, int cookingTime) {
super(key, result, input, experience, cookingTime);
}
}

View File

@ -0,0 +1,6 @@
package org.bukkit.inventory;
/**
* Interface to the inventory of a Stonecutter.
*/
public interface StonecutterInventory extends Inventory { }

View File

@ -0,0 +1,126 @@
package org.bukkit.inventory;
import com.google.common.base.Preconditions;
import java.util.Collections;
import org.bukkit.Keyed;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.jetbrains.annotations.NotNull;
/**
* Represents a Stonecutting recipe.
*/
public class StonecuttingRecipe implements Recipe, Keyed {
private final NamespacedKey key;
private ItemStack output;
private RecipeChoice ingredient;
private String group = "";
/**
* Create a Stonecutting recipe to craft the specified ItemStack.
*
* @param key The unique recipe key
* @param result The item you want the recipe to create.
* @param source The input material.
*/
public StonecuttingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull Material source) {
this(key, result, new RecipeChoice.MaterialChoice(Collections.singletonList(source)));
}
/**
* Create a cooking recipe to craft the specified ItemStack.
*
* @param key The unique recipe key
* @param result The item you want the recipe to create.
* @param input The input choices.
*/
public StonecuttingRecipe(@NotNull NamespacedKey key, @NotNull ItemStack result, @NotNull RecipeChoice input) {
this.key = key;
this.output = new ItemStack(result);
this.ingredient = input;
}
/**
* Sets the input of this cooking recipe.
*
* @param input The input material.
* @return The changed recipe, so you can chain calls.
*/
@NotNull
public StonecuttingRecipe setInput(@NotNull Material input) {
this.ingredient = new RecipeChoice.MaterialChoice(Collections.singletonList(input));
return this;
}
/**
* Get the input material.
*
* @return The input material.
*/
@NotNull
public ItemStack getInput() {
return this.ingredient.getItemStack();
}
/**
* Sets the input of this cooking recipe.
*
* @param input The input choice.
* @return The changed recipe, so you can chain calls.
*/
@NotNull
public StonecuttingRecipe setInputChoice(@NotNull RecipeChoice input) {
this.ingredient = input;
return (StonecuttingRecipe) this;
}
/**
* Get the input choice.
*
* @return The input choice.
*/
@NotNull
public RecipeChoice getInputChoice() {
return this.ingredient.clone();
}
/**
* Get the result of this recipe.
*
* @return The resulting stack.
*/
@NotNull
@Override
public ItemStack getResult() {
return output.clone();
}
@NotNull
@Override
public NamespacedKey getKey() {
return key;
}
/**
* Get the group of this recipe. Recipes with the same group may be grouped
* together when displayed in the client.
*
* @return recipe group. An empty string denotes no group. May not be null.
*/
@NotNull
public String getGroup() {
return group;
}
/**
* Set the group of this recipe. Recipes with the same group may be grouped
* together when displayed in the client.
*
* @param group recipe group. An empty string denotes no group. May not be
* null.
*/
public void setGroup(@NotNull String group) {
Preconditions.checkArgument(group != null, "group");
this.group = group;
}
}

View File

@ -0,0 +1,37 @@
package org.bukkit.inventory.meta;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.jetbrains.annotations.NotNull;
public interface BlockDataMeta extends ItemMeta {
/**
* Returns whether the item has block data currently attached to it.
*
* @return whether block data is already attached
*/
boolean hasBlockData();
/**
* Returns the currently attached block data for this item or creates a new
* one if one doesn't exist.
*
* The state is a copy, it must be set back (or to another item) with
* {@link #setBlockData(org.bukkit.block.data.BlockData)}
*
* @param material the material we wish to get this data in the context of
* @return the attached data or new data
*/
@NotNull
BlockData getBlockData(@NotNull Material material);
/**
* Attaches a copy of the passed block data to the item.
*
* @param blockData the block data to attach to the block.
* @throws IllegalArgumentException if the blockData is null or invalid for
* this item.
*/
void setBlockData(@NotNull BlockData blockData);
}

View File

@ -100,6 +100,39 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
*/
void setLore(@Nullable List<String> lore);
/**
* Checks for existence of custom model data.
* <p>
* CustomModelData is an integer that may be associated client side with a
* custom item model.
*
* @return true if this has custom model data
*/
boolean hasCustomModelData();
/**
* Gets the custom model data that is set.
* <p>
* CustomModelData is an integer that may be associated client side with a
* custom item model.
* <p>
* Plugins should check that hasCustomModelData() returns <code>true</code>
* before calling this method.
*
* @return the localized name that is set
*/
int getCustomModelData();
/**
* Sets the custom model data.
* <p>
* CustomModelData is an integer that may be associated client side with a
* custom item model.
*
* @param data the data to set, or null to clear
*/
void setCustomModelData(@Nullable Integer data);
/**
* Checks for the existence of any enchantments.
*
@ -340,6 +373,15 @@ public interface ItemMeta extends Cloneable, ConfigurationSerializable {
@NotNull
CustomItemTagContainer getCustomTagContainer();
/**
* Internal use only! Do not use under any circumstances!
*
* @param version
* @deprecated
*/
@Deprecated
void setVersion(int version);
@SuppressWarnings("javadoc")
@NotNull
ItemMeta clone();

View File

@ -173,4 +173,22 @@ public interface MapView {
* @param unlimited tracking state
*/
void setUnlimitedTracking(boolean unlimited);
/**
* Gets whether the map is locked or not.
*
* A locked map may not be explored further.
*
* @return lock status
*/
boolean isLocked();
/**
* Gets whether the map is locked or not.
*
* A locked map may not be explored further.
*
* @param locked status
*/
void setLocked(boolean locked);
}

View File

@ -487,6 +487,9 @@ public final class SimplePluginManager implements PluginManager {
}
fireEvent(event);
} else {
if (!server.isPrimaryThread()) {
throw new IllegalStateException(event.getEventName() + " cannot be triggered asynchronously from another thread.");
}
synchronized (this) {
fireEvent(event);
}

View File

@ -165,6 +165,16 @@ public abstract class PotionEffectType {
*/
public static final PotionEffectType DOLPHINS_GRACE = new PotionEffectTypeWrapper(30);
/**
* oof.
*/
public static final PotionEffectType BAD_OMEN = new PotionEffectTypeWrapper(31);
/**
* \o/.
*/
public static final PotionEffectType HERO_OF_THE_VILLAGE = new PotionEffectTypeWrapper(32);
private final int id;
protected PotionEffectType(int id) {
@ -189,7 +199,9 @@ public abstract class PotionEffectType {
* Returns the duration modifier applied to effects of this type.
*
* @return duration modifier
* @deprecated unused, always 1.0
*/
@Deprecated
public abstract double getDurationModifier();
/**
@ -251,7 +263,7 @@ public abstract class PotionEffectType {
return "PotionEffectType[" + id + ", " + getName() + "]";
}
private static final PotionEffectType[] byId = new PotionEffectType[31];
private static final PotionEffectType[] byId = new PotionEffectType[33];
private static final Map<String, PotionEffectType> byName = new HashMap<String, PotionEffectType>();
// will break on updates.
private static boolean acceptingNew = true;

View File

@ -89,14 +89,16 @@ public class PluginManagerTest {
pm.callEvent(event);
} catch (Throwable ex) {
store.value = ex;
assertThat(event.getEventName() + " cannot be triggered asynchronously from another thread.", is(ex.getMessage()));
return;
}
}
}
);
secondThread.start();
secondThread.join();
if (store.value != null) {
throw new RuntimeException((Throwable) store.value);
if (store.value == null) {
throw new IllegalStateException("No exception thrown");
}
}
@ -112,14 +114,16 @@ public class PluginManagerTest {
}
} catch (Throwable ex) {
store.value = ex;
assertThat(event.getEventName() + " cannot be triggered asynchronously from another thread.", is(ex.getMessage()));
return;
}
}
}
);
secondThread.start();
secondThread.join();
if (store.value != null) {
throw new RuntimeException((Throwable) store.value);
if (store.value == null) {
throw new IllegalStateException("No exception thrown");
}
}