Rename and clean up MaplePlayerShop
This commit is contained in:
@@ -163,7 +163,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
private Mount maplemount;
|
private Mount maplemount;
|
||||||
private Party party;
|
private Party party;
|
||||||
private final Pet[] pets = new Pet[3];
|
private final Pet[] pets = new Pet[3];
|
||||||
private MaplePlayerShop playerShop = null;
|
private PlayerShop playerShop = null;
|
||||||
private MapleShop shop = null;
|
private MapleShop shop = null;
|
||||||
private SkinColor skinColor = SkinColor.NORMAL;
|
private SkinColor skinColor = SkinColor.NORMAL;
|
||||||
private MapleStorage storage = null;
|
private MapleStorage storage = null;
|
||||||
@@ -5492,7 +5492,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaplePlayerShop getPlayerShop() {
|
public PlayerShop getPlayerShop() {
|
||||||
return playerShop;
|
return playerShop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5536,7 +5536,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void closePlayerShop() {
|
public void closePlayerShop() {
|
||||||
MaplePlayerShop mps = this.getPlayerShop();
|
PlayerShop mps = this.getPlayerShop();
|
||||||
if (mps == null) {
|
if (mps == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -9277,7 +9277,7 @@ public class Character extends AbstractCharacterObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerShop(MaplePlayerShop playerShop) {
|
public void setPlayerShop(PlayerShop playerShop) {
|
||||||
this.playerShop = playerShop;
|
this.playerShop = playerShop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import net.AbstractPacketHandler;
|
|||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import server.maps.MapObject;
|
import server.maps.MapObject;
|
||||||
import server.maps.MapObjectType;
|
import server.maps.MapObjectType;
|
||||||
import server.maps.MaplePlayerShop;
|
|
||||||
import server.maps.MaplePortal;
|
import server.maps.MaplePortal;
|
||||||
|
import server.maps.PlayerShop;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
@@ -51,7 +51,7 @@ public final class HiredMerchantRequest extends AbstractPacketHandler {
|
|||||||
if (mmo instanceof Character) {
|
if (mmo instanceof Character) {
|
||||||
Character mc = (Character) mmo;
|
Character mc = (Character) mmo;
|
||||||
|
|
||||||
MaplePlayerShop shop = mc.getPlayerShop();
|
PlayerShop shop = mc.getPlayerShop();
|
||||||
if (shop != null && shop.isOwner(mc)) {
|
if (shop != null && shop.isOwner(mc)) {
|
||||||
chr.sendPacket(PacketCreator.getMiniRoomError(13));
|
chr.sendPacket(PacketCreator.getMiniRoomError(13));
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import constants.game.GameConstants;
|
|||||||
import net.AbstractPacketHandler;
|
import net.AbstractPacketHandler;
|
||||||
import net.packet.InPacket;
|
import net.packet.InPacket;
|
||||||
import server.maps.HiredMerchant;
|
import server.maps.HiredMerchant;
|
||||||
import server.maps.MaplePlayerShop;
|
import server.maps.PlayerShop;
|
||||||
import tools.PacketCreator;
|
import tools.PacketCreator;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -43,7 +43,7 @@ public final class OwlWarpHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HiredMerchant hm = c.getWorldServer().getHiredMerchant(ownerid); // if both hired merchant and player shop is on the same map
|
HiredMerchant hm = c.getWorldServer().getHiredMerchant(ownerid); // if both hired merchant and player shop is on the same map
|
||||||
MaplePlayerShop ps;
|
PlayerShop ps;
|
||||||
if(hm == null || hm.getMapId() != mapid || !hm.hasItem(c.getPlayer().getOwlSearch())) {
|
if(hm == null || hm.getMapId() != mapid || !hm.hasItem(c.getPlayer().getOwlSearch())) {
|
||||||
ps = c.getWorldServer().getPlayerShop(ownerid);
|
ps = c.getWorldServer().getPlayerShop(ownerid);
|
||||||
if(ps == null || ps.getMapId() != mapid || !ps.hasItem(c.getPlayer().getOwlSearch())) {
|
if(ps == null || ps.getMapId() != mapid || !ps.hasItem(c.getPlayer().getOwlSearch())) {
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ItemConstants.isPlayerShop(itemId)) {
|
if (ItemConstants.isPlayerShop(itemId)) {
|
||||||
MaplePlayerShop shop = new MaplePlayerShop(chr, desc, itemId);
|
PlayerShop shop = new PlayerShop(chr, desc, itemId);
|
||||||
chr.setPlayerShop(shop);
|
chr.setPlayerShop(shop);
|
||||||
chr.getMap().addMapObject(shop);
|
chr.getMap().addMapObject(shop);
|
||||||
shop.sendShop(c);
|
shop.sendShop(c);
|
||||||
@@ -282,8 +282,8 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
|
|
||||||
int oid = p.readInt();
|
int oid = p.readInt();
|
||||||
MapObject ob = chr.getMap().getMapObject(oid);
|
MapObject ob = chr.getMap().getMapObject(oid);
|
||||||
if (ob instanceof MaplePlayerShop) {
|
if (ob instanceof PlayerShop) {
|
||||||
MaplePlayerShop shop = (MaplePlayerShop) ob;
|
PlayerShop shop = (PlayerShop) ob;
|
||||||
shop.visitShop(chr);
|
shop.visitShop(chr);
|
||||||
} else if (ob instanceof MiniGame) {
|
} else if (ob instanceof MiniGame) {
|
||||||
p.skip(1);
|
p.skip(1);
|
||||||
@@ -318,7 +318,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
if (chr.getTrade() != null) {
|
if (chr.getTrade() != null) {
|
||||||
chr.getTrade().chat(p.readString());
|
chr.getTrade().chat(p.readString());
|
||||||
} else if (chr.getPlayerShop() != null) { //mini game
|
} else if (chr.getPlayerShop() != null) { //mini game
|
||||||
MaplePlayerShop shop = chr.getPlayerShop();
|
PlayerShop shop = chr.getPlayerShop();
|
||||||
if (shop != null) {
|
if (shop != null) {
|
||||||
shop.chat(c, p.readString());
|
shop.chat(c, p.readString());
|
||||||
}
|
}
|
||||||
@@ -358,7 +358,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaplePlayerShop shop = chr.getPlayerShop();
|
PlayerShop shop = chr.getPlayerShop();
|
||||||
HiredMerchant merchant = chr.getHiredMerchant();
|
HiredMerchant merchant = chr.getHiredMerchant();
|
||||||
if (shop != null && shop.isOwner(chr)) {
|
if (shop != null && shop.isOwner(chr)) {
|
||||||
if(YamlConfig.config.server.USE_ERASE_PERMIT_ON_OPENSHOP) {
|
if(YamlConfig.config.server.USE_ERASE_PERMIT_ON_OPENSHOP) {
|
||||||
@@ -600,7 +600,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MaplePlayerShopItem shopItem = new MaplePlayerShopItem(sellItem, bundles, price);
|
MaplePlayerShopItem shopItem = new MaplePlayerShopItem(sellItem, bundles, price);
|
||||||
MaplePlayerShop shop = chr.getPlayerShop();
|
PlayerShop shop = chr.getPlayerShop();
|
||||||
HiredMerchant merchant = chr.getHiredMerchant();
|
HiredMerchant merchant = chr.getHiredMerchant();
|
||||||
if (shop != null && shop.isOwner(chr)) {
|
if (shop != null && shop.isOwner(chr)) {
|
||||||
if (shop.isOpen() || !shop.addItem(shopItem)) { // thanks Vcoc for pointing an exploit with unlimited shop slots
|
if (shop.isOpen() || !shop.addItem(shopItem)) { // thanks Vcoc for pointing an exploit with unlimited shop slots
|
||||||
@@ -649,7 +649,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
} else if (mode == Action.REMOVE_ITEM.getCode()) {
|
} else if (mode == Action.REMOVE_ITEM.getCode()) {
|
||||||
if (isTradeOpen(chr)) return;
|
if (isTradeOpen(chr)) return;
|
||||||
|
|
||||||
MaplePlayerShop shop = chr.getPlayerShop();
|
PlayerShop shop = chr.getPlayerShop();
|
||||||
if (shop != null && shop.isOwner(chr)) {
|
if (shop != null && shop.isOwner(chr)) {
|
||||||
if (shop.isOpen()) {
|
if (shop.isOpen()) {
|
||||||
c.sendPacket(PacketCreator.serverNotice(1, "You can't take it with the store open."));
|
c.sendPacket(PacketCreator.serverNotice(1, "You can't take it with the store open."));
|
||||||
@@ -695,7 +695,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
c.disconnect(true, false);
|
c.disconnect(true, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MaplePlayerShop shop = chr.getPlayerShop();
|
PlayerShop shop = chr.getPlayerShop();
|
||||||
HiredMerchant merchant = chr.getHiredMerchant();
|
HiredMerchant merchant = chr.getHiredMerchant();
|
||||||
if (shop != null && shop.isVisitor(chr)) {
|
if (shop != null && shop.isVisitor(chr)) {
|
||||||
if (shop.buy(c, itemid, quantity)) {
|
if (shop.buy(c, itemid, quantity)) {
|
||||||
@@ -753,7 +753,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
} else if (mode == Action.BAN_PLAYER.getCode()) {
|
} else if (mode == Action.BAN_PLAYER.getCode()) {
|
||||||
p.skip(1);
|
p.skip(1);
|
||||||
|
|
||||||
MaplePlayerShop shop = chr.getPlayerShop();
|
PlayerShop shop = chr.getPlayerShop();
|
||||||
if (shop != null && shop.isOwner(chr)) {
|
if (shop != null && shop.isOwner(chr)) {
|
||||||
shop.banPlayer(p.readString());
|
shop.banPlayer(p.readString());
|
||||||
}
|
}
|
||||||
@@ -802,7 +802,7 @@ public final class PlayerInteractionHandler extends AbstractPacketHandler {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
MaplePlayerShop shop = mc.getPlayerShop();
|
PlayerShop shop = mc.getPlayerShop();
|
||||||
if (shop != null && shop.isOwner(mc)) {
|
if (shop != null && shop.isOwner(mc)) {
|
||||||
chr.sendPacket(PacketCreator.getMiniRoomError(13));
|
chr.sendPacket(PacketCreator.getMiniRoomError(13));
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ public class World {
|
|||||||
private long mountUpdate;
|
private long mountUpdate;
|
||||||
|
|
||||||
private MonitoredReentrantLock activePlayerShopsLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.WORLD_PSHOPS, true);
|
private MonitoredReentrantLock activePlayerShopsLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.WORLD_PSHOPS, true);
|
||||||
private Map<Integer, MaplePlayerShop> activePlayerShops = new LinkedHashMap<>();
|
private Map<Integer, PlayerShop> activePlayerShops = new LinkedHashMap<>();
|
||||||
|
|
||||||
private MonitoredReentrantLock activeMerchantsLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.WORLD_MERCHS, true);
|
private MonitoredReentrantLock activeMerchantsLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.WORLD_MERCHS, true);
|
||||||
private Map<Integer, Pair<HiredMerchant, Integer>> activeMerchants = new LinkedHashMap<>();
|
private Map<Integer, Pair<HiredMerchant, Integer>> activeMerchants = new LinkedHashMap<>();
|
||||||
@@ -1516,7 +1516,7 @@ public class World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerPlayerShop(MaplePlayerShop ps) {
|
public void registerPlayerShop(PlayerShop ps) {
|
||||||
activePlayerShopsLock.lock();
|
activePlayerShopsLock.lock();
|
||||||
try {
|
try {
|
||||||
activePlayerShops.put(ps.getOwner().getId(), ps);
|
activePlayerShops.put(ps.getOwner().getId(), ps);
|
||||||
@@ -1525,7 +1525,7 @@ public class World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterPlayerShop(MaplePlayerShop ps) {
|
public void unregisterPlayerShop(PlayerShop ps) {
|
||||||
activePlayerShopsLock.lock();
|
activePlayerShopsLock.lock();
|
||||||
try {
|
try {
|
||||||
activePlayerShops.remove(ps.getOwner().getId());
|
activePlayerShops.remove(ps.getOwner().getId());
|
||||||
@@ -1534,8 +1534,8 @@ public class World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MaplePlayerShop> getActivePlayerShops() {
|
public List<PlayerShop> getActivePlayerShops() {
|
||||||
List<MaplePlayerShop> psList = new ArrayList<>();
|
List<PlayerShop> psList = new ArrayList<>();
|
||||||
activePlayerShopsLock.lock();
|
activePlayerShopsLock.lock();
|
||||||
try {
|
try {
|
||||||
psList.addAll(activePlayerShops.values());
|
psList.addAll(activePlayerShops.values());
|
||||||
@@ -1546,7 +1546,7 @@ public class World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MaplePlayerShop getPlayerShop(int ownerid) {
|
public PlayerShop getPlayerShop(int ownerid) {
|
||||||
activePlayerShopsLock.lock();
|
activePlayerShopsLock.lock();
|
||||||
try {
|
try {
|
||||||
return activePlayerShops.get(ownerid);
|
return activePlayerShops.get(ownerid);
|
||||||
@@ -1824,7 +1824,7 @@ public class World {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MaplePlayerShop ps : getActivePlayerShops()) {
|
for (PlayerShop ps : getActivePlayerShops()) {
|
||||||
List<MaplePlayerShopItem> itemBundles = ps.sendAvailableBundles(itemid);
|
List<MaplePlayerShopItem> itemBundles = ps.sendAvailableBundles(itemid);
|
||||||
|
|
||||||
for(MaplePlayerShopItem mpsi : itemBundles) {
|
for(MaplePlayerShopItem mpsi : itemBundles) {
|
||||||
|
|||||||
@@ -40,26 +40,25 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author Matze
|
* @author Matze
|
||||||
* @author Ronan - concurrency protection
|
* @author Ronan - concurrency protection
|
||||||
*/
|
*/
|
||||||
public class MaplePlayerShop extends AbstractMapObject {
|
public class PlayerShop extends AbstractMapObject {
|
||||||
private AtomicBoolean open = new AtomicBoolean(false);
|
private final AtomicBoolean open = new AtomicBoolean(false);
|
||||||
private Character owner;
|
private final Character owner;
|
||||||
private int itemid;
|
private final int itemid;
|
||||||
|
|
||||||
private Character[] visitors = new Character[3];
|
private final Character[] visitors = new Character[3];
|
||||||
private List<MaplePlayerShopItem> items = new ArrayList<>();
|
private final List<MaplePlayerShopItem> items = new ArrayList<>();
|
||||||
private List<SoldItem> sold = new LinkedList<>();
|
private final List<SoldItem> sold = new LinkedList<>();
|
||||||
private String description;
|
private String description;
|
||||||
private int boughtnumber = 0;
|
private int boughtnumber = 0;
|
||||||
private List<String> bannedList = new ArrayList<>();
|
private final List<String> bannedList = new ArrayList<>();
|
||||||
private List<Pair<Character, String>> chatLog = new LinkedList<>();
|
private final List<Pair<Character, String>> chatLog = new LinkedList<>();
|
||||||
private Map<Integer, Byte> chatSlot = new LinkedHashMap<>();
|
private final Map<Integer, Byte> chatSlot = new LinkedHashMap<>();
|
||||||
private Lock visitorLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.VISITOR_PSHOP, true);
|
private final Lock visitorLock = MonitoredReentrantLockFactory.createLock(MonitoredLockType.VISITOR_PSHOP, true);
|
||||||
|
|
||||||
public MaplePlayerShop(Character owner, String description, int itemid) {
|
public PlayerShop(Character owner, String description, int itemid) {
|
||||||
this.setPosition(owner.getPosition());
|
this.setPosition(owner.getPosition());
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
@@ -100,11 +99,11 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
try {
|
try {
|
||||||
byte count = 0;
|
byte count = 0;
|
||||||
//if (this.isOpen()) {
|
//if (this.isOpen()) {
|
||||||
for (Character visitor : visitors) {
|
for (Character visitor : visitors) {
|
||||||
if (visitor != null) {
|
if (visitor != null) {
|
||||||
count++;
|
count++;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//} else { shouldn't happen since there isn't a "closed" state for player shops.
|
//} else { shouldn't happen since there isn't a "closed" state for player shops.
|
||||||
// count = (byte) (visitors.length + 1);
|
// count = (byte) (visitors.length + 1);
|
||||||
//}
|
//}
|
||||||
@@ -167,14 +166,20 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
if (visitors[i] != null && visitors[i].getId() == visitor.getId()) {
|
if (visitors[i] != null && visitors[i].getId() == visitor.getId()) {
|
||||||
visitor.setSlot(-1); //absolutely cant remove player slot for late players without dc'ing them... heh
|
visitor.setSlot(-1); //absolutely cant remove player slot for late players without dc'ing them... heh
|
||||||
|
|
||||||
for(int j = i; j < 2; j++) {
|
for (int j = i; j < 2; j++) {
|
||||||
if(visitors[j] != null) owner.sendPacket(PacketCreator.getPlayerShopRemoveVisitor(j + 1));
|
if (visitors[j] != null) {
|
||||||
|
owner.sendPacket(PacketCreator.getPlayerShopRemoveVisitor(j + 1));
|
||||||
|
}
|
||||||
visitors[j] = visitors[j + 1];
|
visitors[j] = visitors[j + 1];
|
||||||
if(visitors[j] != null) visitors[j].setSlot(j);
|
if (visitors[j] != null) {
|
||||||
|
visitors[j].setSlot(j);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
visitors[2] = null;
|
visitors[2] = null;
|
||||||
for(int j = i; j < 2; j++) {
|
for (int j = i; j < 2; j++) {
|
||||||
if(visitors[j] != null) owner.sendPacket(PacketCreator.getPlayerShopNewVisitor(visitors[j], j + 1));
|
if (visitors[j] != null) {
|
||||||
|
owner.sendPacket(PacketCreator.getPlayerShopNewVisitor(visitors[j], j + 1));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.broadcastRestoreToVisitors();
|
this.broadcastRestoreToVisitors();
|
||||||
@@ -201,7 +206,9 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
|
|
||||||
public boolean addItem(MaplePlayerShopItem item) {
|
public boolean addItem(MaplePlayerShopItem item) {
|
||||||
synchronized (items) {
|
synchronized (items) {
|
||||||
if (items.size() >= 16) return false;
|
if (items.size() >= 16) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
items.add(item);
|
items.add(item);
|
||||||
return true;
|
return true;
|
||||||
@@ -219,7 +226,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
public void takeItemBack(int slot, Character chr) {
|
public void takeItemBack(int slot, Character chr) {
|
||||||
synchronized (items) {
|
synchronized (items) {
|
||||||
MaplePlayerShopItem shopItem = items.get(slot);
|
MaplePlayerShopItem shopItem = items.get(slot);
|
||||||
if(shopItem.isExist()) {
|
if (shopItem.isExist()) {
|
||||||
if (shopItem.getBundles() > 0) {
|
if (shopItem.getBundles() > 0) {
|
||||||
Item iitem = shopItem.getItem().copy();
|
Item iitem = shopItem.getItem().copy();
|
||||||
iitem.setQuantity((short) (shopItem.getItem().getQuantity() * shopItem.getBundles()));
|
iitem.setQuantity((short) (shopItem.getItem().getQuantity() * shopItem.getBundles()));
|
||||||
@@ -241,6 +248,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* no warnings for now o.o
|
* no warnings for now o.o
|
||||||
|
*
|
||||||
* @param c
|
* @param c
|
||||||
* @param item
|
* @param item
|
||||||
* @param quantity
|
* @param quantity
|
||||||
@@ -264,7 +272,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
|
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
int price = (int) Math.min((float)pItem.getPrice() * quantity, Integer.MAX_VALUE);
|
int price = (int) Math.min((float) pItem.getPrice() * quantity, Integer.MAX_VALUE);
|
||||||
|
|
||||||
if (c.getPlayer().getMeso() >= price) {
|
if (c.getPlayer().getMeso() >= price) {
|
||||||
if (!owner.canHoldMeso(price)) { // thanks Rohenn for noticing owner hold check misplaced
|
if (!owner.canHoldMeso(price)) { // thanks Rohenn for noticing owner hold check misplaced
|
||||||
@@ -369,7 +377,9 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Character mc : visitorList) forceRemoveVisitor(mc);
|
for (Character mc : visitorList) {
|
||||||
|
forceRemoveVisitor(mc);
|
||||||
|
}
|
||||||
if (owner != null) {
|
if (owner != null) {
|
||||||
forceRemoveVisitor(owner);
|
forceRemoveVisitor(owner);
|
||||||
}
|
}
|
||||||
@@ -402,9 +412,11 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
public void chat(Client c, String chat) {
|
public void chat(Client c, String chat) {
|
||||||
byte s = getVisitorSlot(c.getPlayer());
|
byte s = getVisitorSlot(c.getPlayer());
|
||||||
|
|
||||||
synchronized(chatLog) {
|
synchronized (chatLog) {
|
||||||
chatLog.add(new Pair<>(c.getPlayer(), chat));
|
chatLog.add(new Pair<>(c.getPlayer(), chat));
|
||||||
if(chatLog.size() > 25) chatLog.remove(0);
|
if (chatLog.size() > 25) {
|
||||||
|
chatLog.remove(0);
|
||||||
|
}
|
||||||
chatSlot.put(c.getPlayer().getId(), s);
|
chatSlot.put(c.getPlayer().getId(), s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -412,8 +424,8 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void recoverChatLog() {
|
private void recoverChatLog() {
|
||||||
synchronized(chatLog) {
|
synchronized (chatLog) {
|
||||||
for(Pair<Character, String> it : chatLog) {
|
for (Pair<Character, String> it : chatLog) {
|
||||||
Character chr = it.getLeft();
|
Character chr = it.getLeft();
|
||||||
Byte pos = chatSlot.get(chr.getId());
|
Byte pos = chatSlot.get(chr.getId());
|
||||||
|
|
||||||
@@ -423,7 +435,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void clearChatLog() {
|
private void clearChatLog() {
|
||||||
synchronized(chatLog) {
|
synchronized (chatLog) {
|
||||||
chatLog.clear();
|
chatLog.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -451,7 +463,9 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
Character[] copy = new Character[3];
|
Character[] copy = new Character[3];
|
||||||
for(int i = 0; i < visitors.length; i++) copy[i] = visitors[i];
|
for (int i = 0; i < visitors.length; i++) {
|
||||||
|
copy[i] = visitors[i];
|
||||||
|
}
|
||||||
|
|
||||||
return copy;
|
return copy;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -466,8 +480,8 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasItem(int itemid) {
|
public boolean hasItem(int itemid) {
|
||||||
for(MaplePlayerShopItem mpsi : getItems()) {
|
for (MaplePlayerShopItem mpsi : getItems()) {
|
||||||
if(mpsi.getItem().getItemId() == itemid && mpsi.isExist() && mpsi.getBundles() > 0) {
|
if (mpsi.getItem().getItemId() == itemid && mpsi.isExist() && mpsi.getBundles() > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -501,7 +515,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target != null) {
|
if (target != null) {
|
||||||
target.sendPacket(PacketCreator.shopErrorMessage(5, 1));
|
target.sendPacket(PacketCreator.shopErrorMessage(5, 1));
|
||||||
removeVisitor(target);
|
removeVisitor(target);
|
||||||
}
|
}
|
||||||
@@ -519,7 +533,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
|
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
if(!open.get()) {
|
if (!open.get()) {
|
||||||
chr.dropMessage(1, "This store is not yet open.");
|
chr.dropMessage(1, "This store is not yet open.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -546,8 +560,8 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
all.addAll(items);
|
all.addAll(items);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(MaplePlayerShopItem mpsi : all) {
|
for (MaplePlayerShopItem mpsi : all) {
|
||||||
if(mpsi.getItem().getItemId() == itemid && mpsi.getBundles() > 0 && mpsi.isExist()) {
|
if (mpsi.getItem().getItemId() == itemid && mpsi.getBundles() > 0 && mpsi.isExist()) {
|
||||||
list.add(mpsi);
|
list.add(mpsi);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1954,7 +1954,7 @@ public class PacketCreator {
|
|||||||
p.writeInt(chr.getMount().getTiredness());
|
p.writeInt(chr.getMount().getTiredness());
|
||||||
}
|
}
|
||||||
|
|
||||||
MaplePlayerShop mps = chr.getPlayerShop();
|
PlayerShop mps = chr.getPlayerShop();
|
||||||
if (mps != null && mps.isOwner(chr)) {
|
if (mps != null && mps.isOwner(chr)) {
|
||||||
if (mps.hasFreeSlot()) {
|
if (mps.hasFreeSlot()) {
|
||||||
addAnnounceBox(p, mps, mps.getVisitors().length);
|
addAnnounceBox(p, mps, mps.getVisitors().length);
|
||||||
@@ -2134,7 +2134,7 @@ public class PacketCreator {
|
|||||||
* to.
|
* to.
|
||||||
* @param shop The shop to announce.
|
* @param shop The shop to announce.
|
||||||
*/
|
*/
|
||||||
private static void addAnnounceBox(final OutPacket p, MaplePlayerShop shop, int availability) {
|
private static void addAnnounceBox(final OutPacket p, PlayerShop shop, int availability) {
|
||||||
p.writeByte(4);
|
p.writeByte(4);
|
||||||
p.writeInt(shop.getObjectId());
|
p.writeInt(shop.getObjectId());
|
||||||
p.writeString(shop.getDescription());
|
p.writeString(shop.getDescription());
|
||||||
@@ -2173,7 +2173,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updatePlayerShopBoxInfo(OutPacket p, MaplePlayerShop shop) {
|
private static void updatePlayerShopBoxInfo(OutPacket p, PlayerShop shop) {
|
||||||
byte[] roomInfo = shop.getShopRoomInfo();
|
byte[] roomInfo = shop.getShopRoomInfo();
|
||||||
|
|
||||||
p.writeByte(4);
|
p.writeByte(4);
|
||||||
@@ -2186,14 +2186,14 @@ public class PacketCreator {
|
|||||||
p.writeByte(0);
|
p.writeByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet updatePlayerShopBox(MaplePlayerShop shop) {
|
public static Packet updatePlayerShopBox(PlayerShop shop) {
|
||||||
final OutPacket p = OutPacket.create(SendOpcode.UPDATE_CHAR_BOX);
|
final OutPacket p = OutPacket.create(SendOpcode.UPDATE_CHAR_BOX);
|
||||||
p.writeInt(shop.getOwner().getId());
|
p.writeInt(shop.getOwner().getId());
|
||||||
updatePlayerShopBoxInfo(p, shop);
|
updatePlayerShopBoxInfo(p, shop);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet removePlayerShopBox(MaplePlayerShop shop) {
|
public static Packet removePlayerShopBox(PlayerShop shop) {
|
||||||
OutPacket p = OutPacket.create(SendOpcode.UPDATE_CHAR_BOX);
|
OutPacket p = OutPacket.create(SendOpcode.UPDATE_CHAR_BOX);
|
||||||
p.writeInt(shop.getOwner().getId());
|
p.writeInt(shop.getOwner().getId());
|
||||||
p.writeByte(0);
|
p.writeByte(0);
|
||||||
@@ -3168,7 +3168,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getPlayerShopItemUpdate(MaplePlayerShop shop) {
|
public static Packet getPlayerShopItemUpdate(PlayerShop shop) {
|
||||||
final OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
final OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.UPDATE_MERCHANT.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.UPDATE_MERCHANT.getCode());
|
||||||
p.writeByte(shop.getItems().size());
|
p.writeByte(shop.getItems().size());
|
||||||
@@ -3181,7 +3181,7 @@ public class PacketCreator {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Packet getPlayerShopOwnerUpdate(MaplePlayerShop.SoldItem item, int position) {
|
public static Packet getPlayerShopOwnerUpdate(PlayerShop.SoldItem item, int position) {
|
||||||
final OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
final OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.UPDATE_PLAYERSHOP.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.UPDATE_PLAYERSHOP.getCode());
|
||||||
p.writeByte(position);
|
p.writeByte(position);
|
||||||
@@ -3197,7 +3197,7 @@ public class PacketCreator {
|
|||||||
* @param owner
|
* @param owner
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static Packet getPlayerShop(MaplePlayerShop shop, boolean owner) {
|
public static Packet getPlayerShop(PlayerShop shop, boolean owner) {
|
||||||
final OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
final OutPacket p = OutPacket.create(SendOpcode.PLAYER_INTERACTION);
|
||||||
p.writeByte(PlayerInteractionHandler.Action.ROOM.getCode());
|
p.writeByte(PlayerInteractionHandler.Action.ROOM.getCode());
|
||||||
p.writeByte(4);
|
p.writeByte(4);
|
||||||
@@ -3205,9 +3205,9 @@ public class PacketCreator {
|
|||||||
p.writeByte(owner ? 0 : 1);
|
p.writeByte(owner ? 0 : 1);
|
||||||
|
|
||||||
if (owner) {
|
if (owner) {
|
||||||
List<MaplePlayerShop.SoldItem> sold = shop.getSold();
|
List<PlayerShop.SoldItem> sold = shop.getSold();
|
||||||
p.writeByte(sold.size());
|
p.writeByte(sold.size());
|
||||||
for (MaplePlayerShop.SoldItem s : sold) {
|
for (PlayerShop.SoldItem s : sold) {
|
||||||
p.writeInt(s.getItemId());
|
p.writeInt(s.getItemId());
|
||||||
p.writeShort(s.getQuantity());
|
p.writeShort(s.getQuantity());
|
||||||
p.writeInt(s.getMesos());
|
p.writeInt(s.getMesos());
|
||||||
@@ -5016,7 +5016,7 @@ public class PacketCreator {
|
|||||||
MaplePlayerShopItem item = hme.getLeft();
|
MaplePlayerShopItem item = hme.getLeft();
|
||||||
AbstractMapObject mo = hme.getRight();
|
AbstractMapObject mo = hme.getRight();
|
||||||
|
|
||||||
if (mo instanceof MaplePlayerShop ps) {
|
if (mo instanceof PlayerShop ps) {
|
||||||
Character owner = ps.getOwner();
|
Character owner = ps.getOwner();
|
||||||
|
|
||||||
p.writeString(owner.getName());
|
p.writeString(owner.getName());
|
||||||
|
|||||||
Reference in New Issue
Block a user