Maker & Storage fetch Wz + Buff system & PS / HM patch + Pet Evolution

Storage now fetches transaction fees from the WZ.
Maker now pulls info about catalyzers from the WZ.
Fixed the enhanced buff system disappearing with some statsup when using multiple-statups items.
Fixed hired merchant now removing owner and visitors at expiration time.
Fixed some concurrent issues with player shops and hired merchants.
Fixed pet evolutions, now not only handing out not-expired pets but also refreshing the expire time as well.
Added item replace behaviour on the item expire system.
This commit is contained in:
ronancpl
2018-06-07 12:57:56 -03:00
parent ce74680953
commit cdac59326a
22 changed files with 486 additions and 262 deletions
+90 -44
View File
@@ -147,7 +147,7 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
return -1; //Actually 0 because of the +1's.
}
public void removeAllVisitors() {
private void removeAllVisitors() {
visitorLock.lock();
try {
for (int i = 0; i < 3; i++) {
@@ -271,6 +271,24 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
}
public void forceClose() {
//Server.getInstance().getChannel(world, channel).removeHiredMerchant(ownerId);
map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(getOwnerId()));
map.removeMapObject(this);
MapleCharacter owner = Server.getInstance().getWorld(world).getPlayerStorage().getCharacterById(ownerId);
visitorLock.lock();
try {
setOpen(false);
removeAllVisitors();
if(owner != null && owner.isLoggedinWorld() && this == owner.getHiredMerchant()) {
closeOwnerMerchant(owner);
}
} finally {
visitorLock.unlock();
}
Server.getInstance().getWorld(world).unregisterHiredMerchant(this);
try {
@@ -281,11 +299,7 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
} catch (SQLException ex) {
ex.printStackTrace();
}
//Server.getInstance().getChannel(world, channel).removeHiredMerchant(ownerId);
map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(getOwnerId()));
map.removeMapObject(this);
MapleCharacter player = Server.getInstance().getWorld(world).getPlayerStorage().getCharacterById(ownerId);
if(player != null) {
player.setHasMerchant(false);
@@ -306,55 +320,87 @@ public class MapleHiredMerchant extends AbstractMapleMapObject {
map = null;
}
public void closeShop(MapleClient c, boolean timeout) {
map.removeMapObject(this);
map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(ownerId));
c.getChannelServer().removeHiredMerchant(ownerId);
try {
MapleCharacter player = c.getWorldServer().getPlayerStorage().getCharacterById(ownerId);
if(player != null) {
player.setHasMerchant(false);
} else {
Connection con = DatabaseConnection.getConnection();
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
ps.setInt(1, ownerId);
ps.executeUpdate();
}
con.close();
}
public void closeOwnerMerchant(MapleCharacter chr) {
if(this.isOwner(chr)) {
chr.announce(MaplePacketCreator.hiredMerchantOwnerLeave());
chr.announce(MaplePacketCreator.leaveHiredMerchant(0x00, 0x03));
this.closeShop(chr.getClient(), false);
chr.setHasMerchant(false);
}
}
public void closeShop(MapleClient c, boolean timeout) {
map.removeMapObject(this);
map.broadcastMessage(MaplePacketCreator.destroyHiredMerchant(ownerId));
c.getChannelServer().removeHiredMerchant(ownerId);
List<MaplePlayerShopItem> copyItems = getItems();
if (check(c.getPlayer(), copyItems) && !timeout) {
for (MaplePlayerShopItem mpsi : copyItems) {
if(mpsi.isExist()) {
if (mpsi.getItem().getInventoryType().equals(MapleInventoryType.EQUIP)) {
MapleInventoryManipulator.addFromDrop(c, mpsi.getItem(), false);
} else {
MapleInventoryManipulator.addById(c, mpsi.getItem().getItemId(), (short) (mpsi.getBundles() * mpsi.getItem().getQuantity()), null, -1, mpsi.getItem().getFlag(), mpsi.getItem().getExpiration());
}
try {
MapleCharacter player = c.getWorldServer().getPlayerStorage().getCharacterById(ownerId);
if(player != null) {
player.setHasMerchant(false);
} else {
Connection con = DatabaseConnection.getConnection();
try (PreparedStatement ps = con.prepareStatement("UPDATE characters SET HasMerchant = 0 WHERE id = ?", Statement.RETURN_GENERATED_KEYS)) {
ps.setInt(1, ownerId);
ps.executeUpdate();
}
con.close();
}
List<MaplePlayerShopItem> copyItems = getItems();
if (check(c.getPlayer(), copyItems) && !timeout) {
for (MaplePlayerShopItem mpsi : copyItems) {
if(mpsi.isExist()) {
if (mpsi.getItem().getInventoryType().equals(MapleInventoryType.EQUIP)) {
MapleInventoryManipulator.addFromDrop(c, mpsi.getItem(), false);
} else {
MapleInventoryManipulator.addById(c, mpsi.getItem().getItemId(), (short) (mpsi.getBundles() * mpsi.getItem().getQuantity()), null, -1, mpsi.getItem().getFlag(), mpsi.getItem().getExpiration());
}
}
synchronized (items) {
items.clear();
}
}
try {
this.saveItems(timeout);
} catch (Exception e) {
e.printStackTrace();
}
synchronized (items) {
items.clear();
}
}
try {
this.saveItems(timeout);
} catch (Exception e) {
e.printStackTrace();
}
Server.getInstance().getWorld(world).unregisterHiredMerchant(this);
synchronized (items) {
items.clear();
}
} catch (Exception e) {
e.printStackTrace();
}
Server.getInstance().getWorld(world).unregisterHiredMerchant(this);
}
public synchronized void visitShop(MapleCharacter chr) {
visitorLock.lock();
try {
if (this.isOwner(chr)) {
this.setOpen(false);
this.removeAllVisitors();
chr.announce(MaplePacketCreator.getHiredMerchant(chr, this, false));
} else if (!this.isOpen()) {
chr.announce(MaplePacketCreator.getMiniRoomError(18));
return;
} else if (!this.addVisitor(chr)) {
chr.announce(MaplePacketCreator.getMiniRoomError(2));
return;
} else {
chr.announce(MaplePacketCreator.getHiredMerchant(chr, this, false));
}
chr.setHiredMerchant(this);
} finally {
visitorLock.unlock();
}
}
public String getOwner() {
+1 -1
View File
@@ -1732,7 +1732,7 @@ public class MapleMap {
}
public Point getGroundBelow(Point pos) {
Point spos = new Point(pos.x, pos.y - 7); // Using -7 fixes spawning pets causing a lot of issues.
Point spos = new Point(pos.x, pos.y - 14); // Using -14 fixes spawning pets causing a lot of issues.
spos = calcPointBelow(spos);
spos.y--;//shouldn't be null!
return spos;
+13 -18
View File
@@ -99,20 +99,15 @@ public class MaplePlayerShop extends AbstractMapleMapObject {
}
private void addVisitor(MapleCharacter visitor) {
visitorLock.lock();
try {
for (int i = 0; i < 3; i++) {
if (visitors[i] == null) {
visitors[i] = visitor;
visitor.setSlot(i);
this.broadcast(MaplePacketCreator.getPlayerShopNewVisitor(visitor, i + 1));
if(i == 2) visitor.getMap().broadcastMessage(MaplePacketCreator.addCharBox(owner, 1));
break;
}
for (int i = 0; i < 3; i++) {
if (visitors[i] == null) {
visitors[i] = visitor;
visitor.setSlot(i);
this.broadcast(MaplePacketCreator.getPlayerShopNewVisitor(visitor, i + 1));
if(i == 2) visitor.getMap().broadcastMessage(MaplePacketCreator.addCharBox(owner, 1));
break;
}
} finally {
visitorLock.unlock();
}
}
@@ -490,11 +485,6 @@ public class MaplePlayerShop extends AbstractMapleMapObject {
}
public synchronized boolean visitShop(MapleCharacter chr) {
if(!open.get()) {
chr.dropMessage(1, "This store is not yet open.");
return false;
}
if (this.isBanned(chr.getName())) {
chr.dropMessage(1, "You have been banned from this store.");
return false;
@@ -502,6 +492,11 @@ public class MaplePlayerShop extends AbstractMapleMapObject {
visitorLock.lock();
try {
if(!open.get()) {
chr.dropMessage(1, "This store is not yet open.");
return false;
}
if (this.hasFreeSlot() && !this.isVisitor(chr)) {
this.addVisitor(chr);
chr.setPlayerShop(this);