Create packet class for PacketCreator::showNotes
This commit is contained in:
30
src/main/java/net/packet/out/ShowNotesPacket.java
Normal file
30
src/main/java/net/packet/out/ShowNotesPacket.java
Normal 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());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user