Code Coupons + Worldmap update + Mini-games + Player Interaction wrap
Fixed several cases on the Cash Shop that would freeze some player actions when triggered, requiring exit Cash Shop to unstuck. Implemented Code Coupons, supporting several items bundled on the same code, and also devised a way to automate code generation. Added a current status on-demand option on the Buyback command. Info such as "current fee" or "time remaining" are available now. Reviewed several cases where non-owned items would get stacked with owner-tagged items. Added Door support for Happyville, Crimsonwood Keep. Added worldmap tooltip support for some maps in Masteria's C. Keep and H. House. Added Masteria region to the world map. C. Keep interiors no longer relocates players to entrance after actions such as logout. Overhauled minigame mechanics: from player boxes tooltip and in-match improvements to deploy different minigame types, accordingly with item description or player choice. Fixed Amoria outskirts not relocating players to city after getting KO'ed. Fixed issues with pets, rings and cash items being assigned the same cash unique ids leading to some quirks on the cash shop inventory. Fixed an issue with the recently added HP/MP ratio update, arbitrarily taking off 1 point in certain cases. Answer positions on the explorer's 3rd job quiz are now randomed. Fixed several issues that showed up when the bcrypt system is disabled. DOT from maps such as El Nath and Aqua Road now procs at a 5sec interval, GMS-like. Improved performance of Whodrops and Search commands. Concurrently protected player interaction handlers, thus mitigating several exploits on these lines. Adjusted several expedition timers, such as Horntail, now having a more sane deadline. Concurrently protected chair modules. Fixed "seduce" debuff not working on chairs.
This commit is contained in:
@@ -42,6 +42,7 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
|
||||
protected int hpMpApUsed, remainingAp;
|
||||
protected int[] remainingSp = new int[10];
|
||||
protected transient int clientmaxhp, clientmaxmp, localmaxhp = 50, localmaxmp = 5;
|
||||
protected float transienthp = Float.NEGATIVE_INFINITY, transientmp = Float.NEGATIVE_INFINITY;
|
||||
|
||||
private AbstractCharacterListener listener = null;
|
||||
protected Map<MapleStat, Integer> statUpdates = new HashMap<>();
|
||||
@@ -222,6 +223,8 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
|
||||
} else if (thp > localmaxhp) {
|
||||
thp = localmaxhp;
|
||||
}
|
||||
|
||||
if (this.hp != thp) this.transienthp = Float.NEGATIVE_INFINITY;
|
||||
this.hp = thp;
|
||||
|
||||
dispatchHpChanged(oldHp);
|
||||
@@ -234,6 +237,8 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
|
||||
} else if (tmp > localmaxmp) {
|
||||
tmp = localmaxmp;
|
||||
}
|
||||
|
||||
if (this.mp != tmp) this.transientmp = Float.NEGATIVE_INFINITY;
|
||||
this.mp = tmp;
|
||||
}
|
||||
|
||||
@@ -246,11 +251,13 @@ public abstract class AbstractMapleCharacterObject extends AbstractAnimatedMaple
|
||||
}
|
||||
|
||||
protected void setMaxHp(int hp_) {
|
||||
if (this.maxhp < hp_) this.transienthp = Float.NEGATIVE_INFINITY;
|
||||
this.maxhp = hp_;
|
||||
this.clientmaxhp = Math.min(30000, hp_);
|
||||
}
|
||||
|
||||
protected void setMaxMp(int mp_) {
|
||||
if (this.maxmp < mp_) this.transientmp = Float.NEGATIVE_INFINITY;
|
||||
this.maxmp = mp_;
|
||||
this.clientmaxmp = Math.min(30000, mp_);
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ import client.inventory.MaplePet;
|
||||
import client.inventory.MapleWeaponType;
|
||||
import client.inventory.ModifyInventory;
|
||||
import client.inventory.PetDataFactory;
|
||||
import client.inventory.manipulator.MapleCashidGenerator;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import client.newyear.NewYearCardRecord;
|
||||
import constants.ExpTable;
|
||||
@@ -945,7 +946,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
public void setMasteries(int jobId) {
|
||||
int[] skills = new int[4];
|
||||
for (int i = 0; i > skills.length; i++) {
|
||||
skills[i] = 0; //that initialization meng
|
||||
skills[i] = 0; //that initialization meng
|
||||
}
|
||||
if (jobId == 112) {
|
||||
skills[0] = Hero.ACHILLES;
|
||||
@@ -1002,11 +1003,11 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
skills[1] = Aran.HIGH_MASTERY;
|
||||
skills[2] = Aran.FREEZE_STANDING;
|
||||
} else if (jobId == 2217) {
|
||||
skills[0] = Evan.MAPLE_WARRIOR;
|
||||
skills[1] = Evan.ILLUSION;
|
||||
skills[0] = Evan.MAPLE_WARRIOR;
|
||||
skills[1] = Evan.ILLUSION;
|
||||
} else if (jobId == 2218) {
|
||||
skills[0] = Evan.BLESSING_OF_THE_ONYX;
|
||||
skills[1] = Evan.BLAZE;
|
||||
skills[0] = Evan.BLESSING_OF_THE_ONYX;
|
||||
skills[1] = Evan.BLAZE;
|
||||
}
|
||||
for (Integer skillId : skills) {
|
||||
if (skillId != 0) {
|
||||
@@ -1341,12 +1342,11 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
|
||||
private boolean buffMapProtection() {
|
||||
effLock.lock();
|
||||
chrLock.lock();
|
||||
|
||||
int thisMapid = mapid;
|
||||
int returnMapid = client.getChannelServer().getMapFactory().getMap(thisMapid).getReturnMapId();
|
||||
|
||||
effLock.lock();
|
||||
chrLock.lock();
|
||||
try {
|
||||
for(Entry<MapleBuffStat, MapleBuffStatValueHolder> mbs : effects.entrySet()) {
|
||||
if(mbs.getKey() == MapleBuffStat.MAP_PROTECTION) {
|
||||
@@ -1884,7 +1884,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
if(hold + quantity <= ii.getSlotMax(client, itemid))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return getInventory(ItemConstants.getInventoryType(itemid)).getNextFreeSlot() > -1;
|
||||
}
|
||||
|
||||
@@ -1903,7 +1903,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
Skill battleship = SkillFactory.getSkill(Corsair.BATTLE_SHIP);
|
||||
int cooldown = battleship.getEffect(getSkillLevel(battleship)).getCooldown();
|
||||
announce(MaplePacketCreator.skillCooldown(Corsair.BATTLE_SHIP, cooldown));
|
||||
addCooldown(Corsair.BATTLE_SHIP, System.currentTimeMillis(), (long)(cooldown * 1000));
|
||||
addCooldown(Corsair.BATTLE_SHIP, Server.getInstance().getCurrentTime(), (long)(cooldown * 1000));
|
||||
removeCooldown(5221999);
|
||||
cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING);
|
||||
} else {
|
||||
@@ -2080,6 +2080,8 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
ps3.setInt(1, ringid);
|
||||
ps3.executeUpdate();
|
||||
}
|
||||
|
||||
MapleCashidGenerator.freeCashId(ringid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2090,11 +2092,13 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
ps2.executeUpdate();
|
||||
}
|
||||
|
||||
if(rs.getInt("petid") > -1) {
|
||||
int petid = rs.getInt("petid");
|
||||
if(petid > -1) {
|
||||
try (PreparedStatement ps2 = con.prepareStatement("DELETE FROM pets WHERE petid = ?")) {
|
||||
ps2.setInt(1, rs.getInt("petid"));
|
||||
ps2.setInt(1, petid);
|
||||
ps2.executeUpdate();
|
||||
}
|
||||
MapleCashidGenerator.freeCashId(petid);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2453,6 +2457,10 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
chrLock.unlock();
|
||||
}
|
||||
|
||||
if (disease == MapleDisease.SEDUCE && chair.get() != 0) {
|
||||
sitChair(0);
|
||||
}
|
||||
|
||||
final List<Pair<MapleDisease, Integer>> debuff = Collections.singletonList(new Pair<>(disease, Integer.valueOf(skill.getX())));
|
||||
client.announce(MaplePacketCreator.giveDebuff(debuff, skill));
|
||||
|
||||
@@ -2550,7 +2558,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
public void run() {
|
||||
doHurtHp();
|
||||
}
|
||||
}, 10000, 10000 - lastHpTask);
|
||||
}, ServerConstants.MAP_DAMAGE_OVERTIME_INTERVAL, ServerConstants.MAP_DAMAGE_OVERTIME_INTERVAL - lastHpTask);
|
||||
}
|
||||
|
||||
public void resetHpDecreaseTask() {
|
||||
@@ -2559,7 +2567,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
|
||||
long lastHpTask = Server.getInstance().getCurrentTime() - lastHpDec;
|
||||
startHpDecreaseTask((lastHpTask > 10000) ? 10000 : lastHpTask);
|
||||
startHpDecreaseTask((lastHpTask > ServerConstants.MAP_DAMAGE_OVERTIME_INTERVAL) ? ServerConstants.MAP_DAMAGE_OVERTIME_INTERVAL : lastHpTask);
|
||||
}
|
||||
|
||||
public void dropMessage(String message) {
|
||||
@@ -2682,7 +2690,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
effLock.unlock();
|
||||
}
|
||||
|
||||
long curTime = System.currentTimeMillis();
|
||||
long curTime = Server.getInstance().getCurrentTime();
|
||||
for(Entry<Integer, MapleCoolDownValueHolder> bel : es) {
|
||||
MapleCoolDownValueHolder mcdvh = bel.getValue();
|
||||
if(curTime >= mcdvh.startTime + mcdvh.length) {
|
||||
@@ -5247,8 +5255,9 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
this.battleshipHp = (int) length;
|
||||
addCooldown(skillid, 0, length);
|
||||
} else {
|
||||
int time = (int) ((length + starttime) - System.currentTimeMillis());
|
||||
addCooldown(skillid, System.currentTimeMillis(), time);
|
||||
long timeNow = Server.getInstance().getCurrentTime();
|
||||
int time = (int) ((length + starttime) - timeNow);
|
||||
addCooldown(skillid, timeNow, time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5433,9 +5442,43 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
int grade = Math.min(Math.max(level, 30), 120) - 30;
|
||||
|
||||
fee += (grade * ServerConstants.BUYBACK_LEVEL_STACK_FEE);
|
||||
if (ServerConstants.USE_BUYBACK_WITH_MESOS) fee *= ServerConstants.BUYBACK_MESO_MULTIPLIER;
|
||||
|
||||
return (int) Math.floor(fee);
|
||||
}
|
||||
|
||||
public void showBuybackInfo() {
|
||||
String s = "#eBUYBACK STATUS#n\r\n\r\nCurrent buyback fee: #b" + getBuybackFee() + " " + (ServerConstants.USE_BUYBACK_WITH_MESOS ? "mesos" : "NX") + "#k\r\n\r\n";
|
||||
|
||||
long timeNow = Server.getInstance().getCurrentTime();
|
||||
boolean avail = true;
|
||||
if (!isAlive()) {
|
||||
long timeLapsed = timeNow - lastDeathtime;
|
||||
long timeRemaining = ServerConstants.BUYBACK_RETURN_MINUTES * 60 * 1000 - (timeLapsed + Math.max(0, getNextBuybackTime() - timeNow));
|
||||
if (timeRemaining < 1) {
|
||||
s += "Buyback #e#rUNAVAILABLE#k#n";
|
||||
avail = false;
|
||||
} else {
|
||||
s += "Buyback countdown: #e#b" + getTimeRemaining(ServerConstants.BUYBACK_RETURN_MINUTES * 60 * 1000 - timeLapsed) + "#k#n";
|
||||
}
|
||||
s += "\r\n";
|
||||
}
|
||||
|
||||
if (timeNow < getNextBuybackTime() && avail) {
|
||||
s += "Buyback available in #r" + getTimeRemaining(getNextBuybackTime() - timeNow) + "#k";
|
||||
s += "\r\n";
|
||||
}
|
||||
|
||||
this.showHint(s);
|
||||
}
|
||||
|
||||
private static String getTimeRemaining(long timeLeft) {
|
||||
int seconds = (int) Math.floor(timeLeft / 1000) % 60;
|
||||
int minutes = (int) Math.floor(timeLeft / (1000*60)) % 60;
|
||||
|
||||
return (minutes > 0 ? (String.format("%02d", minutes) + " minutes, ") : "") + String.format("%02d", seconds) + " seconds";
|
||||
}
|
||||
|
||||
public boolean couldBuyback() { // Ronan's buyback system
|
||||
long timeNow = Server.getInstance().getCurrentTime();
|
||||
|
||||
@@ -5447,16 +5490,12 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
long nextBuybacktime = getNextBuybackTime();
|
||||
if (timeNow < nextBuybacktime) {
|
||||
long timeLeft = nextBuybacktime - timeNow;
|
||||
int seconds = (int) Math.floor(timeLeft / 1000) % 60;
|
||||
int minutes = (int) Math.floor(timeLeft / (1000*60)) % 60;
|
||||
|
||||
this.dropMessage(5, "Next buyback available in " + (minutes > 0 ? (String.format("%02d", minutes) + " minutes, ") : "") + String.format("%02d", seconds) + " seconds.");
|
||||
this.dropMessage(5, "Next buyback available in " + getTimeRemaining(timeLeft) + ".");
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean usingMesos = ServerConstants.USE_BUYBACK_WITH_MESOS;
|
||||
int fee = getBuybackFee();
|
||||
if (usingMesos) fee *= ServerConstants.BUYBACK_MESO_MULTIPLIER;
|
||||
|
||||
if (!canBuyback(fee, usingMesos)) {
|
||||
this.dropMessage(5, "You don't have " + fee + " " + (usingMesos ? "mesos" : "NX") + " to buyback.");
|
||||
@@ -5528,7 +5567,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
public void leaveMap() {
|
||||
controlled.clear();
|
||||
visibleMapObjects.clear();
|
||||
chair.set(0);
|
||||
setChair(0);
|
||||
if (hpDecreaseTask != null) {
|
||||
hpDecreaseTask.cancel(false);
|
||||
}
|
||||
@@ -5710,7 +5749,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
if (ServerConstants.USE_PERFECT_PITCH && level >= 30) {
|
||||
//milestones?
|
||||
if (MapleInventoryManipulator.checkSpace(client, 4310000, (short) 1, "")) {
|
||||
MapleInventoryManipulator.addById(client, 4310000, (short) 1);
|
||||
MapleInventoryManipulator.addById(client, 4310000, (short) 1, "", -1);
|
||||
}
|
||||
} else if (level == 10) {
|
||||
Runnable r = new Runnable() {
|
||||
@@ -6452,7 +6491,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
ps = con.prepareStatement("SELECT SkillID,StartTime,length FROM cooldowns WHERE charid = ?");
|
||||
ps.setInt(1, ret.getId());
|
||||
rs = ps.executeQuery();
|
||||
long curTime = System.currentTimeMillis();
|
||||
long curTime = Server.getInstance().getCurrentTime();
|
||||
while (rs.next()) {
|
||||
final int skillid = rs.getInt("SkillID");
|
||||
final long length = rs.getLong("length"), startTime = rs.getLong("StartTime");
|
||||
@@ -6534,7 +6573,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
ret.storage = MapleStorage.loadOrCreateFromDB(ret.accountid, ret.world);
|
||||
|
||||
int startHp = ret.hp, startMp = ret.mp;
|
||||
ret.recalcLocalStats();
|
||||
ret.reapplyLocalStats();
|
||||
ret.changeHpMp(startHp, startMp, true);
|
||||
//ret.resetBattleshipHp();
|
||||
}
|
||||
@@ -6651,7 +6690,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
private void playerDead() {
|
||||
cancelAllBuffs(false);
|
||||
dispelDebuffs();
|
||||
lastDeathtime = System.currentTimeMillis();
|
||||
lastDeathtime = Server.getInstance().getCurrentTime();
|
||||
|
||||
EventInstanceManager eim = getEventInstance();
|
||||
if (eim != null) {
|
||||
@@ -6702,14 +6741,53 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
cancelEffectFromBuffStat(MapleBuffStat.MONSTER_RIDING);
|
||||
}
|
||||
|
||||
if (getChair() != 0) {
|
||||
setChair(0);
|
||||
client.announce(MaplePacketCreator.cancelChair(-1));
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.showChair(getId(), 0), false);
|
||||
}
|
||||
unsitChairInternal();
|
||||
client.announce(MaplePacketCreator.enableActions());
|
||||
}
|
||||
|
||||
private void unsitChairInternal() {
|
||||
if (chair.get() != 0) {
|
||||
setChair(0);
|
||||
if (unregisterChairBuff()) {
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.cancelForeignChairSkillEffect(this.getId()), false);
|
||||
}
|
||||
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.showChair(this.getId(), 0), false);
|
||||
}
|
||||
|
||||
announce(MaplePacketCreator.cancelChair(-1));
|
||||
}
|
||||
|
||||
public void sitChair(int itemId) {
|
||||
if (client.tryacquireClient()) {
|
||||
try {
|
||||
if (itemId >= 1000000) { // sit on item chair
|
||||
if (chair.get() == 0) {
|
||||
setChair(itemId);
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.showChair(this.getId(), itemId), false);
|
||||
}
|
||||
announce(MaplePacketCreator.enableActions());
|
||||
} else if (itemId != 0) { // sit on map chair
|
||||
if (chair.get() == 0) {
|
||||
setChair(itemId);
|
||||
if (registerChairBuff()) {
|
||||
getMap().broadcastMessage(this, MaplePacketCreator.giveForeignChairSkillEffect(this.getId()), false);
|
||||
}
|
||||
announce(MaplePacketCreator.cancelChair(itemId));
|
||||
}
|
||||
} else { // stand up
|
||||
unsitChairInternal();
|
||||
}
|
||||
} finally {
|
||||
client.releaseClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setChair(int chair) {
|
||||
this.chair.set(chair);
|
||||
}
|
||||
|
||||
public void respawn(int returnMap) {
|
||||
respawn(null, returnMap); // unspecified EIM, don't force EIM unregister in this case
|
||||
}
|
||||
@@ -6780,15 +6858,11 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
localwatk += equipwatk;
|
||||
}
|
||||
|
||||
private List<Pair<MapleStat, Integer>> recalcLocalStats() {
|
||||
private void reapplyLocalStats() {
|
||||
effLock.lock();
|
||||
chrLock.lock();
|
||||
statWlock.lock();
|
||||
try {
|
||||
List<Pair<MapleStat, Integer>> hpmpupdate = new ArrayList<>(2);
|
||||
|
||||
int oldlocalmaxhp = localmaxhp;
|
||||
int oldlocalmaxmp = localmaxmp;
|
||||
|
||||
localmaxhp = getMaxHp();
|
||||
localmaxmp = getMaxMp();
|
||||
localdex = getDex();
|
||||
@@ -6815,11 +6889,6 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
localmaxhp = Math.min(30000, localmaxhp);
|
||||
localmaxmp = Math.min(30000, localmaxmp);
|
||||
|
||||
if (ServerConstants.USE_FIXED_RATIO_HPMP_UPDATE) {
|
||||
if (localmaxhp != oldlocalmaxhp) hpmpupdate.add(calcHpRatioUpdate(localmaxhp, oldlocalmaxhp));
|
||||
if (localmaxmp != oldlocalmaxmp) hpmpupdate.add(calcMpRatioUpdate(localmaxmp, oldlocalmaxmp));
|
||||
}
|
||||
|
||||
MapleStatEffect combo = getBuffEffect(MapleBuffStat.ARAN_COMBO);
|
||||
if (combo != null) {
|
||||
localwatk += combo.getX();
|
||||
@@ -6906,10 +6975,54 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
// Add throwing stars to dmg.
|
||||
}
|
||||
} finally {
|
||||
statWlock.unlock();
|
||||
chrLock.unlock();
|
||||
effLock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
private List<Pair<MapleStat, Integer>> recalcLocalStats() {
|
||||
effLock.lock();
|
||||
chrLock.lock();
|
||||
statWlock.lock();
|
||||
try {
|
||||
List<Pair<MapleStat, Integer>> hpmpupdate = new ArrayList<>(2);
|
||||
int oldlocalmaxhp = localmaxhp;
|
||||
int oldlocalmaxmp = localmaxmp;
|
||||
|
||||
reapplyLocalStats();
|
||||
|
||||
if (ServerConstants.USE_FIXED_RATIO_HPMP_UPDATE) {
|
||||
if (localmaxhp != oldlocalmaxhp) {
|
||||
Pair<MapleStat, Integer> hpUpdate;
|
||||
|
||||
if (transienthp == Float.NEGATIVE_INFINITY) {
|
||||
hpUpdate = calcHpRatioUpdate(localmaxhp, oldlocalmaxhp);
|
||||
} else {
|
||||
hpUpdate = calcHpRatioTransient();
|
||||
}
|
||||
|
||||
hpmpupdate.add(hpUpdate);
|
||||
}
|
||||
|
||||
if (localmaxmp != oldlocalmaxmp) {
|
||||
Pair<MapleStat, Integer> mpUpdate;
|
||||
|
||||
if (transientmp == Float.NEGATIVE_INFINITY) {
|
||||
mpUpdate = calcMpRatioUpdate(localmaxmp, oldlocalmaxmp);
|
||||
} else {
|
||||
mpUpdate = calcMpRatioTransient();
|
||||
}
|
||||
|
||||
hpmpupdate.add(mpUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
return hpmpupdate;
|
||||
} finally {
|
||||
statWlock.unlock();
|
||||
chrLock.unlock();
|
||||
effLock.unlock();
|
||||
}
|
||||
}
|
||||
@@ -7789,10 +7902,6 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
}
|
||||
|
||||
public void setChair(int chair) {
|
||||
this.chair.set(chair);
|
||||
}
|
||||
|
||||
public void setChalkboard(String text) {
|
||||
this.chalktext = text;
|
||||
}
|
||||
@@ -7968,7 +8077,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
private Pair<MapleStat, Integer> calcHpRatioUpdate(int newHp, int oldHp) {
|
||||
int delta = newHp - oldHp;
|
||||
this.hp = calcHpMpRatioUpdate(hp, oldHp, delta);
|
||||
this.hp = calcHpRatioUpdate(hp, oldHp, delta);
|
||||
|
||||
hpChangeAction(Short.MIN_VALUE);
|
||||
return new Pair<>(MapleStat.HP, hp);
|
||||
@@ -7976,19 +8085,47 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
|
||||
private Pair<MapleStat, Integer> calcMpRatioUpdate(int newMp, int oldMp) {
|
||||
int delta = newMp - oldMp;
|
||||
this.mp = calcHpMpRatioUpdate(mp, oldMp, delta);
|
||||
this.mp = calcMpRatioUpdate(mp, oldMp, delta);
|
||||
return new Pair<>(MapleStat.MP, mp);
|
||||
}
|
||||
|
||||
private static int calcHpMpRatioUpdate(int curpoint, int maxpoint, int diffpoint) {
|
||||
private static int calcTransientRatio(float transientpoint) {
|
||||
int ret = (int) transientpoint;
|
||||
return !(ret <= 0 && transientpoint > 0.0f) ? ret : 1;
|
||||
}
|
||||
|
||||
private Pair<MapleStat, Integer> calcHpRatioTransient() {
|
||||
this.hp = calcTransientRatio(transienthp * localmaxhp);
|
||||
|
||||
hpChangeAction(Short.MIN_VALUE);
|
||||
return new Pair<>(MapleStat.HP, hp);
|
||||
}
|
||||
|
||||
private Pair<MapleStat, Integer> calcMpRatioTransient() {
|
||||
this.mp = calcTransientRatio(transientmp * localmaxmp);
|
||||
return new Pair<>(MapleStat.MP, mp);
|
||||
}
|
||||
|
||||
private int calcHpRatioUpdate(int curpoint, int maxpoint, int diffpoint) {
|
||||
int curMax = maxpoint;
|
||||
int nextMax = Math.min(30000, maxpoint + diffpoint);
|
||||
|
||||
float temp = curpoint * nextMax;
|
||||
int ret = (int) Math.round(temp / curMax);
|
||||
int ret = (int) Math.ceil(temp / curMax);
|
||||
|
||||
//System.out.println("cur: " + curpoint + " next: " + ret + " max: " + curMax + " nextmax:" + nextMax + " diff: " + diffpoint);
|
||||
return !(ret <= 0 && curpoint > 0) ? ret : 1;
|
||||
transienthp = (maxpoint > nextMax) ? ((float) curpoint) / maxpoint : ((float) ret) / nextMax;
|
||||
return ret;
|
||||
}
|
||||
|
||||
private int calcMpRatioUpdate(int curpoint, int maxpoint, int diffpoint) {
|
||||
int curMax = maxpoint;
|
||||
int nextMax = Math.min(30000, maxpoint + diffpoint);
|
||||
|
||||
float temp = curpoint * nextMax;
|
||||
int ret = (int) Math.ceil(temp / curMax);
|
||||
|
||||
transientmp = (maxpoint > nextMax) ? ((float) curpoint) / maxpoint : ((float) ret) / nextMax;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean applyHpMpChange(int hpCon, int hpchange, int mpchange) {
|
||||
@@ -8137,7 +8274,6 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
doorSlot = -1;
|
||||
|
||||
party = null;
|
||||
//cancelMagicDoor(); // cancel magic doors if kicked out / quitted from party.
|
||||
} else {
|
||||
party = p;
|
||||
}
|
||||
@@ -9082,11 +9218,27 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
}
|
||||
pendantExp = 0;
|
||||
}
|
||||
|
||||
private Collection<Item> getUpgradeableEquipList() {
|
||||
Collection<Item> fullList = getInventory(MapleInventoryType.EQUIPPED).list();
|
||||
if (ServerConstants.USE_EQUIPMNT_LVLUP_CASH) {
|
||||
return fullList;
|
||||
}
|
||||
|
||||
Collection<Item> eqpList = new LinkedHashSet<>();
|
||||
for (Item it : fullList) {
|
||||
if (!ii.isCash(it.getItemId())) {
|
||||
eqpList.add(it);
|
||||
}
|
||||
}
|
||||
|
||||
return eqpList;
|
||||
}
|
||||
|
||||
public void increaseEquipExp(int expGain) {
|
||||
if(expGain < 0) expGain = Integer.MAX_VALUE;
|
||||
|
||||
for (Item item : getInventory(MapleInventoryType.EQUIPPED).list()) {
|
||||
for (Item item : getUpgradeableEquipList()) {
|
||||
Equip nEquip = (Equip) item;
|
||||
String itemName = ii.getName(nEquip.getItemId());
|
||||
if (itemName == null) {
|
||||
|
||||
@@ -41,6 +41,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.locks.Lock;
|
||||
|
||||
import tools.*;
|
||||
@@ -109,8 +110,10 @@ public class MapleClient {
|
||||
private String pic = null;
|
||||
private String hwid = null;
|
||||
private int picattempt = 0;
|
||||
private byte csattempt = 0;
|
||||
private byte gender = -1;
|
||||
private boolean disconnecting = false;
|
||||
private final Semaphore actionsSemaphore = new Semaphore(7);
|
||||
private final Lock lock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CLIENT, true);
|
||||
private final Lock encoderLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CLIENT_ENCODER, true);
|
||||
private static final Lock loginLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.CLIENT_LOGIN, true);
|
||||
@@ -532,7 +535,6 @@ public class MapleClient {
|
||||
gender = rs.getByte("gender");
|
||||
characterSlots = rs.getByte("characterslots");
|
||||
String passhash = rs.getString("password");
|
||||
String salt = rs.getString("salt");
|
||||
byte tos = rs.getByte("tos");
|
||||
|
||||
ps.close();
|
||||
@@ -547,8 +549,9 @@ public class MapleClient {
|
||||
loginok = 7;
|
||||
} else if (passhash.charAt(0) == '$' && passhash.charAt(1) == '2' && BCrypt.checkpw(pwd, passhash)) {
|
||||
loginok = (tos == 0) ? 23 : 0;
|
||||
} else if (pwd.equals(passhash) || checkHash(passhash, "SHA-1", pwd) || checkHash(passhash, "SHA-512", pwd + salt)) {
|
||||
loginok = (tos == 0) ? -23 : -10; // migrate to bcrypt
|
||||
} else if (pwd.equals(passhash) || checkHash(passhash, "SHA-1", pwd) || checkHash(passhash, "SHA-512", pwd)) {
|
||||
// thanks GabrielSin for detecting some no-bcrypt inconsistencies here
|
||||
loginok = (tos == 0) ? (!ServerConstants.BCRYPT_MIGRATION ? 23 : -23) : (!ServerConstants.BCRYPT_MIGRATION ? 0 : -10); // migrate to bcrypt
|
||||
} else {
|
||||
loggedIn = false;
|
||||
loginok = 4;
|
||||
@@ -775,7 +778,7 @@ public class MapleClient {
|
||||
if (!rs.next()) {
|
||||
rs.close();
|
||||
ps.close();
|
||||
throw new RuntimeException("getLoginState - MapleClient");
|
||||
throw new RuntimeException("getLoginState - MapleClient AccID: " + getAccID());
|
||||
}
|
||||
|
||||
birthday = Calendar.getInstance();
|
||||
@@ -1170,10 +1173,20 @@ public class MapleClient {
|
||||
lock.unlock();
|
||||
}
|
||||
|
||||
public boolean trylockClient() {
|
||||
return lock.tryLock();
|
||||
public boolean tryacquireClient() {
|
||||
if (actionsSemaphore.tryAcquire()) {
|
||||
lockClient();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void releaseClient() {
|
||||
unlockClient();
|
||||
actionsSemaphore.release();
|
||||
}
|
||||
|
||||
public void lockEncoder() {
|
||||
encoderLock.lock();
|
||||
}
|
||||
@@ -1198,7 +1211,7 @@ public class MapleClient {
|
||||
try {
|
||||
MessageDigest digester = MessageDigest.getInstance(type);
|
||||
digester.update(password.getBytes("UTF-8"), 0, password.length());
|
||||
return HexTool.toString(digester.digest()).replace(" ", "").toLowerCase().equals(hash);
|
||||
return HexTool.toString(digester.digest()).replace(" ", "").toLowerCase().equals(hash);
|
||||
} catch (NoSuchAlgorithmException | UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("Encoding the string failed", e);
|
||||
}
|
||||
@@ -1431,4 +1444,22 @@ public class MapleClient {
|
||||
this.removeClickedNPC();
|
||||
NPCScriptManager.getInstance().dispose(this);
|
||||
}
|
||||
|
||||
public boolean attemptCsCoupon() {
|
||||
if (csattempt > 2) {
|
||||
resetCsCoupon();
|
||||
return false;
|
||||
}
|
||||
|
||||
csattempt++;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void resetCsCoupon() {
|
||||
csattempt = 0;
|
||||
}
|
||||
|
||||
public void enableCSActions() {
|
||||
announce(MaplePacketCreator.enableCSUse(player));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,9 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import tools.Pair;
|
||||
import tools.DatabaseConnection;
|
||||
import client.inventory.manipulator.MapleCashidGenerator;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -86,6 +87,9 @@ public class MapleRing implements Comparable<MapleRing> {
|
||||
ps.executeBatch();
|
||||
ps.close();
|
||||
|
||||
MapleCashidGenerator.freeCashId(ring.getRingId());
|
||||
MapleCashidGenerator.freeCashId(ring.getPartnerRingId());
|
||||
|
||||
ps = con.prepareStatement("UPDATE inventoryequipment SET ringid=-1 WHERE ringid=?");
|
||||
ps.setInt(1, ring.getRingId());
|
||||
ps.addBatch();
|
||||
@@ -102,46 +106,40 @@ public class MapleRing implements Comparable<MapleRing> {
|
||||
}
|
||||
}
|
||||
|
||||
public static int createRing(int itemid, final MapleCharacter partner1, final MapleCharacter partner2) {
|
||||
public static Pair<Integer, Integer> createRing(int itemid, final MapleCharacter partner1, final MapleCharacter partner2) {
|
||||
try {
|
||||
if (partner1 == null) {
|
||||
return -2;
|
||||
return new Pair<>(-3, -3);
|
||||
} else if (partner2 == null) {
|
||||
return -1;
|
||||
return new Pair<>(-2, -2);
|
||||
}
|
||||
|
||||
int[] ringID = new int[2];
|
||||
ringID[0] = MapleCashidGenerator.generateCashId();
|
||||
ringID[1] = MapleCashidGenerator.generateCashId();
|
||||
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO rings (itemid, partnerChrId, partnername) VALUES (?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
ps.setInt(1, itemid);
|
||||
ps.setInt(2, partner2.getId());
|
||||
ps.setString(3, partner2.getName());
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO rings (id, itemid, partnerRingId, partnerChrId, partnername) VALUES (?, ?, ?, ?, ?)");
|
||||
ps.setInt(1, ringID[0]);
|
||||
ps.setInt(2, itemid);
|
||||
ps.setInt(3, ringID[1]);
|
||||
ps.setInt(4, partner2.getId());
|
||||
ps.setString(5, partner2.getName());
|
||||
ps.executeUpdate();
|
||||
ResultSet rs = ps.getGeneratedKeys();
|
||||
rs.next();
|
||||
ringID[0] = rs.getInt(1); // ID.
|
||||
rs.close();
|
||||
ps.close();
|
||||
ps = con.prepareStatement("INSERT INTO rings (itemid, partnerRingId, partnerChrId, partnername) VALUES (?, ?, ?, ?)", Statement.RETURN_GENERATED_KEYS);
|
||||
ps.setInt(1, itemid);
|
||||
ps.setInt(2, ringID[0]);
|
||||
ps.setInt(3, partner1.getId());
|
||||
ps.setString(4, partner1.getName());
|
||||
ps.executeUpdate();
|
||||
rs = ps.getGeneratedKeys();
|
||||
rs.next();
|
||||
ringID[1] = rs.getInt(1);
|
||||
rs.close();
|
||||
ps.close();
|
||||
ps = con.prepareStatement("UPDATE rings SET partnerRingId = ? WHERE id = ?");
|
||||
ps = con.prepareStatement("INSERT INTO rings (id, itemid, partnerRingId, partnerChrId, partnername) VALUES (?, ?, ?, ?, ?)");
|
||||
ps.setInt(1, ringID[1]);
|
||||
ps.setInt(2, ringID[0]);
|
||||
ps.setInt(2, itemid);
|
||||
ps.setInt(3, ringID[0]);
|
||||
ps.setInt(4, partner1.getId());
|
||||
ps.setString(5, partner1.getName());
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
con.close();
|
||||
return ringID[0];
|
||||
return new Pair<>(ringID[0], ringID[1]);
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
return -1;
|
||||
return new Pair<>(-1, -1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ package client.autoban;
|
||||
import client.MapleCharacter;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import net.server.Server;
|
||||
import tools.FilePrinter;
|
||||
|
||||
/**
|
||||
@@ -35,12 +36,12 @@ public class AutobanManager {
|
||||
return;
|
||||
}
|
||||
if (lastTime.containsKey(fac)) {
|
||||
if (lastTime.get(fac) < (System.currentTimeMillis() - fac.getExpire())) {
|
||||
if (lastTime.get(fac) < (Server.getInstance().getCurrentTime() - fac.getExpire())) {
|
||||
points.put(fac, points.get(fac) / 2); //So the points are not completely gone.
|
||||
}
|
||||
}
|
||||
if (fac.getExpire() != -1)
|
||||
lastTime.put(fac, System.currentTimeMillis());
|
||||
lastTime.put(fac, Server.getInstance().getCurrentTime());
|
||||
|
||||
if (points.containsKey(fac)) {
|
||||
points.put(fac, points.get(fac) + 1);
|
||||
@@ -76,7 +77,7 @@ public class AutobanManager {
|
||||
|
||||
//Don't use the same type for more than 1 thing
|
||||
public void spam(int type) {
|
||||
this.spam[type] = System.currentTimeMillis();
|
||||
this.spam[type] = Server.getInstance().getCurrentTime();
|
||||
}
|
||||
|
||||
public void spam(int type, int timestamp) {
|
||||
|
||||
@@ -162,6 +162,7 @@ public class CommandsExecutor {
|
||||
addCommand("droplimit", DropLimitCommand.class);
|
||||
addCommand("time", TimeCommand.class);
|
||||
addCommand("credits", StaffCommand.class);
|
||||
addCommand("buyback", BuyBackCommand.class);
|
||||
addCommand("uptime", UptimeCommand.class);
|
||||
addCommand("gacha", GachaCommand.class);
|
||||
addCommand("dispose", DisposeCommand.class);
|
||||
@@ -345,6 +346,7 @@ public class CommandsExecutor {
|
||||
addCommand("shutdown", 6, ShutdownCommand.class);
|
||||
addCommand("clearquestcache", 6, ClearQuestCacheCommand.class);
|
||||
addCommand("clearquest", 6, ClearQuestCommand.class);
|
||||
addCommand("supplyratecoupon", 6, SupplyRateCouponCommand.class);
|
||||
addCommand("spawnallpnpcs", 6, SpawnAllPNpcsCommand.class);
|
||||
addCommand("eraseallpnpcs", 6, EraseAllPNpcsCommand.class);
|
||||
addCommand("addchannel", 6, ServerAddChannelCommand.class);
|
||||
|
||||
@@ -30,6 +30,15 @@ import client.processor.BuybackProcessor;
|
||||
public class BuyBackCommand extends Command {
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
BuybackProcessor.processBuyback(c);
|
||||
if (params.length < 1) {
|
||||
c.getPlayer().yellowMessage("Syntax: @buyback <info|now>");
|
||||
return;
|
||||
}
|
||||
|
||||
if (params[0].contentEquals("now")) {
|
||||
BuybackProcessor.processBuyback(c);
|
||||
} else {
|
||||
c.getPlayer().showBuybackInfo();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StatDexCommand extends Command {
|
||||
int remainingAp = player.getRemainingAp();
|
||||
|
||||
int amount = (params.length > 0) ? Math.min(Integer.parseInt(params[0]), remainingAp) : Math.min(remainingAp, ServerConstants.MAX_AP - player.getDex());
|
||||
if (!player.assignDex(amount)) {
|
||||
if (!player.assignDex(Math.max(amount, 0))) {
|
||||
player.dropMessage("Please make sure your AP is not over " + ServerConstants.MAX_AP + " and you have enough to distribute.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StatIntCommand extends Command {
|
||||
int remainingAp = player.getRemainingAp();
|
||||
|
||||
int amount = (params.length > 0) ? Math.min(Integer.parseInt(params[0]), remainingAp) : Math.min(remainingAp, ServerConstants.MAX_AP - player.getInt());
|
||||
if (!player.assignInt(amount)) {
|
||||
if (!player.assignInt(Math.max(amount, 0))) {
|
||||
player.dropMessage("Please make sure your AP is not over " + ServerConstants.MAX_AP + " and you have enough to distribute.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StatLukCommand extends Command {
|
||||
int remainingAp = player.getRemainingAp();
|
||||
|
||||
int amount = (params.length > 0) ? Math.min(Integer.parseInt(params[0]), remainingAp) : Math.min(remainingAp, ServerConstants.MAX_AP - player.getLuk());
|
||||
if (!player.assignLuk(amount)) {
|
||||
if (!player.assignLuk(Math.max(amount, 0))) {
|
||||
player.dropMessage("Please make sure your AP is not over " + ServerConstants.MAX_AP + " and you have enough to distribute.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ public class StatStrCommand extends Command {
|
||||
int remainingAp = player.getRemainingAp();
|
||||
int amount = (params.length > 0) ? Math.min(Integer.parseInt(params[0]), remainingAp) : Math.min(remainingAp, ServerConstants.MAX_AP - player.getStr());
|
||||
|
||||
if (!player.assignStr(amount)) {
|
||||
if (!player.assignStr(Math.max(amount, 0))) {
|
||||
player.dropMessage("Please make sure your AP is not over " + ServerConstants.MAX_AP + " and you have enough to distribute.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,40 +49,49 @@ public class WhoDropsCommand extends Command {
|
||||
player.dropMessage(5, "Please do @whodrops <item name>");
|
||||
return;
|
||||
}
|
||||
String searchString = joinStringFrom(params, 0);
|
||||
String output = "";
|
||||
Iterator<Pair<Integer, String>> listIterator = MapleItemInformationProvider.getInstance().getItemDataByName(searchString).iterator();
|
||||
if(listIterator.hasNext()) {
|
||||
int count = 1;
|
||||
while(listIterator.hasNext() && count <= 3) {
|
||||
Pair<Integer, String> data = listIterator.next();
|
||||
output += "#b" + data.getRight() + "#k is dropped by:\r\n";
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT dropperid FROM drop_data WHERE itemid = ? LIMIT 50");
|
||||
ps.setInt(1, data.getLeft());
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while(rs.next()) {
|
||||
String resultName = MapleMonsterInformationProvider.getMobNameFromID(rs.getInt("dropperid"));
|
||||
if (resultName != null) {
|
||||
output += resultName + ", ";
|
||||
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
String searchString = joinStringFrom(params, 0);
|
||||
String output = "";
|
||||
Iterator<Pair<Integer, String>> listIterator = MapleItemInformationProvider.getInstance().getItemDataByName(searchString).iterator();
|
||||
if(listIterator.hasNext()) {
|
||||
int count = 1;
|
||||
while(listIterator.hasNext() && count <= 3) {
|
||||
Pair<Integer, String> data = listIterator.next();
|
||||
output += "#b" + data.getRight() + "#k is dropped by:\r\n";
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT dropperid FROM drop_data WHERE itemid = ? LIMIT 50");
|
||||
ps.setInt(1, data.getLeft());
|
||||
ResultSet rs = ps.executeQuery();
|
||||
while(rs.next()) {
|
||||
String resultName = MapleMonsterInformationProvider.getMobNameFromID(rs.getInt("dropperid"));
|
||||
if (resultName != null) {
|
||||
output += resultName + ", ";
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (Exception e) {
|
||||
player.dropMessage(6, "There was a problem retrieving the required data. Please try again.");
|
||||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
output += "\r\n\r\n";
|
||||
count++;
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
} catch (Exception e) {
|
||||
player.dropMessage(6, "There was a problem retrieving the required data. Please try again.");
|
||||
e.printStackTrace();
|
||||
} else {
|
||||
player.dropMessage(5, "The item you searched for doesn't exist.");
|
||||
return;
|
||||
}
|
||||
output += "\r\n\r\n";
|
||||
count++;
|
||||
c.announce(MaplePacketCreator.getNPCTalk(9010000, (byte) 0, output, "00 00", (byte) 0));
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} else {
|
||||
player.dropMessage(5, "The item you searched for doesn't exist.");
|
||||
return;
|
||||
player.dropMessage(5, "Please wait a while for your request to be processed.");
|
||||
}
|
||||
c.announce(MaplePacketCreator.getNPCTalk(9010000, (byte) 0, output, "00 00", (byte) 0));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,6 @@ public class ItemDropCommand extends Command {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Item toDrop;
|
||||
if (ItemConstants.getInventoryType(itemId) == MapleInventoryType.EQUIP) {
|
||||
|
||||
@@ -37,8 +37,19 @@ import tools.Pair;
|
||||
import java.io.File;
|
||||
|
||||
public class SearchCommand extends Command {
|
||||
private static MapleData npcStringData;
|
||||
private static MapleData mobStringData;
|
||||
private static MapleData skillStringData;
|
||||
private static MapleData mapStringData;
|
||||
|
||||
{
|
||||
setDescription("");
|
||||
|
||||
MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File("wz/String.wz"));
|
||||
npcStringData = dataProvider.getData("Npc.img");
|
||||
mobStringData = dataProvider.getData("Mob.img");
|
||||
skillStringData = dataProvider.getData("Skill.img");
|
||||
mapStringData = dataProvider.getData("Map.img");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,26 +64,43 @@ public class SearchCommand extends Command {
|
||||
String search = joinStringFrom(params,1);
|
||||
long start = System.currentTimeMillis();//for the lulz
|
||||
MapleData data = null;
|
||||
MapleDataProvider dataProvider = MapleDataProviderFactory.getDataProvider(new File("wz/String.wz"));
|
||||
if (!params[0].equalsIgnoreCase("ITEM")) {
|
||||
boolean mapSearch = false;
|
||||
|
||||
if (params[0].equalsIgnoreCase("NPC")) {
|
||||
data = dataProvider.getData("Npc.img");
|
||||
data = npcStringData;
|
||||
} else if (params[0].equalsIgnoreCase("MOB") || params[0].equalsIgnoreCase("MONSTER")) {
|
||||
data = dataProvider.getData("Mob.img");
|
||||
data = mobStringData;
|
||||
} else if (params[0].equalsIgnoreCase("SKILL")) {
|
||||
data = dataProvider.getData("Skill.img");
|
||||
/*} else if (sub[1].equalsIgnoreCase("MAP")) {
|
||||
TODO
|
||||
*/
|
||||
data = skillStringData;
|
||||
} else if (params[0].equalsIgnoreCase("MAP")) {
|
||||
data = mapStringData;
|
||||
mapSearch = true;
|
||||
} else {
|
||||
sb.append("#bInvalid search.\r\nSyntax: '!search [type] [name]', where [type] is NPC, ITEM, MOB, or SKILL.");
|
||||
sb.append("#bInvalid search.\r\nSyntax: '!search [type] [name]', where [type] is MAP, NPC, ITEM, MOB, or SKILL.");
|
||||
}
|
||||
if (data != null) {
|
||||
String name;
|
||||
for (MapleData searchData : data.getChildren()) {
|
||||
name = MapleDataTool.getString(searchData.getChildByPath("name"), "NO-NAME");
|
||||
if (name.toLowerCase().contains(search.toLowerCase())) {
|
||||
sb.append("#b").append(Integer.parseInt(searchData.getName())).append("#k - #r").append(name).append("\r\n");
|
||||
|
||||
if (!mapSearch) {
|
||||
for (MapleData searchData : data.getChildren()) {
|
||||
name = MapleDataTool.getString(searchData.getChildByPath("name"), "NO-NAME");
|
||||
if (name.toLowerCase().contains(search.toLowerCase())) {
|
||||
sb.append("#b").append(Integer.parseInt(searchData.getName())).append("#k - #r").append(name).append("\r\n");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
String mapName, streetName;
|
||||
|
||||
for (MapleData searchDataDir : data.getChildren()) {
|
||||
for (MapleData searchData : searchDataDir.getChildren()) {
|
||||
mapName = MapleDataTool.getString(searchData.getChildByPath("mapName"), "NO-NAME");
|
||||
streetName = MapleDataTool.getString(searchData.getChildByPath("streetName"), "NO-NAME");
|
||||
|
||||
if (mapName.toLowerCase().contains(search.toLowerCase()) || streetName.toLowerCase().contains(search.toLowerCase())) {
|
||||
sb.append("#b").append(Integer.parseInt(searchData.getName())).append("#k - #r").append(streetName).append(" - ").append(mapName).append("\r\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,25 +17,27 @@
|
||||
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/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
@Author: Arthur L - Refactored command content into modules
|
||||
*/
|
||||
package client.command.commands.gm6;
|
||||
|
||||
import client.command.Command;
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import tools.MaplePacketCreator;
|
||||
import client.MapleClient;
|
||||
import client.command.Command;
|
||||
import constants.ServerConstants;
|
||||
|
||||
public class FredCommand extends Command {
|
||||
public class SupplyRateCouponCommand extends Command {
|
||||
{
|
||||
setDescription("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(MapleClient c, String[] params) {
|
||||
c.announce(MaplePacketCreator.fredrickMessage(Byte.valueOf(params[0])));
|
||||
|
||||
MapleCharacter player = c.getPlayer();
|
||||
if (params.length < 1) {
|
||||
player.dropMessage(5, "Syntax: !supplyratecoupon <yes|no>");
|
||||
return;
|
||||
}
|
||||
|
||||
ServerConstants.USE_SUPPLY_RATE_COUPONS = params[0].compareToIgnoreCase("no") != 0;
|
||||
player.dropMessage(5, "Rate coupons are now " + (ServerConstants.USE_SUPPLY_RATE_COUPONS ? "enabled" : "disabled") + " for purchase at the Cash Shop.");
|
||||
}
|
||||
}
|
||||
@@ -26,10 +26,12 @@ import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import client.inventory.manipulator.MapleKarmaManipulator;
|
||||
import server.MapleItemInformationProvider;
|
||||
|
||||
public class Item implements Comparable<Item> {
|
||||
|
||||
private static AtomicInteger runningCashId = new AtomicInteger(0);
|
||||
private static AtomicInteger runningCashId = new AtomicInteger(777000000); // pets & rings shares cashid values
|
||||
|
||||
private int id, cashId, sn;
|
||||
private short position;
|
||||
@@ -83,7 +85,7 @@ public class Item implements Comparable<Item> {
|
||||
|
||||
public int getCashId() {
|
||||
if (cashId == 0) {
|
||||
cashId = runningCashId.incrementAndGet();
|
||||
cashId = runningCashId.getAndIncrement();
|
||||
}
|
||||
return cashId;
|
||||
}
|
||||
@@ -177,4 +179,8 @@ public class Item implements Comparable<Item> {
|
||||
public MaplePet getPet() {
|
||||
return pet;
|
||||
}
|
||||
|
||||
public boolean isUntradeable() {
|
||||
return ((this.getFlag() & ItemConstants.UNTRADEABLE) == ItemConstants.UNTRADEABLE) || (MapleItemInformationProvider.getInstance().isDropRestricted(this.getItemId()) && !MapleKarmaManipulator.hasKarmaFlag(this));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package client.inventory;
|
||||
|
||||
import com.mysql.jdbc.Statement;
|
||||
import constants.ExpTable;
|
||||
import java.awt.Point;
|
||||
import java.sql.PreparedStatement;
|
||||
@@ -34,6 +33,7 @@ import server.movement.AbsoluteLifeMovement;
|
||||
import server.movement.LifeMovement;
|
||||
import server.movement.LifeMovementFragment;
|
||||
import client.MapleCharacter;
|
||||
import client.inventory.manipulator.MapleCashidGenerator;
|
||||
import java.sql.Connection;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
@@ -90,6 +90,8 @@ public class MaplePet extends Item {
|
||||
ps.executeUpdate();
|
||||
ps.close();
|
||||
con.close();
|
||||
|
||||
MapleCashidGenerator.freeCashId(this.getUniqueId());
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@@ -116,15 +118,11 @@ public class MaplePet extends Item {
|
||||
public static int createPet(int itemid) {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness, summoned) VALUES (?, 1, 0, 100, 0)", Statement.RETURN_GENERATED_KEYS);
|
||||
ps.setString(1, MapleItemInformationProvider.getInstance().getName(itemid));
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (petid, name, level, closeness, fullness, summoned) VALUES (?, ?, 1, 0, 100, 0)");
|
||||
int ret = MapleCashidGenerator.generateCashId();
|
||||
ps.setInt(1, ret);
|
||||
ps.setString(2, MapleItemInformationProvider.getInstance().getName(itemid));
|
||||
ps.executeUpdate();
|
||||
ResultSet rs = ps.getGeneratedKeys();
|
||||
int ret = -1;
|
||||
if (rs.next()) {
|
||||
ret = rs.getInt(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
return ret;
|
||||
@@ -137,18 +135,14 @@ public class MaplePet extends Item {
|
||||
public static int createPet(int itemid, byte level, int closeness, int fullness) {
|
||||
try {
|
||||
Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (name, level, closeness, fullness, summoned) VALUES (?, ?, ?, ?, 0)", Statement.RETURN_GENERATED_KEYS);
|
||||
ps.setString(1, MapleItemInformationProvider.getInstance().getName(itemid));
|
||||
ps.setByte(2, level);
|
||||
ps.setInt(3, closeness);
|
||||
ps.setInt(4, fullness);
|
||||
PreparedStatement ps = con.prepareStatement("INSERT INTO pets (petid, name, level, closeness, fullness, summoned) VALUES (?, ?, ?, ?, ?, 0)");
|
||||
int ret = MapleCashidGenerator.generateCashId();
|
||||
ps.setInt(1, ret);
|
||||
ps.setString(2, MapleItemInformationProvider.getInstance().getName(itemid));
|
||||
ps.setByte(3, level);
|
||||
ps.setInt(4, closeness);
|
||||
ps.setInt(5, fullness);
|
||||
ps.executeUpdate();
|
||||
ResultSet rs = ps.getGeneratedKeys();
|
||||
int ret = -1;
|
||||
if (rs.next()) {
|
||||
ret = rs.getInt(1);
|
||||
}
|
||||
rs.close();
|
||||
ps.close();
|
||||
con.close();
|
||||
return ret;
|
||||
|
||||
104
src/client/inventory/manipulator/MapleCashidGenerator.java
Normal file
104
src/client/inventory/manipulator/MapleCashidGenerator.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
This file is part of the HeavenMS MapleStory Server
|
||||
Copyleft (L) 2016 - 2018 RonanLana
|
||||
|
||||
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 client.inventory.manipulator;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import tools.DatabaseConnection;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author RonanLana
|
||||
*/
|
||||
public class MapleCashidGenerator {
|
||||
|
||||
private final static Set<Integer> existentCashids = new HashSet<>(10000);
|
||||
private static Integer runningCashid = 0;
|
||||
|
||||
private static void loadExistentCashIdsFromQuery(Connection con, String query) throws SQLException {
|
||||
PreparedStatement ps = con.prepareStatement(query);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
|
||||
while (rs.next()) {
|
||||
existentCashids.add(rs.getInt(1));
|
||||
}
|
||||
|
||||
rs.close();
|
||||
ps.close();
|
||||
}
|
||||
|
||||
public static synchronized void loadExistentCashIdsFromDb() {
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
|
||||
loadExistentCashIdsFromQuery(con, "SELECT id FROM rings");
|
||||
loadExistentCashIdsFromQuery(con, "SELECT petid FROM pets");
|
||||
|
||||
con.close();
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
if (con != null && !con.isClosed()) {
|
||||
con.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
runningCashid = 0;
|
||||
do {
|
||||
runningCashid++; // hopefully the id will never surpass the allotted amount for pets/rings?
|
||||
} while (existentCashids.contains(runningCashid));
|
||||
}
|
||||
|
||||
private static void getNextAvailableCashId() {
|
||||
runningCashid++;
|
||||
if (runningCashid >= 777000000) {
|
||||
existentCashids.clear();
|
||||
loadExistentCashIdsFromDb();
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized int generateCashId() {
|
||||
while (true) {
|
||||
if (!existentCashids.contains(runningCashid)) {
|
||||
int ret = runningCashid;
|
||||
getNextAvailableCashId();
|
||||
|
||||
// existentCashids.add(ret)... no need to do this since the wrap over already refetches already used cashids from the DB
|
||||
return ret;
|
||||
}
|
||||
|
||||
getNextAvailableCashId();
|
||||
}
|
||||
}
|
||||
|
||||
public static synchronized void freeCashId(int cashId) {
|
||||
existentCashids.remove(cashId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -520,16 +520,18 @@ public class MapleInventoryManipulator {
|
||||
|
||||
//1112413, 1112414, 1112405 (Lilin's Ring)
|
||||
source = (Equip) eqpInv.getItem(src);
|
||||
Equip target = (Equip) eqpdInv.getItem(dst);
|
||||
eqpInv.removeSlot(src);
|
||||
if (target != null) {
|
||||
eqpdInv.lockInventory();
|
||||
try {
|
||||
|
||||
Equip target;
|
||||
eqpdInv.lockInventory();
|
||||
try {
|
||||
target = (Equip) eqpdInv.getItem(dst);
|
||||
if (target != null) {
|
||||
chr.unequippedItem(target);
|
||||
eqpdInv.removeSlot(dst);
|
||||
} finally {
|
||||
eqpdInv.unlockInventory();
|
||||
}
|
||||
} finally {
|
||||
eqpdInv.unlockInventory();
|
||||
}
|
||||
|
||||
final List<ModifyInventory> mods = new ArrayList<>();
|
||||
@@ -705,7 +707,7 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
|
||||
private static boolean isDroppedItemRestricted(Item it) {
|
||||
return ServerConstants.USE_ERASE_UNTRADEABLE_DROP && ((it.getFlag() & ItemConstants.UNTRADEABLE) == ItemConstants.UNTRADEABLE);
|
||||
return ServerConstants.USE_ERASE_UNTRADEABLE_DROP && it.isUntradeable();
|
||||
}
|
||||
|
||||
public static boolean isSandboxItem(Item it) {
|
||||
|
||||
@@ -43,7 +43,7 @@ public class AssignSPProcessor {
|
||||
c.lockClient();
|
||||
try {
|
||||
if (skillid == Aran.HIDDEN_FULL_DOUBLE || skillid == Aran.HIDDEN_FULL_TRIPLE || skillid == Aran.HIDDEN_OVER_DOUBLE || skillid == Aran.HIDDEN_OVER_TRIPLE) {
|
||||
c.getSession().write(MaplePacketCreator.enableActions());
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,16 +21,13 @@ package client.processor;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.MapleCharacter;
|
||||
import client.MapleStat;
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import server.maps.MapleMap;
|
||||
import server.movement.AbsoluteLifeMovement;
|
||||
import server.movement.LifeMovementFragment;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.Pair;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -345,167 +345,171 @@ public class DueyProcessor {
|
||||
}
|
||||
|
||||
public static void dueySendItem(MapleClient c, byte inventId, short itemPos, short amount, int mesos, String recipient) {
|
||||
c.lockClient();
|
||||
try {
|
||||
final int fee = 5000;
|
||||
final long sendMesos = (long) mesos + fee;
|
||||
if (mesos < 0 || sendMesos > Integer.MAX_VALUE || (amount < 1 && mesos == 0)) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with duey.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use duey with mesos " + mesos + " and amount " + amount + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
int finalcost = mesos + fee;
|
||||
if (c.getPlayer().getMeso() >= finalcost) {
|
||||
int accid = getAccIdFromCNAME(recipient, true);
|
||||
if (accid != -1) {
|
||||
if (accid == c.getAccID()) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SAMEACC_ERROR.getCode()));
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
final int fee = 5000;
|
||||
final long sendMesos = (long) mesos + fee;
|
||||
if (mesos < 0 || sendMesos > Integer.MAX_VALUE || (amount < 1 && mesos == 0)) {
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with duey.");
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to use duey with mesos " + mesos + " and amount " + amount + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
int finalcost = mesos + fee;
|
||||
if (c.getPlayer().getMeso() >= finalcost) {
|
||||
int accid = getAccIdFromCNAME(recipient, true);
|
||||
if (accid != -1) {
|
||||
if (accid == c.getAccID()) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SAMEACC_ERROR.getCode()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NOT_ENOUGH_MESOS.getCode()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NOT_ENOUGH_MESOS.getCode()));
|
||||
return;
|
||||
}
|
||||
|
||||
MapleClient rClient = null;
|
||||
int channel = c.getWorldServer().find(recipient);
|
||||
if (channel > -1) {
|
||||
Channel rcserv = c.getWorldServer().getChannel(channel);
|
||||
if(rcserv != null) {
|
||||
MapleCharacter rChr = rcserv.getPlayerStorage().getCharacterByName(recipient);
|
||||
if(rChr != null) {
|
||||
rClient = rChr.getClient();
|
||||
MapleClient rClient = null;
|
||||
int channel = c.getWorldServer().find(recipient);
|
||||
if (channel > -1) {
|
||||
Channel rcserv = c.getWorldServer().getChannel(channel);
|
||||
if(rcserv != null) {
|
||||
MapleCharacter rChr = rcserv.getPlayerStorage().getCharacterByName(recipient);
|
||||
if(rChr != null) {
|
||||
rClient = rChr.getClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inventId > 0) {
|
||||
MapleInventoryType inv = MapleInventoryType.getByType(inventId);
|
||||
Item item = c.getPlayer().getInventory(inv).getItem(itemPos);
|
||||
if (item != null && c.getPlayer().getItemQuantity(item.getItemId(), false) >= amount) {
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
if (ItemConstants.isRechargeable(item.getItemId())) {
|
||||
MapleInventoryManipulator.removeFromSlot(c, inv, itemPos, item.getQuantity(), true);
|
||||
if (inventId > 0) {
|
||||
MapleInventoryType inv = MapleInventoryType.getByType(inventId);
|
||||
Item item = c.getPlayer().getInventory(inv).getItem(itemPos);
|
||||
if (item != null && c.getPlayer().getItemQuantity(item.getItemId(), false) >= amount) {
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
if (ItemConstants.isRechargeable(item.getItemId())) {
|
||||
MapleInventoryManipulator.removeFromSlot(c, inv, itemPos, item.getQuantity(), true);
|
||||
} else {
|
||||
MapleInventoryManipulator.removeFromSlot(c, inv, itemPos, amount, true, false);
|
||||
}
|
||||
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
addItemToDB(item, amount, mesos - getFee(mesos), c.getPlayer().getName(), getAccIdFromCNAME(recipient, false));
|
||||
} else {
|
||||
MapleInventoryManipulator.removeFromSlot(c, inv, itemPos, amount, true, false);
|
||||
if (item != null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_INCORRECT_REQUEST.getCode()));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
addItemToDB(item, amount, mesos - getFee(mesos), c.getPlayer().getName(), getAccIdFromCNAME(recipient, false));
|
||||
} else {
|
||||
if (item != null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_INCORRECT_REQUEST.getCode()));
|
||||
}
|
||||
return;
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
addMesoToDB(mesos - getFee(mesos), c.getPlayer().getName(), getAccIdFromCNAME(recipient, false));
|
||||
}
|
||||
} else {
|
||||
c.getPlayer().gainMeso(-finalcost, false);
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
|
||||
addMesoToDB(mesos - getFee(mesos), c.getPlayer().getName(), getAccIdFromCNAME(recipient, false));
|
||||
if (rClient != null && rClient.isLoggedIn() && !rClient.getPlayer().isAwayFromWorld()) {
|
||||
showDueyNotification(rClient, rClient.getPlayer());
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
|
||||
if (rClient != null && rClient.isLoggedIn() && !rClient.getPlayer().isAwayFromWorld()) {
|
||||
showDueyNotification(rClient, rClient.getPlayer());
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dueyRemovePackage(MapleClient c, int packageid) {
|
||||
c.lockClient();
|
||||
try {
|
||||
removeItemFromDB(packageid);
|
||||
c.announce(MaplePacketCreator.removeItemFromDuey(true, packageid));
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
removeItemFromDB(packageid);
|
||||
c.announce(MaplePacketCreator.removeItemFromDuey(true, packageid));
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void dueyClaimPackage(MapleClient c, int packageid) {
|
||||
c.lockClient();
|
||||
try {
|
||||
List<DueyPackages> packages = new LinkedList<>();
|
||||
DueyPackages dp = null;
|
||||
Connection con = null;
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
DueyPackages dueypack;
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM dueypackages LEFT JOIN dueyitems USING (PackageId) WHERE PackageId = ?")) {
|
||||
ps.setInt(1, packageid);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
dueypack = null;
|
||||
if (rs.next()) {
|
||||
dueypack = getItemByPID(rs);
|
||||
dueypack.setSender(rs.getString("SenderName"));
|
||||
dueypack.setMesos(rs.getInt("Mesos"));
|
||||
dueypack.setSentTime(rs.getString("TimeStamp"));
|
||||
List<DueyPackages> packages = new LinkedList<>();
|
||||
DueyPackages dp = null;
|
||||
Connection con = null;
|
||||
try {
|
||||
con = DatabaseConnection.getConnection();
|
||||
DueyPackages dueypack;
|
||||
try (PreparedStatement ps = con.prepareStatement("SELECT * FROM dueypackages LEFT JOIN dueyitems USING (PackageId) WHERE PackageId = ?")) {
|
||||
ps.setInt(1, packageid);
|
||||
try (ResultSet rs = ps.executeQuery()) {
|
||||
dueypack = null;
|
||||
if (rs.next()) {
|
||||
dueypack = getItemByPID(rs);
|
||||
dueypack.setSender(rs.getString("SenderName"));
|
||||
dueypack.setMesos(rs.getInt("Mesos"));
|
||||
dueypack.setSentTime(rs.getString("TimeStamp"));
|
||||
|
||||
packages.add(dueypack);
|
||||
packages.add(dueypack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
dp = dueypack;
|
||||
if(dp == null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to receive package from duey with id " + packageid + "\r\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (dp.getItem() != null) {
|
||||
if (!MapleInventoryManipulator.checkSpace(c, dp.getItem().getItemId(), dp.getItem().getQuantity(), dp.getItem().getOwner())) {
|
||||
int itemid = dp.getItem().getItemId();
|
||||
if(MapleItemInformationProvider.getInstance().isPickupRestricted(itemid) && c.getPlayer().getInventory(ItemConstants.getInventoryType(itemid)).findById(itemid) != null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_RECEIVER_WITH_UNIQUE.getCode()));
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_NO_FREE_SLOTS.getCode()));
|
||||
}
|
||||
|
||||
dp = dueypack;
|
||||
if(dp == null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to receive package from duey with id " + packageid + "\r\n");
|
||||
return;
|
||||
} else {
|
||||
MapleInventoryManipulator.addFromDrop(c, dp.getItem(), false);
|
||||
}
|
||||
|
||||
if (dp.getItem() != null) {
|
||||
if (!MapleInventoryManipulator.checkSpace(c, dp.getItem().getItemId(), dp.getItem().getQuantity(), dp.getItem().getOwner())) {
|
||||
int itemid = dp.getItem().getItemId();
|
||||
if(MapleItemInformationProvider.getInstance().isPickupRestricted(itemid) && c.getPlayer().getInventory(ItemConstants.getInventoryType(itemid)).findById(itemid) != null) {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_RECEIVER_WITH_UNIQUE.getCode()));
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_NO_FREE_SLOTS.getCode()));
|
||||
}
|
||||
|
||||
return;
|
||||
} else {
|
||||
MapleInventoryManipulator.addFromDrop(c, dp.getItem(), false);
|
||||
}
|
||||
}
|
||||
|
||||
long gainmesos;
|
||||
long totalmesos = (long) dp.getMesos() + c.getPlayer().getMeso();
|
||||
|
||||
if (totalmesos < 0 || dp.getMesos() < 0) {
|
||||
gainmesos = 0;
|
||||
} else {
|
||||
totalmesos = Math.min(totalmesos, Integer.MAX_VALUE);
|
||||
gainmesos = totalmesos - c.getPlayer().getMeso();
|
||||
}
|
||||
|
||||
c.getPlayer().gainMeso((int)gainmesos, false);
|
||||
|
||||
removeItemFromDB(packageid);
|
||||
c.announce(MaplePacketCreator.removeItemFromDuey(false, packageid));
|
||||
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
long gainmesos;
|
||||
long totalmesos = (long) dp.getMesos() + c.getPlayer().getMeso();
|
||||
|
||||
if (totalmesos < 0 || dp.getMesos() < 0) {
|
||||
gainmesos = 0;
|
||||
} else {
|
||||
totalmesos = Math.min(totalmesos, Integer.MAX_VALUE);
|
||||
gainmesos = totalmesos - c.getPlayer().getMeso();
|
||||
}
|
||||
|
||||
c.getPlayer().gainMeso((int)gainmesos, false);
|
||||
|
||||
removeItemFromDB(packageid);
|
||||
c.announce(MaplePacketCreator.removeItemFromDuey(false, packageid));
|
||||
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
public static void dueySendTalk(MapleClient c) {
|
||||
c.lockClient();
|
||||
try {
|
||||
c.announce(MaplePacketCreator.sendDuey((byte) 8, loadItems(c.getPlayer())));
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
c.announce(MaplePacketCreator.sendDuey((byte) 8, loadItems(c.getPlayer())));
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -70,42 +70,43 @@ public class FredrickProcessor {
|
||||
}
|
||||
|
||||
public static void fredrickRetrieveItems(MapleClient c) { // thanks Gustav for pointing out the dupe on Fredrick handling
|
||||
c.lockClient();
|
||||
try {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
|
||||
List<Pair<Item, MapleInventoryType>> items;
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
items = ItemFactory.MERCHANT.loadItems(chr.getId(), false);
|
||||
if (!canRetrieveFromFredrick(chr, items)) {
|
||||
chr.announce(MaplePacketCreator.fredrickMessage((byte) 0x21));
|
||||
return;
|
||||
}
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
|
||||
chr.withdrawMerchantMesos();
|
||||
|
||||
if (deleteFredrickItems(chr.getId())) {
|
||||
MapleHiredMerchant merchant = chr.getHiredMerchant();
|
||||
|
||||
if(merchant != null)
|
||||
merchant.clearItems();
|
||||
|
||||
for (Pair<Item, MapleInventoryType> it : items) {
|
||||
Item item = it.getLeft();
|
||||
MapleInventoryManipulator.addFromDrop(chr.getClient(), item, false);
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.FREDRICK + chr.getName() + ".txt", chr.getName() + " gained " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
List<Pair<Item, MapleInventoryType>> items;
|
||||
try {
|
||||
items = ItemFactory.MERCHANT.loadItems(chr.getId(), false);
|
||||
if (!canRetrieveFromFredrick(chr, items)) {
|
||||
chr.announce(MaplePacketCreator.fredrickMessage((byte) 0x21));
|
||||
return;
|
||||
}
|
||||
|
||||
chr.announce(MaplePacketCreator.fredrickMessage((byte) 0x1E));
|
||||
} else {
|
||||
chr.message("An unknown error has occured.");
|
||||
chr.withdrawMerchantMesos();
|
||||
|
||||
if (deleteFredrickItems(chr.getId())) {
|
||||
MapleHiredMerchant merchant = chr.getHiredMerchant();
|
||||
|
||||
if(merchant != null)
|
||||
merchant.clearItems();
|
||||
|
||||
for (Pair<Item, MapleInventoryType> it : items) {
|
||||
Item item = it.getLeft();
|
||||
MapleInventoryManipulator.addFromDrop(chr.getClient(), item, false);
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.FREDRICK + chr.getName() + ".txt", chr.getName() + " gained " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
}
|
||||
|
||||
chr.announce(MaplePacketCreator.fredrickMessage((byte) 0x1E));
|
||||
} else {
|
||||
chr.message("An unknown error has occured.");
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import client.inventory.MapleInventoryType;
|
||||
import constants.ItemConstants;
|
||||
import constants.ServerConstants;
|
||||
import client.inventory.manipulator.MapleInventoryManipulator;
|
||||
import constants.EquipType;
|
||||
import constants.GameConstants;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
@@ -47,168 +46,169 @@ public class MakerProcessor {
|
||||
private static MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
|
||||
public static void makerAction(SeekableLittleEndianAccessor slea, MapleClient c) {
|
||||
c.lockClient();
|
||||
try {
|
||||
int type = slea.readInt();
|
||||
int toCreate = slea.readInt();
|
||||
int toDisassemble = -1, pos = -1;
|
||||
boolean makerSucceeded = true;
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
int type = slea.readInt();
|
||||
int toCreate = slea.readInt();
|
||||
int toDisassemble = -1, pos = -1;
|
||||
boolean makerSucceeded = true;
|
||||
|
||||
MakerItemFactory.MakerItemCreateEntry recipe;
|
||||
Map<Integer, Short> reagentids = new LinkedHashMap<>();
|
||||
int stimulantid = -1;
|
||||
MakerItemFactory.MakerItemCreateEntry recipe;
|
||||
Map<Integer, Short> reagentids = new LinkedHashMap<>();
|
||||
int stimulantid = -1;
|
||||
|
||||
if(type == 3) { // building monster crystal
|
||||
int fromLeftover = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromLeftover(toCreate);
|
||||
if(toCreate == -1) {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal conversion."));
|
||||
return;
|
||||
}
|
||||
if(type == 3) { // building monster crystal
|
||||
int fromLeftover = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromLeftover(toCreate);
|
||||
if(toCreate == -1) {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal conversion."));
|
||||
return;
|
||||
}
|
||||
|
||||
recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover);
|
||||
} else if(type == 4) { // disassembling
|
||||
slea.readInt(); // 1... probably inventory type
|
||||
pos = slea.readInt();
|
||||
recipe = MakerItemFactory.generateLeftoverCrystalEntry(fromLeftover);
|
||||
} else if(type == 4) { // disassembling
|
||||
slea.readInt(); // 1... probably inventory type
|
||||
pos = slea.readInt();
|
||||
|
||||
Item it = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short) pos);
|
||||
if(it != null && it.getItemId() == toCreate) {
|
||||
Pair<Integer, Integer> p;
|
||||
Item it = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short) pos);
|
||||
if(it != null && it.getItemId() == toCreate) {
|
||||
Pair<Integer, Integer> p;
|
||||
|
||||
if((p = generateDisassemblyInfo(toCreate)) != null) {
|
||||
recipe = MakerItemFactory.generateDisassemblyCrystalEntry(p.getLeft(), p.getRight());
|
||||
toDisassemble = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromEquip(toCreate);
|
||||
if((p = generateDisassemblyInfo(toCreate)) != null) {
|
||||
recipe = MakerItemFactory.generateDisassemblyCrystalEntry(p.getLeft(), p.getRight());
|
||||
toDisassemble = toCreate;
|
||||
toCreate = ii.getMakerCrystalFromEquip(toCreate);
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, ii.getName(toCreate) + " is unavailable for Monster Crystal disassembly."));
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "An unknown error occurred when trying to apply that item for disassembly."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "An unknown error occurred when trying to apply that item for disassembly."));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
|
||||
if(slea.readByte() != 0) { // stimulant
|
||||
stimulantid = ii.getMakerStimulant(toCreate);
|
||||
if(!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
|
||||
stimulantid = -1;
|
||||
}
|
||||
}
|
||||
|
||||
int reagents = Math.min(slea.readInt(), getMakerReagentSlots(toCreate));
|
||||
for(int i = 0; i < reagents; i++) { // crystals
|
||||
int reagentid = slea.readInt();
|
||||
if(ItemConstants.isMakerReagent(reagentid)) {
|
||||
Short rs = reagentids.get(reagentid);
|
||||
if(rs == null) {
|
||||
reagentids.put(reagentid, (short) 1);
|
||||
} else {
|
||||
reagentids.put(reagentid, (short) (rs + 1));
|
||||
if(ItemConstants.isEquipment(toCreate)) { // only equips uses stimulant and reagents
|
||||
if(slea.readByte() != 0) { // stimulant
|
||||
stimulantid = ii.getMakerStimulant(toCreate);
|
||||
if(!c.getAbstractPlayerInteraction().haveItem(stimulantid)) {
|
||||
stimulantid = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Pair<Integer, Short>> toUpdate = new LinkedList<>();
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
int qty = c.getAbstractPlayerInteraction().getItemQuantity(r.getKey());
|
||||
|
||||
if(qty < r.getValue()) {
|
||||
toUpdate.add(new Pair<>(r.getKey(), (short) qty));
|
||||
}
|
||||
}
|
||||
|
||||
// remove those not present on player inventory
|
||||
if(!toUpdate.isEmpty()) {
|
||||
for(Pair<Integer, Short> rp : toUpdate) {
|
||||
if(rp.getRight() > 0) {
|
||||
reagentids.put(rp.getLeft(), rp.getRight());
|
||||
} else {
|
||||
reagentids.remove(rp.getLeft());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!reagentids.isEmpty()) {
|
||||
if(!removeOddMakerReagents(toCreate, reagentids)) {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You can only use WATK and MATK Strengthening Gems on weapon items."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
recipe = MakerItemFactory.getItemCreateEntry(toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
short createStatus = getCreateStatus(c, recipe);
|
||||
|
||||
switch(createStatus) {
|
||||
case -1:// non-available for Maker itemid has been tried to forge
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS, "Player " + c.getPlayer().getName() + " tried to craft itemid " + toCreate + " using the Maker skill.");
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
|
||||
break;
|
||||
|
||||
case 1: // no items
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have all required items in your inventory to make " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
|
||||
break;
|
||||
|
||||
case 2: // no meso
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough mesos (" + GameConstants.numberWithCommas(recipe.getCost()) + ") to complete this operation."));
|
||||
break;
|
||||
|
||||
case 3: // no req level
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough level to complete this operation."));
|
||||
break;
|
||||
|
||||
case 4: // no req skill level
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough Maker level to complete this operation."));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (MapleInventoryManipulator.checkSpace(c, toCreate, (short) recipe.getRewardAmount(), "")) {
|
||||
for (Pair<Integer, Integer> p : recipe.getReqItems()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(p.getLeft(), (short) -p.getRight());
|
||||
}
|
||||
|
||||
if(toDisassemble != -1) {
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (short) pos, (short) 1, false);
|
||||
c.announce(MaplePacketCreator.getShowItemGain(toDisassemble, (short) -1, true));
|
||||
}
|
||||
|
||||
int cost = recipe.getCost();
|
||||
if(stimulantid == -1 && reagentids.isEmpty()) {
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost);
|
||||
|
||||
c.getPlayer().setCS(true);
|
||||
c.getAbstractPlayerInteraction().gainItem(toCreate, (short) recipe.getRewardAmount());
|
||||
c.getPlayer().setCS(false);
|
||||
} else {
|
||||
if(stimulantid != -1) c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1);
|
||||
if(!reagentids.isEmpty()) {
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(r.getKey(), (short) (-1 * r.getValue()));
|
||||
int reagents = Math.min(slea.readInt(), getMakerReagentSlots(toCreate));
|
||||
for(int i = 0; i < reagents; i++) { // crystals
|
||||
int reagentid = slea.readInt();
|
||||
if(ItemConstants.isMakerReagent(reagentid)) {
|
||||
Short rs = reagentids.get(reagentid);
|
||||
if(rs == null) {
|
||||
reagentids.put(reagentid, (short) 1);
|
||||
} else {
|
||||
reagentids.put(reagentid, (short) (rs + 1));
|
||||
}
|
||||
}
|
||||
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost);
|
||||
makerSucceeded = addBoostedMakerItem(c, toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
if(makerSucceeded) c.announce(MaplePacketCreator.serverNotice(1, "You have successfully created " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
|
||||
else c.getPlayer().dropMessage(5, "The Maker skill lights up, but the skill winds up as if nothing happened.");
|
||||
List<Pair<Integer, Short>> toUpdate = new LinkedList<>();
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
int qty = c.getAbstractPlayerInteraction().getItemQuantity(r.getKey());
|
||||
|
||||
c.announce(MaplePacketCreator.showMakerEffect(makerSucceeded));
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showForeignMakerEffect(c.getPlayer().getId(), makerSucceeded), false);
|
||||
|
||||
if(toCreate == 4260003 && c.getPlayer().getQuestStatus(6033) == 1) {
|
||||
c.getAbstractPlayerInteraction().setQuestProgress(6033, 1);
|
||||
if(qty < r.getValue()) {
|
||||
toUpdate.add(new Pair<>(r.getKey(), (short) qty));
|
||||
}
|
||||
}
|
||||
|
||||
// remove those not present on player inventory
|
||||
if(!toUpdate.isEmpty()) {
|
||||
for(Pair<Integer, Short> rp : toUpdate) {
|
||||
if(rp.getRight() > 0) {
|
||||
reagentids.put(rp.getLeft(), rp.getRight());
|
||||
} else {
|
||||
reagentids.remove(rp.getLeft());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(!reagentids.isEmpty()) {
|
||||
if(!removeOddMakerReagents(toCreate, reagentids)) {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You can only use WATK and MATK Strengthening Gems on weapon items."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "Your inventory is full."));
|
||||
}
|
||||
|
||||
recipe = MakerItemFactory.getItemCreateEntry(toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
short createStatus = getCreateStatus(c, recipe);
|
||||
|
||||
switch(createStatus) {
|
||||
case -1:// non-available for Maker itemid has been tried to forge
|
||||
FilePrinter.printError(FilePrinter.EXPLOITS, "Player " + c.getPlayer().getName() + " tried to craft itemid " + toCreate + " using the Maker skill.");
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "The requested item could not be crafted on this operation."));
|
||||
break;
|
||||
|
||||
case 1: // no items
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have all required items in your inventory to make " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
|
||||
break;
|
||||
|
||||
case 2: // no meso
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough mesos (" + GameConstants.numberWithCommas(recipe.getCost()) + ") to complete this operation."));
|
||||
break;
|
||||
|
||||
case 3: // no req level
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough level to complete this operation."));
|
||||
break;
|
||||
|
||||
case 4: // no req skill level
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "You don't have enough Maker level to complete this operation."));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (MapleInventoryManipulator.checkSpace(c, toCreate, (short) recipe.getRewardAmount(), "")) {
|
||||
for (Pair<Integer, Integer> p : recipe.getReqItems()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(p.getLeft(), (short) -p.getRight());
|
||||
}
|
||||
|
||||
if(toDisassemble != -1) {
|
||||
MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, (short) pos, (short) 1, false);
|
||||
c.announce(MaplePacketCreator.getShowItemGain(toDisassemble, (short) -1, true));
|
||||
}
|
||||
|
||||
int cost = recipe.getCost();
|
||||
if(stimulantid == -1 && reagentids.isEmpty()) {
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost);
|
||||
|
||||
c.getPlayer().setCS(true);
|
||||
c.getAbstractPlayerInteraction().gainItem(toCreate, (short) recipe.getRewardAmount());
|
||||
c.getPlayer().setCS(false);
|
||||
} else {
|
||||
if(stimulantid != -1) c.getAbstractPlayerInteraction().gainItem(stimulantid, (short) -1);
|
||||
if(!reagentids.isEmpty()) {
|
||||
for(Map.Entry<Integer, Short> r : reagentids.entrySet()) {
|
||||
c.getAbstractPlayerInteraction().gainItem(r.getKey(), (short) (-1 * r.getValue()));
|
||||
}
|
||||
}
|
||||
|
||||
if(cost > 0) c.getPlayer().gainMeso(-cost);
|
||||
makerSucceeded = addBoostedMakerItem(c, toCreate, stimulantid, reagentids);
|
||||
}
|
||||
|
||||
if(makerSucceeded) c.announce(MaplePacketCreator.serverNotice(1, "You have successfully created " + recipe.getRewardAmount() + " " + ii.getName(toCreate) + "."));
|
||||
else c.getPlayer().dropMessage(5, "The Maker skill lights up, but the skill winds up as if nothing happened.");
|
||||
|
||||
c.announce(MaplePacketCreator.showMakerEffect(makerSucceeded));
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showForeignMakerEffect(c.getPlayer().getId(), makerSucceeded), false);
|
||||
|
||||
if(toCreate == 4260003 && c.getPlayer().getQuestStatus(6033) == 1) {
|
||||
c.getAbstractPlayerInteraction().setQuestProgress(6033, 1);
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.serverNotice(1, "Your inventory is full."));
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -40,60 +40,61 @@ public class SpawnPetProcessor {
|
||||
private static MapleDataProvider dataRoot = MapleDataProviderFactory.getDataProvider(new File(System.getProperty("wzpath") + "/Item.wz"));
|
||||
|
||||
public static void processSpawnPet(MapleClient c, byte slot, boolean lead) {
|
||||
c.lockClient();
|
||||
try {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MaplePet pet = chr.getInventory(MapleInventoryType.CASH).getItem(slot).getPet();
|
||||
if (pet == null) return;
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
MaplePet pet = chr.getInventory(MapleInventoryType.CASH).getItem(slot).getPet();
|
||||
if (pet == null) return;
|
||||
|
||||
int petid = pet.getItemId();
|
||||
if (petid == 5000028 || petid == 5000047) //Handles Dragon AND Robos
|
||||
{
|
||||
if (chr.haveItem(petid + 1)) {
|
||||
chr.dropMessage(5, "You can't hatch your " + (petid == 5000028 ? "Dragon egg" : "Robo egg") + " if you already have a Baby " + (petid == 5000028 ? "Dragon." : "Robo."));
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
} else {
|
||||
int evolveid = MapleDataTool.getInt("info/evol1", dataRoot.getData("Pet/" + petid + ".img"));
|
||||
int petId = MaplePet.createPet(evolveid);
|
||||
if (petId == -1) {
|
||||
int petid = pet.getItemId();
|
||||
if (petid == 5000028 || petid == 5000047) //Handles Dragon AND Robos
|
||||
{
|
||||
if (chr.haveItem(petid + 1)) {
|
||||
chr.dropMessage(5, "You can't hatch your " + (petid == 5000028 ? "Dragon egg" : "Robo egg") + " if you already have a Baby " + (petid == 5000028 ? "Dragon." : "Robo."));
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
} else {
|
||||
int evolveid = MapleDataTool.getInt("info/evol1", dataRoot.getData("Pet/" + petid + ".img"));
|
||||
int petId = MaplePet.createPet(evolveid);
|
||||
if (petId == -1) {
|
||||
return;
|
||||
}
|
||||
long expiration = chr.getInventory(MapleInventoryType.CASH).getItem(slot).getExpiration();
|
||||
MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, petid, (short) 1, false, false);
|
||||
MapleInventoryManipulator.addById(c, evolveid, (short) 1, null, petId, expiration);
|
||||
pet.deleteFromDb();
|
||||
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
long expiration = chr.getInventory(MapleInventoryType.CASH).getItem(slot).getExpiration();
|
||||
MapleInventoryManipulator.removeById(c, MapleInventoryType.CASH, petid, (short) 1, false, false);
|
||||
MapleInventoryManipulator.addById(c, evolveid, (short) 1, null, petId, expiration);
|
||||
pet.deleteFromDb();
|
||||
|
||||
}
|
||||
if (chr.getPetIndex(pet) != -1) {
|
||||
chr.unequipPet(pet, true);
|
||||
} else {
|
||||
if (chr.getSkillLevel(SkillFactory.getSkill(8)) == 0 && chr.getPet(0) != null) {
|
||||
chr.unequipPet(chr.getPet(0), false);
|
||||
}
|
||||
if (lead) {
|
||||
chr.shiftPetsRight();
|
||||
}
|
||||
Point pos = chr.getPosition();
|
||||
pos.y -= 12;
|
||||
pet.setPos(pos);
|
||||
pet.setFh(chr.getMap().getFootholds().findBelow(pet.getPos()).getId());
|
||||
pet.setStance(0);
|
||||
pet.setSummoned(true);
|
||||
pet.saveToDb();
|
||||
chr.addPet(pet);
|
||||
chr.getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showPet(c.getPlayer(), pet, false, false), true);
|
||||
c.announce(MaplePacketCreator.petStatUpdate(c.getPlayer()));
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (chr.getPetIndex(pet) != -1) {
|
||||
chr.unequipPet(pet, true);
|
||||
} else {
|
||||
if (chr.getSkillLevel(SkillFactory.getSkill(8)) == 0 && chr.getPet(0) != null) {
|
||||
chr.unequipPet(chr.getPet(0), false);
|
||||
}
|
||||
if (lead) {
|
||||
chr.shiftPetsRight();
|
||||
}
|
||||
Point pos = chr.getPosition();
|
||||
pos.y -= 12;
|
||||
pet.setPos(pos);
|
||||
pet.setFh(chr.getMap().getFootholds().findBelow(pet.getPos()).getId());
|
||||
pet.setStance(0);
|
||||
pet.setSummoned(true);
|
||||
pet.saveToDb();
|
||||
chr.addPet(pet);
|
||||
chr.getMap().broadcastMessage(c.getPlayer(), MaplePacketCreator.showPet(c.getPlayer(), pet, false, false), true);
|
||||
c.announce(MaplePacketCreator.petStatUpdate(c.getPlayer()));
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
|
||||
chr.commitExcludedItems();
|
||||
chr.getClient().getWorldServer().registerPetHunger(chr, chr.getPetIndex(pet));
|
||||
chr.commitExcludedItems();
|
||||
chr.getClient().getWorldServer().registerPetHunger(chr, chr.getPetIndex(pet));
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,123 +54,124 @@ public class StorageProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
c.lockClient();
|
||||
try {
|
||||
if (mode == 4) { // take out
|
||||
byte type = slea.readByte();
|
||||
byte slot = slea.readByte();
|
||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to work with storage slot " + slot + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
slot = storage.getSlot(MapleInventoryType.getByType(type), slot);
|
||||
Item item = storage.getItem(slot);
|
||||
if (item != null) {
|
||||
if (MapleItemInformationProvider.getInstance().isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0C));
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
if (mode == 4) { // take out
|
||||
byte type = slea.readByte();
|
||||
byte slot = slea.readByte();
|
||||
if (slot < 0 || slot > storage.getSlots()) { // removal starts at zero
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to work with storage slot " + slot + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
int takeoutFee = storage.getTakeOutFee();
|
||||
if (chr.getMeso() < takeoutFee) {
|
||||
slot = storage.getSlot(MapleInventoryType.getByType(type), slot);
|
||||
Item item = storage.getItem(slot);
|
||||
if (item != null) {
|
||||
if (MapleItemInformationProvider.getInstance().isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0C));
|
||||
return;
|
||||
}
|
||||
|
||||
int takeoutFee = storage.getTakeOutFee();
|
||||
if (chr.getMeso() < takeoutFee) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0B));
|
||||
return;
|
||||
} else {
|
||||
chr.gainMeso(-takeoutFee, false);
|
||||
}
|
||||
|
||||
if (MapleInventoryManipulator.checkSpace(c, item.getItemId(), item.getQuantity(), item.getOwner())) {
|
||||
item = storage.takeOut(slot);//actually the same but idc
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " took out " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
chr.setUsedStorage();
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.addFromDrop(c, item, false);
|
||||
storage.sendTakenOut(c, item.getInventoryType());
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0A));
|
||||
}
|
||||
}
|
||||
} else if (mode == 5) { // store
|
||||
short slot = slea.readShort();
|
||||
int itemId = slea.readInt();
|
||||
short quantity = slea.readShort();
|
||||
MapleInventoryType slotType = ItemConstants.getInventoryType(itemId);
|
||||
MapleInventory Inv = chr.getInventory(slotType);
|
||||
if (slot < 1 || slot > Inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to store item at slot " + slot + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
if (quantity < 1 || chr.getItemQuantity(itemId, false) < quantity) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
if (storage.isFull()) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x11));
|
||||
return;
|
||||
}
|
||||
|
||||
int storeFee = storage.getStoreFee();
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
MapleInventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Item item = chr.getInventory(invType).getItem(slot).copy();
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
chr.gainMeso(-storeFee, false, true, false);
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
item.setQuantity(quantity);
|
||||
storage.store(item);
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
chr.setUsedStorage();
|
||||
}
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
if(ServerConstants.USE_STORAGE_ITEM_SORT) storage.arrangeItems(c);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
} else if (mode == 7) { // meso
|
||||
int meso = slea.readInt();
|
||||
int storageMesos = storage.getMeso();
|
||||
int playerMesos = chr.getMeso();
|
||||
if ((meso > 0 && storageMesos >= meso) || (meso < 0 && playerMesos >= -meso)) {
|
||||
if (meso < 0 && (storageMesos - meso) < 0) {
|
||||
meso = Integer.MIN_VALUE + storageMesos;
|
||||
if (meso < playerMesos) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (meso > 0 && (playerMesos + meso) < 0) {
|
||||
meso = Integer.MAX_VALUE - playerMesos;
|
||||
if (meso > storageMesos) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
storage.setMeso(storageMesos - meso);
|
||||
chr.gainMeso(meso, false, true, false);
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + (meso > 0 ? " took out " : " stored ") + Math.abs(meso) + " mesos\r\n");
|
||||
chr.setUsedStorage();
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
} else {
|
||||
chr.gainMeso(-takeoutFee, false);
|
||||
}
|
||||
|
||||
if (MapleInventoryManipulator.checkSpace(c, item.getItemId(), item.getQuantity(), item.getOwner())) {
|
||||
item = storage.takeOut(slot);//actually the same but idc
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " took out " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
chr.setUsedStorage();
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.addFromDrop(c, item, false);
|
||||
storage.sendTakenOut(c, item.getInventoryType());
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0A));
|
||||
}
|
||||
storage.sendMeso(c);
|
||||
} else if (mode == 8) {// close
|
||||
storage.close();
|
||||
}
|
||||
} else if (mode == 5) { // store
|
||||
short slot = slea.readShort();
|
||||
int itemId = slea.readInt();
|
||||
short quantity = slea.readShort();
|
||||
MapleInventoryType slotType = ItemConstants.getInventoryType(itemId);
|
||||
MapleInventory Inv = chr.getInventory(slotType);
|
||||
if (slot < 1 || slot > Inv.getSlotLimit()) { //player inv starts at one
|
||||
AutobanFactory.PACKET_EDIT.alert(c.getPlayer(), c.getPlayer().getName() + " tried to packet edit with storage.");
|
||||
FilePrinter.print(FilePrinter.EXPLOITS + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + " tried to store item at slot " + slot + "\r\n");
|
||||
c.disconnect(true, false);
|
||||
return;
|
||||
}
|
||||
if (quantity < 1 || chr.getItemQuantity(itemId, false) < quantity) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
if (storage.isFull()) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x11));
|
||||
return;
|
||||
}
|
||||
|
||||
int storeFee = storage.getStoreFee();
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.announce(MaplePacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
MapleInventoryType invType = ItemConstants.getInventoryType(itemId);
|
||||
Item item = chr.getInventory(invType).getItem(slot).copy();
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isRechargeable(itemId)) {
|
||||
quantity = item.getQuantity();
|
||||
}
|
||||
|
||||
chr.gainMeso(-storeFee, false, true, false);
|
||||
MapleKarmaManipulator.toggleKarmaFlagToUntradeable(item);
|
||||
MapleInventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
item.setQuantity(quantity);
|
||||
storage.store(item);
|
||||
storage.sendStored(c, ItemConstants.getInventoryType(itemId));
|
||||
String itemName = MapleItemInformationProvider.getInstance().getName(item.getItemId());
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getAccountName() + ".txt", c.getPlayer().getName() + " stored " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")\r\n");
|
||||
chr.setUsedStorage();
|
||||
}
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
if(ServerConstants.USE_STORAGE_ITEM_SORT) storage.arrangeItems(c);
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
} else if (mode == 7) { // meso
|
||||
int meso = slea.readInt();
|
||||
int storageMesos = storage.getMeso();
|
||||
int playerMesos = chr.getMeso();
|
||||
if ((meso > 0 && storageMesos >= meso) || (meso < 0 && playerMesos >= -meso)) {
|
||||
if (meso < 0 && (storageMesos - meso) < 0) {
|
||||
meso = -2147483648 + storageMesos;
|
||||
if (meso < playerMesos) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (meso > 0 && (playerMesos + meso) < 0) {
|
||||
meso = 2147483647 - playerMesos;
|
||||
if (meso > storageMesos) {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
storage.setMeso(storageMesos - meso);
|
||||
chr.gainMeso(meso, false, true, false);
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + (meso > 0 ? " took out " : " stored ") + Math.abs(meso) + " mesos\r\n");
|
||||
chr.setUsedStorage();
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
storage.sendMeso(c);
|
||||
} else if (mode == 8) {// close
|
||||
storage.close();
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
} finally {
|
||||
c.unlockClient();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user