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:
P0nk
2021-08-21 01:36:51 +02:00
parent b5cd6887ae
commit 8f6860d7d7
231 changed files with 6403 additions and 6927 deletions

View File

@@ -28,6 +28,7 @@ import constants.game.GameConstants;
import net.AbstractMaplePacketHandler;
import net.server.Server;
import net.server.coordinator.matchchecker.MatchCheckerListenerFactory.MatchCheckerType;
import net.server.guild.GuildPackets;
import net.server.guild.MapleAlliance;
import net.server.guild.MapleGuild;
import net.server.guild.MapleGuildResponse;
@@ -59,7 +60,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
int allianceId = -1;
switch (type) {
case 0x00:
//c.announce(PacketCreator.showGuildInfo(mc));
//c.sendPacket(PacketCreator.showGuildInfo(mc));
break;
case 0x02:
if (mc.getGuildId() > 0) {
@@ -109,7 +110,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
String targetName = slea.readMapleAsciiString();
MapleGuildResponse mgr = MapleGuild.sendInvitation(c, targetName);
if (mgr != null) {
c.announce(mgr.getPacket(targetName));
c.sendPacket(mgr.getPacket(targetName));
} else {} // already sent invitation, do nothing
break;
@@ -140,14 +141,14 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
return;
}
c.announce(PacketCreator.showGuildInfo(mc));
c.sendPacket(GuildPackets.showGuildInfo(mc));
allianceId = mc.getGuild().getAllianceId();
if(allianceId > 0) Server.getInstance().getAlliance(allianceId).updateAlliancePackets(mc);
mc.saveGuildStatus(); // update database
mc.getMap().broadcastMessage(mc, PacketCreator.guildNameChanged(mc.getId(), mc.getGuild().getName())); // thanks Vcoc for pointing out an issue with updating guild tooltip to players in the map
mc.getMap().broadcastMessage(mc, PacketCreator.guildMarkChanged(mc.getId(), mc.getGuild()));
mc.getMap().broadcastPacket(mc, GuildPackets.guildNameChanged(mc.getId(), mc.getGuild().getName())); // thanks Vcoc for pointing out an issue with updating guild tooltip to players in the map
mc.getMap().broadcastPacket(mc, GuildPackets.guildMarkChanged(mc.getId(), mc.getGuild()));
break;
case 0x07:
cid = slea.readInt();
@@ -159,16 +160,16 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
allianceId = mc.getGuild().getAllianceId();
c.announce(PacketCreator.updateGP(mc.getGuildId(), 0));
c.sendPacket(GuildPackets.updateGP(mc.getGuildId(), 0));
Server.getInstance().leaveGuild(mc.getMGC());
c.announce(PacketCreator.showGuildInfo(null));
c.sendPacket(GuildPackets.showGuildInfo(null));
if(allianceId > 0) Server.getInstance().getAlliance(allianceId).updateAlliancePackets(mc);
mc.getMGC().setGuildId(0);
mc.getMGC().setGuildRank(5);
mc.saveGuildStatus();
mc.getMap().broadcastMessage(mc, PacketCreator.guildNameChanged(mc.getId(), ""));
mc.getMap().broadcastPacket(mc, GuildPackets.guildNameChanged(mc.getId(), ""));
break;
case 0x08:
allianceId = mc.getGuild().getAllianceId();
@@ -213,7 +214,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
return;
}
if (mc.getMeso() < YamlConfig.config.server.CHANGE_EMBLEM_COST) {
c.announce(PacketCreator.serverNotice(1, "You do not have " + GameConstants.numberWithCommas(YamlConfig.config.server.CHANGE_EMBLEM_COST) + " mesos to change the Guild emblem."));
c.sendPacket(PacketCreator.serverNotice(1, "You do not have " + GameConstants.numberWithCommas(YamlConfig.config.server.CHANGE_EMBLEM_COST) + " mesos to change the Guild emblem."));
return;
}
short bg = slea.readShort();
@@ -224,7 +225,7 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
if (mc.getGuild() != null && mc.getGuild().getAllianceId() > 0) {
MapleAlliance alliance = mc.getAlliance();
Server.getInstance().allianceMessage(alliance.getId(), PacketCreator.getGuildAlliances(alliance, c.getWorld()), -1, -1);
Server.getInstance().allianceMessage(alliance.getId(), GuildPackets.getGuildAlliances(alliance, c.getWorld()), -1, -1);
}
mc.gainMeso(-YamlConfig.config.server.CHANGE_EMBLEM_COST, true, false, true);