Advertisement
Guest User

Untitled

a guest
Aug 19th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.36 KB | None | 0 0
  1. package server.model.items;
  2.  
  3. import java.io.File;
  4. import java.io.*;
  5. import java.io.FileInputStream;
  6. import java.io.IOException;
  7. import java.util.concurrent.CopyOnWriteArrayList;
  8.  
  9. import server.Config;
  10. import server.Server;
  11.  
  12. public class Item {
  13.  
  14. public static CopyOnWriteArrayList<Integer> stackableItems = new CopyOnWriteArrayList<Integer>();
  15. public static CopyOnWriteArrayList<Integer> notedItems = new CopyOnWriteArrayList<Integer>();
  16.  
  17. public static int[] targetSlots = new int[Config.ITEM_LIMIT];
  18.  
  19. public static int capes[]={8091,8094,9074,9101,9747,9748,9750,9751,9753,9754,9756,9757,9759,9760,9762,9763,9765,9766,9768,9769,9771,9772,9774,9775,9777,9778,9780,9781,9783,9784,9786,9787,9789,9790,9792,9793,9795,9796,9798,9799,9801,9802,9804,9805,9807,9808,9810,9811,9813,9817,9818,9819,9820,9821,9822,9843,9844,9845,9846,9847,9848,9868,9869,9870,9871,9872,9873,9948,9949,10069,10070,10071,10072,10073,10074,10171,10566,10636,10637,10638,10639,10640,10641,10642,10643,10644,10645,10646,10647,10648,10649,10650,10651,10652,10653,10654,10655,10656,10657,10658,10659,10660,10661,10662,10663,10664,10720,7918,7535,3759,3761,3763,3765,3777,3779,3781,3783,3785,3787,3789,4041,4042,4514,4516,6111,6570,6568,1007,1019,1021,1023,1027,1029,1031,1052,2412,2413,2414,4304,4315,4317,4319,4321,4323,4325,4327,4329,4331,4333,4335,4337,4339,4341,4343,4345,4347,4349,4351,4353,4355,4357,4359,4361,4363,4365,4367,4369,4371,4373,4375,4377,4379,4381,4383,4385,4387,4389,4391,4393,4395,4397,4399,4401,4403,4405,4407,4409,4411,4413,4514,4516,6070,6568,6570};
  20.  
  21. public static int boots[]={9005,9006,9073,9100,9921,10552,10607,10689,10696,10724,10839,10865,10933,10958,10959,11728,11729,11732,11733,6666,6790,6377,6367,6357,3393,1837,1846,3105,3107,3700,3791,5064,7159,88,6619,7114,6328,6920,6349,7596,6106,88,89,626,628,630,632,634,1061,1837,1846,2577,2579,2894,2904,2914,2924,2934,3061,3105,3107,3791,4097,4107,4117,4119,4121,4123,4125,4127,4129,4131,4310,5064,5345,5557,6069,6106,6143,6145,6147,6328};
  22.  
  23. public static int gloves[]={10077,10078,10079,10080,10081,10082,10083,10084,10085,10086,10336,10337,8842,9072,9099,9922,10553,10554,10725,11136,11138,11140,7453,7454,7455,7456,7457,7458,7459,7460,7461,7462,6720,6379,6369,6359,6347,1495,1580,6068,3391,6629,6330,6922,7595,2491,1065,2487,2489,3060,1495,775,776,777,778,6708,1059,1063,1065,1580,2487,2489,2491,2902,2912,2922,2932,2942,3060,3799,4095,4105,4115,4308,5556,6068,6110,6149,6151,6153};
  24.  
  25. public static int shields[]={8105,8106,8107,8282,8714,8716,8718,8720,8722,8724,8726,8728,8730,8732,8734,8736,8738,8740,8742,8744,8746,8748,8750,8752,8754,8756,8758,8760,8762,8764,8766,8768,8770,8772,8774,8776,8856,9704,9731,9732,10352,10353,10665,10666,10667,10668,10669,10670,10671,10672,10673,10674,10675,10676,10677,10678,10679,10826,10827,11164,11283,11284,11285,8844,8845,8846,8847,8848,8849,8850,7676,6788,6789,6889,2997,7332,7334,7336,7338,7340,7342,7344,7346,7348,7350,7352,7354,7356,7358,7360,6631,6633,7053,1171,1173,1175,1177,1179,1181,1183,1185,1187,1189,1191,1193,1195,1197,1199,1201,1540,2589,2597,2603,2611,2621,2629,2659,2667,2675,2890,3122,3488,3758,3839,3840,3841,3842,3843,3844,4072,4156,4224,4225,4226,4227,4228,4229,4230,4231,4232,4233,4234,4507,4512,6215,6217,6219,6221,6223,6225,6227,6229,6231,6233,6235,6237,6239,6241,6243,6245,6247,6249,6251,6253,6255,6257,6259,6261,6263,6265,6267,6269,6271,6273,6275,6277,6279,6524};
  26.  
  27. public static int hats[]={8464,8466,8468,8470,8472,8474,8476,8478,8480,8482,8484,8486,8488,8490,8492,8494,8682,8684,8686,8688,8690,8692,8694,8696,8698,8700,8702,8704,8706,8708,8710,8712,8901,8902,8903,8904,8905,8906,8907,8908,8909,8910,8911,8912,8913,8914,8915,8916,8917,8918,8919,8920,8921,8922,9920,9925,10612,10615,10616,10617,10629,10692,10721,10723,10728,11277,11278,11280,11281,11282,8950,8959,8960,8961,8962,8963,8964,8965,9069,9815,10039,10040,10045,10046,10342,10343,10507,10547,10548,10549,10550,10601,10602,10603,10608,10722,10774,10796,10836,10862,10883,10941,4166,7917,4168,1025,1167,1169,7003,4502,6665,1506,6548,6547,7319,7321,7323,7325,7327,6885,6886,6887,2645,2647,2649,7534,7539,3327,3329,3331,3333,3335,3337,3339,3341,3343,74,6621,6623,7394,7396,7112,7124,7130,7136,7594,6856,6858,6860,6862,6326,7400,6656,4856,4857,4858,4859,4880,4881,4882,4883,4904,4905,4906,4907,4928,4929,4930,4931,4952,4953,4954,4955,4976,4977,4978,4979,4732,4753,4611,6188,6182,4511,4056,4071,4724,2639,2641,2643,2665,6109,5525,5527,5529,5531,5533,5535,5537,5539,5541,5543,5545,5547,5549,5551,74,579,656,658,660,662,664,740,1017,1037,1038,1040,1042,1044,1046,1048,1050,1053,1055,1057,1137,1139,1141,1143,1145,1147,1149,1151,1153,1155,1157,1159,1161,1163,1165,1949,2422,2581,2587,2595,2605,2613,2619,2627,2631,2633,2635,2637,2651,2657,2673,2900,2910,2920,2930,2940,2978,2979,2980,2981,2982,2983,2984,2985,2986,2987,2988,2989,2990,2991,2992,2993,2994,2995,3057,3385,3486,3748,3749,3751,3753,3755,3797,4041,4042,4071,4089,4099,4109,4164,4302,4506,4511,4513,4515,4551,4567,4708,4716,4724,4745,4753,4856,4857,4858,4859,4880,4881,4882,4883,4904,4905,4906,4907,4952,4953,4954,4955,4976,4977,4978,4979,5013,5014,5554,5574,6109,6128,6131,6137,6182,6188,6335,6337,6339,6345,6355,6365,6375,6382,6392,6400,6918};
  28.  
  29. public static int amulets[]={9102,10344,10345,10364,10365,10500,10588,10736,1654,6707,6544,5521,4306,3853,3855,3857,3859,3861,3863,3865,3867,2406,1664,1662,1660,1658,1656,1009,774,616,1796,6581,6577,1716,1722,1718,1724,6857,6859,6861,6863,7803,6585,86,87,295,421,552,589,1478,1692,1694,1696,1698,1700,1702,1704,1706,1708,1710,1712,1725,1727,1729,1731,4021,4081,4250,4677,6040,6041,6208};
  30.  
  31. public static int arrows[]={8882,9139,9140,9141,9142,9143,9144,9145,9187,9188,9189,9190,9191,9192,9193,9194,9236,9237,9238,9239,9240,9241,9242,9243,9244,9245,9286,9287,9288,9289,9290,9291,9292,9293,9294,9295,9296,9297,9298,9299,9300,9301,9302,9303,9304,9305,9306,9335,9336,9337,9338,9339,9340,9341,9342,9375,9376,9377,9378,9379,9380,9381,9382,10158,10159,9706,11212,11217,11222,11227,11228,11229,11237,6061,4773,4778,4783,4788,4793,4798,4803,78,598,877,878,879,880,881,882,883,884,885,886,887,888,889,890,891,892,893,942,2532,2533,2534,2535,2536,2537,2538,2539,2540,2541,2866,4160,4172,4173,4174,4175,4740,5616,5617,5618,5619,5620,5621,5622,5623,5624,5625,5626,5627,6061,6062};
  32.  
  33. public static int rings[]={8023,8024,8025,9104,9438,9439,10729,10844,10848,10853,10872,11014,6731,6733,6735,6737,7927,6583,6575,773,1635,1637,1639,1641,1643,1645,2550,2552,2554,2556,2558,2560,2562,2564,2566,2568,2570,2572,4202,4657,6465};
  34.  
  35. public static int body[]={8839,9634,9635,9640,9641,9655,10037,10038,10043,10044,10049,10050,10053,10054,10057,10058,10061,10062,10065,10066,10330,10331,10338,10339,10458,10459,10460,10461,10462,10463,10605,10611,10621,10622,10623,10624,10625,10626,10627,10628,10632,10633,10688,10784,10786,10788,10837,10939,10945,8952,8953,8954,8955,8956,8957,8958,9924,10316,10317,10318,10319,10320,10321,10322,10323,10324,10325,10400,10401,10404,10405,10408,10409,10412,10413,10416,10417,10631,10714,10715,10716,10717,10718,10727,10748,10750,10752,10754,10756,10863,11274,10348,10349,10564,10565,10618,10680,10681,10682,10683,10684,10685,10690,10691,10697,10698,10776,10780,10782,10798,10800,10954,10955,5024,4988,4989,4990,4991,4940,4941,4942,4943,4868,4869,4870,4871,2405,1757,1005,6786,6750,6065,430,75,6371,6361,6351,6341,581,3793,577,546,544,5026,5028,6394,6402,426,5030,5032,5034,3767,3769,3771,3773,3775,6617,6615,7134,7110,7122,7128,1131,1133,1135,1129,6322,7362,7364,2896,2906,2916,2926,2936,1844,636,638,640,642,644,7592,6129,4298,1135,2499,2501,6654,7374,7376,7370,7372,6139,2503,7399,7390,7392,5575,6916,1035,540,5553,4757,1833,6388,6384,2501,2499,1355,4111,4101,4091,6186,6184,6180,3058,4509,4504,4069,4728,4736,4712,6107,2661,3140,1101,1103,1105,1107,1109,1111,1113,1115,1117,1119,1121,1123,1125,1127,1129,1131,1133,1135,2499,2501,2583,2591,2599,2607,2615,2623,2653,2669,3387,3481,4712,4720,4728,4749,4892,4893,4894,4895,4916,4917,4918,4919,4964,4965,4966,4967,6107,6133,6322};
  36.  
  37. public static int legs[]={9071,9098,9551,9552,9636,9637,10035,10036,10041,10042,10047,10048,10055,10056,10059,10060,10063,10064,10067,10068,10332,10333,10346,10347,10402,10403,10406,10407,10410,10411,10414,10415,10418,10419,10422,10423,10426,10427,10430,10431,10434,10435,10438,10439,10464,10465,10466,10467,10468,10469,10555,10824,10825,10940,10963,11018,11022,11722,11723,5042,5044,5046,5040,5038,5036,6787,6752,6067,6353,6363,6373,6343,548,428,542,6625,6627,7116,7126,7132,7138,1095,1097,1099,6324,7366,7368,2898,2908,2918,2928,2938,1845,646,648,650,652,654,7593,4300,1835,538,6655,1033,6141,6135,7382,7384,7378,7380,5555,7386,7388,7398,4759,6386,6390,2497,2495,2493,1099,4113,4103,4093,6924,6187,6185,6181,3059,4510,4505,4070,6108,538,542,548,1011,1013,1015,1067,1069,1071,1073,1075,1077,1079,1081,1083,1085,1087,1089,1091,1093,2585,2593,2601,2609,2617,2625,2655,2663,2671,3059,3389,3472,3473,3474,3475,3476,3477,3478,3479,3480,3483,3485,3795,4087,4585,4712,4714,4722,4730,4738,4751,4759,4874,4875,4876,4877,4898,4899,4900,4901,4922,4923,4924,4925,4946,4947,4948,4949,4970,4971,4972,4973,4994,4995,4996,4997,5048,5050,5052,5576,6107,6130,6187,6390,6386,6390,6396,6404,6809};
  38.  
  39. public static int platebody[]={8839,9634,9635,9640,9641,9655,10037,10038,10043,10044,10049,10050,10053,10054,10057,10058,10061,10062,10065,10066,10330,10331,10338,10339,10458,10459,10460,10461,10462,10463,10605,10611,10621,10622,10623,10624,10625,10626,10627,10628,10632,10633,10688,10784,10786,10788,10837,10939,10945,8952,8953,8954,8955,8956,8957,8958,9924,10316,10317,10318,10319,10320,10321,10322,10323,10324,10325,10400,10401,10404,10405,10408,10409,10412,10413,10416,10417,10631,10714,10715,10716,10717,10718,10727,10748,10750,10752,10754,10756,10863,11274,10348,10349,10618,10690,10691,10697,10698,10776,10780,10782,10798,10800,6065,5028,5026,5024,2405,6786,6750,75,6371,6361,6351,6341,3793,577,581,546,544,426,3767,3769,3771,3773,3775,6617,6322,2896,2906,2916,2926,2936,1844,636,638,640,642,644,5575,6129,6139,6133,4298,7399,6916,7390,7392,5032,5034,5030,1035,540,5553,4757,1833,1835,6388,6384,1355,4111,4101,4868,4869,4870,4871,4892,4893,4894,4895,4916,4917,4918,4919,4940,4941,4942,4943,4964,4965,4966,4967,4988,4989,4990,4991,4091,6186,6184,6180,3058,4509,4504,4069,4728,4736,4712,6107,2661,3140,1115,1117,1119,1121,1123,1125,1127,2583,2591,2599,2607,2615,2623,2653,2669,3481,4720,4728,4749,2661};
  40.  
  41. public static int fullHelm[]={8464,8466,8468,8470,8472,8474,8476,8478,8480,8482,8484,8486,8488,8490,8492,8494,8682,8684,8686,8688,8690,8692,8694,8696,8698,8700,8702,8704,8706,8708,8710,8712,8464,8466,8468,8470,8472,8474,8476,8478,8480,8482,8484,8486,8488,8490,8492,8494,8682,8684,8686,8688,8690,8692,8694,8696,8698,8700,8702,8704,8706,8708,8710,8712,9068,9096,9629,9630,9729,9730,9733,9734,10286,10287,10288,10289,10290,10291,10292,10293,10294,10295,10296,10297,10298,10299,10300,10301,10302,10303,10304,10305,10306,10307,10308,10309,10310,10311,10312,10313,10314,10315,10350,10351,10589,10590,10604,10606,10609,10613,10614,10699,10700,10701,10702,10703,10704,10705,10706,10707,10708,10709,10710,10711,10712,10713,11199,11200,11201,11335,11336,11663,11664,11665,11674,11675,11676,11678,11718,11719,
  42. 9749,9752,9755,9758,9761,9764,9767,9770,9773,9776,9779,9782,9785,9788,9791,9794,9797,9800,9803,9806,9809,4976,4977,4978,4979,4952,4953,4954,4955,4928,4929,4930,4931,4904,4905,4906,4907,4880,4881,4882,4883,4856,4857,4858,4859,4856,4567,4515,4513,4302,74,3748,6137,6131,6128,6621,1151,1143,1145,1147,1141,1137,1139,1149,4753,4708,4716,4745,7003,7534,4551,4745,6623,5574,7112,7124,7130,7136,7594,6326,4732,4753,6188,4511,4506,4071,4724,6109,2665,1153,1155,1157,1159,1161,1163,1165,2587,2595,2605,2613,2619,2627,2657,2673,3486,6402,6394};
  43.  
  44. public static int fullMask[]={1167,1169,1506,6326,4732,4708,4724,4716,4732,5554,4611,6188,3507,4511,4056,4071,4724,2665,6109,1053,1055,1057};
  45.  
  46. private static String[] fullbody = {"top","shirt","platebody","Ahrims robetop","Karils leathertop","brassard","Robe top","robetop","platebody (t)","platebody (g)","chestplate","torso", "hauberk", "Dragon chainbody"};
  47.  
  48. private static String[] fullhat = {"med helm","coif","Dharok's helm","hood","Initiate helm","Coif","Helm of neitiznot","Armadyl helmet","Berserker helm", "Archer helm", "Farseer helm", "Warrior helm", "Void"};
  49.  
  50. private static String[] fullmask = {"full helm","mask","Verac's helm","Guthan's helm","Karil's coif","mask","Torag's helm", "Void", "sallet"};
  51.  
  52. public static boolean isStackable(int id) {
  53. return stackableItems.contains(id);
  54. }
  55.  
  56. public static boolean itemIsNote(int id) {
  57. return notedItems.contains(id);
  58. }
  59.  
  60. public static int getTargetSlot(int id) {
  61. return targetSlots[id];
  62. }
  63.  
  64. public static boolean isFullBody(int itemId) {
  65. String weapon = ItemNamesFixed(itemId);
  66. if (weapon == null)
  67. return false;
  68. if (weapon.endsWith("platebody") || weapon.endsWith("top") || weapon.endsWith("chainbody"))
  69. return true;
  70. for (int i = 0; i < fullbody.length; i++) {
  71. if (weapon.endsWith(fullbody[i])) {
  72. return true;
  73. }
  74. }
  75. return false;
  76. }
  77.  
  78. public static boolean isFullHelm(int itemId) {
  79. String weapon = ItemNamesFixed(itemId);
  80. if (weapon == null)
  81. return false;
  82. if ((weapon.startsWith("Helm") || weapon.endsWith("coif") || weapon.endsWith("mask") || weapon.endsWith("hood") || weapon.endsWith("helm") || weapon.endsWith("helmet")) && !weapon.endsWith("full helm"))
  83. return true;
  84. for (int i = 0; i < fullhat.length; i++) {
  85. if (weapon.endsWith(fullhat[i])) {
  86. return true;
  87. }
  88. }
  89. return false;
  90. }
  91.  
  92. public static boolean isFullMask(int itemId) {
  93. String weapon = ItemNamesFixed(itemId);
  94. if (weapon == null)
  95. return false;
  96. if (weapon.endsWith("full helm"))
  97. return true;
  98. for (int i = 0; i < fullmask.length; i++) {
  99. if (weapon.endsWith(fullmask[i])) {
  100. return true;
  101. }
  102. }
  103. return false;
  104. }
  105.  
  106. public static String getItemName(int id) {
  107. for (int j = 0; j < Server.itemHandler.ItemList.length; j++) {
  108. if (Server.itemHandler.ItemList[j] != null)
  109. if (Server.itemHandler.ItemList[j].itemId == id)
  110. return Server.itemHandler.ItemList[j].itemName;
  111. }
  112. return null;
  113. }
  114.  
  115. public static void load() {
  116. int counter = 0;
  117. int c;
  118.  
  119. try {
  120. FileInputStream dataIn = new FileInputStream(new File("./Data/data/stackable.dat"));
  121. while ((c = dataIn.read()) != -1) {
  122. if (c == 0) {
  123. //itemStackable[counter] = false;
  124. } else {
  125. //itemStackable[counter] = true;
  126. stackableItems.add(counter);
  127. }
  128. counter++;
  129. }
  130. //itemStackable[892] = true;
  131. stackableItems.add(892);
  132. dataIn.close();
  133. } catch (IOException e) {
  134. System.out.println("Critical error while loading stackabledata! Trace:");
  135. e.printStackTrace();
  136. }
  137.  
  138. counter = 0;
  139.  
  140. try {
  141. FileInputStream dataIn = new FileInputStream(new File("./Data/data/notes.dat"));
  142. while ((c = dataIn.read()) != -1) {
  143. if (c == 0) {
  144. notedItems.add(counter);
  145. }
  146. counter++;
  147. }
  148. notedItems.add(15273);
  149. dataIn.close();
  150. } catch (IOException e) {
  151. System.out.println("Critical error while loading notedata! Trace:");
  152. e.printStackTrace();
  153. }
  154.  
  155.  
  156. counter = 0;
  157. try {
  158. FileInputStream dataIn = new FileInputStream(new File("./Data/data/equipment.dat"));
  159. while ((c = dataIn.read()) != -1) {
  160. targetSlots[counter++] = c;
  161. }
  162. dataIn.close();
  163. } catch (IOException e) {
  164. System.out.println("Critical error while loading notedata! Trace:");
  165. e.printStackTrace();
  166. }
  167. }
  168. public static String ItemNames(int id) {
  169. if(allItemNames == null)
  170. setName();
  171. if(id > 0 && id < 23000)
  172. return allItemNames[id];
  173. return "";
  174. }
  175. public static String ItemNamesFixed(int id) {
  176. if(allItemNames == null)
  177. setName();
  178. if(id > 0 && id < 23000)
  179. {
  180. String name = allItemNames[id];
  181. if(name.endsWith(")"))
  182. {
  183. name = name.substring(0, name.indexOf("("));
  184. if(name.endsWith(" "))
  185. name = name.substring(0, name.length()-1);
  186. }
  187. return name;
  188. }
  189. return "";
  190. }
  191. public static String[] allItemNames;
  192. public static void setName(){
  193. try {
  194. allItemNames = new String[23000];
  195. System.out.println("loading item names..");
  196. BufferedReader in = new BufferedReader(new FileReader("./Data/data/items.txt"));
  197. String name;
  198. int itemID = 0;
  199. while ((name = in.readLine()) != null)
  200. allItemNames[itemID++] = name;
  201.  
  202. } catch (IOException e)
  203. {
  204. e.printStackTrace();
  205. }
  206. }
  207. }c
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement