From ee9d8ea63be3fc58a3c73028d8442ccbe25570ef Mon Sep 17 00:00:00 2001 From: Hendrik Brummermann Date: Tue, 12 Apr 2011 17:43:50 +0000 Subject: [PATCH] backported fix for "Xhiphin takes more than one flask of water"- ID: 3284741 reported by monsterdhal. The action now defaults to only taking 1 item but you could also specify a larger amount (by kymara) --- .../npc/action/DropInfostringItemAction.java | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/games/stendhal/server/entity/npc/action/DropInfostringItemAction.java b/src/games/stendhal/server/entity/npc/action/DropInfostringItemAction.java index bb74d6bad8..0b70e6a200 100644 --- a/src/games/stendhal/server/entity/npc/action/DropInfostringItemAction.java +++ b/src/games/stendhal/server/entity/npc/action/DropInfostringItemAction.java @@ -32,6 +32,7 @@ public class DropInfostringItemAction implements ChatAction { private static Logger logger = Logger.getLogger(DropItemAction.class); private final String itemName; private final String infostring; + private final int amount; /** * Creates a new DropInfostringItemAction. @@ -43,6 +44,23 @@ public class DropInfostringItemAction implements ChatAction { */ public DropInfostringItemAction(final String itemName, final String infostring) { this.itemName = itemName; + this.amount = 1; + this.infostring = infostring; + } + + /** + * Creates a new DropInfostringItemAction. + * + * @param itemName + * name of item + * @param amount + * amount of item + * @param infostring + * infostring of the dropped item + */ + public DropInfostringItemAction(final String itemName, final int amount, final String infostring) { + this.itemName = itemName; + this.amount = amount; this.infostring = infostring; } @@ -51,7 +69,7 @@ public class DropInfostringItemAction implements ChatAction { boolean res = false; for (final Item item : items) { if (infostring.equalsIgnoreCase(item.getInfoString())) { - res = player.drop(item); + res = player.drop(item.getName(), amount); break; } } @@ -64,7 +82,7 @@ public class DropInfostringItemAction implements ChatAction { @Override public String toString() { - return "drop item <" + itemName + "> with infostring <" + infostring + ">"; + return "drop " + amount + " of item <" + itemName + "> with infostring <" + infostring + ">"; } @Override @@ -87,6 +105,9 @@ public class DropInfostringItemAction implements ChatAction { if (!infostring.equals(other.infostring)) { return false; } + if (amount != other.amount) { + return false; + } if (itemName == null) { if (other.itemName != null) { return false;