All packet creating methods now create Packet instead of byte[]
This commit got way too big... - Remove deprecated methods for sending packets - Favor OutPacket & Packet over MaplePacketLittleEndianWriter, LittleEndianWriter, and byte array - Split up some packet creating methods into separate classes
This commit is contained in:
@@ -117,7 +117,7 @@ public class DueyProcessor {
|
||||
ps2.setInt(1, player.getId());
|
||||
ps2.executeUpdate();
|
||||
|
||||
c.announce(PacketCreator.sendDueyParcelReceived(rs.getString("SenderName"), rs.getInt("Type") == 1));
|
||||
c.sendPacket(PacketCreator.sendDueyParcelReceived(rs.getString("SenderName"), rs.getInt("Type") == 1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -305,21 +305,21 @@ public class DueyProcessor {
|
||||
int recipientAccId = accIdCid.getLeft();
|
||||
if (recipientAccId != -1) {
|
||||
if (recipientAccId == c.getAccID()) {
|
||||
c.announce(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SAMEACC_ERROR.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SAMEACC_ERROR.getCode()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NOT_ENOUGH_MESOS.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NOT_ENOUGH_MESOS.getCode()));
|
||||
return;
|
||||
}
|
||||
|
||||
int recipientCid = accIdCid.getRight();
|
||||
if (recipientCid == -1) {
|
||||
c.announce(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_NAME_DOES_NOT_EXIST.getCode()));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -329,18 +329,18 @@ public class DueyProcessor {
|
||||
|
||||
int packageId = createPackage(sendMesos, sendMessage, c.getPlayer().getName(), recipientCid, quick);
|
||||
if (packageId == -1) {
|
||||
c.announce(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_ENABLE_ACTIONS.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_ENABLE_ACTIONS.getCode()));
|
||||
return;
|
||||
}
|
||||
c.getPlayer().gainMeso((int) -finalcost, false);
|
||||
|
||||
int res = addPackageItemFromInventory(packageId, c, invTypeId, itemPos, amount);
|
||||
if (res == 0) {
|
||||
c.announce(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_SUCCESSFULLY_SENT.getCode()));
|
||||
} else if (res > 0) {
|
||||
c.announce(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_ENABLE_ACTIONS.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_ENABLE_ACTIONS.getCode()));
|
||||
} else {
|
||||
c.announce(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_INCORRECT_REQUEST.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(DueyProcessor.Actions.TOCLIENT_SEND_INCORRECT_REQUEST.getCode()));
|
||||
}
|
||||
|
||||
MapleClient rClient = null;
|
||||
@@ -368,7 +368,7 @@ public class DueyProcessor {
|
||||
if (c.tryacquireClient()) {
|
||||
try {
|
||||
removePackageFromDB(packageid);
|
||||
c.announce(PacketCreator.removeItemFromDuey(playerRemove, packageid));
|
||||
c.sendPacket(PacketCreator.removeItemFromDuey(playerRemove, packageid));
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
}
|
||||
@@ -392,29 +392,29 @@ public class DueyProcessor {
|
||||
}
|
||||
|
||||
if (dp == null) {
|
||||
c.announce(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
c.sendPacket(PacketCreator.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);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dp.isDeliveringTime()) {
|
||||
c.announce(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
return;
|
||||
}
|
||||
|
||||
Item dpItem = dp.getItem();
|
||||
if (dpItem != null) {
|
||||
if (!c.getPlayer().canHoldMeso(dp.getMesos())) {
|
||||
c.announce(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_UNKNOWN_ERROR.getCode()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!MapleInventoryManipulator.checkSpace(c, dpItem.getItemId(), dpItem.getQuantity(), dpItem.getOwner())) {
|
||||
int itemid = dpItem.getItemId();
|
||||
if (MapleItemInformationProvider.getInstance().isPickupRestricted(itemid) && c.getPlayer().getInventory(ItemConstants.getInventoryType(itemid)).findById(itemid) != null) {
|
||||
c.announce(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_RECEIVER_WITH_UNIQUE.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_RECEIVER_WITH_UNIQUE.getCode()));
|
||||
} else {
|
||||
c.announce(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_NO_FREE_SLOTS.getCode()));
|
||||
c.sendPacket(PacketCreator.sendDueyMSG(Actions.TOCLIENT_RECV_NO_FREE_SLOTS.getCode()));
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -440,15 +440,15 @@ public class DueyProcessor {
|
||||
try {
|
||||
long timeNow = System.currentTimeMillis();
|
||||
if (timeNow - c.getPlayer().getNpcCooldown() < YamlConfig.config.server.BLOCK_NPC_RACE_CONDT) {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
c.getPlayer().setNpcCooldown(timeNow);
|
||||
|
||||
if (quickDelivery) {
|
||||
c.announce(PacketCreator.sendDuey(0x1A, null));
|
||||
c.sendPacket(PacketCreator.sendDuey(0x1A, null));
|
||||
} else {
|
||||
c.announce(PacketCreator.sendDuey(0x8, loadPackages(c.getPlayer())));
|
||||
c.sendPacket(PacketCreator.sendDuey(0x8, loadPackages(c.getPlayer())));
|
||||
}
|
||||
} finally {
|
||||
c.releaseClient();
|
||||
|
||||
@@ -275,7 +275,7 @@ public class FredrickProcessor {
|
||||
|
||||
byte response = canRetrieveFromFredrick(chr, items);
|
||||
if (response != 0) {
|
||||
chr.announce(PacketCreator.fredrickMessage(response));
|
||||
chr.sendPacket(PacketCreator.fredrickMessage(response));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ public class FredrickProcessor {
|
||||
FilePrinter.print(FilePrinter.FREDRICK + chr.getName() + ".txt", chr.getName() + " gained " + item.getQuantity() + " " + itemName + " (" + item.getItemId() + ")");
|
||||
}
|
||||
|
||||
chr.announce(PacketCreator.fredrickMessage((byte) 0x1E));
|
||||
chr.sendPacket(PacketCreator.fredrickMessage((byte) 0x1E));
|
||||
removeFredrickLog(chr.getId());
|
||||
} else {
|
||||
chr.message("An unknown error has occured.");
|
||||
|
||||
@@ -52,7 +52,7 @@ public class StorageProcessor {
|
||||
|
||||
if (chr.getLevel() < 15){
|
||||
chr.dropMessage(1, "You may only use the storage once you have reached level 15.");
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -71,13 +71,13 @@ public class StorageProcessor {
|
||||
Item item = storage.getItem(slot);
|
||||
if (item != null) {
|
||||
if (ii.isPickupRestricted(item.getItemId()) && chr.haveItemWithId(item.getItemId(), true)) {
|
||||
c.announce(PacketCreator.getStorageError((byte) 0x0C));
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0C));
|
||||
return;
|
||||
}
|
||||
|
||||
int takeoutFee = storage.getTakeOutFee();
|
||||
if (chr.getMeso() < takeoutFee) {
|
||||
c.announce(PacketCreator.getStorageError((byte) 0x0B));
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0B));
|
||||
return;
|
||||
} else {
|
||||
chr.gainMeso(-takeoutFee, false);
|
||||
@@ -95,11 +95,11 @@ public class StorageProcessor {
|
||||
|
||||
storage.sendTakenOut(c, item.getInventoryType());
|
||||
} else {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
c.announce(PacketCreator.getStorageError((byte) 0x0A));
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0A));
|
||||
}
|
||||
}
|
||||
} else if (mode == 5) { // store
|
||||
@@ -115,17 +115,17 @@ public class StorageProcessor {
|
||||
return;
|
||||
}
|
||||
if (quantity < 1) {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
if (storage.isFull()) {
|
||||
c.announce(PacketCreator.getStorageError((byte) 0x11));
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x11));
|
||||
return;
|
||||
}
|
||||
|
||||
int storeFee = storage.getStoreFee();
|
||||
if (chr.getMeso() < storeFee) {
|
||||
c.announce(PacketCreator.getStorageError((byte) 0x0B));
|
||||
c.sendPacket(PacketCreator.getStorageError((byte) 0x0B));
|
||||
} else {
|
||||
Item item;
|
||||
|
||||
@@ -134,7 +134,7 @@ public class StorageProcessor {
|
||||
item = inv.getItem(slot);
|
||||
if (item != null && item.getItemId() == itemId && (item.getQuantity() >= quantity || ItemConstants.isRechargeable(itemId))) {
|
||||
if (ItemConstants.isWeddingRing(itemId) || ItemConstants.isWeddingToken(itemId)) {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public class StorageProcessor {
|
||||
|
||||
MapleInventoryManipulator.removeFromSlot(c, invType, slot, quantity, false);
|
||||
} else {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ public class StorageProcessor {
|
||||
}
|
||||
} else if (mode == 6) { // arrange items
|
||||
if(YamlConfig.config.server.USE_STORAGE_ITEM_SORT) storage.arrangeItems(c);
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
} else if (mode == 7) { // meso
|
||||
int meso = slea.readInt();
|
||||
int storageMesos = storage.getMeso();
|
||||
@@ -177,13 +177,13 @@ public class StorageProcessor {
|
||||
if (meso < 0 && (storageMesos - meso) < 0) {
|
||||
meso = Integer.MIN_VALUE + storageMesos;
|
||||
if (meso < playerMesos) {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (meso > 0 && (playerMesos + meso) < 0) {
|
||||
meso = Integer.MAX_VALUE - playerMesos;
|
||||
if (meso > storageMesos) {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -193,7 +193,7 @@ public class StorageProcessor {
|
||||
FilePrinter.print(FilePrinter.STORAGE + c.getPlayer().getName() + ".txt", c.getPlayer().getName() + (meso > 0 ? " took out " : " stored ") + Math.abs(meso) + " mesos");
|
||||
storage.sendMeso(c);
|
||||
} else {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
}
|
||||
} else if (mode == 8) {// close... unless the player decides to enter cash shop!
|
||||
|
||||
Reference in New Issue
Block a user