2019-04-23 06:47:07 +02:00
|
|
|
From 823936f1edcfbf8cb8d8cf2d6ba18eb14f86b9ac Mon Sep 17 00:00:00 2001
|
2016-05-02 05:54:08 +02:00
|
|
|
From: Aikar <aikar@aikar.co>
|
|
|
|
Date: Sun, 1 May 2016 15:19:49 -0400
|
|
|
|
Subject: [PATCH] LootTable API
|
|
|
|
|
|
|
|
Provides API to control what Loot Table an object uses.
|
|
|
|
|
|
|
|
Also provides an Event to control if a lootable inventory should
|
|
|
|
auto replenish for a player.
|
|
|
|
|
|
|
|
Provides methods to determine players looted state for an object
|
|
|
|
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableBlockInventory.java b/src/main/java/com/destroystokyo/paper/loottable/LootableBlockInventory.java
|
|
|
|
new file mode 100644
|
2019-04-23 06:47:07 +02:00
|
|
|
index 00000000..92d7b853
|
2016-05-02 05:54:08 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/LootableBlockInventory.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,17 @@
|
2016-05-02 05:54:08 +02:00
|
|
|
+package com.destroystokyo.paper.loottable;
|
|
|
|
+
|
|
|
|
+import org.bukkit.block.Block;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
2018-08-12 19:11:08 +02:00
|
|
|
+/**
|
|
|
|
+ * Represents an Inventory that can generate loot, such as Chests inside of Fortresses and Mineshafts
|
|
|
|
+ */
|
2016-05-02 05:54:08 +02:00
|
|
|
+public interface LootableBlockInventory extends LootableInventory {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the block that is lootable
|
|
|
|
+ * @return The Block
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2016-05-02 05:54:08 +02:00
|
|
|
+ Block getBlock();
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableEntityInventory.java b/src/main/java/com/destroystokyo/paper/loottable/LootableEntityInventory.java
|
|
|
|
new file mode 100644
|
2019-04-23 06:47:07 +02:00
|
|
|
index 00000000..b387894f
|
2016-05-02 05:54:08 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/LootableEntityInventory.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,17 @@
|
2016-05-02 05:54:08 +02:00
|
|
|
+package com.destroystokyo.paper.loottable;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Entity;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
2018-08-12 19:11:08 +02:00
|
|
|
+/**
|
|
|
|
+ * Represents an Inventory that can generate loot, such as Minecarts inside of Mineshafts
|
|
|
|
+ */
|
2016-05-02 05:54:08 +02:00
|
|
|
+public interface LootableEntityInventory extends LootableInventory {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the entity that is lootable
|
|
|
|
+ * @return The Entity
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2016-05-02 05:54:08 +02:00
|
|
|
+ Entity getEntity();
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java
|
|
|
|
new file mode 100644
|
2019-04-23 06:47:07 +02:00
|
|
|
index 00000000..97815eeb
|
2016-05-02 05:54:08 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/LootableInventory.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,116 @@
|
2016-05-02 05:54:08 +02:00
|
|
|
+package com.destroystokyo.paper.loottable;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Player;
|
2018-08-26 20:11:49 +02:00
|
|
|
+import org.bukkit.loot.Lootable;
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
|
|
|
+import java.util.UUID;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
|
+import org.jetbrains.annotations.Nullable;
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Represents an Inventory that contains a Loot Table associated to it that will
|
|
|
|
+ * automatically fill on first open.
|
|
|
|
+ *
|
|
|
|
+ * A new feature and API is provided to support automatically refreshing the contents
|
|
|
|
+ * of the inventory based on that Loot Table after a configurable amount of time has passed.
|
|
|
|
+ *
|
|
|
|
+ * The behavior of how the Inventory is filled based on the loot table may vary based
|
|
|
|
+ * on Minecraft versions and the Loot Table feature.
|
|
|
|
+ */
|
|
|
|
+public interface LootableInventory extends Lootable {
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Server owners have to enable whether or not an object in a world should refill
|
|
|
|
+ *
|
|
|
|
+ * @return If the world this inventory is currently in has Replenishable Lootables enabled
|
|
|
|
+ */
|
|
|
|
+ boolean isRefillEnabled();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Whether or not this object has ever been filled
|
|
|
|
+ * @return Has ever been filled
|
|
|
|
+ */
|
|
|
|
+ boolean hasBeenFilled();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Has this player ever looted this block
|
|
|
|
+ * @param player The player to check
|
|
|
|
+ * @return Whether or not this player has looted this block
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ default boolean hasPlayerLooted(@NotNull Player player) {
|
2016-05-02 05:54:08 +02:00
|
|
|
+ return hasPlayerLooted(player.getUniqueId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Has this player ever looted this block
|
|
|
|
+ * @param player The player to check
|
|
|
|
+ * @return Whether or not this player has looted this block
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ boolean hasPlayerLooted(@NotNull UUID player);
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the timestamp, in milliseconds, of when the player last looted this object
|
|
|
|
+ *
|
|
|
|
+ * @param player The player to check
|
|
|
|
+ * @return Timestamp last looted, or null if player has not looted this object
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @Nullable
|
|
|
|
+ default Long getLastLooted(@NotNull Player player) {
|
2016-05-02 05:54:08 +02:00
|
|
|
+ return getLastLooted(player.getUniqueId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the timestamp, in milliseconds, of when the player last looted this object
|
|
|
|
+ *
|
|
|
|
+ * @param player The player to check
|
|
|
|
+ * @return Timestamp last looted, or null if player has not looted this object
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @Nullable
|
|
|
|
+ Long getLastLooted(@NotNull UUID player);
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Change the state of whether or not a player has looted this block
|
|
|
|
+ * @param player The player to change state for
|
|
|
|
+ * @param looted true to add player to looted list, false to remove
|
|
|
|
+ * @return The previous state of whether the player had looted this or not
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ default boolean setHasPlayerLooted(@NotNull Player player, boolean looted) {
|
2016-05-02 05:54:08 +02:00
|
|
|
+ return setHasPlayerLooted(player.getUniqueId(), looted);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Change the state of whether or not a player has looted this block
|
|
|
|
+ * @param player The player to change state for
|
|
|
|
+ * @param looted true to add player to looted list, false to remove
|
|
|
|
+ * @return The previous state of whether the player had looted this or not
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ boolean setHasPlayerLooted(@NotNull UUID player, boolean looted);
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns Whether or not this object has been filled and now has a pending refill
|
|
|
|
+ * @return Has pending refill
|
|
|
|
+ */
|
|
|
|
+ boolean hasPendingRefill();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the timestamp in milliseconds that the Lootable object was last refilled
|
|
|
|
+ *
|
|
|
|
+ * @return -1 if it was never refilled, or timestamp in milliseconds
|
|
|
|
+ */
|
|
|
|
+ long getLastFilled();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Gets the timestamp in milliseconds that the Lootable object will refill
|
|
|
|
+ *
|
|
|
|
+ * @return -1 if it is not scheduled for refill, or timestamp in milliseconds
|
|
|
|
+ */
|
|
|
|
+ long getNextRefill();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Sets the timestamp in milliseconds of the next refill for this object
|
|
|
|
+ *
|
|
|
|
+ * @param refillAt timestamp in milliseconds. -1 to clear next refill
|
|
|
|
+ * @return The previous scheduled time to refill, or -1 if was not scheduled
|
|
|
|
+ */
|
|
|
|
+ long setNextRefill(long refillAt);
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java b/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java
|
|
|
|
new file mode 100644
|
2019-04-23 06:47:07 +02:00
|
|
|
index 00000000..fd184f13
|
2016-05-02 05:54:08 +02:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/com/destroystokyo/paper/loottable/LootableInventoryReplenishEvent.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -0,0 +1,45 @@
|
2016-05-02 05:54:08 +02:00
|
|
|
+package com.destroystokyo.paper.loottable;
|
|
|
|
+
|
|
|
|
+import org.bukkit.entity.Player;
|
|
|
|
+import org.bukkit.event.Cancellable;
|
|
|
|
+import org.bukkit.event.HandlerList;
|
|
|
|
+import org.bukkit.event.player.PlayerEvent;
|
2019-03-20 01:28:15 +01:00
|
|
|
+import org.jetbrains.annotations.NotNull;
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
|
|
|
+public class LootableInventoryReplenishEvent extends PlayerEvent implements Cancellable {
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull private final LootableInventory inventory;
|
2016-05-02 05:54:08 +02:00
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ public LootableInventoryReplenishEvent(@NotNull Player player, @NotNull LootableInventory inventory) {
|
2016-05-02 05:54:08 +02:00
|
|
|
+ super(player);
|
|
|
|
+ this.inventory = inventory;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2016-05-02 05:54:08 +02:00
|
|
|
+ public LootableInventory getInventory() {
|
|
|
|
+ return inventory;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static final HandlerList handlers = new HandlerList();
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2016-05-02 05:54:08 +02:00
|
|
|
+ public HandlerList getHandlers() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
2019-03-20 01:28:15 +01:00
|
|
|
+ @NotNull
|
2016-05-02 05:54:08 +02:00
|
|
|
+ public static HandlerList getHandlerList() {
|
|
|
|
+ return handlers;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private boolean cancelled = false;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public boolean isCancelled() {
|
|
|
|
+ return cancelled;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void setCancelled(boolean cancel) {
|
|
|
|
+ cancelled = cancel;
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/bukkit/block/Chest.java b/src/main/java/org/bukkit/block/Chest.java
|
2019-04-23 06:47:07 +02:00
|
|
|
index c67d7110..a569c7b6 100644
|
2016-05-02 05:54:08 +02:00
|
|
|
--- a/src/main/java/org/bukkit/block/Chest.java
|
|
|
|
+++ b/src/main/java/org/bukkit/block/Chest.java
|
2019-04-23 06:47:07 +02:00
|
|
|
@@ -1,5 +1,7 @@
|
2016-05-02 05:54:08 +02:00
|
|
|
package org.bukkit.block;
|
|
|
|
|
2019-04-23 06:47:07 +02:00
|
|
|
+import com.destroystokyo.paper.loottable.LootableBlockInventory; // Paper
|
|
|
|
+import org.bukkit.Nameable; // Paper
|
2016-05-02 05:54:08 +02:00
|
|
|
import org.bukkit.inventory.Inventory;
|
2018-08-12 19:11:08 +02:00
|
|
|
import org.bukkit.loot.Lootable;
|
2019-04-23 06:47:07 +02:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
@@ -7,7 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
2016-05-02 05:54:08 +02:00
|
|
|
/**
|
2017-08-06 00:36:47 +02:00
|
|
|
* Represents a captured state of a chest.
|
2016-05-02 05:54:08 +02:00
|
|
|
*/
|
2019-04-23 06:47:07 +02:00
|
|
|
-public interface Chest extends Container, Lootable {
|
|
|
|
+public interface Chest extends Container, LootableBlockInventory { // Paper
|
2016-05-02 05:54:08 +02:00
|
|
|
|
|
|
|
/**
|
2017-08-06 00:36:47 +02:00
|
|
|
* Gets the inventory of the chest block represented by this block state.
|
2016-05-02 05:54:08 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/block/Dispenser.java b/src/main/java/org/bukkit/block/Dispenser.java
|
2019-04-23 06:47:07 +02:00
|
|
|
index 74cd194c..07af1a3f 100644
|
2016-05-02 05:54:08 +02:00
|
|
|
--- a/src/main/java/org/bukkit/block/Dispenser.java
|
|
|
|
+++ b/src/main/java/org/bukkit/block/Dispenser.java
|
2018-08-12 19:11:08 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2016-05-02 05:54:08 +02:00
|
|
|
package org.bukkit.block;
|
|
|
|
|
2018-08-12 19:11:08 +02:00
|
|
|
+import com.destroystokyo.paper.loottable.LootableBlockInventory;
|
2016-11-19 05:58:56 +01:00
|
|
|
import org.bukkit.Nameable;
|
2018-08-12 19:11:08 +02:00
|
|
|
import org.bukkit.loot.Lootable;
|
2016-05-02 05:54:08 +02:00
|
|
|
import org.bukkit.projectiles.BlockProjectileSource;
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -8,7 +9,7 @@ import org.jetbrains.annotations.Nullable;
|
2016-05-02 05:54:08 +02:00
|
|
|
/**
|
2017-08-06 00:36:47 +02:00
|
|
|
* Represents a captured state of a dispenser.
|
2016-05-02 05:54:08 +02:00
|
|
|
*/
|
2018-08-12 19:11:08 +02:00
|
|
|
-public interface Dispenser extends Container, Nameable, Lootable {
|
|
|
|
+public interface Dispenser extends Container, Nameable, LootableBlockInventory { // Paper
|
2016-05-02 05:54:08 +02:00
|
|
|
|
|
|
|
/**
|
2017-08-06 00:36:47 +02:00
|
|
|
* Gets the BlockProjectileSource object for the dispenser.
|
2018-08-12 19:11:08 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/block/Dropper.java b/src/main/java/org/bukkit/block/Dropper.java
|
2019-04-23 06:47:07 +02:00
|
|
|
index 424392fb..c7620232 100644
|
2018-08-12 19:11:08 +02:00
|
|
|
--- a/src/main/java/org/bukkit/block/Dropper.java
|
|
|
|
+++ b/src/main/java/org/bukkit/block/Dropper.java
|
2019-04-23 06:47:07 +02:00
|
|
|
@@ -1,11 +1,12 @@
|
2018-08-12 19:11:08 +02:00
|
|
|
package org.bukkit.block;
|
|
|
|
|
|
|
|
+import com.destroystokyo.paper.loottable.LootableBlockInventory;
|
|
|
|
import org.bukkit.loot.Lootable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Represents a captured state of a dropper.
|
|
|
|
*/
|
2019-04-23 06:47:07 +02:00
|
|
|
-public interface Dropper extends Container, Lootable {
|
|
|
|
+public interface Dropper extends Container, LootableBlockInventory { // Paper
|
2018-08-12 19:11:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Tries to drop a randomly selected item from the dropper's inventory,
|
2016-05-02 05:54:08 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/block/Hopper.java b/src/main/java/org/bukkit/block/Hopper.java
|
2019-04-23 06:47:07 +02:00
|
|
|
index 58e49309..7ade312f 100644
|
2016-05-02 05:54:08 +02:00
|
|
|
--- a/src/main/java/org/bukkit/block/Hopper.java
|
|
|
|
+++ b/src/main/java/org/bukkit/block/Hopper.java
|
2019-04-23 06:47:07 +02:00
|
|
|
@@ -1,8 +1,9 @@
|
2016-05-02 05:54:08 +02:00
|
|
|
package org.bukkit.block;
|
|
|
|
|
2018-08-12 19:11:08 +02:00
|
|
|
+import com.destroystokyo.paper.loottable.LootableBlockInventory;
|
|
|
|
import org.bukkit.loot.Lootable;
|
2016-05-02 05:54:08 +02:00
|
|
|
|
|
|
|
/**
|
2017-08-06 00:36:47 +02:00
|
|
|
* Represents a captured state of a hopper.
|
2016-05-02 05:54:08 +02:00
|
|
|
*/
|
2019-04-23 06:47:07 +02:00
|
|
|
-public interface Hopper extends Container, Lootable { }
|
|
|
|
+public interface Hopper extends Container, LootableBlockInventory { } // Paper
|
2016-11-19 18:31:01 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/block/ShulkerBox.java b/src/main/java/org/bukkit/block/ShulkerBox.java
|
2019-04-23 06:47:07 +02:00
|
|
|
index 938f9aea..42f5b4ea 100644
|
2016-11-19 18:31:01 +01:00
|
|
|
--- a/src/main/java/org/bukkit/block/ShulkerBox.java
|
|
|
|
+++ b/src/main/java/org/bukkit/block/ShulkerBox.java
|
2018-08-12 19:11:08 +02:00
|
|
|
@@ -1,5 +1,6 @@
|
2016-11-19 18:31:01 +01:00
|
|
|
package org.bukkit.block;
|
|
|
|
|
2018-08-12 19:11:08 +02:00
|
|
|
+import com.destroystokyo.paper.loottable.LootableBlockInventory;
|
2016-11-19 18:31:01 +01:00
|
|
|
import org.bukkit.DyeColor;
|
2018-08-12 19:11:08 +02:00
|
|
|
import org.bukkit.loot.Lootable;
|
2019-04-23 06:47:07 +02:00
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
@@ -7,7 +8,7 @@ import org.jetbrains.annotations.NotNull;
|
2016-11-19 18:31:01 +01:00
|
|
|
/**
|
2017-08-06 00:36:47 +02:00
|
|
|
* Represents a captured state of a ShulkerBox.
|
2016-11-19 18:31:01 +01:00
|
|
|
*/
|
2019-04-23 06:47:07 +02:00
|
|
|
-public interface ShulkerBox extends Container, Lootable {
|
|
|
|
+public interface ShulkerBox extends Container, LootableBlockInventory { // Paper
|
2016-11-19 18:31:01 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the {@link DyeColor} corresponding to this ShulkerBox
|
2018-08-12 19:11:08 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java
|
2019-04-23 06:47:07 +02:00
|
|
|
index 937b99f8..db69687a 100644
|
2018-08-12 19:11:08 +02:00
|
|
|
--- a/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/minecart/HopperMinecart.java
|
|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
package org.bukkit.entity.minecart;
|
|
|
|
|
|
|
|
+import com.destroystokyo.paper.loottable.LootableEntityInventory;
|
|
|
|
import org.bukkit.entity.Minecart;
|
|
|
|
import org.bukkit.inventory.InventoryHolder;
|
|
|
|
import org.bukkit.loot.Lootable;
|
|
|
|
@@ -7,7 +8,7 @@ import org.bukkit.loot.Lootable;
|
|
|
|
/**
|
|
|
|
* Represents a Minecart with a Hopper inside it
|
|
|
|
*/
|
|
|
|
-public interface HopperMinecart extends Minecart, InventoryHolder, Lootable {
|
|
|
|
+public interface HopperMinecart extends Minecart, InventoryHolder, LootableEntityInventory {
|
|
|
|
|
|
|
|
/**
|
2019-04-23 06:47:07 +02:00
|
|
|
* Checks whether or not this Minecart will pick up
|
2018-08-12 19:11:08 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/entity/minecart/StorageMinecart.java b/src/main/java/org/bukkit/entity/minecart/StorageMinecart.java
|
2019-04-23 06:47:07 +02:00
|
|
|
index 9ea403e6..238d118f 100644
|
2018-08-12 19:11:08 +02:00
|
|
|
--- a/src/main/java/org/bukkit/entity/minecart/StorageMinecart.java
|
|
|
|
+++ b/src/main/java/org/bukkit/entity/minecart/StorageMinecart.java
|
|
|
|
@@ -1,5 +1,6 @@
|
|
|
|
package org.bukkit.entity.minecart;
|
|
|
|
|
|
|
|
+import com.destroystokyo.paper.loottable.LootableEntityInventory;
|
|
|
|
import org.bukkit.entity.Minecart;
|
|
|
|
import org.bukkit.inventory.InventoryHolder;
|
|
|
|
import org.bukkit.loot.Lootable;
|
|
|
|
@@ -9,5 +10,5 @@ import org.bukkit.loot.Lootable;
|
|
|
|
* minecarts} have their own inventory that can be accessed using methods
|
|
|
|
* from the {@link InventoryHolder} interface.
|
|
|
|
*/
|
|
|
|
-public interface StorageMinecart extends Minecart, InventoryHolder, Lootable {
|
|
|
|
+public interface StorageMinecart extends Minecart, InventoryHolder, LootableEntityInventory { // Paper
|
|
|
|
}
|
|
|
|
diff --git a/src/main/java/org/bukkit/loot/Lootable.java b/src/main/java/org/bukkit/loot/Lootable.java
|
2019-04-23 06:47:07 +02:00
|
|
|
index 24a3d989..901db852 100644
|
2018-08-12 19:11:08 +02:00
|
|
|
--- a/src/main/java/org/bukkit/loot/Lootable.java
|
|
|
|
+++ b/src/main/java/org/bukkit/loot/Lootable.java
|
2019-03-20 01:28:15 +01:00
|
|
|
@@ -36,6 +36,34 @@ public interface Lootable {
|
|
|
|
@Nullable
|
2018-08-12 19:11:08 +02:00
|
|
|
LootTable getLootTable();
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ /**
|
|
|
|
+ * Set the loot table and seed for a container or entity at the same time.
|
|
|
|
+ *
|
|
|
|
+ * @param table the Loot Table this {@link org.bukkit.block.Container} or {@link org.bukkit.entity.Mob} will have.
|
|
|
|
+ * @param seed the seed to used to generate loot. Default is 0.
|
|
|
|
+ */
|
2019-03-20 01:28:15 +01:00
|
|
|
+ default void setLootTable(@Nullable LootTable table, long seed) {
|
2018-08-26 20:11:49 +02:00
|
|
|
+ setLootTable(table);
|
|
|
|
+ setSeed(seed);
|
|
|
|
+ }
|
2018-08-12 19:11:08 +02:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns whether or not this object has a Loot Table
|
|
|
|
+ * @return Has a loot table
|
|
|
|
+ */
|
|
|
|
+ default boolean hasLootTable() {
|
|
|
|
+ return getLootTable() != null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Clears the associated Loot Table to this object
|
|
|
|
+ */
|
|
|
|
+ default void clearLootTable() {
|
|
|
|
+ setLootTable(null);
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
/**
|
|
|
|
* Set the seed used when this Loot Table generates loot.
|
|
|
|
*
|
2016-05-02 05:54:08 +02:00
|
|
|
--
|
2019-03-20 01:28:15 +01:00
|
|
|
2.21.0
|
2016-05-02 05:54:08 +02:00
|
|
|
|