Save chr slots to PG
This commit is contained in:
@@ -327,7 +327,7 @@ public final class PacketProcessor {
|
||||
registerHandler(RecvOpcode.TAKE_DAMAGE, new TakeDamageHandler());
|
||||
registerHandler(RecvOpcode.MOVE_PLAYER, new MovePlayerHandler());
|
||||
registerHandler(RecvOpcode.USE_CASH_ITEM, new UseCashItemHandler(channelDeps.noteService(),
|
||||
channelDeps.shopFactory()));
|
||||
channelDeps.shopFactory(), channelDeps.accountService()));
|
||||
registerHandler(RecvOpcode.USE_ITEM, new UseItemHandler());
|
||||
registerHandler(RecvOpcode.USE_RETURN_SCROLL, new UseItemHandler());
|
||||
registerHandler(RecvOpcode.USE_UPGRADE_SCROLL, new ScrollHandler());
|
||||
@@ -369,7 +369,8 @@ public final class PacketProcessor {
|
||||
registerHandler(RecvOpcode.MESSENGER, new MessengerHandler());
|
||||
registerHandler(RecvOpcode.NPC_ACTION, new NPCAnimationHandler());
|
||||
registerHandler(RecvOpcode.CHECK_CASH, new TouchingCashShopHandler());
|
||||
registerHandler(RecvOpcode.CASHSHOP_OPERATION, new CashOperationHandler(channelDeps.noteService()));
|
||||
registerHandler(RecvOpcode.CASHSHOP_OPERATION, new CashOperationHandler(channelDeps.noteService(),
|
||||
channelDeps.accountService()));
|
||||
registerHandler(RecvOpcode.COUPON_CODE, new CouponCodeHandler());
|
||||
registerHandler(RecvOpcode.SPAWN_PET, new SpawnPetHandler());
|
||||
registerHandler(RecvOpcode.MOVE_PET, new MovePetHandler());
|
||||
|
||||
@@ -42,6 +42,7 @@ import server.CashShop;
|
||||
import server.CashShop.CashItem;
|
||||
import server.CashShop.CashItemFactory;
|
||||
import server.ItemInformationProvider;
|
||||
import service.AccountService;
|
||||
import service.NoteService;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
@@ -56,9 +57,11 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(CashOperationHandler.class);
|
||||
|
||||
private final NoteService noteService;
|
||||
private final AccountService accountService;
|
||||
|
||||
public CashOperationHandler(NoteService noteService) {
|
||||
public CashOperationHandler(NoteService noteService, AccountService accountService) {
|
||||
this.noteService = noteService;
|
||||
this.accountService = accountService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -257,14 +260,13 @@ public final class CashOperationHandler extends AbstractPacketHandler {
|
||||
return;
|
||||
}
|
||||
cs.gainCash(cash, cItem, chr.getWorld());
|
||||
if (c.gainCharacterSlot()) {
|
||||
c.sendPacket(PacketCreator.showBoughtCharacterSlot(c.getCharacterSlots()));
|
||||
c.sendPacket(PacketCreator.showCash(chr));
|
||||
} else {
|
||||
if (!accountService.addChrSlot(c)) {
|
||||
log.warn("Could not add a chr slot to {}'s account", Character.makeMapleReadable(chr.getName()));
|
||||
c.enableCSActions();
|
||||
return;
|
||||
}
|
||||
c.sendPacket(PacketCreator.showBoughtCharacterSlot(c.getCharacterSlots()));
|
||||
c.sendPacket(PacketCreator.showCash(chr));
|
||||
} else if (action == 0x0D) { // Take from Cash Inventory
|
||||
Item item = cs.findByCashId(p.readInt());
|
||||
if (item == null) {
|
||||
|
||||
@@ -64,6 +64,7 @@ import server.maps.MapleTVEffect;
|
||||
import server.maps.PlayerShopItem;
|
||||
import server.shop.Shop;
|
||||
import server.shop.ShopFactory;
|
||||
import service.AccountService;
|
||||
import service.NoteService;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
@@ -82,10 +83,12 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
|
||||
|
||||
private final NoteService noteService;
|
||||
private final ShopFactory shopFactory;
|
||||
private final AccountService accountService;
|
||||
|
||||
public UseCashItemHandler(NoteService noteService, ShopFactory shopFactory) {
|
||||
public UseCashItemHandler(NoteService noteService, ShopFactory shopFactory, AccountService accountService) {
|
||||
this.noteService = noteService;
|
||||
this.shopFactory = shopFactory;
|
||||
this.accountService = accountService;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -493,7 +496,7 @@ public final class UseCashItemHandler extends AbstractPacketHandler {
|
||||
remove(c, position, itemId);
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
} else if (itemType == 543) {
|
||||
if (itemId == ItemId.MAPLE_LIFE_B && !c.gainCharacterSlot()) {
|
||||
if (itemId == ItemId.MAPLE_LIFE_B && !accountService.addChrSlot(c)) {
|
||||
player.dropMessage(1, "You have already used up all 12 extra character slots.");
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user