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,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();