Experimental DB pool + fixed stat overflow on equips
Implemented EXPERIMENTAL DBCP (connection pool), trying to improve concorrent access to DB. Added door portals on Kerning Square. Fixed equipments getting stat overflow when upgrading stats. Fixed expiring pets crashing the client in some cases.
This commit is contained in:
@@ -162,8 +162,10 @@ public class CashShop {
|
||||
}
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM specialcashitems");
|
||||
con = DatabaseConnection.getConnection();
|
||||
ps = con.prepareStatement("SELECT * FROM specialcashitems");
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
specialcashitems.add(new SpecialCashItem(rs.getInt("sn"), rs.getInt("modifier"), rs.getByte("info")));
|
||||
@@ -172,8 +174,9 @@ public class CashShop {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) rs.close();
|
||||
if (ps != null) ps.close();
|
||||
if (rs != null && !rs.isClosed()) rs.close();
|
||||
if (ps != null && !ps.isClosed()) ps.close();
|
||||
if (con != null && !con.isClosed()) con.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@@ -206,8 +209,10 @@ public class CashShop {
|
||||
specialcashitems.clear();
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM specialcashitems");
|
||||
con = DatabaseConnection.getConnection();
|
||||
ps = con.prepareStatement("SELECT * FROM specialcashitems");
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
specialcashitems.add(new SpecialCashItem(rs.getInt("sn"), rs.getInt("modifier"), rs.getByte("info")));
|
||||
@@ -216,14 +221,16 @@ public class CashShop {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) rs.close();
|
||||
if (ps != null) ps.close();
|
||||
if (rs != null && !rs.isClosed()) rs.close();
|
||||
if (ps != null && !ps.isClosed()) ps.close();
|
||||
if (con != null && !con.isClosed()) con.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int accountId, characterId, nxCredit, maplePoint, nxPrepaid;
|
||||
private boolean opened;
|
||||
private ItemFactory factory;
|
||||
@@ -274,9 +281,11 @@ public class CashShop {
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} finally {
|
||||
if (ps != null) ps.close();
|
||||
if (rs != null) rs.close();
|
||||
if (ps != null && !ps.isClosed()) ps.close();
|
||||
if (rs != null && !rs.isClosed()) rs.close();
|
||||
if (con != null && !con.isClosed()) con.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -361,31 +370,35 @@ public class CashShop {
|
||||
|
||||
public void gift(int recipient, String from, String message, int sn, int ringid) {
|
||||
PreparedStatement ps = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO `gifts` VALUES (DEFAULT, ?, ?, ?, ?, ?)");
|
||||
con = DatabaseConnection.getConnection();
|
||||
ps = con.prepareStatement("INSERT INTO `gifts` VALUES (DEFAULT, ?, ?, ?, ?, ?)");
|
||||
ps.setInt(1, recipient);
|
||||
ps.setString(2, from);
|
||||
ps.setString(3, message);
|
||||
ps.setInt(4, sn);
|
||||
ps.setInt(5, ringid);
|
||||
ps.executeUpdate();
|
||||
con.close();
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (ps != null) ps.close();
|
||||
if (ps != null && !ps.isClosed()) ps.close();
|
||||
if (con != null && !con.isClosed()) con.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<Pair<Item, String>> loadGifts() {
|
||||
List<Pair<Item, String>> gifts = new ArrayList<>();
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
Connection con = null;
|
||||
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM `gifts` WHERE `to` = ?");
|
||||
ps.setInt(1, characterId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
@@ -419,6 +432,7 @@ public class CashShop {
|
||||
ps.setInt(1, characterId);
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class MakerItemFactory {
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
createCache.put(toCreate, ret);
|
||||
} catch (SQLException sqle) {
|
||||
sqle.printStackTrace();
|
||||
|
||||
@@ -65,6 +65,7 @@ import constants.ItemConstants;
|
||||
import constants.skills.Assassin;
|
||||
import constants.skills.Gunslinger;
|
||||
import constants.skills.NightWalker;
|
||||
import java.sql.Connection;
|
||||
import server.life.MapleMonsterInformationProvider;
|
||||
|
||||
/**
|
||||
@@ -533,10 +534,6 @@ public class MapleItemInformationProvider {
|
||||
return type[cat - 30];
|
||||
}
|
||||
|
||||
private boolean isCleanSlate(int scrollId) {
|
||||
return scrollId > 2048999 && scrollId < 2049004;
|
||||
}
|
||||
|
||||
private static double testYourLuck() {
|
||||
double result = 100.0, rolled;
|
||||
int i, j = ServerConstants.SCROLL_CHANCE_RATE;
|
||||
@@ -554,6 +551,14 @@ public class MapleItemInformationProvider {
|
||||
return(testYourLuck() <= prop && prop > 0.0);
|
||||
}
|
||||
|
||||
private static short getMaximumShortMaxIfOverflow(int value1, int value2) {
|
||||
return (short)Math.min(Short.MAX_VALUE, Math.max(value1, value2));
|
||||
}
|
||||
|
||||
private static short getShortMaxIfOverflow(int value) {
|
||||
return (short)Math.min(Short.MAX_VALUE, value);
|
||||
}
|
||||
|
||||
public Item scrollEquipWithId(Item equip, int scrollId, boolean usingWhiteScroll, boolean isGM) {
|
||||
if (equip instanceof Equip) {
|
||||
Equip nEquip = (Equip) equip;
|
||||
@@ -561,7 +566,7 @@ public class MapleItemInformationProvider {
|
||||
Map<String, Integer> stats = this.getEquipStats(scrollId);
|
||||
Map<String, Integer> eqstats = this.getEquipStats(equip.getItemId());
|
||||
|
||||
if (((nEquip.getUpgradeSlots() > 0 || isCleanSlate(scrollId))) || isGM) {
|
||||
if (((nEquip.getUpgradeSlots() > 0 || ItemConstants.isCleanSlate(scrollId))) || isGM) {
|
||||
if(isGM || rollSuccessChance((double)stats.get("success"))) {
|
||||
short flag = nEquip.getFlag();
|
||||
switch (scrollId) {
|
||||
@@ -600,7 +605,7 @@ public class MapleItemInformationProvider {
|
||||
for(i = 0; i < ServerConstants.SCROLL_CHANCE_RATE; i++) {
|
||||
if (nEquip.getStr() > 0) {
|
||||
temp = (nEquip.getStr() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setStr((short) Math.max(mdStr, temp));
|
||||
nEquip.setStr(getMaximumShortMaxIfOverflow(mdStr, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdStr = nEquip.getStr();
|
||||
@@ -612,7 +617,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getDex() > 0) {
|
||||
temp = (nEquip.getDex() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setDex((short) Math.max(mdDex, temp));
|
||||
nEquip.setDex(getMaximumShortMaxIfOverflow(mdDex, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdDex = nEquip.getDex();
|
||||
@@ -624,7 +629,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getInt() > 0) {
|
||||
temp = (nEquip.getInt() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setInt((short) Math.max(mdInt, temp));
|
||||
nEquip.setInt(getMaximumShortMaxIfOverflow(mdInt, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdInt = nEquip.getInt();
|
||||
@@ -636,7 +641,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getLuk() > 0) {
|
||||
temp = (nEquip.getLuk() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setLuk((short) Math.max(mdLuk, temp));
|
||||
nEquip.setLuk(getMaximumShortMaxIfOverflow(mdLuk, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdLuk = nEquip.getLuk();
|
||||
@@ -648,7 +653,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getWatk() > 0) {
|
||||
temp = (nEquip.getWatk() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setWatk((short) Math.max(mdWatk, temp));
|
||||
nEquip.setWatk(getMaximumShortMaxIfOverflow(mdWatk, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdWatk = nEquip.getWatk();
|
||||
@@ -660,7 +665,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getWdef() > 0) {
|
||||
temp = (nEquip.getWdef() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setWdef((short) Math.max(mdWdef, temp));
|
||||
nEquip.setWdef(getMaximumShortMaxIfOverflow(mdWdef, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdWdef = nEquip.getWdef();
|
||||
@@ -672,7 +677,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getMatk() > 0) {
|
||||
temp = (nEquip.getMatk() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setMatk((short) Math.max(mdMatk, temp));
|
||||
nEquip.setMatk(getMaximumShortMaxIfOverflow(mdMatk, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdMatk = nEquip.getMatk();
|
||||
@@ -684,7 +689,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getMdef() > 0) {
|
||||
temp = (nEquip.getMdef() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setMdef((short) Math.max(mdMdef, temp));
|
||||
nEquip.setMdef(getMaximumShortMaxIfOverflow(mdMdef, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdMdef = nEquip.getMdef();
|
||||
@@ -696,7 +701,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getAcc() > 0) {
|
||||
temp = (nEquip.getAcc() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setAcc((short) Math.max(mdAcc, temp));
|
||||
nEquip.setAcc(getMaximumShortMaxIfOverflow(mdAcc, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdAcc = nEquip.getAcc();
|
||||
@@ -708,7 +713,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getAvoid() > 0) {
|
||||
temp = (nEquip.getAvoid() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setAvoid((short) Math.max(mdAvoid, temp));
|
||||
nEquip.setAvoid(getMaximumShortMaxIfOverflow(mdAvoid, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdAvoid = nEquip.getAvoid();
|
||||
@@ -720,7 +725,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getSpeed() > 0) {
|
||||
temp = (nEquip.getSpeed() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setSpeed((short) Math.max(mdSpeed, temp));
|
||||
nEquip.setSpeed(getMaximumShortMaxIfOverflow(mdSpeed, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdSpeed = nEquip.getSpeed();
|
||||
@@ -732,7 +737,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getJump() > 0) {
|
||||
temp = (nEquip.getJump() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setJump((short) Math.max(mdJump, temp));
|
||||
nEquip.setJump(getMaximumShortMaxIfOverflow(mdJump, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdJump = nEquip.getJump();
|
||||
@@ -744,7 +749,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getHp() > 0) {
|
||||
temp = (nEquip.getHp() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setHp((short) Math.max(mdHp, temp));
|
||||
nEquip.setHp(getMaximumShortMaxIfOverflow(mdHp, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdHp = nEquip.getHp();
|
||||
@@ -756,7 +761,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
if (nEquip.getMp() > 0) {
|
||||
temp = (nEquip.getMp() + Randomizer.nextInt(6) * inc);
|
||||
nEquip.setMp((short) Math.max(mdMp, temp));
|
||||
nEquip.setMp(getMaximumShortMaxIfOverflow(mdMp, temp));
|
||||
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) {
|
||||
mdMp = nEquip.getMp();
|
||||
@@ -778,60 +783,60 @@ public class MapleItemInformationProvider {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) inc = 1;
|
||||
|
||||
if (nEquip.getStr() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setStr((short) Math.max(nEquip.getStr(), (nEquip.getStr() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setStr((short) Math.max(0, (nEquip.getStr() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setStr(getMaximumShortMaxIfOverflow(nEquip.getStr(), (nEquip.getStr() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setStr(getMaximumShortMaxIfOverflow(0, (nEquip.getStr() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getDex() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setDex((short) Math.max(nEquip.getDex(), (nEquip.getDex() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setDex((short) Math.max(0, (nEquip.getDex() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setDex(getMaximumShortMaxIfOverflow(nEquip.getDex(), (nEquip.getDex() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setDex(getMaximumShortMaxIfOverflow(0, (nEquip.getDex() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getInt() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setInt((short) Math.max(nEquip.getInt(), (nEquip.getInt() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setInt((short) Math.max(0, (nEquip.getInt() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setInt(getMaximumShortMaxIfOverflow(nEquip.getInt(), (nEquip.getInt() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setInt(getMaximumShortMaxIfOverflow(0, (nEquip.getInt() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getLuk() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setLuk((short) Math.max(nEquip.getLuk(), (nEquip.getLuk() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setLuk((short) Math.max(0, (nEquip.getLuk() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setLuk(getMaximumShortMaxIfOverflow(nEquip.getLuk(), (nEquip.getLuk() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setLuk(getMaximumShortMaxIfOverflow(0, (nEquip.getLuk() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getWatk() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setWatk((short) Math.max(nEquip.getWatk(), (nEquip.getWatk() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setWatk((short) Math.max(0, (nEquip.getWatk() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setWatk(getMaximumShortMaxIfOverflow(nEquip.getWatk(), (nEquip.getWatk() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setWatk(getMaximumShortMaxIfOverflow(0, (nEquip.getWatk() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getWdef() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setWdef((short) Math.max(nEquip.getWdef(), (nEquip.getWdef() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setWdef((short) Math.max(0, (nEquip.getWdef() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setWdef(getMaximumShortMaxIfOverflow(nEquip.getWdef(), (nEquip.getWdef() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setWdef(getMaximumShortMaxIfOverflow(0, (nEquip.getWdef() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getMatk() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMatk((short) Math.max(nEquip.getMatk(), (nEquip.getMatk() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setMatk((short) Math.max(0, (nEquip.getMatk() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMatk(getMaximumShortMaxIfOverflow(nEquip.getMatk(), (nEquip.getMatk() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setMatk(getMaximumShortMaxIfOverflow(0, (nEquip.getMatk() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getMdef() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMdef((short) Math.max(nEquip.getMdef(), (nEquip.getMdef() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setMdef((short) Math.max(0, (nEquip.getMdef() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMdef(getMaximumShortMaxIfOverflow(nEquip.getMdef(), (nEquip.getMdef() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setMdef(getMaximumShortMaxIfOverflow(0, (nEquip.getMdef() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getAcc() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setAcc((short) Math.max(nEquip.getAcc(), (nEquip.getAcc() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setAcc((short) Math.max(0, (nEquip.getAcc() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setAcc(getMaximumShortMaxIfOverflow(nEquip.getAcc(), (nEquip.getAcc() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setAcc(getMaximumShortMaxIfOverflow(0, (nEquip.getAcc() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getAvoid() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setAvoid((short) Math.max(nEquip.getAvoid(), (nEquip.getAvoid() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setAvoid((short) Math.max(0, (nEquip.getAvoid() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setAvoid(getMaximumShortMaxIfOverflow(nEquip.getAvoid(), (nEquip.getAvoid() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setAvoid(getMaximumShortMaxIfOverflow(0, (nEquip.getAvoid() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getSpeed() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setSpeed((short) Math.max(nEquip.getSpeed(), (nEquip.getSpeed() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setSpeed((short) Math.max(0, (nEquip.getSpeed() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setSpeed(getMaximumShortMaxIfOverflow(nEquip.getSpeed(), (nEquip.getSpeed() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setSpeed(getMaximumShortMaxIfOverflow(0, (nEquip.getSpeed() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getJump() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setJump((short) Math.max(nEquip.getJump(), (nEquip.getJump() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setJump((short) Math.max(0, (nEquip.getJump() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setJump(getMaximumShortMaxIfOverflow(nEquip.getJump(), (nEquip.getJump() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setJump(getMaximumShortMaxIfOverflow(0, (nEquip.getJump() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getHp() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setHp((short) Math.max(nEquip.getHp(), (nEquip.getHp() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setHp((short) Math.max(0, (nEquip.getHp() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setHp(getMaximumShortMaxIfOverflow(nEquip.getHp(), (nEquip.getHp() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setHp(getMaximumShortMaxIfOverflow(0, (nEquip.getHp() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
if (nEquip.getMp() > 0) {
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMp((short) Math.max(nEquip.getMp(), (nEquip.getMp() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setMp((short) Math.max(0, (nEquip.getMp() + Randomizer.nextInt(6) * inc)));
|
||||
if(ServerConstants.USE_ENHANCED_CHSCROLL == true) nEquip.setMp(getMaximumShortMaxIfOverflow(nEquip.getMp(), (nEquip.getMp() + Randomizer.nextInt(6) * inc)));
|
||||
else nEquip.setMp(getMaximumShortMaxIfOverflow(0, (nEquip.getMp() + Randomizer.nextInt(6) * inc)));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -840,46 +845,46 @@ public class MapleItemInformationProvider {
|
||||
for (Entry<String, Integer> stat : stats.entrySet()) {
|
||||
switch (stat.getKey()) {
|
||||
case "STR":
|
||||
nEquip.setStr((short) (nEquip.getStr() + stat.getValue().intValue()));
|
||||
nEquip.setStr(getShortMaxIfOverflow(nEquip.getStr() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "DEX":
|
||||
nEquip.setDex((short) (nEquip.getDex() + stat.getValue().intValue()));
|
||||
nEquip.setDex(getShortMaxIfOverflow(nEquip.getDex() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "INT":
|
||||
nEquip.setInt((short) (nEquip.getInt() + stat.getValue().intValue()));
|
||||
nEquip.setInt(getShortMaxIfOverflow(nEquip.getInt() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "LUK":
|
||||
nEquip.setLuk((short) (nEquip.getLuk() + stat.getValue().intValue()));
|
||||
nEquip.setLuk(getShortMaxIfOverflow(nEquip.getLuk() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "PAD":
|
||||
nEquip.setWatk((short) (nEquip.getWatk() + stat.getValue().intValue()));
|
||||
nEquip.setWatk(getShortMaxIfOverflow(nEquip.getWatk() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "PDD":
|
||||
nEquip.setWdef((short) (nEquip.getWdef() + stat.getValue().intValue()));
|
||||
nEquip.setWdef(getShortMaxIfOverflow(nEquip.getWdef() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "MAD":
|
||||
nEquip.setMatk((short) (nEquip.getMatk() + stat.getValue().intValue()));
|
||||
nEquip.setMatk(getShortMaxIfOverflow(nEquip.getMatk() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "MDD":
|
||||
nEquip.setMdef((short) (nEquip.getMdef() + stat.getValue().intValue()));
|
||||
nEquip.setMdef(getShortMaxIfOverflow(nEquip.getMdef() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "ACC":
|
||||
nEquip.setAcc((short) (nEquip.getAcc() + stat.getValue().intValue()));
|
||||
nEquip.setAcc(getShortMaxIfOverflow(nEquip.getAcc() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "EVA":
|
||||
nEquip.setAvoid((short) (nEquip.getAvoid() + stat.getValue().intValue()));
|
||||
nEquip.setAvoid(getShortMaxIfOverflow(nEquip.getAvoid() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "Speed":
|
||||
nEquip.setSpeed((short) (nEquip.getSpeed() + stat.getValue().intValue()));
|
||||
nEquip.setSpeed(getShortMaxIfOverflow(nEquip.getSpeed() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "Jump":
|
||||
nEquip.setJump((short) (nEquip.getJump() + stat.getValue().intValue()));
|
||||
nEquip.setJump(getShortMaxIfOverflow(nEquip.getJump() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "MHP":
|
||||
nEquip.setHp((short) (nEquip.getHp() + stat.getValue().intValue()));
|
||||
nEquip.setHp(getShortMaxIfOverflow(nEquip.getHp() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "MMP":
|
||||
nEquip.setMp((short) (nEquip.getMp() + stat.getValue().intValue()));
|
||||
nEquip.setMp(getShortMaxIfOverflow(nEquip.getMp() + stat.getValue().intValue()));
|
||||
break;
|
||||
case "afterImage":
|
||||
break;
|
||||
@@ -887,7 +892,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (!isCleanSlate(scrollId)) {
|
||||
if (!ItemConstants.isCleanSlate(scrollId)) {
|
||||
if (ServerConstants.USE_PERFECT_SCROLLING == true && !isGM && !usingWhiteScroll) {
|
||||
nEquip.setUpgradeSlots((byte) (nEquip.getUpgradeSlots() - 1));
|
||||
}
|
||||
@@ -895,14 +900,14 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
}
|
||||
|
||||
if (ServerConstants.USE_PERFECT_SCROLLING == false && !isCleanSlate(scrollId)) {
|
||||
if (ServerConstants.USE_PERFECT_SCROLLING == false && !ItemConstants.isCleanSlate(scrollId)) {
|
||||
if (!isGM && !usingWhiteScroll) {
|
||||
nEquip.setUpgradeSlots((byte) (nEquip.getUpgradeSlots() - 1));
|
||||
}
|
||||
//nEquip.setLevel((byte) (nEquip.getLevel() + 1));
|
||||
}
|
||||
} else {
|
||||
if (!usingWhiteScroll && !isCleanSlate(scrollId) && !isGM) {
|
||||
if (!usingWhiteScroll && !ItemConstants.isCleanSlate(scrollId) && !isGM) {
|
||||
nEquip.setUpgradeSlots((byte) (nEquip.getUpgradeSlots() - 1));
|
||||
}
|
||||
if (Randomizer.nextInt(101) < stats.get("cursed")) {
|
||||
@@ -1153,24 +1158,30 @@ public class MapleItemInformationProvider {
|
||||
private void loadCardIdData() {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
ps = DatabaseConnection.getConnection().prepareStatement("SELECT cardid, mobid FROM monstercarddata");
|
||||
con = DatabaseConnection.getConnection();
|
||||
ps = con.prepareStatement("SELECT cardid, mobid FROM monstercarddata");
|
||||
rs = ps.executeQuery();
|
||||
while (rs.next()) {
|
||||
monsterBookID.put(rs.getInt(1), rs.getInt(2));
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
if (rs != null && !rs.isClosed()) {
|
||||
rs.close();
|
||||
}
|
||||
if (ps != null) {
|
||||
if (ps != null && !ps.isClosed()) {
|
||||
ps.close();
|
||||
}
|
||||
if (con != null && !con.isClosed()) {
|
||||
con.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -1307,20 +1318,6 @@ public class MapleItemInformationProvider {
|
||||
eq.getAvoid() > 0 || eq.getSpeed() > 0 || eq.getJump() > 0 || eq.getHp() > 0 || eq.getMp() > 0);
|
||||
}
|
||||
|
||||
|
||||
public boolean isRateCoupon(int itemId) {
|
||||
int itemType = itemId / 1000;
|
||||
return itemType == 5211 || itemType == 5360;
|
||||
}
|
||||
|
||||
public boolean isPartyItem(int itemId) {
|
||||
return itemId >= 2022430 && itemId <= 2022433;
|
||||
}
|
||||
|
||||
public boolean isPartyAllcure(int itemId) {
|
||||
return itemId == 2022433;
|
||||
}
|
||||
|
||||
public Collection<Item> canWearEquipment(MapleCharacter chr, Collection<Item> items) {
|
||||
MapleInventory inv = chr.getInventory(MapleInventoryType.EQUIPPED);
|
||||
if (inv.checked()) {
|
||||
@@ -1523,9 +1520,10 @@ public class MapleItemInformationProvider {
|
||||
|
||||
public Set<String> getWhoDrops(Integer itemId) {
|
||||
Set<String> list = new HashSet<>();
|
||||
|
||||
Connection con = null;
|
||||
try {
|
||||
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM drop_data WHERE itemid = ? LIMIT 50");
|
||||
con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM drop_data WHERE itemid = ? LIMIT 50");
|
||||
ps.setInt(1, itemId);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while(rs.next()) {
|
||||
@@ -1536,6 +1534,7 @@ public class MapleItemInformationProvider {
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -233,6 +233,7 @@ public class MapleShop {
|
||||
} else {
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
return null;
|
||||
}
|
||||
ps = con.prepareStatement("SELECT * FROM shopitems WHERE shopid = ? ORDER BY position DESC");
|
||||
@@ -255,6 +256,7 @@ public class MapleShop {
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -61,11 +61,14 @@ public class MapleStorage {
|
||||
|
||||
private static MapleStorage create(int id, int world) {
|
||||
try {
|
||||
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("INSERT INTO storages (accountid, world, slots, meso) VALUES (?, ?, 4, 0)")) {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
try (PreparedStatement ps = con.prepareStatement("INSERT INTO storages (accountid, world, slots, meso) VALUES (?, ?, 4, 0)")) {
|
||||
ps.setInt(1, id);
|
||||
ps.setInt(2, world);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
|
||||
con.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -84,6 +87,7 @@ public class MapleStorage {
|
||||
if (!rs.next()) {
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
return create(id, world);
|
||||
} else {
|
||||
storeId = rs.getInt("storageid");
|
||||
@@ -94,6 +98,8 @@ public class MapleStorage {
|
||||
ret.items.add(item.getLeft());
|
||||
}
|
||||
}
|
||||
|
||||
con.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -59,9 +59,10 @@ public class MapleMonsterInformationProvider {
|
||||
private void retrieveGlobal() {
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
|
||||
try {
|
||||
final Connection con = DatabaseConnection.getConnection();
|
||||
con = DatabaseConnection.getConnection();
|
||||
ps = con.prepareStatement("SELECT * FROM drop_data_global WHERE chance > 0");
|
||||
rs = ps.executeQuery();
|
||||
|
||||
@@ -76,18 +77,23 @@ public class MapleMonsterInformationProvider {
|
||||
rs.getInt("maximum_quantity"),
|
||||
rs.getShort("questid")));
|
||||
}
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
System.err.println("Error retrieving drop" + e);
|
||||
} finally {
|
||||
try {
|
||||
if (ps != null) {
|
||||
if (ps != null && !ps.isClosed()) {
|
||||
ps.close();
|
||||
}
|
||||
if (rs != null) {
|
||||
if (rs != null && !rs.isClosed()) {
|
||||
rs.close();
|
||||
}
|
||||
if (con != null && !con.isClosed()) {
|
||||
con.close();
|
||||
}
|
||||
} catch (SQLException ignore) {
|
||||
ignore.printStackTrace();
|
||||
}
|
||||
@@ -102,8 +108,10 @@ public class MapleMonsterInformationProvider {
|
||||
|
||||
PreparedStatement ps = null;
|
||||
ResultSet rs = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM drop_data WHERE dropperid = ?");
|
||||
con = DatabaseConnection.getConnection();
|
||||
ps = con.prepareStatement("SELECT * FROM drop_data WHERE dropperid = ?");
|
||||
ps.setInt(1, monsterId);
|
||||
rs = ps.executeQuery();
|
||||
|
||||
@@ -116,17 +124,22 @@ public class MapleMonsterInformationProvider {
|
||||
rs.getInt("maximum_quantity"),
|
||||
rs.getShort("questid")));
|
||||
}
|
||||
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
e.printStackTrace();
|
||||
return ret;
|
||||
} finally {
|
||||
try {
|
||||
if (ps != null) {
|
||||
if (ps != null && !ps.isClosed()) {
|
||||
ps.close();
|
||||
}
|
||||
if (rs != null) {
|
||||
if (rs != null && !rs.isClosed()) {
|
||||
rs.close();
|
||||
}
|
||||
if (con != null && !con.isClosed()) {
|
||||
con.close();
|
||||
}
|
||||
} catch (SQLException ignore) {
|
||||
ignore.printStackTrace();
|
||||
return ret;
|
||||
|
||||
@@ -167,10 +167,14 @@ public class HiredMerchant extends AbstractMapleMapObject {
|
||||
owner.addMerchantMesos(price);
|
||||
} else {
|
||||
try {
|
||||
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET MerchantMesos = MerchantMesos + " + price + " WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET MerchantMesos = MerchantMesos + " + price + " WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
|
||||
ps.setInt(1, ownerId);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
|
||||
con.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -204,57 +208,67 @@ public class HiredMerchant extends AbstractMapleMapObject {
|
||||
|
||||
map.removeMapObject(this);
|
||||
|
||||
MapleCharacter player = Server.getInstance().getWorld(world).getPlayerStorage().getCharacterById(ownerId);
|
||||
if(player != null) {
|
||||
player.setHasMerchant(false);
|
||||
} else {
|
||||
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
|
||||
ps.setInt(1, ownerId);
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
MapleCharacter player = Server.getInstance().getWorld(world).getPlayerStorage().getCharacterById(ownerId);
|
||||
if(player != null) {
|
||||
player.setHasMerchant(false);
|
||||
} else {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS);
|
||||
ps.setInt(1, ownerId);
|
||||
ps.executeUpdate();
|
||||
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
map = null;
|
||||
schedule = null;
|
||||
}
|
||||
|
||||
public void closeShop(MapleClient c, boolean timeout) {
|
||||
map.removeMapObject(this);
|
||||
map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(ownerId));
|
||||
c.getChannelServer().removeHiredMerchant(ownerId);
|
||||
try {
|
||||
MapleCharacter player = c.getWorldServer().getPlayerStorage().getCharacterById(ownerId);
|
||||
if(player != null) {
|
||||
player.setHasMerchant(false);
|
||||
} else {
|
||||
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
|
||||
ps.setInt(1, ownerId);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
}
|
||||
if (check(c.getPlayer(), getItems()) && !timeout) {
|
||||
for (MaplePlayerShopItem mpsi : getItems()) {
|
||||
if (mpsi.isExist() && (mpsi.getItem().getType() == MapleInventoryType.EQUIP.getType())) {
|
||||
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().getFlag(), mpsi.getItem().getExpiration());
|
||||
}
|
||||
}
|
||||
items.clear();
|
||||
}
|
||||
map.removeMapObject(this);
|
||||
map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(ownerId));
|
||||
c.getChannelServer().removeHiredMerchant(ownerId);
|
||||
|
||||
try {
|
||||
this.saveItems(timeout);
|
||||
MapleCharacter player = c.getWorldServer().getPlayerStorage().getCharacterById(ownerId);
|
||||
if(player != null) {
|
||||
player.setHasMerchant(false);
|
||||
} else {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
|
||||
ps.setInt(1, ownerId);
|
||||
ps.executeUpdate();
|
||||
}
|
||||
con.close();
|
||||
}
|
||||
|
||||
if (check(c.getPlayer(), getItems()) && !timeout) {
|
||||
for (MaplePlayerShopItem mpsi : getItems()) {
|
||||
if (mpsi.isExist() && (mpsi.getItem().getType() == MapleInventoryType.EQUIP.getType())) {
|
||||
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().getFlag(), mpsi.getItem().getExpiration());
|
||||
}
|
||||
}
|
||||
items.clear();
|
||||
}
|
||||
|
||||
try {
|
||||
this.saveItems(timeout);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
items.clear();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
items.clear();
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
schedule.cancel(false);
|
||||
schedule.cancel(false);
|
||||
}
|
||||
|
||||
public String getOwner() {
|
||||
@@ -343,8 +357,10 @@ public class HiredMerchant extends AbstractMapleMapObject {
|
||||
itemsWithType.add(new Pair<>(newItem, MapleInventoryType.getByType(newItem.getType())));
|
||||
}
|
||||
}
|
||||
|
||||
ItemFactory.MERCHANT.saveItems(itemsWithType, this.ownerId, DatabaseConnection.getConnection());
|
||||
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
ItemFactory.MERCHANT.saveItems(itemsWithType, this.ownerId, con);
|
||||
con.close();
|
||||
}
|
||||
|
||||
private static boolean check(MapleCharacter chr, List<MaplePlayerShopItem> items) {
|
||||
|
||||
@@ -23,8 +23,10 @@ package server.maps;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.Rectangle;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
@@ -168,7 +170,9 @@ public class MapleMapFactory {
|
||||
map.addMapleArea(new Rectangle(x1, y1, (x2 - x1), (y2 - y1)));
|
||||
}
|
||||
}
|
||||
try { try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT * FROM playernpcs WHERE map = ?")) {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM playernpcs WHERE map = ?")) {
|
||||
ps.setInt(1, omapid);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
while (rs.next()) {
|
||||
@@ -176,7 +180,9 @@ public class MapleMapFactory {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.sql.ResultSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import client.MapleClient;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.MaplePacketCreator;
|
||||
@@ -54,7 +55,9 @@ public class PlayerNPCs extends AbstractMapleMapObject {
|
||||
RX1 = rs.getInt("rx1");
|
||||
npcId = rs.getInt("ScriptId");
|
||||
setPosition(new Point(rs.getInt("x"), CY));
|
||||
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT equippos, equipid FROM playernpcs_equip WHERE NpcId = ?");
|
||||
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT equippos, equipid FROM playernpcs_equip WHERE NpcId = ?");
|
||||
ps.setInt(1, rs.getInt("id"));
|
||||
ResultSet rs2 = ps.executeQuery();
|
||||
while (rs2.next()) {
|
||||
@@ -62,6 +65,7 @@ public class PlayerNPCs extends AbstractMapleMapObject {
|
||||
}
|
||||
rs2.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -147,8 +147,9 @@ public class MonsterCarnival {
|
||||
}
|
||||
|
||||
public void saveResults() {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO carnivalresults VALUES (?,?,?,?)");
|
||||
for (MapleCharacter chr : red.getMembers()) {
|
||||
ps.setInt(1, chr.getId());
|
||||
@@ -165,6 +166,7 @@ public class MonsterCarnival {
|
||||
ps.execute();
|
||||
}
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import provider.MapleDataProviderFactory;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.actions.*;
|
||||
import server.quest.requirements.*;
|
||||
import tools.FilePrinter;
|
||||
import tools.MaplePacketCreator;
|
||||
|
||||
/**
|
||||
@@ -113,8 +112,9 @@ public class MapleQuest {
|
||||
for (MapleData completeReq : completeReqData.getChildren()) {
|
||||
MapleQuestRequirementType type = MapleQuestRequirementType.getByWZName(completeReq.getName());
|
||||
MapleQuestRequirement req = this.getRequirement(type, completeReq);
|
||||
if(req == null)
|
||||
continue;
|
||||
|
||||
if(req == null)
|
||||
continue;
|
||||
|
||||
if (type.equals(MapleQuestRequirementType.INFO_NUMBER)) {
|
||||
infoNumber = (short) MapleDataTool.getInt(completeReq, 0);
|
||||
@@ -230,6 +230,9 @@ public class MapleQuest {
|
||||
}
|
||||
for (MapleQuestRequirement r : completeReqs.values()) {
|
||||
if (r == null || !r.check(c, npcid)) {
|
||||
if(r.getType() == MapleQuestRequirementType.MESO) { // TODO: find a way to tell the client about the new MESO requirement type.
|
||||
c.dropMessage(5, "You don't have enough mesos to complete this quest.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -402,6 +405,9 @@ public class MapleQuest {
|
||||
case MAX_LEVEL:
|
||||
ret = new MaxLevelRequirement(this, data);
|
||||
break;
|
||||
case MESO:
|
||||
ret = new MesoRequirement(this, data);
|
||||
break;
|
||||
case MIN_LEVEL:
|
||||
ret = new MinLevelRequirement(this, data);
|
||||
break;
|
||||
|
||||
@@ -26,7 +26,7 @@ package server.quest;
|
||||
* @author Matze
|
||||
*/
|
||||
public enum MapleQuestRequirementType {
|
||||
UNDEFINED(-1), JOB(0), ITEM(1), QUEST(2), MIN_LEVEL(3), MAX_LEVEL(4), END_DATE(5), MOB(6), NPC(7), FIELD_ENTER(8), INTERVAL(9), SCRIPT(10), PET(11), MIN_PET_TAMENESS(12), MONSTER_BOOK(13), NORMAL_AUTO_START(14), INFO_NUMBER(15), INFO_EX(16), COMPLETED_QUEST(17), START(18), END(19), DAY_BY_DAY(20);
|
||||
UNDEFINED(-1), JOB(0), ITEM(1), QUEST(2), MIN_LEVEL(3), MAX_LEVEL(4), END_DATE(5), MOB(6), NPC(7), FIELD_ENTER(8), INTERVAL(9), SCRIPT(10), PET(11), MIN_PET_TAMENESS(12), MONSTER_BOOK(13), NORMAL_AUTO_START(14), INFO_NUMBER(15), INFO_EX(16), COMPLETED_QUEST(17), START(18), END(19), DAY_BY_DAY(20), MESO(21);
|
||||
final byte type;
|
||||
|
||||
private MapleQuestRequirementType(int type) {
|
||||
@@ -82,6 +82,8 @@ public enum MapleQuestRequirementType {
|
||||
return END;
|
||||
} else if(name.equals("daybyday")) {
|
||||
return DAY_BY_DAY;
|
||||
} else if (name.equals("money")) {
|
||||
return MESO;
|
||||
} else {
|
||||
return UNDEFINED;
|
||||
}
|
||||
|
||||
52
src/server/quest/requirements/MesoRequirement.java
Normal file
52
src/server/quest/requirements/MesoRequirement.java
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
This file is part of the OdinMS Maple Story Server
|
||||
Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
|
||||
Matthias Butz <matze@odinms.de>
|
||||
Jan Christian Meyer <vimes@odinms.de>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as
|
||||
published by the Free Software Foundation version 3 as published by
|
||||
the Free Software Foundation. You may not use, modify or distribute
|
||||
this program under any other version of the GNU Affero General Public
|
||||
License.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package server.quest.requirements;
|
||||
|
||||
import provider.MapleData;
|
||||
import provider.MapleDataTool;
|
||||
import server.quest.MapleQuest;
|
||||
import server.quest.MapleQuestRequirementType;
|
||||
import client.MapleCharacter;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Ronan
|
||||
*/
|
||||
public class MesoRequirement extends MapleQuestRequirement {
|
||||
private int meso = 0;
|
||||
|
||||
public MesoRequirement(MapleQuest quest, MapleData data) {
|
||||
super(MapleQuestRequirementType.MESO);
|
||||
processData(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processData(MapleData data) {
|
||||
meso = MapleDataTool.getInt(data);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean check(MapleCharacter chr, Integer npcid) {
|
||||
return chr.getMeso() >= meso;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user