コード例 #1
0
 public static boolean checkSpace(
     final MapleClient c, final int Id, int quantity, final String owner) {
   final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   final MapleInventoryType type = ii.getInventoryType(Id);
   if (!type.equals(MapleInventoryType.EQUIP)) {
     final short slotMax = ii.getSlotMax(c, Id);
     final List<IItem> existing = c.getPlayer().getInventory(type).listById(Id);
     if (!InventoryConstants.isRechargable(Id)) {
       if (existing.size() > 0) {
         for (IItem eItem : existing) {
           final short oldQ = eItem.getQuantity();
           if (oldQ < slotMax && owner.equals(eItem.getOwner())) {
             final short newQ = (short) Math.min(oldQ + quantity, slotMax);
             quantity -= (newQ - oldQ);
           }
           if (quantity <= 0) {
             break;
           }
         }
       }
     }
     final int numSlotsNeeded;
     if (slotMax > 0) {
       numSlotsNeeded = (int) (Math.ceil(((double) quantity) / slotMax));
     } else if (InventoryConstants.isRechargable(Id)) {
       numSlotsNeeded = 1;
     } else {
       numSlotsNeeded = 1;
       System.out.println("checkSpace error");
     }
     return !c.getPlayer().getInventory(type).isFull(numSlotsNeeded - 1);
   } else {
     return !c.getPlayer().getInventory(type).isFull();
   }
 }
コード例 #2
0
 private static final void dropItem(MapleClient c, IItem target, Point dropPos) {
   if (MapleItemInformationProvider.getInstance().isDropRestricted(target.getId())
       || c.getPlayer().gmLevel() == 1
       || c.getPlayer().gmLevel() == 2) {
     c.getPlayer()
         .getMap()
         .disappearingItemDrop(
             c.getPlayer().getObjectId(),
             c.getPlayer().getPosition(),
             c.getPlayer(),
             target,
             dropPos);
   } else {
     c.getPlayer()
         .getMap()
         .spawnItemDrop(
             c.getPlayer().getObjectId(),
             c.getPlayer().getPosition(),
             c.getPlayer(),
             target,
             dropPos,
             true,
             !c.getPlayer().getMap().getEverlast());
   }
 }
コード例 #3
0
ファイル: Start.java プロジェクト: eee123666/mapleLemon
  public static void loadData(boolean reload) {
    System.out.println("载入数据(因为数据量大可能比较久而且内存消耗会飙升)");

    System.out.println("加载等级经验数据");
    GameConstants.LoadEXP();

    System.out.println("加载排名信息数据");
    MapleGuildRanking.getInstance().load(reload);

    // System.out.println("加载公会数据并清理不存在公会");
    // MapleGuild.loadAll();

    System.out.println("加载任务数据");
    // 加载任务信息
    MapleLifeFactory.loadQuestCounts(reload);
    // 加载转存到数据库的任务信息
    MapleQuest.initQuests(reload);

    System.out.println("加载爆物数据");
    // 加载爆物数据
    MapleMonsterInformationProvider.getInstance().addExtra();
    // 加载全域爆物数据
    MapleMonsterInformationProvider.getInstance().load();

    System.out.println("加载道具数据");
    // 加载道具信息(从WZ)
    MapleItemInformationProvider.getInstance().runEtc(reload);
    // 加载道具信息(从SQL)
    MapleItemInformationProvider.getInstance().runItems(reload);
    // 加载发型脸型
    MapleItemInformationProvider.getInstance().loadHairFace(reload);

    System.out.println("加载技能数据");
    // 加载技能
    SkillFactory.loadAllSkills(reload);

    MobSkillFactory.getInstance(); // 载入怪物技能

    System.out.println("loadSpeedRuns");
    // ?
    SpeedRunner.loadSpeedRuns(reload);

    System.out.println("加载商城道具数据");
    // 加载商城道具信息
    CashItemFactory.getInstance().initialize(reload);
    System.out.println("数据载入完成!\r\n");
  }
コード例 #4
0
 public static boolean addRing(final MapleCharacter chr, final int Id, final int ringId) {
   MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   MapleInventoryType type = ii.getInventoryType(Id);
   IItem nEquip = ii.getEquipById(Id, ringId);
   short newSlot = chr.getInventory(type).addItem(nEquip);
   if (newSlot == -1) {
     return false;
   }
   chr.getClient().announce(InventoryFactory.addInventorySlot(type, nEquip));
   return true;
 }
コード例 #5
0
  public static boolean addRing(MapleCharacter chr, int itemId, int ringId) {
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    MapleInventoryType type = ii.getInventoryType(itemId);
    IItem nEquip = ii.getEquipById(itemId, ringId);

    byte newSlot = chr.getInventory(type).addItem(nEquip);
    if (newSlot == -1) {
      return false;
    }
    chr.getClient().getSession().write(MaplePacketCreator.addInventorySlot(type, nEquip));
    return true;
  }
コード例 #6
0
ファイル: CashShop.java プロジェクト: jerbe/Acernis-v144
 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;
 }
コード例 #7
0
 public static void removeAllById(MapleClient c, int itemId, boolean checkEquipped) {
   MapleInventoryType type = MapleItemInformationProvider.getInstance().getInventoryType(itemId);
   for (IItem item : c.getPlayer().getInventory(type).listById(itemId)) {
     if (item != null) {
       removeFromSlot(c, type, item.getPosition(), item.getQuantity(), true, false);
     }
   }
   if (checkEquipped) {
     IItem ii = c.getPlayer().getInventory(type).findById(itemId);
     if (ii != null) {
       c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).removeItem(ii.getPosition());
       c.getPlayer().equipChanged();
     }
   }
 }
コード例 #8
0
 private boolean fitsInInventory() {
   MapleItemInformationProvider mii = MapleItemInformationProvider.getInstance();
   Map<MapleInventoryType, Integer> neededSlots = new LinkedHashMap<MapleInventoryType, Integer>();
   for (IItem item : exchangeItems) {
     MapleInventoryType type = mii.getInventoryType(item.getItemId());
     if (neededSlots.get(type) == null) {
       neededSlots.put(type, 1);
     } else {
       neededSlots.put(type, neededSlots.get(type) + 1);
     }
   }
   for (Map.Entry<MapleInventoryType, Integer> entry : neededSlots.entrySet()) {
     if (chr.getInventory(entry.getKey()).isFull(entry.getValue() - 1)) {
       return false;
     }
   }
   return true;
 }
コード例 #9
0
 public static void removeFromSlot(
     MapleClient c,
     MapleInventoryType type,
     byte slot,
     short quantity,
     boolean fromDrop,
     boolean consume) {
   IItem item = c.getPlayer().getInventory(type).getItem(slot);
   MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   boolean allowZero =
       consume && (ii.isThrowingStar(item.getItemId()) || ii.isBullet(item.getItemId()));
   c.getPlayer().getInventory(type).removeItem(slot, quantity, allowZero);
   if (item.getQuantity() == 0 && !allowZero) {
     c.getSession()
         .write(MaplePacketCreator.clearInventoryItem(type, item.getPosition(), fromDrop));
   } else {
     c.getSession().write(MaplePacketCreator.updateInventorySlot(type, (Item) item, fromDrop));
   }
 }
コード例 #10
0
  public static void move(
      final MapleClient c, final MapleInventoryType type, final short src, final short dst) {
    if (src < 0 || dst < 0) {
      return;
    }
    final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    final IItem source = c.getPlayer().getInventory(type).getItem(src);
    final IItem initialTarget = c.getPlayer().getInventory(type).getItem(dst);
    if (source == null) {
      return;
    }

    short olddstQ = -1;
    if (initialTarget != null) {
      olddstQ = initialTarget.getQuantity();
    }
    final short oldsrcQ = source.getQuantity();
    final short slotMax = ii.getSlotMax(c, source.getId());

    c.getPlayer().getInventory(type).move(src, dst, slotMax);
    if (!type.equals(MapleInventoryType.EQUIP)
        && initialTarget != null
        && initialTarget.getId() == source.getId()
        && !InventoryConstants.isRechargable(source.getId())) {
      if ((olddstQ + oldsrcQ) > slotMax) {
        c.announce(
            InventoryFactory.moveAndMergeWithRestInventoryItem(
                type, src, dst, (short) ((olddstQ + oldsrcQ) - slotMax), slotMax));
      } else {
        c.announce(
            InventoryFactory.moveAndMergeInventoryItem(
                type,
                src,
                dst,
                ((Item) c.getPlayer().getInventory(type).getItem(dst)).getQuantity()));
      }
    } else {
      c.announce(InventoryFactory.moveInventoryItem(type, src, dst));
    }
  }
コード例 #11
0
 public static void move(MapleClient c, MapleInventoryType type, byte src, byte dst) {
   if (src < 0 || dst < 0) {
     return;
   }
   MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   IItem source = c.getPlayer().getInventory(type).getItem(src);
   IItem initialTarget = c.getPlayer().getInventory(type).getItem(dst);
   if (source == null) {
     return;
   }
   short olddstQ = -1;
   if (initialTarget != null) {
     olddstQ = initialTarget.getQuantity();
   }
   short oldsrcQ = source.getQuantity();
   short slotMax = ii.getSlotMax(c, source.getItemId());
   c.getPlayer().getInventory(type).move(src, dst, slotMax);
   if (!type.equals(MapleInventoryType.EQUIP)
       && initialTarget != null
       && initialTarget.getItemId() == source.getItemId()
       && !ii.isThrowingStar(source.getItemId())
       && !ii.isBullet(source.getItemId())) {
     if ((olddstQ + oldsrcQ) > slotMax) {
       c.getSession()
           .write(
               MaplePacketCreator.moveAndMergeWithRestInventoryItem(
                   type, src, dst, (short) ((olddstQ + oldsrcQ) - slotMax), slotMax));
     } else {
       c.getSession()
           .write(
               MaplePacketCreator.moveAndMergeInventoryItem(
                   type,
                   src,
                   dst,
                   ((Item) c.getPlayer().getInventory(type).getItem(dst)).getQuantity()));
     }
   } else {
     c.getSession().write(MaplePacketCreator.moveInventoryItem(type, src, dst));
   }
 }
コード例 #12
0
  public static boolean checkSpace(MapleClient c, int itemid, int quantity, String owner) {
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    MapleInventoryType type = ii.getInventoryType(itemid);

    if (!type.equals(MapleInventoryType.EQUIP)) {
      short slotMax = ii.getSlotMax(c, itemid);
      List<IItem> existing = c.getPlayer().getInventory(type).listById(itemid);
      if (!ii.isThrowingStar(itemid) && !ii.isBullet(itemid)) {
        if (existing.size() > 0) { // first update all existing slots to slotMax

          for (IItem eItem : existing) {
            short oldQ = eItem.getQuantity();
            if (oldQ < slotMax && owner.equals(eItem.getOwner())) {
              short newQ = (short) Math.min(oldQ + quantity, slotMax);
              quantity -= (newQ - oldQ);
            }
            if (quantity <= 0) {
              break;
            }
          }
        }
      }
      // add new slots if there is still something left
      final int numSlotsNeeded;
      if (slotMax > 0) {
        numSlotsNeeded = (int) (Math.ceil(((double) quantity) / slotMax));
      } else if (ii.isThrowingStar(itemid) || ii.isBullet(itemid)) {
        numSlotsNeeded = 1;
      } else {
        numSlotsNeeded = 1;
        log.error("SUCK ERROR - FIX ME! - 0 slotMax");
      }
      return !c.getPlayer().getInventory(type).isFull(numSlotsNeeded - 1);
    } else {
      return !c.getPlayer().getInventory(type).isFull();
    }
  }
コード例 #13
0
  public static boolean addById(
      MapleClient c, int itemId, short quantity, String owner, int petid) {
    if (quantity >= 4000 || quantity < 0) {
      AutobanManager.getInstance()
          .autoban(c.getPlayer().getClient(), "PE Item: " + quantity + "x " + itemId);
      return false;
    }
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    MapleInventoryType type = ii.getInventoryType(itemId);
    if (!type.equals(MapleInventoryType.EQUIP)) {
      short slotMax = ii.getSlotMax(c, itemId);
      List<IItem> existing = c.getPlayer().getInventory(type).listById(itemId);
      if (!ii.isThrowingStar(itemId) && !ii.isBullet(itemId)) {
        if (existing.size() > 0) { // first update all existing slots to slotMax

          Iterator<IItem> i = existing.iterator();
          while (quantity > 0) {
            if (i.hasNext()) {
              Item eItem = (Item) i.next();
              short oldQ = eItem.getQuantity();
              if (oldQ < slotMax && (eItem.getOwner().equals(owner) || owner == null)) {
                short newQ = (short) Math.min(oldQ + quantity, slotMax);
                quantity -= (newQ - oldQ);
                eItem.setQuantity(newQ);
                c.getSession().write(MaplePacketCreator.updateInventorySlot(type, eItem));
              }
            } else {
              break;
            }
          }
        }
        // add new slots if there is still something left
        while (quantity > 0 || ii.isThrowingStar(itemId) || ii.isBullet(itemId)) {
          short newQ = (short) Math.min(quantity, slotMax);
          if (newQ != 0) {
            quantity -= newQ;
            Item nItem = new Item(itemId, (byte) 0, newQ, petid);
            byte newSlot = c.getPlayer().getInventory(type).addItem(nItem);
            if (newSlot == -1) {
              c.getSession().write(MaplePacketCreator.getInventoryFull());
              c.getSession().write(MaplePacketCreator.getShowInventoryFull());
              return false;
            }
            if (owner != null) {
              nItem.setOwner(owner);
            }
            c.getSession().write(MaplePacketCreator.addInventorySlot(type, nItem));
            if ((ii.isThrowingStar(itemId) || ii.isBullet(itemId)) && quantity == 0) {
              break;
            }
          } else {
            c.getSession().write(MaplePacketCreator.enableActions());
            return false;
          }
        }
      } else {
        // Throwing Stars and Bullets - Add all into one slot regardless of quantity.
        Item nItem = new Item(itemId, (byte) 0, quantity);
        byte newSlot = c.getPlayer().getInventory(type).addItem(nItem);

        if (newSlot == -1) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return false;
        }
        c.getSession().write(MaplePacketCreator.addInventorySlot(type, nItem));
        c.getSession().write(MaplePacketCreator.enableActions());
      }
    } else {
      if (quantity == 1) {
        IItem nEquip = ii.getEquipById(itemId);
        if (owner != null) {
          nEquip.setOwner(owner);
        }

        byte newSlot = c.getPlayer().getInventory(type).addItem(nEquip);
        if (newSlot == -1) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return false;
        }
        c.getSession().write(MaplePacketCreator.addInventorySlot(type, nEquip));
      } else {
        throw new InventoryException("Trying to create equip with non-one quantity");
      }
    }
    return true;
  }
コード例 #14
0
  public static void drop(MapleClient c, MapleInventoryType type, byte src, short quantity) {
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    if (src < 0) {
      type = MapleInventoryType.EQUIPPED;
    }
    IItem source = c.getPlayer().getInventory(type).getItem(src);
    int itemId = source.getItemId();
    if (itemId == 1302065 || itemId == 1302033) {
      c.getPlayer().hasflag = false;
      c.getPlayer().setCanPickup(true);
    }

    if (itemId == 1112000) {
      c.getPlayer().dropMessage("Super Rebirth rings cannot be dropped or traded.");
      return;
    }

    if (itemId == 1012076) {
      c.getPlayer().dropMessage("The Beta Mask cannot be traded or dropped.");
      return;
    }

    if (c.getPlayer().getItemEffect() == itemId && source.getQuantity() == 1) {
      c.getPlayer().setItemEffect(0);
      c.getPlayer()
          .getMap()
          .broadcastMessage(MaplePacketCreator.itemEffect(c.getPlayer().getId(), 0));
    } else if (itemId == 5370000 || itemId == 5370001) {
      if (c.getPlayer().getItemQuantity(itemId, false) == 1) {
        c.getPlayer().setChalkboard(null);
      }
    }

    if (itemId == 4000076) {
      c.getPlayer().mapCheck();
    }

    if (quantity < 0
        || source == null
        || quantity == 0 && !ii.isThrowingStar(itemId) && !ii.isBullet(itemId)) {
      String message =
          "Dropping "
              + quantity
              + " "
              + (source == null ? "?" : itemId)
              + " ("
              + type.name()
              + "/"
              + src
              + ")";
      // AutobanManager.getInstance().addPoints(c, 1000, 0, message);
      log.info(MapleClient.getLogMessage(c, message));
      c.getSession()
          .close(); // disconnect the client as is inventory is inconsistent with the serverside
                    // inventory -> f**k

      return;
    }
    Point dropPos = new Point(c.getPlayer().getPosition());
    // dropPos.y -= 99;
    if (quantity < source.getQuantity() && !ii.isThrowingStar(itemId) && !ii.isBullet(itemId)) {
      IItem target = source.copy();
      target.setQuantity(quantity);
      source.setQuantity((short) (source.getQuantity() - quantity));
      c.getSession().write(MaplePacketCreator.dropInventoryItemUpdate(type, source));
      boolean weddingRing =
          source.getItemId() == 1112803
              || source.getItemId() == 1112806
              || source.getItemId() == 1112807
              || source.getItemId() == 1112809;
      if (weddingRing) {
        c.getPlayer().getMap().disappearingItemDrop(c.getPlayer(), c.getPlayer(), target, dropPos);
      } else if (c.getPlayer().getMap().getEverlast()) {
        if (!c.getChannelServer().allowUndroppablesDrop()
            && ii.isDropRestricted(target.getItemId())) {
          c.getPlayer()
              .getMap()
              .disappearingItemDrop(c.getPlayer(), c.getPlayer(), target, dropPos);
        } else {
          c.getPlayer()
              .getMap()
              .spawnItemDrop(c.getPlayer(), c.getPlayer(), target, dropPos, true, false);
        }
      } else {
        if (!c.getChannelServer().allowUndroppablesDrop()
            && ii.isDropRestricted(target.getItemId())) {
          c.getPlayer()
              .getMap()
              .disappearingItemDrop(c.getPlayer(), c.getPlayer(), target, dropPos);
        } else {
          c.getPlayer()
              .getMap()
              .spawnItemDrop(c.getPlayer(), c.getPlayer(), target, dropPos, true, true);
        }
      }
    } else {
      c.getPlayer().getInventory(type).removeSlot(src);
      c.getSession()
          .write(
              MaplePacketCreator.dropInventoryItem(
                  (src < 0 ? MapleInventoryType.EQUIP : type), src));
      if (src < 0) {
        c.getPlayer().equipChanged();
      }
      if (c.getPlayer().getMap().getEverlast()) {
        if (!c.getChannelServer().allowUndroppablesDrop() && ii.isDropRestricted(itemId)) {
          c.getPlayer()
              .getMap()
              .disappearingItemDrop(c.getPlayer(), c.getPlayer(), source, dropPos);
        } else {
          c.getPlayer()
              .getMap()
              .spawnItemDrop(c.getPlayer(), c.getPlayer(), source, dropPos, true, false);
        }
      } else {
        if (!c.getChannelServer().allowUndroppablesDrop() && ii.isDropRestricted(itemId)) {
          c.getPlayer()
              .getMap()
              .disappearingItemDrop(c.getPlayer(), c.getPlayer(), source, dropPos);
        } else {
          c.getPlayer()
              .getMap()
              .spawnItemDrop(c.getPlayer(), c.getPlayer(), source, dropPos, true, true);
        }
      }
    }
  }
コード例 #15
0
 public static void equip(final MapleClient c, final short src, short dst) {
   Equip source = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(src);
   Equip target = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
   if (dst == -12 && target != null) {
     if (c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short) -13) == null) {
       dst = (short) -13;
       target = null;
     }
     for (int i = 0; i < 2; i++) {
       if (c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short) (i - 16))
           == null) {
         dst = (short) (i - 16);
         target = null;
       }
     }
     if (target != null) {
       return;
     }
   }
   if (isPE(source.getId(), dst)
       || source == null
       || (MapleItemInformationProvider.getInstance().getReqLevel(source.getId())
               > c.getPlayer().getLevel()
           && c.getPlayer().gmLevel() < 1)
       || (((source.getId() >= 1902000 && source.getId() <= 1902002) || source.getId() == 1912000)
           && c.getPlayer().getJobType() != 0)
       || (((source.getId() >= 1902005 && source.getId() <= 1902007) || source.getId() == 1912005)
           && c.getPlayer().getJobType() != 1)
       || (((source.getId() >= 1902015 && source.getId() <= 1902018) || source.getId() == 1912011)
           && !c.getPlayer().isAran())) {
     return;
   }
   if (MapleItemInformationProvider.getInstance().isUntradeableOnEquip(source.getId())) {
     source.setFlag((byte) InventoryConstants.UNTRADEABLE);
     c.announce(InventoryFactory.updateSlot(source));
   }
   if (dst == -6) { // unequip the overall
     final IItem top = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short) -5);
     if (top != null && isOverall(top.getId())) {
       if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull()) {
         c.announce(InventoryFactory.getInventoryFull());
         c.announce(InventoryFactory.getShowInventoryFull());
         return;
       }
       unequip(
           c, (short) -5, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
     }
   } else if (dst == -5) { // equip overall
     final IItem bottom =
         c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short) -6);
     if (bottom != null && isOverall(source.getId())) {
       if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull()) {
         c.announce(InventoryFactory.getInventoryFull());
         c.announce(InventoryFactory.getShowInventoryFull());
         return;
       }
       unequip(
           c, (short) -6, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
     }
   } else if (dst == -10) { // check if weapon is two-handed
     final IItem weapon =
         c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short) -11);
     if (weapon != null
         && MapleItemInformationProvider.getInstance().isTwoHanded(weapon.getId())) {
       if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull()) {
         c.announce(InventoryFactory.getInventoryFull());
         c.announce(InventoryFactory.getShowInventoryFull());
         return;
       }
       unequip(
           c, (short) -11, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
     }
   } else if (dst == -11) { // unequip shield
     final IItem shield =
         c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((short) -10);
     if (shield != null
         && MapleItemInformationProvider.getInstance().isTwoHanded(source.getId())) {
       if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull()) {
         c.announce(InventoryFactory.getInventoryFull());
         c.announce(InventoryFactory.getShowInventoryFull());
         return;
       }
       unequip(
           c, (short) -10, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
     }
   }
   if (dst == -18) {
     if (c.getPlayer().getMount() != null) {
       c.getPlayer().getMount().setId(source.getId());
     }
   }
   c.getPlayer().getInventory(MapleInventoryType.EQUIP).removeSlot(src);
   if (target != null) {
     c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).removeSlot(dst);
   }
   source.setPosition(dst);
   c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).addFromDB(source);
   if (target != null) {
     target.setPosition(src);
     c.getPlayer().getInventory(MapleInventoryType.EQUIP).addFromDB(target);
   }
   if (c.getPlayer().getBuffedValue(MapleBuffStat.BOOSTER) != null && isWeapon(source.getId())) {
     c.getPlayer().cancelBuffStats(MapleBuffStat.BOOSTER);
   }
   c.announce(InventoryFactory.moveInventoryItem(MapleInventoryType.EQUIP, src, dst, (byte) 2));
   c.getPlayer().equipChanged();
   if (source.getId() >= 1112001 && source.getId() <= 1112006) {
     c.getPlayer().setMarriageRing(MapleRing.loadFromDB(c.getPlayer()));
     c.announce(IntraPersonalFactory.getCharInfo(c.getPlayer()));
     c.getPlayer().getMap().removePlayer(c.getPlayer());
     c.getPlayer().getMap().addPlayer(c.getPlayer());
   }
 }
コード例 #16
0
  public static void equip(MapleClient c, byte src, byte dst) {
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    Equip source = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(src);
    Equip target = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
    if (source == null) {
      return;
    }
    if (!c.getPlayer().isGM() && !c.getChannelServer().CanGMItem()) {
      switch (source.getItemId()) {
        case 1002140: // Wizet Invincible Hat
        case 1042003: // Wizet Plain Suit
        case 1062007: // Wizet Plain Suit Pants
        case 1322013: // Wizet Secret Agent Suitcase
          removeAllById(c, source.getItemId(), false);
          c.getPlayer().dropMessage(1, "You're not a GM");
          return;
      }
    }

    if (source.getItemId() == 1302065 || source.getItemId() == 1302033) {
      c.getPlayer().dropMessage(6, "You cannot equip the Capture the Flag items.");
      return;
    }

    if (source.getItemId() == 1812006) {
      removeAllById(c, source.getItemId(), false);
      c.getPlayer().dropMessage(1, "Magic Scale Has Been Blocked");
      return;
    }

    if (source.getItemId() == 1002425 && c.getPlayer().getLevel() == 200) {
      c.getPlayer().setLevel(2);
      c.getPlayer().setJob(0);
      c.getPlayer().setReborns(1);
      c.getPlayer().doReborn();
      c.getPlayer().setRebirthPoints(c.getPlayer().getRebirthPoints() + 1);
      c.getPlayer()
          .dropMessage("Congratulations on your rebirth! I have given you one rebrth point.");
    }

    if (source.getItemId() == 1002083 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(412)); // Night Lord
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002082 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(422)); // Bandit
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002081 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(112)); // hero
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002080 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(122)); // paladin
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002393 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(132)); // DK
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002394 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(212)); // Bishop
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002392 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(222)); // FP mage
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002391 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(232)); // IL mage
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002395 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(512)); // brawler
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002515 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(312)); // bowman
      removeAllById(c, source.getItemId(), false);
    }
    if (source.getItemId() == 1002397 && c.getPlayer().getLevel() >= 120) {
      c.getPlayer().saveToDB(true, true);
      c.getPlayer().changeJob(MapleJob.getById(322)); // xbow
      removeAllById(c, source.getItemId(), false);
    }

    if (dst == -6) {
      // unequip the overall
      IItem top = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -5);
      if (top != null && ii.isOverall(top.getItemId())) {
        if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull()) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return;
        }
        unequip(
            c, (byte) -5, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
      }
    } else if (dst == -5) {
      // unequip the bottom and top
      IItem top = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -5);
      IItem bottom = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -6);
      if (top != null && ii.isOverall(source.getItemId())) {
        if (c.getPlayer()
            .getInventory(MapleInventoryType.EQUIP)
            .isFull(bottom != null && ii.isOverall(source.getItemId()) ? 1 : 0)) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return;
        }
        unequip(
            c, (byte) -5, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
      }
      if (bottom != null && ii.isOverall(source.getItemId())) {
        if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull()) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return;
        }
        unequip(
            c, (byte) -6, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
      }
    } else if (dst == -10) {
      // check if weapon is two-handed
      IItem weapon = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -11);
      if (weapon != null && ii.isTwoHanded(weapon.getItemId())) {
        if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull()) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return;
        }
        unequip(
            c, (byte) -11, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
      }
    } else if (dst == -11) {
      IItem shield = c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem((byte) -10);
      if (shield != null && ii.isTwoHanded(source.getItemId())) {
        if (c.getPlayer().getInventory(MapleInventoryType.EQUIP).isFull()) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return;
        }
        unequip(
            c, (byte) -10, c.getPlayer().getInventory(MapleInventoryType.EQUIP).getNextFreeSlot());
      }
    } else if (dst == -18) {
      c.getPlayer().getMount().setItemId(source.getItemId());
    }
    source = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(src);
    target = (Equip) c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).getItem(dst);
    c.getPlayer().getInventory(MapleInventoryType.EQUIP).removeSlot(src);
    if (target != null) {
      c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).removeSlot(dst);
    }
    source.setPosition(dst);
    c.getPlayer().getInventory(MapleInventoryType.EQUIPPED).addFromDB(source);
    if (target != null) {
      target.setPosition(src);
      c.getPlayer().getInventory(MapleInventoryType.EQUIP).addFromDB(target);
    }
    if (c.getPlayer().getBuffedValue(MapleBuffStat.BOOSTER) != null
        && ii.isWeapon(source.getItemId())) {
      c.getPlayer().cancelBuffStats(MapleBuffStat.BOOSTER);
    }
    c.getSession()
        .write(MaplePacketCreator.moveInventoryItem(MapleInventoryType.EQUIP, src, dst, (byte) 2));
    c.getPlayer().equipChanged();
  }
コード例 #17
0
 public static boolean addById(MapleClient c, int Id, short quantity, String owner, int petid) {
   final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   final MapleInventoryType type = ii.getInventoryType(Id);
   if (!type.equals(MapleInventoryType.EQUIP)) {
     final short slotMax = ii.getSlotMax(c, Id);
     final List<IItem> existing = c.getPlayer().getInventory(type).listById(Id);
     if (!InventoryConstants.isRechargable(Id)) {
       if (existing.size() > 0) { // first update all existing slots to slotMax
         Iterator<IItem> i = existing.iterator();
         while (quantity > 0) {
           if (i.hasNext()) {
             Item eItem = (Item) i.next();
             short oldQ = eItem.getQuantity();
             if (oldQ < slotMax && (eItem.getOwner().equals(owner) || owner == null)) {
               short newQ = (short) Math.min(oldQ + quantity, slotMax);
               quantity -= (newQ - oldQ);
               eItem.setQuantity(newQ);
               c.announce(InventoryFactory.updateInventorySlot(type, eItem));
             }
           } else {
             break;
           }
         }
       }
       while (quantity > 0 || InventoryConstants.isRechargable(Id)) {
         short newQ = (short) Math.min(quantity, slotMax);
         if (newQ != 0) {
           quantity -= newQ;
           Item nItem = new Item(Id, (short) 0, newQ, petid);
           short newSlot = c.getPlayer().getInventory(type).addItem(nItem);
           if (newSlot == -1) {
             c.announce(InventoryFactory.getInventoryFull());
             c.announce(InventoryFactory.getShowInventoryFull());
             return false;
           }
           if (owner != null) {
             nItem.setOwner(owner);
           }
           c.announce(InventoryFactory.addInventorySlot(type, nItem));
           if ((InventoryConstants.isRechargable(Id)) && quantity == 0) {
             break;
           }
         } else {
           c.announce(IntraPersonalFactory.enableActions());
           return false;
         }
       }
     } else {
       final Item nItem = new Item(Id, (short) 0, quantity);
       final short newSlot = c.getPlayer().getInventory(type).addItem(nItem);
       if (newSlot == -1) {
         c.announce(InventoryFactory.getInventoryFull());
         c.announce(InventoryFactory.getShowInventoryFull());
         return false;
       }
       c.announce(InventoryFactory.addInventorySlot(type, nItem));
       c.announce(IntraPersonalFactory.enableActions());
     }
   } else if (quantity == 1) {
     IItem nEquip = ii.getEquipById(Id);
     if (owner != null) {
       nEquip.setOwner(owner);
     }
     short newSlot = c.getPlayer().getInventory(type).addItem(nEquip);
     if (newSlot == -1) {
       c.announce(InventoryFactory.getInventoryFull());
       c.announce(InventoryFactory.getShowInventoryFull());
       return false;
     }
     c.announce(InventoryFactory.addInventorySlot(type, nEquip));
   } else {
     throw new RuntimeException("Trying to create equip with non-one quantity");
   }
   return true;
 }
コード例 #18
0
  public static int editEquipById(
      MapleCharacter chr, int max, int itemid, String stat, short newval) {
    // Is it an equip?
    if (!MapleItemInformationProvider.getInstance().isEquip(itemid)) {
      return -1;
    }

    // Get List
    List<IItem> equips = chr.getInventory(MapleInventoryType.EQUIP).listById(itemid);
    List<IItem> equipped = chr.getInventory(MapleInventoryType.EQUIPPED).listById(itemid);

    // Do you have any?
    if (equips.size() == 0 && equipped.size() == 0) {
      return 0;
    }

    int edited = 0;

    // edit items
    for (IItem itm : equips) {
      Equip e = (Equip) itm;
      if (edited >= max) {
        break;
      }
      edited++;
      if (stat.equals("str")) {
        e.setStr(newval);
      } else if (stat.equals("dex")) {
        e.setDex(newval);
      } else if (stat.equals("int")) {
        e.setInt(newval);
      } else if (stat.equals("luk")) {
        e.setLuk(newval);
      } else if (stat.equals("watk")) {
        e.setWatk(newval);
      } else if (stat.equals("matk")) {
        e.setMatk(newval);
      } else {
        return -2;
      }
    }
    for (IItem itm : equipped) {
      Equip e = (Equip) itm;
      if (edited >= max) {
        break;
      }
      edited++;
      if (stat.equals("str")) {
        e.setStr(newval);
      } else if (stat.equals("dex")) {
        e.setDex(newval);
      } else if (stat.equals("int")) {
        e.setInt(newval);
      } else if (stat.equals("luk")) {
        e.setLuk(newval);
      } else if (stat.equals("watk")) {
        e.setWatk(newval);
      } else if (stat.equals("matk")) {
        e.setMatk(newval);
      } else {
        return -2;
      }
    }

    // Return items edited
    return (edited);
  }
コード例 #19
0
 public static boolean addFromDrop(
     final MapleClient c, final IItem item, final boolean show, final boolean showAnyMessage) {
   final MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   if (ii.isPickupRestricted(item.getId())
       && c.getPlayer().getItemQuantity(item.getId(), true) > 0
       && showAnyMessage) {
     c.announce(InventoryFactory.getInventoryFull());
     c.announce(InventoryFactory.showItemUnavailable());
     return false;
   }
   final MapleInventoryType type = ii.getInventoryType(item.getId());
   short quantity = item.getQuantity();
   if (!type.equals(MapleInventoryType.EQUIP)) {
     final short slotMax = ii.getSlotMax(c, item.getId());
     final List<IItem> existing = c.getPlayer().getInventory(type).listById(item.getId());
     if (!InventoryConstants.isRechargable(item.getId())) {
       if (existing.size() > 0) { // first update all existing slots to slotMax
         Iterator<IItem> i = existing.iterator();
         while (quantity > 0) {
           if (i.hasNext()) {
             final Item eItem = (Item) i.next();
             final short oldQ = eItem.getQuantity();
             if (oldQ < slotMax && item.getOwner().equals(eItem.getOwner())) {
               short newQ = (short) Math.min(oldQ + quantity, slotMax);
               quantity -= (newQ - oldQ);
               eItem.setQuantity(newQ);
               short newQi = (short) Math.min(quantity, slotMax);
               quantity -= newQi;
               Item nItem = new Item(item.getId(), (short) 0, newQi);
               nItem.setOwner(item.getOwner());
               if (c.getPlayer().getInventory(type).fakeAddItem(nItem) == -1) {
                 eItem.setQuantity(oldQ);
                 return false;
               }
               quantity += newQi;
               c.announce(InventoryFactory.updateInventorySlot(type, eItem, showAnyMessage));
             }
           } else {
             break;
           }
         }
       }
       while (quantity > 0 || InventoryConstants.isRechargable(item.getId())) {
         final short newQ = (short) Math.min(quantity, slotMax);
         quantity -= newQ;
         final Item nItem = new Item(item.getId(), (short) 0, newQ);
         nItem.setOwner(item.getOwner());
         final short newSlot = c.getPlayer().getInventory(type).addItem(nItem);
         if (newSlot == -1) {
           if (showAnyMessage) {
             c.announce(InventoryFactory.getInventoryFull());
             c.announce(InventoryFactory.getShowInventoryFull());
           }
           item.setQuantity((short) (quantity + newQ));
           return false;
         }
         c.announce(InventoryFactory.addInventorySlot(type, nItem, true));
         if ((InventoryConstants.isRechargable(item.getId())) && quantity == 0) {
           break;
         }
       }
     } else {
       final Item nItem = new Item(item.getId(), (short) 0, quantity);
       final short newSlot = c.getPlayer().getInventory(type).addItem(nItem);
       if (newSlot == -1) {
         if (showAnyMessage) {
           c.announce(InventoryFactory.getInventoryFull());
           c.announce(InventoryFactory.getShowInventoryFull());
         }
         return false;
       }
       c.announce(InventoryFactory.addInventorySlot(type, nItem));
       c.announce(IntraPersonalFactory.enableActions());
     }
   } else if (quantity == 1) {
     final short newSlot = c.getPlayer().getInventory(type).addItem(item);
     if (newSlot == -1) {
       if (showAnyMessage) {
         c.announce(InventoryFactory.getInventoryFull());
         c.announce(InventoryFactory.getShowInventoryFull());
       }
       return false;
     }
     c.announce(InventoryFactory.addInventorySlot(type, item, true));
   } else {
     return false;
   }
   if (show) {
     c.announce(EffectFactory.getShowItemGain(item.getId(), item.getQuantity()));
   }
   return true;
 }
コード例 #20
0
  public static boolean addFromDrop(MapleClient c, IItem item, boolean show, String owner) {
    MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
    MapleInventoryType type = ii.getInventoryType(item.getItemId());

    if (!c.getChannelServer().allowMoreThanOne()
        && ii.isPickupRestricted(item.getItemId())
        && c.getPlayer().haveItem(item.getItemId(), 1, true, false)) {
      c.getSession().write(MaplePacketCreator.getInventoryFull());
      c.getSession().write(MaplePacketCreator.showItemUnavailable());
      return false;
    }
    short quantity = item.getQuantity();
    if (quantity >= 4000 || quantity < 0) {
      AutobanManager.getInstance()
          .autoban(c.getPlayer().getClient(), "PE Item: " + quantity + "x " + item.getItemId());
      return false;
    }

    if (!type.equals(MapleInventoryType.EQUIP)) {
      short slotMax = ii.getSlotMax(c, item.getItemId());
      List<IItem> existing = c.getPlayer().getInventory(type).listById(item.getItemId());
      if (!ii.isThrowingStar(item.getItemId()) && !ii.isBullet(item.getItemId())) {
        if (existing.size() > 0) { // first update all existing slots to slotMax

          Iterator<IItem> i = existing.iterator();
          while (quantity > 0) {
            if (i.hasNext()) {
              Item eItem = (Item) i.next();
              short oldQ = eItem.getQuantity();
              if (oldQ < slotMax && item.getOwner().equals(eItem.getOwner())) {
                short newQ = (short) Math.min(oldQ + quantity, slotMax);
                quantity -= (newQ - oldQ);
                eItem.setQuantity(newQ);
                c.getSession().write(MaplePacketCreator.updateInventorySlot(type, eItem, true));
              }
            } else {
              break;
            }
          }
        }
        // add new slots if there is still something left
        while (quantity > 0
            || ii.isThrowingStar(item.getItemId())
            || ii.isBullet(item.getItemId())) {
          short newQ = (short) Math.min(quantity, slotMax);
          quantity -= newQ;
          Item nItem = new Item(item.getItemId(), (byte) 0, newQ);
          nItem.setOwner(item.getOwner());
          byte newSlot = c.getPlayer().getInventory(type).addItem(nItem);
          if (newSlot == -1) {
            c.getSession().write(MaplePacketCreator.getInventoryFull());
            c.getSession().write(MaplePacketCreator.getShowInventoryFull());
            item.setQuantity((short) (quantity + newQ));
            return false;
          }
          c.getSession().write(MaplePacketCreator.addInventorySlot(type, nItem, true));
        }
      } else {
        // Throwing Stars and Bullets - Add all into one slot regardless of quantity.
        Item nItem = new Item(item.getItemId(), (byte) 0, quantity);
        byte newSlot = c.getPlayer().getInventory(type).addItem(nItem);
        if (newSlot == -1) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return false;
        }
        c.getSession().write(MaplePacketCreator.addInventorySlot(type, nItem));
        c.getSession().write(MaplePacketCreator.enableActions());
      }
    } else {
      if (quantity == 1) {
        byte newSlot = c.getPlayer().getInventory(type).addItem(item);

        if (newSlot == -1) {
          c.getSession().write(MaplePacketCreator.getInventoryFull());
          c.getSession().write(MaplePacketCreator.getShowInventoryFull());
          return false;
        }
        c.getSession().write(MaplePacketCreator.addInventorySlot(type, item, true));
      } else {
        throw new RuntimeException("Trying to create equip with non-one quantity");
      }
    }
    if (owner != null) {
      item.setOwner(owner);
    }
    if (show) {
      c.getSession()
          .write(MaplePacketCreator.getShowItemGain(item.getItemId(), item.getQuantity()));
    }
    return true;
  }
コード例 #21
0
 private static final boolean isPE(final int id, short dst) {
   if (dst == -14
       || dst == -117
       || (dst >= -48 && dst <= -20)
       || (dst >= -100 && dst <= -52)
       || (dst > -1000
           && dst < -100
           && MapleItemInformationProvider.getInstance().getCash(id) != 1)) {
     return true;
   }
   switch (dst) {
     case -1: // == x - 1
     case -2:
     case -3:
     case -4:
       if (id / 10000 - 100 != -dst - 1) {
         return true;
       }
       break;
     case -5:
       if (id / 10000 - 100 != 4 && id / 10000 - 100 != 5) {
         return true;
       }
       break;
     case -6: // == x
     case -7:
     case -8:
       if (id / 10000 - 100 != -dst) {
         return true;
       }
       break;
     case -9: // == x + 1
       if (id / 10000 != 110) {
         return true;
       }
       break;
     case -10: // == x - 1
       if (id / 10000 != 109 && id / 10000 != 134) {
         return true;
       }
       break;
     case -11: // weapons
       if (!isWeapon(id)) {
         return true;
       }
       break;
     case -12: // rings
     case -13:
     case -15:
     case -16:
       if (id / 10000 != 111) {
         return true;
       }
       break;
     case -17:
       if (id / 10000 != 112) {
         return true;
       }
       break;
     case -18:
       if (id / 10000 != 190) {
         return true;
       }
       break;
     case -19:
       if (id / 10000 != 191) {
         return true;
       }
       break;
     case -49:
       if (id / 10000 != 114) {
         return true;
       }
       break;
     case -50:
       if (id / 10000 != 113) {
         return true;
       }
       break;
     case -51:
       if (id / 10000 != 115) {
         return true;
       }
       break;
     case -1000: // 194
     case -1001: // 195
     case -1002: // 196
     case -1003: // 197
       if (id / 10000 - 100 != -dst - 906) { // IF 95 == 1001 - 906
         return true;
       }
       break;
   }
   return false;
 }