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:
@@ -532,8 +532,8 @@ public class Equip extends Item {
|
||||
showLevelupMessage(showStr, c); // thanks to Polaris dev team !
|
||||
c.getPlayer().dropMessage(6, lvupStr);
|
||||
|
||||
c.announce(PacketCreator.showEquipmentLevelUp());
|
||||
c.getPlayer().getMap().broadcastMessage(c.getPlayer(), PacketCreator.showForeignEffect(c.getPlayer().getId(), 15));
|
||||
c.sendPacket(PacketCreator.showEquipmentLevelUp());
|
||||
c.getPlayer().getMap().broadcastPacket(c.getPlayer(), PacketCreator.showForeignEffect(c.getPlayer().getId(), 15));
|
||||
c.getPlayer().forceUpdateItem(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ public class MaplePet extends Item {
|
||||
closeness = newCloseness;
|
||||
while(newCloseness >= ExpTable.getClosenessNeededForLevel(level)) {
|
||||
level += 1;
|
||||
owner.getClient().announce(PacketCreator.showOwnPetLevelUp(slot));
|
||||
owner.sendPacket(PacketCreator.showOwnPetLevelUp(slot));
|
||||
owner.getMap().broadcastMessage(PacketCreator.showPetLevelUp(owner, slot));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ public class MapleInventoryManipulator {
|
||||
quantity -= (newQ - oldQ);
|
||||
eItem.setQuantity(newQ);
|
||||
eItem.setExpiration(expiration);
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(1, eItem))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(1, eItem))));
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -109,17 +109,17 @@ public class MapleInventoryManipulator {
|
||||
nItem.setExpiration(expiration);
|
||||
short newSlot = inv.addItem(nItem);
|
||||
if (newSlot == -1) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return false;
|
||||
}
|
||||
if (owner != null) {
|
||||
nItem.setOwner(owner);
|
||||
}
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
if(sandboxItem) chr.setHasSandboxItem();
|
||||
} else {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -129,11 +129,11 @@ public class MapleInventoryManipulator {
|
||||
nItem.setExpiration(expiration);
|
||||
short newSlot = inv.addItem(nItem);
|
||||
if (newSlot == -1) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return false;
|
||||
}
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
if(MapleInventoryManipulator.isSandboxItem(nItem)) chr.setHasSandboxItem();
|
||||
}
|
||||
} else if (quantity == 1) {
|
||||
@@ -145,11 +145,11 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
short newSlot = inv.addItem(nEquip);
|
||||
if (newSlot == -1) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return false;
|
||||
}
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nEquip))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nEquip))));
|
||||
if(MapleInventoryManipulator.isSandboxItem(nEquip)) chr.setHasSandboxItem();
|
||||
} else {
|
||||
throw new RuntimeException("Trying to create equip with non-one quantity");
|
||||
@@ -182,8 +182,8 @@ public class MapleInventoryManipulator {
|
||||
MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
|
||||
int itemid = item.getItemId();
|
||||
if (ii.isPickupRestricted(itemid) && chr.haveItemWithId(itemid, true)) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.showItemUnavailable());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.showItemUnavailable());
|
||||
return false;
|
||||
}
|
||||
short quantity = item.getQuantity();
|
||||
@@ -203,7 +203,7 @@ public class MapleInventoryManipulator {
|
||||
quantity -= (newQ - oldQ);
|
||||
eItem.setQuantity(newQ);
|
||||
item.setPosition(eItem.getPosition());
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(1, eItem))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(1, eItem))));
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
@@ -219,14 +219,14 @@ public class MapleInventoryManipulator {
|
||||
nItem.setFlag(item.getFlag());
|
||||
short newSlot = inv.addItem(nItem);
|
||||
if (newSlot == -1) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
item.setQuantity((short) (quantity + newQ));
|
||||
return false;
|
||||
}
|
||||
nItem.setPosition(newSlot);
|
||||
item.setPosition(newSlot);
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
if (MapleInventoryManipulator.isSandboxItem(nItem)) chr.setHasSandboxItem();
|
||||
}
|
||||
} else {
|
||||
@@ -236,34 +236,34 @@ public class MapleInventoryManipulator {
|
||||
|
||||
short newSlot = inv.addItem(nItem);
|
||||
if (newSlot == -1) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return false;
|
||||
}
|
||||
nItem.setPosition(newSlot);
|
||||
item.setPosition(newSlot);
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, nItem))));
|
||||
if (MapleInventoryManipulator.isSandboxItem(nItem)) chr.setHasSandboxItem();
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
}
|
||||
} else if (quantity == 1) {
|
||||
short newSlot = inv.addItem(item);
|
||||
if (newSlot == -1) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return false;
|
||||
}
|
||||
item.setPosition(newSlot);
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, item))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(0, item))));
|
||||
if (MapleInventoryManipulator.isSandboxItem(item)) chr.setHasSandboxItem();
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.ITEM, "Tried to pickup Equip id " + itemid + " containing more than 1 quantity --> " + quantity);
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.showItemUnavailable());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.showItemUnavailable());
|
||||
return false;
|
||||
}
|
||||
if (show) {
|
||||
c.announce(PacketCreator.getShowItemGain(itemid, item.getQuantity()));
|
||||
c.sendPacket(PacketCreator.getShowItemGain(itemid, item.getQuantity()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -429,9 +429,9 @@ public class MapleInventoryManipulator {
|
||||
|
||||
private static void announceModifyInventory(MapleClient c, Item item, boolean fromDrop, boolean allowZero) {
|
||||
if (item.getQuantity() == 0 && !allowZero) {
|
||||
c.announce(PacketCreator.modifyInventory(fromDrop, Collections.singletonList(new ModifyInventory(3, item))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(fromDrop, Collections.singletonList(new ModifyInventory(3, item))));
|
||||
} else {
|
||||
c.announce(PacketCreator.modifyInventory(fromDrop, Collections.singletonList(new ModifyInventory(1, item))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(fromDrop, Collections.singletonList(new ModifyInventory(1, item))));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -498,7 +498,7 @@ public class MapleInventoryManipulator {
|
||||
} else {
|
||||
mods.add(new ModifyInventory(2, source, src));
|
||||
}
|
||||
c.announce(PacketCreator.modifyInventory(true, mods));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, mods));
|
||||
}
|
||||
|
||||
public static void equip(MapleClient c, short src, short dst) {
|
||||
@@ -510,7 +510,7 @@ public class MapleInventoryManipulator {
|
||||
|
||||
Equip source = (Equip) eqpInv.getItem(src);
|
||||
if (source == null || !ii.canWearEquipment(chr, source, dst)) {
|
||||
c.announce(PacketCreator.enableActions());
|
||||
c.sendPacket(PacketCreator.enableActions());
|
||||
return;
|
||||
} else if ((((source.getItemId() >= 1902000 && source.getItemId() <= 1902002) || source.getItemId() == 1912000) && chr.isCygnus()) || ((source.getItemId() >= 1902005 && source.getItemId() <= 1902007) || source.getItemId() == 1912005) && !chr.isCygnus()) {// Adventurer taming equipment
|
||||
return;
|
||||
@@ -527,8 +527,8 @@ public class MapleInventoryManipulator {
|
||||
Item top = eqpdInv.getItem((short) -5);
|
||||
if (top != null && ItemConstants.isOverall(top.getItemId())) {
|
||||
if (eqpInv.isFull()) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return;
|
||||
}
|
||||
unequip(c, (byte) -5, eqpInv.getNextFreeSlot());
|
||||
@@ -537,8 +537,8 @@ public class MapleInventoryManipulator {
|
||||
final Item bottom = eqpdInv.getItem((short) -6);
|
||||
if (bottom != null && ItemConstants.isOverall(source.getItemId())) {
|
||||
if (eqpInv.isFull()) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return;
|
||||
}
|
||||
unequip(c, (byte) -6, eqpInv.getNextFreeSlot());
|
||||
@@ -547,8 +547,8 @@ public class MapleInventoryManipulator {
|
||||
Item weapon = eqpdInv.getItem((short) -11);
|
||||
if (weapon != null && ii.isTwoHanded(weapon.getItemId())) {
|
||||
if (eqpInv.isFull()) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return;
|
||||
}
|
||||
unequip(c, (byte) -11, eqpInv.getNextFreeSlot());
|
||||
@@ -557,8 +557,8 @@ public class MapleInventoryManipulator {
|
||||
Item shield = eqpdInv.getItem((short) -10);
|
||||
if (shield != null && ii.isTwoHanded(source.getItemId())) {
|
||||
if (eqpInv.isFull()) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.announce(PacketCreator.getShowInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getShowInventoryFull());
|
||||
return;
|
||||
}
|
||||
unequip(c, (byte) -10, eqpInv.getNextFreeSlot());
|
||||
@@ -614,7 +614,7 @@ public class MapleInventoryManipulator {
|
||||
}
|
||||
|
||||
mods.add(new ModifyInventory(2, source, src));
|
||||
c.announce(PacketCreator.modifyInventory(true, mods));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, mods));
|
||||
chr.equipChanged();
|
||||
}
|
||||
|
||||
@@ -632,7 +632,7 @@ public class MapleInventoryManipulator {
|
||||
return;
|
||||
}
|
||||
if (target != null && src <= 0) {
|
||||
c.announce(PacketCreator.getInventoryFull());
|
||||
c.sendPacket(PacketCreator.getInventoryFull());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -656,7 +656,7 @@ public class MapleInventoryManipulator {
|
||||
target.setPosition(src);
|
||||
eqpdInv.addItemFromDB(target);
|
||||
}
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(2, source, src))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(2, source, src))));
|
||||
chr.equipChanged();
|
||||
}
|
||||
|
||||
@@ -712,7 +712,7 @@ public class MapleInventoryManipulator {
|
||||
Item target = source.copy();
|
||||
target.setQuantity(quantity);
|
||||
source.setQuantity((short) (source.getQuantity() - quantity));
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(1, source))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(1, source))));
|
||||
|
||||
if (ItemConstants.isNewYearCardEtc(itemId)) {
|
||||
if(itemId == 4300000) {
|
||||
@@ -742,7 +742,7 @@ public class MapleInventoryManipulator {
|
||||
inv.removeSlot(src);
|
||||
}
|
||||
|
||||
c.announce(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(3, source))));
|
||||
c.sendPacket(PacketCreator.modifyInventory(true, Collections.singletonList(new ModifyInventory(3, source))));
|
||||
if (src < 0) {
|
||||
chr.equipChanged();
|
||||
} else if (ItemConstants.isNewYearCardEtc(itemId)) {
|
||||
|
||||
Reference in New Issue
Block a user