Create packet class for PacketCreator::showNotes

This commit is contained in:
P0nk
2022-12-27 12:10:33 +01:00
parent 2a460de911
commit 65111ae209
4 changed files with 57 additions and 32 deletions

View File

@@ -0,0 +1,30 @@
package net.packet.out;
import model.Note;
import net.opcodes.SendOpcode;
import net.packet.ByteBufOutPacket;
import java.util.List;
import java.util.Objects;
import static tools.PacketCreator.getTime;
public final class ShowNotesPacket extends ByteBufOutPacket {
public ShowNotesPacket(List<Note> notes) {
super(SendOpcode.MEMO_RESULT);
Objects.requireNonNull(notes);
writeByte(3);
writeByte(notes.size());
notes.forEach(this::writeNote);
}
private void writeNote(Note note) {
writeInt(note.id());
writeString(note.from() + " "); //Stupid nexon forgot space lol
writeString(note.message());
writeLong(getTime(note.timestamp()));
writeByte(note.fame());
}
}