From 24cb66a5a6ff30615e8b3603e90b7ff5ca7de95e Mon Sep 17 00:00:00 2001 From: Morphan1 Date: Fri, 11 Mar 2016 16:43:22 -0500 Subject: [PATCH] Add "offhand" to EquipCommand, fixes #1334 --- .../scripts/commands/BukkitCommandRegistry.java | 4 ++-- .../scripts/commands/entity/EquipCommand.java | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/BukkitCommandRegistry.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/BukkitCommandRegistry.java index 9a03975f52..37abd368b0 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/BukkitCommandRegistry.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/BukkitCommandRegistry.java @@ -989,7 +989,7 @@ public void registerCoreMembers() { // <--[command] // @Name Equip - // @Syntax equip (|...) (hand:) (head:) (chest:) (legs:) (boots:) (saddle:) (horse_armor:) + // @Syntax equip (|...) (hand:) (offhand:) (head:) (chest:) (legs:) (boots:) (saddle:) (horse_armor:) // @Required 1 // @Stable stable // @Short Equips items and armor on a list of entities. @@ -1017,7 +1017,7 @@ public void registerCoreMembers() { // - equip e@pig saddle:i@saddle // --> registerCoreMember(EquipCommand.class, - "EQUIP", "equip (|...) (hand:) (head:) (chest:) (legs:) (boots:) (saddle:) (horse_armor:)", 1); + "EQUIP", "equip (|...) (offhand:) (hand:) (head:) (chest:) (legs:) (boots:) (saddle:) (horse_armor:)", 1); // <--[command] diff --git a/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/EquipCommand.java b/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/EquipCommand.java index d1668340be..3807e0f012 100644 --- a/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/EquipCommand.java +++ b/src/main/java/net/aufdemrand/denizen/scripts/commands/entity/EquipCommand.java @@ -69,6 +69,11 @@ else if (arg.matchesArgumentType(dItem.class) equipment.put("horse_armor", dItem.valueOf(arg.getValue())); } + else if (arg.matchesArgumentType(dItem.class) + && arg.matchesPrefix("offhand")) { + equipment.put("offhand", dItem.valueOf(arg.getValue())); + } + // Default to item in hand if no prefix is used else if (arg.matchesArgumentType(dItem.class)) { equipment.put("hand", dItem.valueOf(arg.getValue())); @@ -137,6 +142,9 @@ else if (entity.isCitizensNPC()) { if (equipment.get("boots") != null) { trait.set(4, equipment.get("boots").getItemStack()); } + if (equipment.get("offhand") != null) { + trait.set(5, equipment.get("offhand").getItemStack()); + } } } @@ -168,7 +176,7 @@ else if (livingEntity.getType() == EntityType.PIG) { else { if (equipment.get("hand") != null) { - livingEntity.getEquipment().setItemInHand(equipment.get("hand").getItemStack()); + livingEntity.getEquipment().setItemInMainHand(equipment.get("hand").getItemStack()); } if (equipment.get("head") != null) { livingEntity.getEquipment().setHelmet(equipment.get("head").getItemStack()); @@ -182,6 +190,9 @@ else if (livingEntity.getType() == EntityType.PIG) { if (equipment.get("boots") != null) { livingEntity.getEquipment().setBoots(equipment.get("boots").getItemStack()); } + if (equipment.get("offhand") != null) { + livingEntity.getEquipment().setItemInOffHand(equipment.get("offhand").getItemStack()); + } } } }