use of client.inventory.Equip in project HeavenMS by ronancpl.
the class MTSHandler method getMTS.
private static byte[] getMTS(int tab, int type, int page) {
List<MTSItemInfo> items = new ArrayList<>();
Connection con = null;
PreparedStatement ps;
ResultSet rs;
int pages = 0;
try {
con = DatabaseConnection.getConnection();
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"), (short) 0, (short) rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((Item) 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((Item) 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();
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
// resniff
return MaplePacketCreator.sendMTS(items, tab, type, page, pages);
}
use of client.inventory.Equip in project HeavenMS by ronancpl.
the class MTSHandler method getMTSSearch.
public byte[] getMTSSearch(int tab, int type, int cOi, String search, int page) {
List<MTSItemInfo> items = new ArrayList<>();
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
String listaitems = "";
if (cOi != 0) {
List<String> retItems = new ArrayList<>();
for (Pair<Integer, String> itemPair : ii.getAllItems()) {
if (itemPair.getRight().toLowerCase().contains(search.toLowerCase())) {
retItems.add(" itemid=" + itemPair.getLeft() + " 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 = null;
PreparedStatement ps;
ResultSet rs;
int pages = 0;
try {
con = DatabaseConnection.getConnection();
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"), (short) 0, (short) rs.getInt("quantity"));
i.setOwner(rs.getString("owner"));
items.add(new MTSItemInfo((Item) 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((Item) 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 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();
}
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
return MaplePacketCreator.sendMTS(items, tab, type, page, pages);
}
use of client.inventory.Equip in project HeavenMS by ronancpl.
the class InventorySortHandler method PartitionByLevel.
private void PartitionByLevel(int Esq, int Dir, ArrayList<Item> A) {
Equip x, w, eqpI, eqpJ;
i = Esq;
j = Dir;
x = (Equip) (A.get((i + j) / 2));
do {
eqpI = (Equip) A.get(i);
eqpJ = (Equip) A.get(j);
while (x.getLevel() > eqpI.getLevel()) i++;
while (x.getLevel() < eqpJ.getLevel()) j--;
if (i <= j) {
w = (Equip) A.get(i);
A.set(i, A.get(j));
A.set(j, (Item) w);
i++;
j--;
}
} while (i <= j);
}
use of client.inventory.Equip in project HeavenMS by ronancpl.
the class MapleMap method spawnItemDropList.
// spawns item instances of all defined item ids on a list
public final void spawnItemDropList(List<Integer> list, int minCopies, int maxCopies, final MapleMapObject dropper, final MapleCharacter owner, Point pos, final boolean ffaDrop, final boolean playerDrop) {
int copies = (maxCopies - minCopies) + 1;
if (copies < 1)
return;
Collections.shuffle(list);
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
Random rnd = new Random();
final Point dropPos = new Point(pos);
dropPos.x -= (12 * list.size());
for (int i = 0; i < list.size(); i++) {
if (list.get(i) == 0) {
spawnMesoDrop(owner != null ? 10 * owner.getMesoRate() : 10, calcDropPos(dropPos, pos), dropper, owner, playerDrop, (byte) (ffaDrop ? 2 : 0));
} else {
final Item drop;
int randomedId = list.get(i);
if (ItemConstants.getInventoryType(randomedId) != MapleInventoryType.EQUIP) {
drop = new Item(randomedId, (short) 0, (short) (rnd.nextInt(copies) + minCopies));
} else {
drop = ii.randomizeStats((Equip) ii.getEquipById(randomedId));
}
spawnItemDrop(dropper, owner, drop, calcDropPos(dropPos, pos), ffaDrop, playerDrop);
}
dropPos.x += 25;
}
}
use of client.inventory.Equip in project HeavenMS by ronancpl.
the class Commands method executeHeavenMsCommandLv4.
public static boolean executeHeavenMsCommandLv4(Channel cserv, Server srv, MapleClient c, String[] sub) {
// SuperGM
MapleCharacter player = c.getPlayer();
switch(sub[0]) {
case "servermessage":
c.getWorldServer().setServerMessage(joinStringFrom(sub, 1));
break;
case "proitem":
if (sub.length < 3) {
player.yellowMessage("Syntax: !proitem <itemid> <statvalue>");
break;
}
int itemid = Integer.parseInt(sub[1]);
short multiply = Short.parseShort(sub[2]);
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
MapleInventoryType type = ItemConstants.getInventoryType(itemid);
if (type.equals(MapleInventoryType.EQUIP)) {
Item it = ii.getEquipById(itemid);
it.setOwner(player.getName());
hardsetItemStats((Equip) it, multiply);
MapleInventoryManipulator.addFromDrop(c, it);
} else {
player.dropMessage(6, "Make sure it's an equippable item.");
}
break;
case "seteqstat":
if (sub.length < 2) {
player.yellowMessage("Syntax: !seteqstat <statvalue>");
break;
}
int newStat = Integer.parseInt(sub[1]);
MapleInventory equip = player.getInventory(MapleInventoryType.EQUIP);
for (byte i = 1; i <= equip.getSlotLimit(); i++) {
try {
Equip eu = (Equip) equip.getItem(i);
if (eu == null)
continue;
short incval = (short) newStat;
eu.setWdef(incval);
eu.setAcc(incval);
eu.setAvoid(incval);
eu.setJump(incval);
eu.setMatk(incval);
eu.setMdef(incval);
eu.setHp(incval);
eu.setMp(incval);
eu.setSpeed(incval);
eu.setWatk(incval);
eu.setDex(incval);
eu.setInt(incval);
eu.setStr(incval);
eu.setLuk(incval);
byte flag = eu.getFlag();
flag |= ItemConstants.UNTRADEABLE;
eu.setFlag(flag);
player.forceUpdateItem(eu);
} catch (Exception e) {
e.printStackTrace();
}
}
break;
case "exprate":
if (sub.length < 2) {
player.yellowMessage("Syntax: !exprate <newrate>");
break;
}
int exprate = Math.max(Integer.parseInt(sub[1]), 1);
c.getWorldServer().setExpRate(exprate);
c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Exp Rate has been changed to " + exprate + "x."));
break;
case "mesorate":
if (sub.length < 2) {
player.yellowMessage("Syntax: !mesorate <newrate>");
break;
}
int mesorate = Math.max(Integer.parseInt(sub[1]), 1);
c.getWorldServer().setMesoRate(mesorate);
c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Meso Rate has been changed to " + mesorate + "x."));
break;
case "droprate":
if (sub.length < 2) {
player.yellowMessage("Syntax: !droprate <newrate>");
break;
}
int droprate = Math.max(Integer.parseInt(sub[1]), 1);
c.getWorldServer().setDropRate(droprate);
c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Drop Rate has been changed to " + droprate + "x."));
break;
case "questrate":
if (sub.length < 2) {
player.yellowMessage("Syntax: !questrate <newrate>");
break;
}
int questrate = Math.max(Integer.parseInt(sub[1]), 1);
c.getWorldServer().setQuestRate(questrate);
c.getWorldServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "[Rate] Quest Rate has been changed to " + questrate + "x."));
break;
case "itemvac":
List<MapleMapObject> list = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
for (MapleMapObject item : list) {
player.pickupItem(item);
}
break;
case "forcevac":
List<MapleMapObject> items = player.getMap().getMapObjectsInRange(player.getPosition(), Double.POSITIVE_INFINITY, Arrays.asList(MapleMapObjectType.ITEM));
for (MapleMapObject item : items) {
MapleMapItem mapItem = (MapleMapItem) item;
if (mapItem.getMeso() > 0) {
player.gainMeso(mapItem.getMeso(), true);
} else if (mapItem.getItemId() == 4031865 || mapItem.getItemId() == 4031866) {
// Add NX to account, show effect and make item disappear
player.getCashShop().gainCash(1, mapItem.getItemId() == 4031865 ? 100 : 250);
} else if (mapItem.getItem().getItemId() >= 5000000 && mapItem.getItem().getItemId() <= 5000100) {
int petId = MaplePet.createPet(mapItem.getItem().getItemId());
if (petId == -1) {
continue;
}
MapleInventoryManipulator.addById(c, mapItem.getItem().getItemId(), mapItem.getItem().getQuantity(), null, petId);
} else {
MapleInventoryManipulator.addFromDrop(c, mapItem.getItem(), true);
}
player.getMap().pickItemDrop(MaplePacketCreator.removeItemFromMap(mapItem.getObjectId(), 2, player.getId()), mapItem);
}
break;
case "zakum":
player.getMap().spawnFakeMonsterOnGroundBelow(MapleLifeFactory.getMonster(8800000), player.getPosition());
for (int x = 8800003; x < 8800011; x++) {
player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(x), player.getPosition());
}
break;
case "horntail":
final Point targetPoint = player.getPosition();
final MapleMap targetMap = player.getMap();
targetMap.spawnHorntailOnGroundBelow(targetPoint);
break;
case "pinkbean":
player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8820001), player.getPosition());
break;
case "pap":
player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8500001), player.getPosition());
break;
case "pianus":
player.getMap().spawnMonsterOnGroundBelow(MapleLifeFactory.getMonster(8510000), player.getPosition());
break;
case "cake":
MapleMonster monster = MapleLifeFactory.getMonster(9400606);
if (sub.length > 1) {
int newHp = Integer.parseInt(sub[1]);
if (newHp < 0)
newHp = Integer.MAX_VALUE;
monster.getStats().setHp(newHp);
monster.setStartingHp(newHp);
}
player.getMap().spawnMonsterOnGroundBelow(monster, player.getPosition());
break;
default:
return false;
}
return true;
}
Aggregations