Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1. public class TKBulletinPost extends TKBulletin {
  2.  
  3.     public int postID = 0x00;
  4.     public String poster = "";
  5.     public int month = 0;
  6.     public int year = 0;
  7.     public String subject = "";
  8.     public String text = "";
  9.    
  10.     public LinkedList<TKBulletinSubject> boards = new LinkedList<TKBulletinSubject>();
  11.    
  12.     public TKBulletinPost(TKMain main, int postID, String poster, int month, int year, String subject, String text) {
  13.         super(main);
  14.         this.postID = postID;
  15.         this.poster = poster;
  16.         this.month = month;
  17.         this.year = year;
  18.         this.subject = subject;
  19.         this.text = text;
  20.     }
  21.  
  22.    
  23.    
  24.     public byte[] getData() {
  25.         try {
  26.         ByteArrayOutputStream bout = new ByteArrayOutputStream();
  27.         bout.write(0x03);
  28.         bout.write(0x03);
  29.         bout.write(0x0);
  30.         ByteBuffer bb = ByteBuffer.allocate(2);
  31.         bb.putShort((short)postID);
  32.         bout.write(bb.array());
  33.         bout.write(poster.length());
  34.         bout.write(poster.getBytes());
  35.         bout.write(month);
  36.         bout.write(year);
  37.         bout.write(subject.length());
  38.         bout.write(subject.getBytes());
  39.         bb.clear();
  40.         bb.putShort((short)text.length());
  41.         bout.write(bb.array());
  42.         bout.write(text.getBytes());
  43.         bout.flush();
  44.         //main.log(3,"data: " + TKPacket.toHexString(bout.toByteArray()));
  45.         return bout.toByteArray();
  46.         } catch(Exception ex) {
  47.             main.log(3, "Error creating BB packet", ex);
  48.             return null;
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement