From c1ea13885a16570cc9d004de14a56347289785a9 Mon Sep 17 00:00:00 2001 From: Alex 'mcmonkey' Goodwin Date: Sun, 22 Aug 2021 19:56:05 -0700 Subject: [PATCH] add exception to async check for paper's async tab packets also multiple meta improvements --- .../denizen/objects/MaterialTag.java | 2 +- .../scripts/commands/item/GiveCommand.java | 41 +++++++++++-------- .../handlers/DenizenNetworkManagerImpl.java | 4 +- 3 files changed, 29 insertions(+), 18 deletions(-) diff --git a/plugin/src/main/java/com/denizenscript/denizen/objects/MaterialTag.java b/plugin/src/main/java/com/denizenscript/denizen/objects/MaterialTag.java index 8a120ea48a..a7d60128f5 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/objects/MaterialTag.java +++ b/plugin/src/main/java/com/denizenscript/denizen/objects/MaterialTag.java @@ -419,7 +419,7 @@ public static void registerTags() { // @attribute // @returns ElementTag(Boolean) // @description - // Returns whether the material is a block that is solid (cannot be walked through). + // Returns whether the material is a block that is solid (can be built upon). // --> registerTag("is_solid", (attribute, object) -> { return new ElementTag(object.material.isSolid()); diff --git a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/GiveCommand.java b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/GiveCommand.java index d88d8e2be8..124e9b8617 100644 --- a/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/GiveCommand.java +++ b/plugin/src/main/java/com/denizenscript/denizen/scripts/commands/item/GiveCommand.java @@ -40,11 +40,19 @@ public GiveCommand() { // // @Description // Gives the linked player or inventory items, xp, or money. + // // Optionally specify a slot to put the items into. If the slot is already filled, the next available slot will be used. - // If the player's inventory is full, the items will be dropped on the ground at the inventory's location. + // If the inventory is full, the items will be dropped on the ground at the inventory's location. + // For player inventories, only the storage contents are valid - to equip armor or an offhand item, use <@link command equip>. + // // Specifying "unlimit_stack_size" will allow an item to stack up to 64. This is useful for stacking items // with a max stack size that is less than 64 (for example, most weapon and armor items have a stack size of 1). - // If an economy is registered, specifying money instead of a item will give money to the player's economy. + // + // When giving an item, you can specify any valid inventory as a target. If unspecified, the linked player's inventory will be used. + // + // If an economy is registered, specifying money instead of a item will give money to the linked player's economy. + // + // If 'xp' is specified, this will give experience points to the linked player. // // @Tags // @@ -127,14 +135,21 @@ else if (!scriptEntry.hasObject("slot") .defaultObject("quantity", new ElementTag(1)) .defaultObject("slot", new ElementTag(1)); Type type = (Type) scriptEntry.getObject("type"); - if (type != Type.MONEY && scriptEntry.getObject("inventory") == null) { - scriptEntry.addObject("inventory", Utilities.entryHasPlayer(scriptEntry) ? Utilities.getEntryPlayer(scriptEntry).getInventory() : null); - } - if (!scriptEntry.hasObject("inventory") && type != Type.MONEY) { - throw new InvalidArgumentsException("Must specify an inventory to give to!"); + if (type == Type.ITEM) { + if (!scriptEntry.hasObject("items")) { + throw new InvalidArgumentsException("Must specify item/items!"); + } + if (!scriptEntry.hasObject("inventory")) { + if (!Utilities.entryHasPlayer(scriptEntry)) { + throw new InvalidArgumentsException("Must specify an inventory to give to!"); + } + scriptEntry.addObject("inventory", Utilities.getEntryPlayer(scriptEntry).getInventory()); + } } - if (type == Type.ITEM && scriptEntry.getObject("items") == null) { - throw new InvalidArgumentsException("Must specify item/items!"); + else { + if (!Utilities.entryHasPlayer(scriptEntry)) { + throw new InvalidArgumentsException("Must link a player to give money or XP!"); + } } } @@ -151,13 +166,7 @@ public void execute(ScriptEntry scriptEntry) { items = (List) items_object; } if (scriptEntry.dbCallShouldDebug()) { - Debug.report(scriptEntry, getName(), - ArgumentHelper.debugObj("Type", type.name()) - + (inventory != null ? inventory.debug() : "") - + quantity.debug() - + unlimit_stack_size.debug() - + (items != null ? ArgumentHelper.debugObj("Items", items) : "") - + slot.debug()); + Debug.report(scriptEntry, getName(), ArgumentHelper.debugObj("Type", type.name()), inventory, quantity, unlimit_stack_size, (items != null ? ArgumentHelper.debugObj("Items", items) : ""), slot); } switch (type) { case MONEY: diff --git a/v1_17/src/main/java/com/denizenscript/denizen/nms/v1_17/impl/network/handlers/DenizenNetworkManagerImpl.java b/v1_17/src/main/java/com/denizenscript/denizen/nms/v1_17/impl/network/handlers/DenizenNetworkManagerImpl.java index ffe4d008a1..e5d26927eb 100644 --- a/v1_17/src/main/java/com/denizenscript/denizen/nms/v1_17/impl/network/handlers/DenizenNetworkManagerImpl.java +++ b/v1_17/src/main/java/com/denizenscript/denizen/nms/v1_17/impl/network/handlers/DenizenNetworkManagerImpl.java @@ -165,7 +165,9 @@ public void send(Packet packet, GenericFutureListener