public static void displayMerch(MapleClient c) { int conv = c.getPlayer().getConversation(); boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId()); MerchItemPackage pack; if (merch) { c.getPlayer().dropMessage(1, "Please close the existing store and try again."); c.getPlayer().setConversation(0); } else if (c.getChannelServer().isShutdown()) { c.getPlayer().dropMessage(1, "The world is going to shut down."); c.getPlayer().setConversation(0); } else if (conv == 3) { pack = loadItemFrom_Database(c.getPlayer().getAccountID()); if (pack == null) { c.getPlayer().dropMessage(1, "You do not have any item(s) with Fredrick."); c.getPlayer().setConversation(0); } else if (pack.getItems().size() <= 0) { if (!check(c.getPlayer(), pack)) { c.getSession().write(PlayerShopPacket.merchItem_Message(33)); return; } if (deletePackage( c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId())) { c.getPlayer().fakeRelog(); c.getPlayer().gainMeso(pack.getMesos(), false); c.getSession().write(PlayerShopPacket.merchItem_Message(29)); c.getPlayer().dropMessage(1, "You have retrieved your mesos."); } else { c.getPlayer().dropMessage(1, "An unknown error occured."); } c.getPlayer().setConversation(0); } else { c.getSession().write(PlayerShopPacket.merchItemStore_ItemData(pack)); MapleInventoryManipulator.checkSpace(c, conv, conv, null); for (Item item : pack.getItems()) { if (c.getPlayer() .getInventory(GameConstants.getInventoryType(item.getItemId())) .isFull()) { c.removeClickedNPC(); c.getPlayer().dropMessage(1, "Your inventory is full (Please relog)"); break; } MapleInventoryManipulator.addFromDrop(c, item, true); deletePackage(c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId()); c.removeClickedNPC(); } c.getPlayer().dropMessage(1, "Items have been returned to you, please relog."); } } c.getSession().write(CWvsContext.enableActions()); }
private static void requestItems(MapleClient c, boolean request) { if (c.getPlayer().getConversation() != 3) { return; } boolean merch = World.hasMerchant(c.getPlayer().getAccountID(), c.getPlayer().getId()); if (merch) { c.getPlayer().dropMessage(1, "Please close the existing store and try again."); c.getPlayer().setConversation(0); return; } MerchItemPackage pack = loadItemFrom_Database(c.getPlayer().getAccountID()); if (pack == null) { c.getPlayer().dropMessage(1, "An unknown error occured."); return; } if (c.getChannelServer().isShutdown()) { c.getPlayer().dropMessage(1, "The world is going to shut down."); c.getPlayer().setConversation(0); return; } int days = StringUtil.getDaysAmount(pack.getSavedTime(), System.currentTimeMillis()); double percentage = days / 100.0D; int fee = (int) Math.ceil(percentage * pack.getMesos()); if ((request) && (days > 0) && (percentage > 0.0D) && (pack.getMesos() > 0) && (fee > 0)) { c.getSession().write(PlayerShopPacket.merchItemStore((byte) 38, days, fee)); return; } if (fee < 0) { c.getSession().write(PlayerShopPacket.merchItem_Message(33)); return; } if (c.getPlayer().getMeso() < fee) { c.getSession().write(PlayerShopPacket.merchItem_Message(35)); return; } if (!check(c.getPlayer(), pack)) { c.getSession().write(PlayerShopPacket.merchItem_Message(36)); return; } if (deletePackage(c.getPlayer().getAccountID(), pack.getPackageid(), c.getPlayer().getId())) { if (fee > 0) { c.getPlayer().gainMeso(-fee, true); } c.getPlayer().gainMeso(pack.getMesos(), false); for (Item item : pack.getItems()) { MapleInventoryManipulator.addFromDrop(c, item, false); } c.getSession().write(PlayerShopPacket.merchItem_Message(32)); } else { c.getPlayer().dropMessage(1, "An unknown error occured."); } }