Skip to content

Commit

Permalink
Fix - take bydisplay:...
Browse files Browse the repository at this point in the history
This is to fix rare situations in which it would remove two items rather
than just one.
  • Loading branch information
mcmonkey4eva committed Nov 2, 2013
1 parent 0d9b3f8 commit cc5dd8f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 7 deletions.
Expand Up @@ -42,7 +42,7 @@ public static void _initialize() throws IOException, ClassNotFoundException {
dB.echoApproval("Added objects to the ObjectFetcher " + adding.keySet().toString());
fetchable_objects.clear();
}

public static void _registerCoreObjects() throws NoSuchMethodException, ClassNotFoundException, IOException {

// Initialize the ObjectFetcher
Expand All @@ -61,9 +61,9 @@ public static void _registerCoreObjects() throws NoSuchMethodException, ClassNot
registerWithObjectFetcher(Element.class); // el@
registerWithObjectFetcher(Duration.class); // d@
registerWithObjectFetcher(dChunk.class); // ch@

_initialize();

}

private static ArrayList<Class> fetchable_objects = new ArrayList<Class>();
Expand Down
Expand Up @@ -24,7 +24,7 @@ public class HealCommand extends AbstractCommand {

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

boolean specified_targets = false;

for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
Expand Down
Expand Up @@ -24,7 +24,7 @@ public class HurtCommand extends AbstractCommand {

@Override
public void parseArgs(ScriptEntry scriptEntry) throws InvalidArgumentsException {

boolean specified_targets = false;

for (aH.Argument arg : aH.interpret(scriptEntry.getArguments())) {
Expand Down
Expand Up @@ -2,6 +2,7 @@

import java.util.List;

import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;

Expand Down Expand Up @@ -178,14 +179,15 @@ else if (!inventory.getInventory().removeItem(is).isEmpty())
for (ItemStack it : inventory.getContents()) {
if (found_items < qty.asInt() && it != null && it.hasItemMeta() && it.getItemMeta().hasDisplayName() &&
it.getItemMeta().getDisplayName().equalsIgnoreCase(displayname.identify())) {
int amt = it.getAmount();
if (found_items + it.getAmount() <= qty.asInt()) {
inventory.remove(it);
inventory.getInventory().removeItem(it);
}
else {
it.setAmount(it.getAmount() - (qty.asInt() - found_items));
break;
}
found_items += it.getAmount();
found_items += amt;
}
}
break;
Expand Down

0 comments on commit cc5dd8f

Please sign in to comment.