Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. package extremetk.dialog;
  2.  
  3. import java.nio.ByteBuffer;
  4. import java.util.Iterator;
  5. import java.util.LinkedList;
  6.  
  7. import extremetk.TKMain;
  8.  
  9. public abstract class TKDialog {
  10.  
  11.     public int npcGuid = 0;
  12.     protected LinkedList<TKDialogComponent> components = new LinkedList<TKDialogComponent>();
  13.     protected byte dialogType = 0;
  14.    
  15.     protected TKMain main;
  16.    
  17.     public TKDialog(TKMain main) {
  18.         this.main = main;
  19.     }
  20.    
  21.     public byte[] getData() {
  22.         int bufsize = 0;
  23.         bufsize += 7;
  24.         Iterator<TKDialogComponent> it = components.iterator();
  25.         while(it.hasNext()) {
  26.             TKDialogComponent com = it.next();
  27.             bufsize += com.getData().length;
  28.         }
  29.        
  30.         ByteBuffer bb = ByteBuffer.allocate(bufsize);
  31.         bb.put(dialogType);
  32.         bb.put((byte)0x1); //FIXME don't know what this is
  33.         bb.putInt(npcGuid);
  34.         bb.put((byte)0x1); //FIXME don't know what this is
  35.        
  36.         it = components.iterator();
  37.         while(it.hasNext()) {
  38.             TKDialogComponent com = it.next();
  39.             bb.put(com.getData());
  40.         }
  41.         return bb.array();
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement