Exemplo n.º 1
0
 public Item toItem(CashItem cItem, int uniqueid, String gift) {
   if (uniqueid <= 0) {
     uniqueid = MapleInventoryIdentifier.getInstance();
   }
   long period = cItem.getExpire();
   if ((period <= 0
           && GameConstants.getInventoryType(cItem.getItemId()) != MapleInventoryType.EQUIP)
       || GameConstants.isPet(cItem.getItemId())) {
     period = GameConstants.GMS ? 90 : 45;
   }
   if (cItem.getItemId() >= 5000100 && cItem.getItemId() < 5000200) { // permanent pet
     period = 20000; // permanent time millis
   }
   Item ret;
   if (GameConstants.getInventoryType(cItem.getItemId()) == MapleInventoryType.EQUIP) {
     Equip eq =
         (Equip)
             MapleItemInformationProvider.getInstance().getEquipById(cItem.getItemId(), uniqueid);
     if (period > 0) {
       eq.setExpiration(
           (long) (System.currentTimeMillis() + (long) (period * 24 * 60 * 60 * 1000)));
     }
     eq.setGMLog("Cash Shop: " + cItem.getSN() + " on " + FileoutputUtil.CurrentReadable_Date());
     eq.setGiftFrom(gift);
     if (GameConstants.isEffectRing(cItem.getItemId()) && uniqueid > 0) {
       MapleRing ring = MapleRing.loadFromDb(uniqueid);
       if (ring != null) {
         eq.setRing(ring);
       }
     }
     ret = eq.copy();
   } else {
     Item item =
         new Item(cItem.getItemId(), (byte) 0, (short) cItem.getQuantity(), (byte) 0, uniqueid);
     if (period > 0) {
       item.setExpiration(
           (long) (System.currentTimeMillis() + (long) (period * 24 * 60 * 60 * 1000)));
     }
     item.setGMLog("Cash Shop: " + cItem.getSN() + " on " + FileoutputUtil.CurrentReadable_Date());
     item.setGiftFrom(gift);
     if (GameConstants.isPet(cItem.getItemId())) {
       final MaplePet pet = MaplePet.createPet(cItem.getItemId(), uniqueid);
       if (pet != null) {
         item.setPet(pet);
       }
     }
     ret = item.copy();
   }
   return ret;
 }
Exemplo n.º 2
0
 public void checkExpire(MapleClient c) {
   List<Item> toberemove = new ArrayList<>();
   for (Item item : inventory) {
     if (item != null
         && !GameConstants.isPet(item.getItemId())
         && item.getExpiration() > 0
         && item.getExpiration() < System.currentTimeMillis()) {
       toberemove.add(item);
     }
   }
   if (toberemove.size() > 0) {
     for (Item item : toberemove) {
       removeFromInventory(item);
       c.getSession().write(CSPacket.cashItemExpired(item.getUniqueId()));
     }
     toberemove.clear();
   }
 }