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

@@ -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 {
}