Welcome! Here you can paste sources and general debugging text, You can even set yourself a password if you want to keep it just for yourself.

Posted by loadequipsjava on January Thu 26th 10:49 PM - Expires on February Sun 26th 10:49 PM
View followups from Anonymous | Download | New paste

  1. package com.rs2hd.content;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileReader;
  5. import com.rs2hd.util.log.Logger;
  6.  
  7. /**
  8.  * Item Definition class
  9.  * @author Graham
  10.  *
  11.  */
  12. public class LoadEquips {
  13.  
  14. private int [] EquipsIds = new int[16000];
  15.  
  16.  
  17.     public LoadEquips() {
  18. int amt = 0;
  19.         String line = "", token = "", token2 = "", token2_2 = "", token3[] = new String[10];
  20.         BufferedReader list = null;
  21.         try {
  22.             list = new BufferedReader(new FileReader("./data/equip.txt"));
  23.             line = list.readLine().trim();
  24.         } catch (Exception e) {
  25.             Logger.getInstance().info("Error loading item list.");
  26.         }
  27.         while (line != null) {
  28.             int spot = line.indexOf("=");
  29.             if (spot > -1) {
  30.                 token = line.substring(0, spot).trim();
  31.                 token2 = line.substring(spot + 1).trim();
  32.                 token2_2 = token2.replaceAll("\t\t", "\t");
  33.                 token2_2 = token2_2.replaceAll("\t\t", "\t");
  34.                 token2_2 = token2_2.replaceAll("\t\t", "\t");
  35.                 token3 = token2_2.split("\t");
  36.                 if (token.equals("item")) {
  37. amt ++;
  38. int ItemId = Integer.parseInt(token3[0]);
  39. EquipsIds[ItemId] = Integer.parseInt(token3[1]);
  40.                     }             
  41.             } else {
  42.                 if (line.equals("[ENDOFEQUIPLIST]")) {
  43.                     try {
  44. Logger.getInstance().info("Loaded "+ amt + "item prices.");
  45.                         list.close();
  46.                     } catch (Exception exception) {
  47.                     }
  48.                     list = null;
  49.                     return;
  50.                 }
  51.             }
  52.             try {
  53.                 line = list.readLine().trim();
  54.             } catch (Exception exception1) {
  55.                 try {
  56.                     list.close();
  57.                 } catch (Exception exception) {
  58.                 }
  59.                 list = null;
  60.                 return;
  61.             }
  62.         }
  63.     }
  64.  
  65. public int getEquipId(int item) {
  66. return EquipsIds[item];
  67. }
  68.  
  69. }
Language:
To highlight particular lines, prefix each line with @@





© 2012 - Powered by PASTE 1.0