Guest User

Untitled

a guest
Jul 23rd, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. package com.rs31se7en.server.cache.loaders;
  2.  
  3. import java.io.IOException;
  4. import java.nio.ByteBuffer;
  5. import java.util.Arrays;
  6.  
  7. import com.rs31se7en.server.cache.Archive;
  8. import com.rs31se7en.server.cache.Cache;
  9.  
  10. public class ChatSensorLoader {
  11.  
  12. private Cache cache;
  13. private Archive sensorsArchive = null;
  14. private ByteBuffer badWordsBuffer = null;
  15. private String[] badwords = null;
  16.  
  17. public ChatSensorLoader(Cache cache) throws Exception {
  18. this.cache = cache;
  19. sensorsArchive = new Archive(cache.getFile(0, 7));
  20. badWordsBuffer = sensorsArchive.getFileAsByteBuffer("badenc.txt");
  21. }
  22.  
  23. public void loadBadWords() throws IOException {
  24. badwords = new String[badWordsBuffer.getInt()];
  25. System.out.println("Loading bad words. ");
  26.  
  27. for (int wordIndex = 0; wordIndex < badwords.length; wordIndex++) {
  28. int wordLength = badWordsBuffer.get();
  29. char[] chars = new char[wordLength];
  30. for (int letter=0; letter<wordLength; letter++)
  31. chars[letter] = (char)(badWordsBuffer.get());
  32. badwords[wordIndex] = new String(chars);
  33. /*
  34. * TODO: Identify this
  35. */
  36. int len = badWordsBuffer.get();
  37. for (int i = 0; i < len; i++) {
  38. badWordsBuffer.get();
  39. badWordsBuffer.get();
  40. }
  41.  
  42. }
  43.  
  44. System.out.println("Loaded "+badwords.length+" bad words.");
  45. }
  46.  
  47. }
Add Comment
Please, Sign In to add comment