diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/action/BukkitActionManager.java b/core/src/main/java/net/momirealms/customfishing/bukkit/action/BukkitActionManager.java index bc2ea80a..d3d600e2 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/action/BukkitActionManager.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/action/BukkitActionManager.java @@ -448,6 +448,7 @@ public class BukkitActionManager implements ActionManager { if (args instanceof Section section) { String id = section.getString("item"); int amount = section.getInt("amount", 1); + boolean toInventory = section.getBoolean("to-inventory", false); return context -> { if (Math.random() > chance) return; Player player = context.getHolder(); @@ -460,7 +461,11 @@ public class BukkitActionManager implements ActionManager { amountToGive -= perStackSize; ItemStack more = itemStack.clone(); more.setAmount(perStackSize); - PlayerUtils.dropItem(player, itemStack, true, true, false); + if (toInventory) { + PlayerUtils.giveItem(player, itemStack, itemStack.getAmount()); + } else { + PlayerUtils.dropItem(player, itemStack, true, true, false); + } } } }; diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/command/feature/GetItemCommand.java b/core/src/main/java/net/momirealms/customfishing/bukkit/command/feature/GetItemCommand.java index 82e8738b..44b0d495 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/command/feature/GetItemCommand.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/command/feature/GetItemCommand.java @@ -59,8 +59,10 @@ public class GetItemCommand extends BukkitCommandFeature { })) .optional("amount", IntegerParser.integerParser(1, 6400)) .flag(manager.flagBuilder("silent").withAliases("s").build()) + .flag(manager.flagBuilder("to-inventory").withAliases("t").build()) .handler(context -> { final int amount = context.getOrDefault("amount", 1); + boolean toInv = context.flags().hasFlag("to-inventory"); final String id = context.get("id"); final Player player = context.sender(); try { @@ -75,7 +77,11 @@ public class GetItemCommand extends BukkitCommandFeature { amountToGive -= perStackSize; ItemStack more = itemStack.clone(); more.setAmount(perStackSize); - PlayerUtils.dropItem(player, more, false, true, false); + if (toInv) { + PlayerUtils.putItemsToInventory(player.getInventory(), more, more.getAmount()); + } else { + PlayerUtils.dropItem(player, more, false, true, false); + } } handleFeedback(context, MessageConstants.COMMAND_ITEM_GET_SUCCESS, Component.text(amount), Component.text(id)); } catch (NullPointerException e) { diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/command/feature/GiveItemCommand.java b/core/src/main/java/net/momirealms/customfishing/bukkit/command/feature/GiveItemCommand.java index ce1870d7..24af0952 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/command/feature/GiveItemCommand.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/command/feature/GiveItemCommand.java @@ -60,10 +60,12 @@ public class GiveItemCommand extends BukkitCommandFeature { })) .optional("amount", IntegerParser.integerParser(1, 6400)) .flag(manager.flagBuilder("silent").withAliases("s").build()) + .flag(manager.flagBuilder("to-inventory").withAliases("t").build()) .handler(context -> { final Player player = context.get("player"); final int amount = context.getOrDefault("amount", 1); final String id = context.get("id"); + boolean toInv = context.flags().hasFlag("to-inventory"); try { ItemStack itemStack = BukkitCustomFishingPlugin.getInstance().getItemManager().buildInternal(Context.player(player).arg(ContextKeys.ID, id), id); if (itemStack == null) { @@ -76,7 +78,11 @@ public class GiveItemCommand extends BukkitCommandFeature { amountToGive -= perStackSize; ItemStack more = itemStack.clone(); more.setAmount(perStackSize); - PlayerUtils.dropItem(player, more, false, true, false); + if (toInv) { + PlayerUtils.putItemsToInventory(player.getInventory(), more, more.getAmount()); + } else { + PlayerUtils.dropItem(player, more, false, true, false); + } } handleFeedback(context, MessageConstants.COMMAND_ITEM_GIVE_SUCCESS, Component.text(player.getName()), Component.text(amount), Component.text(id)); } catch (NullPointerException e) { diff --git a/core/src/main/java/net/momirealms/customfishing/bukkit/util/PlayerUtils.java b/core/src/main/java/net/momirealms/customfishing/bukkit/util/PlayerUtils.java index 6ab13e29..f982aa63 100644 --- a/core/src/main/java/net/momirealms/customfishing/bukkit/util/PlayerUtils.java +++ b/core/src/main/java/net/momirealms/customfishing/bukkit/util/PlayerUtils.java @@ -38,6 +38,7 @@ public class PlayerUtils { Location location = player.getLocation().clone(); Item item = player.getWorld().dropItem(player.getEyeLocation().clone().subtract(new Vector(0,0.3,0)), itemStack); item.setPickupDelay(noPickUpDelay ? 0 : 40); + item.setOwner(player.getUniqueId()); if (retainOwnership) { item.setThrower(player.getUniqueId()); }