public static bool emptyPouch(Player p, POUCHES pouch) { if (pouch != POUCHES.SMALL_POUCH && pouch != POUCHES.MEDIUM_POUCH && pouch != POUCHES.LARGE_POUCH && pouch != POUCHES.GIANT_POUCH) { return false; } int freeSpace = p.getInventory().getTotalFreeSlots(); int amount = 0; switch(pouch) { case POUCHES.SMALL_POUCH: amount = p.getSmallPouchAmount(); break; case POUCHES.MEDIUM_POUCH: amount = p.getMediumPouchAmount(); break; case POUCHES.LARGE_POUCH: amount = p.getLargePouchAmount(); break; case POUCHES.GIANT_POUCH: amount = p.getGiantPouchAmount(); break; } if (amount >= freeSpace) { amount = freeSpace; } for (int i = 0; i < amount; i++) { p.getInventory().addItem(ESSENCE); } setRemovePouchAmount(p, pouch, amount); return true; }
public static bool fillPouch(Player p, POUCHES pouch) { if (pouch != POUCHES.SMALL_POUCH && pouch != POUCHES.MEDIUM_POUCH && pouch != POUCHES.LARGE_POUCH && pouch != POUCHES.GIANT_POUCH) { return(false); } int amount = 0; int pouchAmount = 0; int invenEss = p.getInventory().getItemAmount(ESSENCE); switch (pouch) { case POUCHES.SMALL_POUCH: amount = 3; pouchAmount = p.getSmallPouchAmount(); break; case POUCHES.MEDIUM_POUCH: amount = 6; pouchAmount = p.getMediumPouchAmount(); break; case POUCHES.LARGE_POUCH: amount = 9; pouchAmount = p.getLargePouchAmount(); break; case POUCHES.GIANT_POUCH: amount = 12; pouchAmount = p.getGiantPouchAmount(); break; } amount = (amount - pouchAmount); if (invenEss <= 0) { return(true); } if (amount >= invenEss) { amount = invenEss; } if (amount <= 0) { p.getPackets().sendMessage("This pouch is full."); return(true); } for (int i = 0; i < amount; i++) { if (!p.getInventory().deleteItem(ESSENCE)) { p.getPackets().sendMessage("An error occured whilst deleting essence."); return(true); } } setAddPouchAmount(p, pouch, amount); return(true); }
private static void setRemovePouchAmount(Player p, POUCHES pouch, int amount) { switch (pouch) { case POUCHES.SMALL_POUCH: p.setSmallPouchAmount(p.getSmallPouchAmount() - amount); break; case POUCHES.MEDIUM_POUCH: p.setMediumPouchAmount(p.getMediumPouchAmount() - amount); break; case POUCHES.LARGE_POUCH: p.setLargePouchAmount(p.getLargePouchAmount() - amount); break; case POUCHES.GIANT_POUCH: p.setGiantPouchAmount(p.getGiantPouchAmount() - amount); break; } }
public static bool emptyPouch(Player p, POUCHES pouch) { if (pouch != POUCHES.SMALL_POUCH && pouch != POUCHES.MEDIUM_POUCH && pouch != POUCHES.LARGE_POUCH && pouch != POUCHES.GIANT_POUCH) { return(false); } int freeSpace = p.getInventory().getTotalFreeSlots(); int amount = 0; switch (pouch) { case POUCHES.SMALL_POUCH: amount = p.getSmallPouchAmount(); break; case POUCHES.MEDIUM_POUCH: amount = p.getMediumPouchAmount(); break; case POUCHES.LARGE_POUCH: amount = p.getLargePouchAmount(); break; case POUCHES.GIANT_POUCH: amount = p.getGiantPouchAmount(); break; } if (amount >= freeSpace) { amount = freeSpace; } for (int i = 0; i < amount; i++) { p.getInventory().addItem(ESSENCE); } setRemovePouchAmount(p, pouch, amount); return(true); }
public static bool fillPouch(Player p, POUCHES pouch) { if (pouch != POUCHES.SMALL_POUCH && pouch != POUCHES.MEDIUM_POUCH && pouch != POUCHES.LARGE_POUCH && pouch != POUCHES.GIANT_POUCH) { return false; } int amount = 0; int pouchAmount = 0; int invenEss = p.getInventory().getItemAmount(ESSENCE); switch (pouch) { case POUCHES.SMALL_POUCH: amount = 3; pouchAmount = p.getSmallPouchAmount(); break; case POUCHES.MEDIUM_POUCH: amount = 6; pouchAmount = p.getMediumPouchAmount(); break; case POUCHES.LARGE_POUCH: amount = 9; pouchAmount = p.getLargePouchAmount(); break; case POUCHES.GIANT_POUCH: amount = 12; pouchAmount = p.getGiantPouchAmount(); break; } amount = (amount - pouchAmount); if (invenEss <= 0) { return true; } if (amount >= invenEss) { amount = invenEss; } if (amount <= 0) { p.getPackets().sendMessage("This pouch is full."); return true; } for (int i = 0; i < amount; i++) { if (!p.getInventory().deleteItem(ESSENCE)) { p.getPackets().sendMessage("An error occured whilst deleting essence."); return true; } } setAddPouchAmount(p, pouch, amount); return true; }