1
0
mirror of https://github.com/mcMMO-Dev/mcMMO.git synced 2025-07-05 15:14:44 +02:00

Assorted cleanup.

This commit is contained in:
GJ
2014-02-27 10:56:21 -05:00
parent 1d7e034d5e
commit 0056be2d5f
33 changed files with 55 additions and 187 deletions

@ -2,7 +2,6 @@ package com.gmail.nossr50.skills.alchemy;
import java.util.List;
import com.gmail.nossr50.util.Permissions;
import org.bukkit.inventory.ItemStack;
import com.gmail.nossr50.config.experience.ExperienceConfig;

@ -124,25 +124,24 @@ public final class AlchemyPotionBrewer {
}
}
public static boolean transferItems(InventoryView view, int fromSlot, int toSlot, ClickType click) {
public static boolean transferItems(InventoryView view, int fromSlot, ClickType click) {
boolean success = false;
if (click.isLeftClick()) {
success = transferItems(view, fromSlot, toSlot);
success = transferItems(view, fromSlot);
}
else if (click.isRightClick()) {
success = transferOneItem(view, fromSlot, toSlot);
success = transferOneItem(view, fromSlot);
}
return success;
}
private static boolean transferOneItem(InventoryView view, int fromSlot, int toSlot) {
private static boolean transferOneItem(InventoryView view, int fromSlot) {
ItemStack from = view.getItem(fromSlot).clone();
ItemStack to = view.getItem(toSlot).clone();
boolean emptyFrom = isEmpty(from);
ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone();
if (emptyFrom) {
if (isEmpty(from)) {
return false;
}
@ -162,8 +161,8 @@ public final class AlchemyPotionBrewer {
}
from.setAmount(fromAmount - 1);
view.setItem(toSlot, emptyTo ? null : to);
view.setItem(fromSlot, emptyFrom ? null : from);
view.setItem(Alchemy.INGREDIENT_SLOT, emptyTo ? null : to);
view.setItem(fromSlot, from);
return true;
}
@ -174,15 +173,15 @@ public final class AlchemyPotionBrewer {
/**
* Transfer items between two ItemStacks, returning the leftover status
*/
private static boolean transferItems(InventoryView view, int fromSlot, int toSlot) {
private static boolean transferItems(InventoryView view, int fromSlot) {
ItemStack from = view.getItem(fromSlot).clone();
ItemStack to = view.getItem(toSlot).clone();
ItemStack to = view.getItem(Alchemy.INGREDIENT_SLOT).clone();
if (isEmpty(from)) {
return false;
}
else if (isEmpty(to)) {
view.setItem(toSlot, from);
view.setItem(Alchemy.INGREDIENT_SLOT, from);
view.setItem(fromSlot, null);
return true;
@ -196,7 +195,7 @@ public final class AlchemyPotionBrewer {
int left = fromAmount + toAmount - maxSize;
to.setAmount(maxSize);
view.setItem(toSlot, to);
view.setItem(Alchemy.INGREDIENT_SLOT, to);
from.setAmount(left);
view.setItem(fromSlot, from);
@ -206,7 +205,7 @@ public final class AlchemyPotionBrewer {
to.setAmount(fromAmount + toAmount);
view.setItem(fromSlot, null);
view.setItem(toSlot, to);
view.setItem(Alchemy.INGREDIENT_SLOT, to);
return true;
}