public void forceClose() {
    if (schedule != null) {
      schedule.cancel(false);
    }
    try {
      saveItems(true);
    } catch (SQLException ex) {
    }
    Server.getInstance().getChannel(world, channel).removeHiredMerchant(ownerId);
    map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(getOwnerId()));

    map.removeMapObject(this);

    map = null;
    schedule = null;
  }
  public void closeShop(MapleClient c, boolean timeout) {
    map.removeMapObject(this);
    map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(ownerId));
    c.getChannelServer().removeHiredMerchant(ownerId);
    try {
      PreparedStatement ps =
          DatabaseConnection.getConnection()
              .prepareStatement(
                  "UPDATE characters SET HasMerchant = 0 WHERE id = ?",
                  Statement.RETURN_GENERATED_KEYS);
      ps.setInt(1, ownerId);
      ps.executeUpdate();
      ps.close();
      if (check(c.getPlayer(), getItems()) && !timeout) {
        for (MaplePlayerShopItem mpsi : getItems()) {
          if (mpsi.isExist() && (mpsi.getItem().getType() == IItem.EQUIP)) {
            MapleInventoryManipulator.addFromDrop(c, mpsi.getItem(), false);
          } else if (mpsi.isExist()) {
            MapleInventoryManipulator.addById(
                c,
                mpsi.getItem().getItemId(),
                (short) (mpsi.getBundles() * mpsi.getItem().getQuantity()),
                null,
                -1,
                mpsi.getItem().getExpiration());
          }
        }
        items.clear();
      }
      try {
        this.saveItems(false);
      } catch (Exception e) {
      }
      items.clear();

    } catch (Exception e) {
    }
    schedule.cancel(false);
  }
 public int getMapId() {
   return map.getId();
 }
Exemple #4
0
 public final MapleCharacter getOwner() {
   return map.getCharacterById(ownerid);
 }