Let PacketCreator create Packet - initial test
This commit is contained in:
@@ -38,6 +38,7 @@ import constants.game.ExpTable;
|
||||
import constants.game.GameConstants;
|
||||
import constants.inventory.ItemConstants;
|
||||
import constants.skills.*;
|
||||
import net.packet.Packet;
|
||||
import net.server.PlayerBuffValueHolder;
|
||||
import net.server.PlayerCoolDownValueHolder;
|
||||
import net.server.Server;
|
||||
@@ -10048,10 +10049,15 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
announce(PacketCreator.updatePlayerStats(Collections.singletonList(new Pair<>(stat, Integer.valueOf(newval))), itemReaction, this));
|
||||
}
|
||||
|
||||
@Deprecated(forRemoval = true)
|
||||
public void announce(final byte[] packet) {
|
||||
client.announce(packet);
|
||||
}
|
||||
|
||||
public void sendPacket(Packet packet) {
|
||||
client.sendPacket(packet);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getObjectId() {
|
||||
return getId();
|
||||
|
||||
@@ -427,7 +427,7 @@ public final class PlayerLoggedinHandler extends AbstractMaplePacketHandler {
|
||||
npcsIds.put(YamlConfig.config.server.REBIRTH_NPC_ID, "Rebirth");
|
||||
}
|
||||
|
||||
c.announce(PacketCreator.setNPCScriptable(npcsIds));
|
||||
c.sendPacket(PacketCreator.setNPCScriptable(npcsIds));
|
||||
}
|
||||
|
||||
if (newcomer) player.setLoginTime(System.currentTimeMillis());
|
||||
|
||||
@@ -3314,10 +3314,10 @@ public class MapleMap {
|
||||
}
|
||||
|
||||
// not really costly to keep generating imo
|
||||
public void sendNightEffect(MapleCharacter mc) {
|
||||
public void sendNightEffect(MapleCharacter chr) {
|
||||
for (Entry<Integer, Integer> types : backgroundTypes.entrySet()) {
|
||||
if (types.getValue() >= 3) { // 3 is a special number
|
||||
mc.announce(PacketCreator.changeBackgroundEffect(true, types.getKey(), 0));
|
||||
chr.sendPacket(PacketCreator.changeBackgroundEffect(true, types.getKey(), 0));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,6 +38,8 @@ import constants.skills.Corsair;
|
||||
import constants.skills.ThunderBreaker;
|
||||
import net.encryption.InitializationVector;
|
||||
import net.opcodes.SendOpcode;
|
||||
import net.packet.OutPacket;
|
||||
import net.packet.Packet;
|
||||
import net.server.PlayerCoolDownValueHolder;
|
||||
import net.server.Server;
|
||||
import net.server.channel.Channel;
|
||||
@@ -8337,14 +8339,13 @@ public class PacketCreator {
|
||||
* @param transition the time it takes to transition the effect.
|
||||
* @return a packet to change the background effect of a specified layer.
|
||||
*/
|
||||
public static byte[] changeBackgroundEffect(boolean remove, int layer, int transition) {
|
||||
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.SET_BACK_EFFECT.getValue());
|
||||
mplew.writeBool(remove);
|
||||
mplew.writeInt(0); // not sure what this int32 does yet
|
||||
mplew.write(layer);
|
||||
mplew.writeInt(transition);
|
||||
return mplew.getPacket();
|
||||
public static Packet changeBackgroundEffect(boolean remove, int layer, int transition) {
|
||||
OutPacket p = OutPacket.create(SendOpcode.SET_BACK_EFFECT);
|
||||
p.writeBool(remove);
|
||||
p.writeInt(0); // not sure what this int32 does yet
|
||||
p.writeByte(layer);
|
||||
p.writeInt(transition);
|
||||
return p;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -8354,18 +8355,17 @@ public class PacketCreator {
|
||||
* @param scriptableNpcIds Ids of npcs to enable scripts for.
|
||||
* @return a packet which makes the npc's provided scriptable.
|
||||
*/
|
||||
public static byte[] setNPCScriptable(Map<Integer, String> scriptableNpcIds) { // thanks to GabrielSin
|
||||
MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
|
||||
mplew.writeShort(SendOpcode.SET_NPC_SCRIPTABLE.getValue());
|
||||
mplew.write(scriptableNpcIds.size());
|
||||
public static Packet setNPCScriptable(Map<Integer, String> scriptableNpcIds) { // thanks to GabrielSin
|
||||
OutPacket p = OutPacket.create(SendOpcode.SET_NPC_SCRIPTABLE);
|
||||
p.writeByte(scriptableNpcIds.size());
|
||||
scriptableNpcIds.forEach((id, name) -> {
|
||||
mplew.writeInt(id);
|
||||
p.writeInt(id);
|
||||
// The client needs a name for the npc conversation, which is displayed under etc when the npc has a quest available.
|
||||
mplew.writeMapleAsciiString(name);
|
||||
mplew.writeInt(0); // start time
|
||||
mplew.writeInt(Integer.MAX_VALUE); // end time
|
||||
p.writeString(name);
|
||||
p.writeInt(0); // start time
|
||||
p.writeInt(Integer.MAX_VALUE); // end time
|
||||
});
|
||||
return mplew.getPacket();
|
||||
return p;
|
||||
}
|
||||
|
||||
private static byte[] MassacreResult(byte nRank, int nIncExp) {
|
||||
|
||||
Reference in New Issue
Block a user