Пример #1
0
 private static MaplePacket getMTS(int tab, int type, int page) {
   List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
   Connection con = DatabaseConnection.getConnection();
   PreparedStatement ps;
   ResultSet rs;
   int pages = 0;
   try {
     if (type != 0) {
       ps =
           con.prepareStatement(
               "SELECT * FROM mts_items WHERE tab = ? AND type = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
     } else {
       ps =
           con.prepareStatement(
               "SELECT * FROM mts_items WHERE tab = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
     }
     ps.setInt(1, tab);
     if (type != 0) {
       ps.setInt(2, type);
       ps.setInt(3, page * 16);
     } else {
       ps.setInt(2, page * 16);
     }
     rs = ps.executeQuery();
     while (rs.next()) {
       if (rs.getInt("type") != 1) {
         Item i = new Item(rs.getInt("itemid"), (byte) 0, (short) rs.getInt("quantity"));
         i.setOwner(rs.getString("owner"));
         items.add(
             new MTSItemInfo(
                 (IItem) i,
                 rs.getInt("price"),
                 rs.getInt("id"),
                 rs.getInt("seller"),
                 rs.getString("sellername"),
                 rs.getString("sell_ends")));
       } else {
         Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
         equip.setOwner(rs.getString("owner"));
         equip.setQuantity((short) 1);
         equip.setAcc((short) rs.getInt("acc"));
         equip.setAvoid((short) rs.getInt("avoid"));
         equip.setDex((short) rs.getInt("dex"));
         equip.setHands((short) rs.getInt("hands"));
         equip.setHp((short) rs.getInt("hp"));
         equip.setInt((short) rs.getInt("int"));
         equip.setJump((short) rs.getInt("jump"));
         equip.setVicious((short) rs.getInt("vicious"));
         equip.setLuk((short) rs.getInt("luk"));
         equip.setMatk((short) rs.getInt("matk"));
         equip.setMdef((short) rs.getInt("mdef"));
         equip.setMp((short) rs.getInt("mp"));
         equip.setSpeed((short) rs.getInt("speed"));
         equip.setStr((short) rs.getInt("str"));
         equip.setWatk((short) rs.getInt("watk"));
         equip.setWdef((short) rs.getInt("wdef"));
         equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
         equip.setLevel((byte) rs.getInt("level"));
         equip.setFlag((byte) rs.getInt("flag"));
         items.add(
             new MTSItemInfo(
                 (IItem) equip,
                 rs.getInt("price"),
                 rs.getInt("id"),
                 rs.getInt("seller"),
                 rs.getString("sellername"),
                 rs.getString("sell_ends")));
       }
     }
     rs.close();
     ps.close();
     ps =
         con.prepareStatement(
             "SELECT COUNT(*) FROM mts_items WHERE tab = ? "
                 + (type != 0 ? "AND type = ?" : "")
                 + "AND transfer = 0");
     ps.setInt(1, tab);
     if (type != 0) {
       ps.setInt(2, type);
     }
     rs = ps.executeQuery();
     if (rs.next()) {
       pages = rs.getInt(1) / 16;
       if (rs.getInt(1) % 16 > 0) {
         pages++;
       }
     }
     rs.close();
     ps.close();
   } catch (SQLException e) {
   }
   return MaplePacketCreator.sendMTS(items, tab, type, page, pages); // resniff
 }
Пример #2
0
 public MaplePacket getMTSSearch(int tab, int type, int cOi, String search, int page) {
   List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
   MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
   String listaitems = "";
   if (cOi != 0) {
     List<String> retItems = new ArrayList<String>();
     for (ItemNameEntry itemPair : ii.getAllItems()) {
       if (itemPair.name.toLowerCase().contains(search.toLowerCase())) {
         retItems.add(" itemid=" + itemPair.itemId + " OR ");
       }
     }
     listaitems += " AND (";
     if (retItems != null && retItems.size() > 0) {
       for (String singleRetItem : retItems) {
         listaitems += singleRetItem;
       }
       listaitems += " itemid=0 )";
     }
   } else {
     listaitems = " AND sellername LIKE CONCAT('%','" + search + "', '%')";
   }
   Connection con = DatabaseConnection.getConnection();
   PreparedStatement ps;
   ResultSet rs;
   int pages = 0;
   try {
     if (type != 0) {
       ps =
           con.prepareStatement(
               "SELECT * FROM mts_items WHERE tab = ? "
                   + listaitems
                   + " AND type = ? AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
     } else {
       ps =
           con.prepareStatement(
               "SELECT * FROM mts_items WHERE tab = ? "
                   + listaitems
                   + " AND transfer = 0 ORDER BY id DESC LIMIT ?, 16");
     }
     ps.setInt(1, tab);
     if (type != 0) {
       ps.setInt(2, type);
       ps.setInt(3, page * 16);
     } else {
       ps.setInt(2, page * 16);
     }
     rs = ps.executeQuery();
     while (rs.next()) {
       if (rs.getInt("type") != 1) {
         Item i = new Item(rs.getInt("itemid"), (byte) 0, (short) rs.getInt("quantity"));
         i.setOwner(rs.getString("owner"));
         items.add(
             new MTSItemInfo(
                 (IItem) i,
                 rs.getInt("price"),
                 rs.getInt("id"),
                 rs.getInt("seller"),
                 rs.getString("sellername"),
                 rs.getString("sell_ends")));
       } else {
         Equip equip = new Equip(rs.getInt("itemid"), (byte) rs.getInt("position"), -1);
         equip.setOwner(rs.getString("owner"));
         equip.setQuantity((short) 1);
         equip.setAcc((short) rs.getInt("acc"));
         equip.setAvoid((short) rs.getInt("avoid"));
         equip.setDex((short) rs.getInt("dex"));
         equip.setHands((short) rs.getInt("hands"));
         equip.setHp((short) rs.getInt("hp"));
         equip.setInt((short) rs.getInt("int"));
         equip.setJump((short) rs.getInt("jump"));
         equip.setVicious((short) rs.getInt("vicious"));
         equip.setLuk((short) rs.getInt("luk"));
         equip.setMatk((short) rs.getInt("matk"));
         equip.setMdef((short) rs.getInt("mdef"));
         equip.setMp((short) rs.getInt("mp"));
         equip.setSpeed((short) rs.getInt("speed"));
         equip.setStr((short) rs.getInt("str"));
         equip.setWatk((short) rs.getInt("watk"));
         equip.setWdef((short) rs.getInt("wdef"));
         equip.setUpgradeSlots((byte) rs.getInt("upgradeslots"));
         equip.setLevel((byte) rs.getInt("level"));
         equip.setFlag((byte) rs.getInt("flag"));
         items.add(
             new MTSItemInfo(
                 (IItem) equip,
                 rs.getInt("price"),
                 rs.getInt("id"),
                 rs.getInt("seller"),
                 rs.getString("sellername"),
                 rs.getString("sell_ends")));
       }
     }
     rs.close();
     ps.close();
     if (type != 0) {
       ps =
           con.prepareStatement(
               "SELECT COUNT(*) FROM mts_items WHERE tab = ? "
                   + listaitems
                   + " AND type = ? AND transfer = 0");
     } else {
       ps =
           con.prepareStatement(
               "SELECT COUNT(*) FROM mts_items WHERE tab = ? " + listaitems + " AND transfer = 0");
       ps.setInt(1, tab);
       if (type != 0) {
         ps.setInt(2, type);
       }
       rs = ps.executeQuery();
       if (rs.next()) {
         pages = rs.getInt(1) / 16;
         if (rs.getInt(1) % 16 > 0) {
           pages++;
         }
       }
       rs.close();
       ps.close();
     }
   } catch (SQLException e) {
   }
   return MaplePacketCreator.sendMTS(items, tab, type, page, pages);
 }
Пример #3
0
 public MaplePacket getCart(int cid) {
   List<MTSItemInfo> items = new ArrayList<MTSItemInfo>();
   Connection con = DatabaseConnection.getConnection();
   PreparedStatement ps;
   ResultSet rs;
   int pages = 0;
   try {
     ps = con.prepareStatement("SELECT * FROM mts_cart WHERE cid = ? ORDER BY id DESC");
     ps.setInt(1, cid);
     rs = ps.executeQuery();
     while (rs.next()) {
       PreparedStatement pse = con.prepareStatement("SELECT * FROM mts_items WHERE id = ?");
       pse.setInt(1, rs.getInt("itemid"));
       ResultSet rse = pse.executeQuery();
       if (rse.next()) {
         if (rse.getInt("type") != 1) {
           Item i = new Item(rse.getInt("itemid"), (byte) 0, (short) rse.getInt("quantity"));
           i.setOwner(rse.getString("owner"));
           items.add(
               new MTSItemInfo(
                   (IItem) i,
                   rse.getInt("price"),
                   rse.getInt("id"),
                   rse.getInt("seller"),
                   rse.getString("sellername"),
                   rse.getString("sell_ends")));
         } else {
           Equip equip = new Equip(rse.getInt("itemid"), (byte) rse.getInt("position"), -1);
           equip.setOwner(rse.getString("owner"));
           equip.setQuantity((short) 1);
           equip.setAcc((short) rse.getInt("acc"));
           equip.setAvoid((short) rse.getInt("avoid"));
           equip.setDex((short) rse.getInt("dex"));
           equip.setHands((short) rse.getInt("hands"));
           equip.setHp((short) rse.getInt("hp"));
           equip.setInt((short) rse.getInt("int"));
           equip.setJump((short) rse.getInt("jump"));
           equip.setVicious((short) rse.getInt("vicious"));
           equip.setLuk((short) rse.getInt("luk"));
           equip.setMatk((short) rse.getInt("matk"));
           equip.setMdef((short) rse.getInt("mdef"));
           equip.setMp((short) rse.getInt("mp"));
           equip.setSpeed((short) rse.getInt("speed"));
           equip.setStr((short) rse.getInt("str"));
           equip.setWatk((short) rse.getInt("watk"));
           equip.setWdef((short) rse.getInt("wdef"));
           equip.setUpgradeSlots((byte) rse.getInt("upgradeslots"));
           equip.setLevel((byte) rse.getInt("level"));
           equip.setFlag((byte) rs.getInt("flag"));
           items.add(
               new MTSItemInfo(
                   (IItem) equip,
                   rse.getInt("price"),
                   rse.getInt("id"),
                   rse.getInt("seller"),
                   rse.getString("sellername"),
                   rse.getString("sell_ends")));
         }
       }
       pse.close();
     }
     rs.close();
     ps.close();
     ps = con.prepareStatement("SELECT COUNT(*) FROM mts_cart WHERE cid = ?");
     ps.setInt(1, cid);
     rs = ps.executeQuery();
     if (rs.next()) {
       pages = rs.getInt(1) / 16;
       if (rs.getInt(1) % 16 > 0) {
         pages += 1;
       }
     }
     rs.close();
     ps.close();
   } catch (SQLException e) {
   }
   return MaplePacketCreator.sendMTS(items, 4, 0, 0, pages);
 }