summaryrefslogtreecommitdiffstats
path: root/bukkit/src/main
diff options
context:
space:
mode:
authorKrakenied <Krakenied1@gmail.com>2024-07-27 00:04:37 +0200
committerKrakenied <46192742+Krakenied@users.noreply.github.com>2024-08-28 11:37:11 +0200
commite2a644f875eaef26c8763e4b95fca1792a100f53 (patch)
tree658aa8c0846c9ca9d01c492d1991634fa2a7a8a6 /bukkit/src/main
parent5567117cea151d32cef11cb5f01fd6293b2250af (diff)
Drop items that could not be stored
Closes https://github.com/LMBishop/Quests/issues/680
Diffstat (limited to 'bukkit/src/main')
-rw-r--r--bukkit/src/main/java/com/leonardobishop/quests/bukkit/command/AdminItemsCommandHandler.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/command/AdminItemsCommandHandler.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/command/AdminItemsCommandHandler.java
index 32558673..1221e34f 100644
--- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/command/AdminItemsCommandHandler.java
+++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/command/AdminItemsCommandHandler.java
@@ -17,6 +17,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
public class AdminItemsCommandHandler implements CommandHandler {
@@ -91,9 +92,15 @@ public class AdminItemsCommandHandler implements CommandHandler {
amount = Integer.parseInt(args[5]);
}
item.setAmount(amount);
+
// if we got this far, all was well.
// just give the item to the player already ;)
- targetPlayer.getInventory().addItem(item);
+ Map<Integer, ItemStack> itemsToDrop = targetPlayer.getInventory().addItem(item);
+
+ // drop items that could not be stored
+ for (ItemStack itemToDrop : itemsToDrop.values()) {
+ targetPlayer.getWorld().dropItem(targetPlayer.getLocation(), itemToDrop);
+ }
}
}