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;
|
||||||
@@ -69,23 +68,23 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
public int getChannel() {
|
public int getChannel() {
|
||||||
return owner.getClient().getChannel();
|
return owner.getClient().getChannel();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getMapId() {
|
public int getMapId() {
|
||||||
return owner.getMapId();
|
return owner.getMapId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemId() {
|
public int getItemId() {
|
||||||
return itemid;
|
return itemid;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isOpen() {
|
public boolean isOpen() {
|
||||||
return open.get();
|
return open.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOpen(boolean openShop) {
|
public void setOpen(boolean openShop) {
|
||||||
open.set(openShop);
|
open.set(openShop);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFreeSlot() {
|
public boolean hasFreeSlot() {
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
@@ -94,21 +93,21 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getShopRoomInfo() {
|
public byte[] getShopRoomInfo() {
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
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);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
return new byte[]{count, (byte) visitors.length};
|
return new byte[]{count, (byte) visitors.length};
|
||||||
} finally {
|
} finally {
|
||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
@@ -124,7 +123,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
if (visitors[i] == null) {
|
if (visitors[i] == null) {
|
||||||
visitors[i] = visitor;
|
visitors[i] = visitor;
|
||||||
visitor.setSlot(i);
|
visitor.setSlot(i);
|
||||||
|
|
||||||
this.broadcast(PacketCreator.getPlayerShopNewVisitor(visitor, i + 1));
|
this.broadcast(PacketCreator.getPlayerShopNewVisitor(visitor, i + 1));
|
||||||
owner.getMap().broadcastMessage(PacketCreator.updatePlayerShopBox(this));
|
owner.getMap().broadcastMessage(PacketCreator.updatePlayerShopBox(this));
|
||||||
break;
|
break;
|
||||||
@@ -137,7 +136,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
owner.getMap().removeMapObject(this);
|
owner.getMap().removeMapObject(this);
|
||||||
owner.setPlayerShop(null);
|
owner.setPlayerShop(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
@@ -145,7 +144,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitors[i].setPlayerShop(null);
|
visitors[i].setPlayerShop(null);
|
||||||
visitors[i] = null;
|
visitors[i] = null;
|
||||||
visitor.setSlot(-1);
|
visitor.setSlot(-1);
|
||||||
|
|
||||||
this.broadcast(PacketCreator.getPlayerShopRemoveVisitor(i + 1));
|
this.broadcast(PacketCreator.getPlayerShopRemoveVisitor(i + 1));
|
||||||
owner.getMap().broadcastMessage(PacketCreator.updatePlayerShopBox(this));
|
owner.getMap().broadcastMessage(PacketCreator.updatePlayerShopBox(this));
|
||||||
return;
|
return;
|
||||||
@@ -155,7 +154,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeVisitor(Character visitor) {
|
public void removeVisitor(Character visitor) {
|
||||||
if (visitor == owner) {
|
if (visitor == owner) {
|
||||||
owner.getMap().removeMapObject(this);
|
owner.getMap().removeMapObject(this);
|
||||||
@@ -166,17 +165,23 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
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();
|
||||||
owner.getMap().broadcastMessage(PacketCreator.updatePlayerShopBox(this));
|
owner.getMap().broadcastMessage(PacketCreator.updatePlayerShopBox(this));
|
||||||
return;
|
return;
|
||||||
@@ -185,7 +190,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
} finally {
|
} finally {
|
||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
owner.getMap().broadcastMessage(PacketCreator.updatePlayerShopBox(this));
|
owner.getMap().broadcastMessage(PacketCreator.updatePlayerShopBox(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -201,8 +206,10 @@ 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;
|
||||||
}
|
}
|
||||||
@@ -215,32 +222,33 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
private static boolean canBuy(Client c, Item newItem) {
|
private static boolean canBuy(Client c, Item newItem) {
|
||||||
return InventoryManipulator.checkSpace(c, newItem.getItemId(), newItem.getQuantity(), newItem.getOwner()) && InventoryManipulator.addFromDrop(c, newItem, false);
|
return InventoryManipulator.checkSpace(c, newItem.getItemId(), newItem.getQuantity(), newItem.getOwner()) && InventoryManipulator.addFromDrop(c, newItem, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
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()));
|
||||||
|
|
||||||
if (!Inventory.checkSpot(chr, iitem)) {
|
if (!Inventory.checkSpot(chr, iitem)) {
|
||||||
chr.sendPacket(PacketCreator.serverNotice(1, "Have a slot available on your inventory to claim back the item."));
|
chr.sendPacket(PacketCreator.serverNotice(1, "Have a slot available on your inventory to claim back the item."));
|
||||||
chr.sendPacket(PacketCreator.enableActions());
|
chr.sendPacket(PacketCreator.enableActions());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
InventoryManipulator.addFromDrop(chr.getClient(), iitem, true);
|
InventoryManipulator.addFromDrop(chr.getClient(), iitem, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
removeFromSlot(slot);
|
removeFromSlot(slot);
|
||||||
chr.sendPacket(PacketCreator.getPlayerShopItemUpdate(this));
|
chr.sendPacket(PacketCreator.getPlayerShopItemUpdate(this));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* no warnings for now o.o
|
* no warnings for now o.o
|
||||||
|
*
|
||||||
* @param c
|
* @param c
|
||||||
* @param item
|
* @param item
|
||||||
* @param quantity
|
* @param quantity
|
||||||
@@ -250,7 +258,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
if (isVisitor(c.getPlayer())) {
|
if (isVisitor(c.getPlayer())) {
|
||||||
MaplePlayerShopItem pItem = items.get(item);
|
MaplePlayerShopItem pItem = items.get(item);
|
||||||
Item newItem = pItem.getItem().copy();
|
Item newItem = pItem.getItem().copy();
|
||||||
|
|
||||||
newItem.setQuantity((short) ((pItem.getItem().getQuantity() * quantity)));
|
newItem.setQuantity((short) ((pItem.getItem().getQuantity() * quantity)));
|
||||||
if (quantity < 1 || !pItem.isExist() || pItem.getBundles() < quantity) {
|
if (quantity < 1 || !pItem.isExist() || pItem.getBundles() < quantity) {
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
@@ -259,32 +267,32 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
KarmaManipulator.toggleKarmaFlagToUntradeable(newItem);
|
KarmaManipulator.toggleKarmaFlagToUntradeable(newItem);
|
||||||
|
|
||||||
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
|
||||||
c.getPlayer().dropMessage(1, "Transaction failed since the shop owner can't hold any more mesos.");
|
c.getPlayer().dropMessage(1, "Transaction failed since the shop owner can't hold any more mesos.");
|
||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (canBuy(c, newItem)) {
|
if (canBuy(c, newItem)) {
|
||||||
c.getPlayer().gainMeso(-price, false);
|
c.getPlayer().gainMeso(-price, false);
|
||||||
price -= MapleTrade.getFee(price); // thanks BHB for pointing out trade fees not applying here
|
price -= MapleTrade.getFee(price); // thanks BHB for pointing out trade fees not applying here
|
||||||
owner.gainMeso(price, true);
|
owner.gainMeso(price, true);
|
||||||
|
|
||||||
SoldItem soldItem = new SoldItem(c.getPlayer().getName(), pItem.getItem().getItemId(), quantity, price);
|
SoldItem soldItem = new SoldItem(c.getPlayer().getName(), pItem.getItem().getItemId(), quantity, price);
|
||||||
owner.sendPacket(PacketCreator.getPlayerShopOwnerUpdate(soldItem, item));
|
owner.sendPacket(PacketCreator.getPlayerShopOwnerUpdate(soldItem, item));
|
||||||
|
|
||||||
synchronized (sold) {
|
synchronized (sold) {
|
||||||
sold.add(soldItem);
|
sold.add(soldItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
pItem.setBundles((short) (pItem.getBundles() - quantity));
|
pItem.setBundles((short) (pItem.getBundles() - quantity));
|
||||||
if (pItem.getBundles() < 1) {
|
if (pItem.getBundles() < 1) {
|
||||||
pItem.setDoesExist(false);
|
pItem.setDoesExist(false);
|
||||||
@@ -305,7 +313,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
c.sendPacket(PacketCreator.enableActions());
|
c.sendPacket(PacketCreator.enableActions());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} finally {
|
} finally {
|
||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
@@ -315,7 +323,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcastToVisitors(Packet packet) {
|
public void broadcastToVisitors(Packet packet) {
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
@@ -328,7 +336,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void broadcastRestoreToVisitors() {
|
public void broadcastRestoreToVisitors() {
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
@@ -337,13 +345,13 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitors[i].sendPacket(PacketCreator.getPlayerShopRemoveVisitor(i + 1));
|
visitors[i].sendPacket(PacketCreator.getPlayerShopRemoveVisitor(i + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++) {
|
for (int i = 0; i < 3; i++) {
|
||||||
if (visitors[i] != null) {
|
if (visitors[i] != null) {
|
||||||
visitors[i].sendPacket(PacketCreator.getPlayerShop(this, false));
|
visitors[i].sendPacket(PacketCreator.getPlayerShop(this, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
recoverChatLog();
|
recoverChatLog();
|
||||||
} finally {
|
} finally {
|
||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
@@ -352,7 +360,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
|
|
||||||
public void removeVisitors() {
|
public void removeVisitors() {
|
||||||
List<Character> visitorList = new ArrayList<>(3);
|
List<Character> visitorList = new ArrayList<>(3);
|
||||||
|
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
@@ -368,8 +376,10 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
} finally {
|
} finally {
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -395,39 +405,41 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
s = 0;
|
s = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
broadcast(PacketCreator.getPlayerShopChat(c.getPlayer(), chat, s));
|
broadcast(PacketCreator.getPlayerShopChat(c.getPlayer(), chat, s));
|
||||||
}
|
}
|
||||||
|
|
||||||
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());
|
||||||
|
|
||||||
broadcastToVisitors(PacketCreator.getPlayerShopChat(chr, it.getRight(), pos));
|
broadcastToVisitors(PacketCreator.getPlayerShopChat(chr, it.getRight(), pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearChatLog() {
|
private void clearChatLog() {
|
||||||
synchronized(chatLog) {
|
synchronized (chatLog) {
|
||||||
chatLog.clear();
|
chatLog.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void closeShop() {
|
public void closeShop() {
|
||||||
clearChatLog();
|
clearChatLog();
|
||||||
removeVisitors();
|
removeVisitors();
|
||||||
@@ -451,8 +463,10 @@ 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 {
|
||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
@@ -464,14 +478,14 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
return Collections.unmodifiableList(items);
|
return Collections.unmodifiableList(items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -487,7 +501,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
if (!bannedList.contains(name)) {
|
if (!bannedList.contains(name)) {
|
||||||
bannedList.add(name);
|
bannedList.add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Character target = null;
|
Character target = null;
|
||||||
visitorLock.lock();
|
visitorLock.lock();
|
||||||
try {
|
try {
|
||||||
@@ -500,8 +514,8 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
} finally {
|
} finally {
|
||||||
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);
|
||||||
}
|
}
|
||||||
@@ -510,20 +524,20 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
public boolean isBanned(String name) {
|
public boolean isBanned(String name) {
|
||||||
return bannedList.contains(name);
|
return bannedList.contains(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean visitShop(Character chr) {
|
public synchronized boolean visitShop(Character chr) {
|
||||||
if (this.isBanned(chr.getName())) {
|
if (this.isBanned(chr.getName())) {
|
||||||
chr.dropMessage(1, "You have been banned from this store.");
|
chr.dropMessage(1, "You have been banned from this store.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasFreeSlot() && !this.isVisitor(chr)) {
|
if (this.hasFreeSlot() && !this.isVisitor(chr)) {
|
||||||
this.addVisitor(chr);
|
this.addVisitor(chr);
|
||||||
chr.setPlayerShop(this);
|
chr.setPlayerShop(this);
|
||||||
@@ -537,23 +551,23 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
visitorLock.unlock();
|
visitorLock.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<MaplePlayerShopItem> sendAvailableBundles(int itemid) {
|
public List<MaplePlayerShopItem> sendAvailableBundles(int itemid) {
|
||||||
List<MaplePlayerShopItem> list = new LinkedList<>();
|
List<MaplePlayerShopItem> list = new LinkedList<>();
|
||||||
List<MaplePlayerShopItem> all = new ArrayList<>();
|
List<MaplePlayerShopItem> all = new ArrayList<>();
|
||||||
|
|
||||||
synchronized (items) {
|
synchronized (items) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<SoldItem> getSold() {
|
public List<SoldItem> getSold() {
|
||||||
synchronized (sold) {
|
synchronized (sold) {
|
||||||
return Collections.unmodifiableList(sold);
|
return Collections.unmodifiableList(sold);
|
||||||
@@ -574,7 +588,7 @@ public class MaplePlayerShop extends AbstractMapObject {
|
|||||||
public MapObjectType getType() {
|
public MapObjectType getType() {
|
||||||
return MapObjectType.SHOP;
|
return MapObjectType.SHOP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SoldItem {
|
public class SoldItem {
|
||||||
|
|
||||||
int itemid, mesos;
|
int itemid, mesos;
|
||||||
@@ -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