Advertisement
Guest User

Untitled

a guest
Dec 17th, 2018
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.27 KB | None | 0 0
  1. package com.mayhem.rs2.content.io;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.BufferedWriter;
  5. import java.io.File;
  6. import java.io.FileNotFoundException;
  7. import java.io.FileReader;
  8. import java.io.FileWriter;
  9. import java.io.IOException;
  10. import java.util.ArrayList;
  11. import java.util.Arrays;
  12. import java.util.HashMap;
  13. import java.util.List;
  14. import java.util.Set;
  15. import java.util.concurrent.TimeUnit;
  16.  
  17. import com.google.gson.Gson;
  18. import com.google.gson.GsonBuilder;
  19. import com.mayhem.core.util.GameDefinitionLoader;
  20. import com.mayhem.core.util.NameUtil;
  21. import com.mayhem.core.util.Utility;
  22. import com.mayhem.rs2.content.EloRatingSystem;
  23. import com.mayhem.rs2.content.PlayerProperties;
  24. import com.mayhem.rs2.content.PlayerTitle;
  25. import com.mayhem.rs2.content.achievements.AchievementList;
  26. import com.mayhem.rs2.content.bank.Bank;
  27. import com.mayhem.rs2.content.dialogue.DialogueManager;
  28. import com.mayhem.rs2.content.membership.CreditPurchase;
  29. import com.mayhem.rs2.content.quest.QuestManager.Quests;
  30. import com.mayhem.rs2.content.skill.magic.weapons.TridentOfTheSeas;
  31. import com.mayhem.rs2.content.skill.magic.weapons.TridentOfTheSwamp;
  32. import com.mayhem.rs2.content.skill.melee.SerpentineHelmet;
  33. import com.mayhem.rs2.content.skill.ranged.ToxicBlowpipe;
  34. import com.mayhem.rs2.content.skill.slayer.Slayer;
  35. import com.mayhem.rs2.entity.Location;
  36. import com.mayhem.rs2.entity.Entity.AttackType;
  37. import com.mayhem.rs2.entity.item.Equipment;
  38. import com.mayhem.rs2.entity.item.Item;
  39. import com.mayhem.rs2.entity.item.ItemDegrading;
  40. import com.mayhem.rs2.entity.player.Player;
  41.  
  42. public final class PlayerSave {
  43.  
  44. public static final class PlayerFarming {
  45.  
  46. public static boolean loadDetails(Player player) throws Exception {
  47. File file = new File("./data/characters/farming/" + player.getUsername() + ".json");
  48.  
  49. if (!file.exists()) {
  50. return false;
  51. }
  52.  
  53. BufferedReader reader = new BufferedReader(new FileReader(file));
  54. try {
  55. PlayerFarming details = PlayerSave.GSON.fromJson(reader, PlayerFarming.class);
  56.  
  57. long millis = System.currentTimeMillis();
  58.  
  59. if (details.lastFarmingTimer > 0) {
  60. player.getFarming().setFarmingTimer(details.farmingTimer + TimeUnit.MILLISECONDS.toMinutes(millis - details.lastFarmingTimer));
  61. } else {
  62. player.getFarming().setFarmingTimer(details.farmingTimer);
  63. }
  64.  
  65. player.getFarming().getCompost().compostBins = details.compostBins;
  66. player.getFarming().getCompost().compostBinsTimer = details.compostBinsTimer;
  67. player.getFarming().getCompost().organicItemAdded = details.organicItemAdded;
  68. player.getFarming().getBushes().bushesStages = details.bushesStages;
  69. player.getFarming().getBushes().bushesSeeds = details.bushesSeeds;
  70. player.getFarming().getBushes().bushesState = details.bushesState;
  71. player.getFarming().getBushes().bushesTimer = details.bushesTimer;
  72. player.getFarming().getBushes().diseaseChance = details.bushesDiseaseChance;
  73. player.getFarming().getBushes().hasFullyGrown = details.bushesHasFullyGrown;
  74. player.getFarming().getBushes().bushesWatched = details.bushesWatched;
  75. player.getFarming().getAllotment().allotmentStages = details.allotmentStages;
  76. player.getFarming().getAllotment().allotmentSeeds = details.allotmentSeeds;
  77. player.getFarming().getAllotment().allotmentHarvest = details.allotmentHarvest;
  78. player.getFarming().getAllotment().allotmentState = details.allotmentState;
  79. player.getFarming().getAllotment().allotmentTimer = details.allotmentTimer;
  80. player.getFarming().getAllotment().diseaseChance = details.allotmentDiseaseChance;
  81. player.getFarming().getAllotment().allotmentWatched = details.allotmentWatched;
  82. player.getFarming().getAllotment().hasFullyGrown = details.allotmentHasFullyGrown;
  83. player.getFarming().getFlowers().flowerStages = details.flowerStages;
  84. player.getFarming().getFlowers().flowerSeeds = details.flowerSeeds;
  85. player.getFarming().getFlowers().flowerState = details.flowerState;
  86. player.getFarming().getFlowers().flowerTimer = details.flowerTimer;
  87. player.getFarming().getFlowers().diseaseChance = details.flowerDiseaseChance;
  88. player.getFarming().getFlowers().hasFullyGrown = details.flowerHasFullyGrown;
  89. player.getFarming().getFruitTrees().fruitTreeStages = details.fruitTreeStages;
  90. player.getFarming().getFruitTrees().fruitTreeSaplings = details.fruitTreeSaplings;
  91. player.getFarming().getFruitTrees().fruitTreeState = details.fruitTreeState;
  92. player.getFarming().getFruitTrees().fruitTreeTimer = details.fruitTreeTimer;
  93. player.getFarming().getFruitTrees().diseaseChance = details.fruitDiseaseChance;
  94. player.getFarming().getFruitTrees().hasFullyGrown = details.fruitHasFullyGrown;
  95. player.getFarming().getFruitTrees().fruitTreeWatched = details.fruitTreeWatched;
  96. player.getFarming().getHerbs().herbStages = details.herbStages;
  97. player.getFarming().getHerbs().herbSeeds = details.herbSeeds;
  98. player.getFarming().getHerbs().herbHarvest = details.herbHarvest;
  99. player.getFarming().getHerbs().herbState = details.herbState;
  100. player.getFarming().getHerbs().herbTimer = details.herbTimer;
  101. player.getFarming().getHerbs().diseaseChance = details.herbDiseaseChance;
  102. player.getFarming().getHops().hopsStages = details.hopsStages;
  103. player.getFarming().getHops().hopsSeeds = details.hopsSeeds;
  104. player.getFarming().getHops().hopsHarvest = details.hopsHarvest;
  105. player.getFarming().getHops().hopsState = details.hopsState;
  106. player.getFarming().getHops().hopsTimer = details.hopsTimer;
  107. player.getFarming().getHops().diseaseChance = details.hopDiseaseChance;
  108. player.getFarming().getHops().hasFullyGrown = details.hopHasFullyGrown;
  109. player.getFarming().getHops().hopsWatched = details.hopsWatched;
  110. player.getFarming().getSpecialPlantOne().specialPlantStages = details.specialPlantOneStages;
  111. player.getFarming().getSpecialPlantOne().specialPlantSaplings = details.specialPlantOneSeeds;
  112. player.getFarming().getSpecialPlantOne().specialPlantState = details.specialPlantOneState;
  113. player.getFarming().getSpecialPlantOne().specialPlantTimer = details.specialPlantOneTimer;
  114. player.getFarming().getSpecialPlantOne().diseaseChance = details.specialPlantOneDiseaseChance;
  115. player.getFarming().getSpecialPlantOne().hasFullyGrown = details.specialPlantOneHasFullyGrown;
  116. player.getFarming().getSpecialPlantTwo().specialPlantStages = details.specialPlantTwoStages;
  117. player.getFarming().getSpecialPlantTwo().specialPlantSeeds = details.specialPlantTwoSeeds;
  118. player.getFarming().getSpecialPlantTwo().specialPlantState = details.specialPlantTwoState;
  119. player.getFarming().getSpecialPlantTwo().specialPlantTimer = details.specialPlantTwoTimer;
  120. player.getFarming().getSpecialPlantTwo().diseaseChance = details.specialPlantTwoDiseaseChance;
  121. player.getFarming().getSpecialPlantTwo().hasFullyGrown = details.specialPlantTwoHasFullyGrown;
  122. player.getFarming().getTrees().treeStages = details.treeStages;
  123. player.getFarming().getTrees().treeSaplings = details.treeSaplings;
  124. player.getFarming().getTrees().treeHarvest = details.treeHarvest;
  125. player.getFarming().getTrees().treeState = details.treeState;
  126. player.getFarming().getTrees().treeTimer = details.treeTimer;
  127. player.getFarming().getTrees().diseaseChance = details.treeDiseaseChance;
  128. player.getFarming().getTrees().hasFullyGrown = details.treeHasFullyGrown;
  129. player.getFarming().getTrees().treeWatched = details.treeWatched;
  130. } finally {
  131. if (reader != null) {
  132. reader.close();
  133. }
  134. }
  135.  
  136. return true;
  137. }
  138.  
  139. private final long farmingTimer;
  140. private final long lastFarmingTimer;
  141.  
  142. private final int[] compostBins;
  143. private final long[] compostBinsTimer;
  144. private final int[] organicItemAdded;
  145.  
  146. private final int[] bushesStages;
  147. private final int[] bushesSeeds;
  148. private final int[] bushesState;
  149. private final long[] bushesTimer;
  150. private final double[] bushesDiseaseChance;
  151. private final boolean[] bushesHasFullyGrown;
  152. private final boolean[] bushesWatched;
  153.  
  154. private final int[] allotmentStages;
  155. private final int[] allotmentSeeds;
  156. private final int[] allotmentHarvest;
  157. private final int[] allotmentState;
  158. private final long[] allotmentTimer;
  159. private final double[] allotmentDiseaseChance;
  160. private final boolean[] allotmentWatched;
  161. private final boolean[] allotmentHasFullyGrown;
  162.  
  163. private final int[] flowerStages;
  164. private final int[] flowerSeeds;
  165. private final int[] flowerState;
  166. private final long[] flowerTimer;
  167. private final double[] flowerDiseaseChance;
  168. private final boolean[] flowerHasFullyGrown;
  169.  
  170. private final int[] fruitTreeStages;
  171. private final int[] fruitTreeSaplings;
  172. private final int[] fruitTreeState;
  173. private final long[] fruitTreeTimer;
  174. private final double[] fruitDiseaseChance;
  175. private final boolean[] fruitHasFullyGrown;
  176. private final boolean[] fruitTreeWatched;
  177.  
  178. private final int[] herbStages;
  179. private final int[] herbSeeds;
  180. private final int[] herbHarvest;
  181. private final int[] herbState;
  182. private final long[] herbTimer;
  183. private final double[] herbDiseaseChance;
  184.  
  185. private final int[] hopsStages;
  186. private final int[] hopsSeeds;
  187. private final int[] hopsHarvest;
  188. private final int[] hopsState;
  189. private final long[] hopsTimer;
  190. private final double[] hopDiseaseChance;
  191. private final boolean[] hopHasFullyGrown;
  192. private final boolean[] hopsWatched;
  193.  
  194. private final int[] specialPlantOneStages;
  195. private final int[] specialPlantOneSeeds;
  196. private final int[] specialPlantOneState;
  197. private final long[] specialPlantOneTimer;
  198. private final double[] specialPlantOneDiseaseChance;
  199. private final boolean[] specialPlantOneHasFullyGrown;
  200.  
  201. private final int[] specialPlantTwoStages;
  202. private final int[] specialPlantTwoSeeds;
  203. private final int[] specialPlantTwoState;
  204. private final long[] specialPlantTwoTimer;
  205. private final double[] specialPlantTwoDiseaseChance;
  206. private final boolean[] specialPlantTwoHasFullyGrown;
  207.  
  208. private final int[] treeStages;
  209. private final int[] treeSaplings;
  210. private final int[] treeHarvest;
  211. private final int[] treeState;
  212. private final long[] treeTimer;
  213. private final double[] treeDiseaseChance;
  214. private final boolean[] treeHasFullyGrown;
  215. private final boolean[] treeWatched;
  216.  
  217. public PlayerFarming(Player player) {
  218. this.farmingTimer = player.getFarming().getFarmingTimer();
  219. this.lastFarmingTimer = System.currentTimeMillis();
  220. this.compostBins = player.getFarming().getCompost().compostBins;
  221. this.compostBinsTimer = player.getFarming().getCompost().compostBinsTimer;
  222. this.organicItemAdded = player.getFarming().getCompost().organicItemAdded;
  223. this.bushesStages = player.getFarming().getBushes().bushesStages;
  224. this.bushesSeeds = player.getFarming().getBushes().bushesSeeds;
  225. this.bushesState = player.getFarming().getBushes().bushesState;
  226. this.bushesTimer = player.getFarming().getBushes().bushesTimer;
  227. this.bushesDiseaseChance = player.getFarming().getBushes().diseaseChance;
  228. this.bushesHasFullyGrown = player.getFarming().getBushes().hasFullyGrown;
  229. this.bushesWatched = player.getFarming().getBushes().bushesWatched;
  230. this.allotmentStages = player.getFarming().getAllotment().allotmentStages;
  231. this.allotmentSeeds = player.getFarming().getAllotment().allotmentSeeds;
  232. this.allotmentHarvest = player.getFarming().getAllotment().allotmentHarvest;
  233. this.allotmentState = player.getFarming().getAllotment().allotmentState;
  234. this.allotmentTimer = player.getFarming().getAllotment().allotmentTimer;
  235. this.allotmentDiseaseChance = player.getFarming().getAllotment().diseaseChance;
  236. this.allotmentWatched = player.getFarming().getAllotment().allotmentWatched;
  237. this.allotmentHasFullyGrown = player.getFarming().getAllotment().hasFullyGrown;
  238. this.flowerStages = player.getFarming().getFlowers().flowerStages;
  239. this.flowerSeeds = player.getFarming().getFlowers().flowerSeeds;
  240. this.flowerState = player.getFarming().getFlowers().flowerState;
  241. this.flowerTimer = player.getFarming().getFlowers().flowerTimer;
  242. this.flowerDiseaseChance = player.getFarming().getFlowers().diseaseChance;
  243. this.flowerHasFullyGrown = player.getFarming().getFlowers().hasFullyGrown;
  244. this.fruitTreeStages = player.getFarming().getFruitTrees().fruitTreeStages;
  245. this.fruitTreeSaplings = player.getFarming().getFruitTrees().fruitTreeSaplings;
  246. this.fruitTreeState = player.getFarming().getFruitTrees().fruitTreeState;
  247. this.fruitTreeTimer = player.getFarming().getFruitTrees().fruitTreeTimer;
  248. this.fruitDiseaseChance = player.getFarming().getFruitTrees().diseaseChance;
  249. this.fruitHasFullyGrown = player.getFarming().getFruitTrees().hasFullyGrown;
  250. this.fruitTreeWatched = player.getFarming().getFruitTrees().fruitTreeWatched;
  251. this.herbStages = player.getFarming().getHerbs().herbStages;
  252. this.herbSeeds = player.getFarming().getHerbs().herbSeeds;
  253. this.herbHarvest = player.getFarming().getHerbs().herbHarvest;
  254. this.herbState = player.getFarming().getHerbs().herbState;
  255. this.herbTimer = player.getFarming().getHerbs().herbTimer;
  256. this.herbDiseaseChance = player.getFarming().getHerbs().diseaseChance;
  257. this.hopsStages = player.getFarming().getHops().hopsStages;
  258. this.hopsSeeds = player.getFarming().getHops().hopsSeeds;
  259. this.hopsHarvest = player.getFarming().getHops().hopsHarvest;
  260. this.hopsState = player.getFarming().getHops().hopsState;
  261. this.hopsTimer = player.getFarming().getHops().hopsTimer;
  262. this.hopDiseaseChance = player.getFarming().getHops().diseaseChance;
  263. this.hopHasFullyGrown = player.getFarming().getHops().hasFullyGrown;
  264. this.hopsWatched = player.getFarming().getHops().hopsWatched;
  265. this.specialPlantOneStages = player.getFarming().getSpecialPlantOne().specialPlantStages;
  266. this.specialPlantOneSeeds = player.getFarming().getSpecialPlantOne().specialPlantSaplings;
  267. this.specialPlantOneState = player.getFarming().getSpecialPlantOne().specialPlantState;
  268. this.specialPlantOneTimer = player.getFarming().getSpecialPlantOne().specialPlantTimer;
  269. this.specialPlantOneDiseaseChance = player.getFarming().getSpecialPlantOne().diseaseChance;
  270. this.specialPlantOneHasFullyGrown = player.getFarming().getSpecialPlantOne().hasFullyGrown;
  271. this.specialPlantTwoStages = player.getFarming().getSpecialPlantTwo().specialPlantStages;
  272. this.specialPlantTwoSeeds = player.getFarming().getSpecialPlantTwo().specialPlantSeeds;
  273. this.specialPlantTwoState = player.getFarming().getSpecialPlantTwo().specialPlantState;
  274. this.specialPlantTwoTimer = player.getFarming().getSpecialPlantTwo().specialPlantTimer;
  275. this.specialPlantTwoDiseaseChance = player.getFarming().getSpecialPlantTwo().diseaseChance;
  276. this.specialPlantTwoHasFullyGrown = player.getFarming().getSpecialPlantTwo().hasFullyGrown;
  277. this.treeStages = player.getFarming().getTrees().treeStages;
  278. this.treeSaplings = player.getFarming().getTrees().treeSaplings;
  279. this.treeHarvest = player.getFarming().getTrees().treeHarvest;
  280. this.treeState = player.getFarming().getTrees().treeState;
  281. this.treeTimer = player.getFarming().getTrees().treeTimer;
  282. this.treeDiseaseChance = player.getFarming().getTrees().diseaseChance;
  283. this.treeHasFullyGrown = player.getFarming().getTrees().hasFullyGrown;
  284. this.treeWatched = player.getFarming().getTrees().treeWatched;
  285. }
  286.  
  287. public void parseDetails(Player player) throws IOException {
  288. BufferedWriter writer = new BufferedWriter(new FileWriter("./data/characters/farming/" + player.getUsername() + ".json", false));
  289. try {
  290. writer.write(PlayerSave.GSON.toJson(this));
  291. writer.flush();
  292. } finally {
  293. writer.close();
  294. }
  295. }
  296. }
  297.  
  298. public static final class PlayerContainer {
  299.  
  300. public static boolean loadDetails(Player player) throws Exception {
  301. File file = new File("./data/characters/containers/" + player.getUsername() + ".json");
  302.  
  303. if (!file.exists()) {
  304. return false;
  305. }
  306.  
  307. BufferedReader reader = new BufferedReader(new FileReader(file));
  308. try {
  309. PlayerContainer details = PlayerSave.GSON.fromJson(reader, PlayerContainer.class);
  310.  
  311. if (details.shopItems != null) {
  312. player.getPlayerShop().setItems(details.shopItems);
  313. }
  314.  
  315. if (details.shopPrices != null) {
  316. player.getPlayerShop().setPrices(details.shopPrices);
  317. }
  318.  
  319. if (details.tabAmounts != null) {
  320. player.getBank().setTabAmounts(details.tabAmounts);
  321. }
  322.  
  323. if (details.bank != null) {
  324. int tabs = Arrays.stream(player.getBank().getTabAmounts()).sum();
  325. int total = 0;
  326. for (int i = 0, slot = 0; i < Bank.SIZE; i++) {
  327. if (i >= Bank.SIZE) {
  328. break;
  329. }
  330. if (i >= details.bank.length) {
  331. break;
  332. }
  333. Item check = ItemCheck.check(player, details.bank[i]);
  334. player.getBank().getItems()[slot++] = check;
  335. if (check != null) {
  336. total++;
  337. }
  338. }
  339.  
  340. //if (total != tabs) {
  341. // player.getBank().setTabAmounts(new int[] { total, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
  342. // DialogueManager.sendStatement(player, "@dre@There was an issue loading your bank tabs.", "@dre@Your bank tabs have been collapsed as a safety measure.");
  343. //}
  344. }
  345.  
  346. if (details.equipment != null) {
  347. for (int i = 0; i < details.equipment.length; i++) {
  348. player.getEquipment().getItems()[i] = ItemCheck.check(player, details.equipment[i]);
  349. }
  350. }
  351.  
  352. if (details.inventory != null) {
  353. for (int i = 0; i < details.inventory.length; i++) {
  354. player.getInventory().getItems()[i] = ItemCheck.check(player, details.inventory[i]);
  355. }
  356. }
  357.  
  358. if (details.bobInventory != null) {
  359. player.getAttributes().set("summoningbobinventory", details.bobInventory);
  360. }
  361.  
  362. if (details.pouches != null) {
  363. player.setPouches(details.pouches);
  364. }
  365.  
  366. if(details.lootingBag != null)
  367. {
  368. player.getLootBag().setItems(details.lootingBag);
  369. }
  370.  
  371. player.setLastLoginDay(Utility.getDayOfYear());
  372. player.setLastLoginYear(Utility.getYear());
  373.  
  374. } finally {
  375. if (reader != null) {
  376. reader.close();
  377. }
  378. }
  379.  
  380. return true;
  381. }
  382.  
  383. private final Item[] bank;
  384. private final int[] tabAmounts;
  385. private final Item[] inventory;
  386. private final Item[] equipment;
  387. private final List<Item> lootingBag;
  388. private final Item[] bobInventory;
  389. private final Item[] shopItems;
  390. private final int[] shopPrices;
  391. private final byte[] pouches;
  392.  
  393. public PlayerContainer(Player player) {
  394. bank = player.getBank().getItems();
  395. tabAmounts = player.getBank().getTabAmounts();
  396. lootingBag = player.getLootBag().getItems();
  397. inventory = player.getInventory().getItems();
  398. equipment = player.getEquipment().getItems();
  399. bobInventory = (player.getSummoning().isFamilarBOB() ? player.getSummoning().getContainer().getItems() : null);
  400. shopItems = player.getPlayerShop().getItems();
  401. shopPrices = player.getPlayerShop().getPrices();
  402. pouches = player.getPouches();
  403. }
  404.  
  405. public void parseDetails(Player player) throws IOException {
  406. BufferedWriter writer = new BufferedWriter(new FileWriter("./data/characters/containers/" + player.getUsername() + ".json", false));
  407. try {
  408. writer.write(PlayerSave.GSON.toJson(this));
  409. writer.flush();
  410. } finally {
  411. writer.close();
  412. }
  413. }
  414. }
  415.  
  416. public static final class PlayerDetails {
  417.  
  418. public static boolean loadDetails(Player player) throws Exception {
  419. BufferedReader reader = null;
  420. try {
  421. File file = new File("./data/characters/details/" + NameUtil.uppercaseFirstLetter(player.getUsername()) + ".json");
  422.  
  423. if (!file.exists()) {
  424. return false;
  425. }
  426.  
  427. reader = new BufferedReader(new FileReader(file));
  428.  
  429. PlayerDetails details = PlayerSave.GSON.fromJson(reader, PlayerDetails.class);
  430. player.setUsername(details.username);
  431. player.setPassword(details.password);
  432. player.getLocation().setAs(new Location(details.x, details.y, details.z));
  433. player.setRights(details.rights);
  434.  
  435. if (details.lastKnownUID != null) {
  436. player.setLastKnownUID(details.lastKnownUID);
  437. }
  438.  
  439. player.setShopCollection(details.shopCollection);
  440. player.setShopMotto(details.shopMotto);
  441. player.setShopColor(details.shopColor);
  442. player.setLastLike(details.lastLike);
  443. player.setLikesGiven(details.likesGiven);
  444. player.setLikes(details.likes);
  445. player.setDislikes(details.dislikes);
  446. player.setProfileViews(details.profileViews);
  447. player.setRetaliate(details.retaliate);
  448. player.getSkill().setExpLock(details.expLock);
  449. player.getSlayer().setAmount(details.slayerAmount);
  450. player.getSlayer().setTask(details.slayerTask);
  451. player.setPoisonDamage(details.poisonDmg);
  452. player.getSpecialAttack().setSpecialAmount(details.spec);
  453. player.getRunEnergy().setEnergy(details.energy);
  454. player.getSummoning().setAttack(details.summoningAttack);
  455. player.getSummoning().setSpecial(details.summoningSpecialAmount);
  456. player.getSummoning().setTime(details.summoningTime);
  457. player.setPestPoints(details.pestPoints);
  458. player.setArenaPoints(details.arenaPoints);
  459. if (details.summoningFamiliar != -1) {
  460. player.getAttributes().set("summoningfamsave", Integer.valueOf(details.summoningFamiliar));
  461. }
  462.  
  463. player.setRigour(details.rigour);
  464. player.setAugury(details.augury);
  465.  
  466. player.raidCount=details.raids;
  467.  
  468. player.getClient().setLogPlayer(details.logPackets);
  469. player.getRunEnergy().setRunning(details.running);
  470. player.setTeleblockTime(details.teleblockTime);
  471. player.getRareDropEP().setEp(details.rareDropEP);
  472. player.getRareDropEP().setReceived(details.rareDropsReceived);
  473. player.setLastKilledPlayers(details.lastKilledPlayers);
  474. player.setPin(details.pins);
  475. player.setIP(details.IP);
  476. player.setEmailAddress(details.emailAddress);
  477. player.setFullName(details.fullName);
  478. player.setRecovery(details.recovery);
  479. player.ipSet = details.ipSet;
  480. player.nameSet = details.nameSet;
  481. player.recoverySet = details.recoverySet;
  482. player.emailSet = details.emailSet;
  483. player.setCredits(details.credits);
  484. player.setMoneySpent(details.moneySpent);
  485.  
  486. //Set actual points first
  487. player.setMoneyPouch(details.moneyPouch);
  488. player.setBountyPoints(details.bountyPoints);
  489. player.setskillPoints(details.skillPoints);
  490. player.setpvmPoints(details.pvmPoints);
  491. player.setbossPoints(details.bossPoints);
  492. player.setthievePoints(details.thievePoints);
  493. player.setfarmingPoints(details.farmingPoints);
  494. player.setwoodcuttingPoints(details.woodcuttingPoints);
  495. player.setfiremakingPoints(details.firemakingPoints);
  496. player.setfishingPoints(details.fishingPoints);
  497. player.setSmithingPoints(details.smithingPoints);
  498. player.setminingPoints(details.miningPoints);
  499. player.setfletchingPoints(details.fletchingPoints);
  500. player.setcraftingPoints(details.craftingPoints);
  501. player.setherblorePoints(details.herblorePoints);
  502. player.setpuroPoints(details.puroPoints);
  503. player.setrunecraftingPoints(details.runecraftingPoints);
  504. player.setprayerPoints(details.prayerPoints);
  505. player.setSlayerPoints(details.slayerPoints);
  506. player.setSufferingCharges(details.sufferingCharges);
  507. player.setBlackMarks(details.blackMarks);
  508. player.getMagic().setDragonFireShieldCharges(details.dragonFireShieldCharges);
  509. player.setVotePoints(details.votePoints);
  510. player.setDeaths(details.deaths);
  511. player.setKills(details.kills);
  512. player.setRogueKills(details.rogueKills);
  513. player.setRogueRecord(details.rogueRecord);
  514. player.setHunterKills(details.hunterKills);
  515. player.setHunterRecord(details.hunterRecord);
  516. player.setWeaponPoints(details.weaponPoints);
  517.  
  518. player.setMusicVolume((byte) details.musicVolume);
  519. player.setSoundVolume((byte) details.soundVolume);
  520.  
  521. if (details.degrading != null) {
  522. player.getItemDegrading().setDegrading(details.degrading);
  523. }
  524.  
  525. if (details.savedArrows != null) {
  526. player.getRanged().getSavedArrows().setItems(details.savedArrows);
  527. }
  528.  
  529. if(details.eloRating != 0) {
  530. player.eloRating = details.eloRating;
  531. }
  532.  
  533. else
  534. player.eloRating = EloRatingSystem.DEFAULT_ELO_START_RATING;
  535. player.setRecallLocation(details.recallLocation);
  536. if (details.attackStyle != null) {
  537. player.getEquipment().setAttackStyle(details.attackStyle);
  538. }
  539. if (details.attackType != null) {
  540. player.setAttackType(details.attackType);
  541. }
  542. if (details.recoilStage != -1) {
  543. player.getAttributes().set("recoilhits", Integer.valueOf(details.recoilStage));
  544. }
  545.  
  546. player.getSkulling().setLeft(details.left);
  547. if (player.getSkulling().isSkulled()) {
  548. player.getSkulling().setSkullIcon(player, details.skullIcon);
  549. }
  550. if (details.host != null) {
  551. player.getClient().setHost(details.host);
  552. }
  553. if (details.slayerDifficulty != null) {
  554. player.getSlayer().setCurrent(details.slayerDifficulty);
  555. }
  556. player.setUltimateIron(details.isUltimateIron);
  557. player.setMember(details.isMember);
  558. player.setIron(details.isIron);
  559. player.setExtreme(details.isExtreme);
  560. player.setYearCreated(details.yearCreated);
  561. player.setDayCreated(details.dayCreated);
  562.  
  563. player.setBoughtLargePlot(details.boughtLargePlot);
  564. player.setBoughtMediumPlot(details.boughtMediumPlot);
  565. player.setBoughtSmallPlot(details.boughtSmallPlot);
  566.  
  567. player.setLastLoginDay(details.lastLoginDay);
  568. player.setLastLoginYear(details.lastLoginYear);
  569. player.setScreenBrightness(details.bright);
  570. player.setMultipleMouseButtons(details.multipleMouse);
  571. player.setChatEffects(details.chatEffects);
  572. player.setSplitPrivateChat(details.splitPrivate);
  573. player.setTransparentPanel(details.transparentPanel);
  574. player.setTransparentChatbox(details.transparentChatbox);
  575. player.setSideStones(details.sideStones);
  576. player.setAcceptAid(details.acceptAid);
  577. player.getJadDetails().setStage(details.fightCavesWave);
  578. if (details.friends != null) {
  579. for (String i : details.friends) {
  580. player.getPrivateMessaging().getFriends().add(i);
  581. }
  582. }
  583.  
  584. if (details.ignores != null) {
  585. for (String i : details.ignores) {
  586. player.getPrivateMessaging().getIgnores().add(i);
  587. }
  588. }
  589.  
  590. if ((details.poisonDmg > 0) && (details.poisoned)) {
  591. player.poison(details.poisonDmg);
  592. }
  593.  
  594. player.setPouchPayment(details.pouchPayment);
  595.  
  596. player.setGender(details.gender);
  597.  
  598. if (details.appearance != null) {
  599. for (int i = 0; i < details.appearance.length; i++)
  600. player.getAppearance()[i] = details.appearance[i];
  601. }
  602. if (details.colours != null) {
  603. for (int i = 0; i < details.colours.length; i++)
  604. player.getColors()[i] = details.colours[i];
  605. }
  606. if (details.experience != null) {
  607. for (int i = 0; i < details.experience.length; i++) {
  608. player.getSkill().getExperience()[i] = details.experience[i];
  609. }
  610. }
  611. if (details.skillsLevel != null) {
  612. for (int i = 0; i < details.skillsLevel.length; i++) {
  613. player.getLevels()[i] = details.skillsLevel[i];
  614. }
  615. }
  616. if (details.experience != null) {
  617. for (int i = 0; i < details.experience.length; i++) {
  618. player.getMaxLevels()[i] = player.getSkill().getLevelForExperience(i, details.experience[i]);
  619. }
  620. }
  621.  
  622. if (details.gwkc != null) {
  623. player.getMinigames().setGWKC(details.gwkc);
  624. }
  625.  
  626. boolean banned = details.banned;
  627. boolean muted = details.muted;
  628. boolean jailed = details.jailed;
  629.  
  630. if ((banned) && (TimeUnit.MILLISECONDS.toSeconds(details.banLength - System.currentTimeMillis()) > 0 || details.banLength == -1)) {
  631. player.setBanned(true);
  632. player.setBanLength(details.banLength);
  633. }
  634.  
  635. if ((jailed) && (TimeUnit.MILLISECONDS.toSeconds(details.jailLength - System.currentTimeMillis()) > 0 || details.jailLength == -1)) {
  636. player.setJailed(true);
  637. player.setJailLength(details.jailLength);
  638. }
  639.  
  640. if ((muted) && (TimeUnit.MILLISECONDS.toSeconds(details.muteLength - System.currentTimeMillis()) > 0 || details.muteLength == -1)) {
  641. player.setMuted(true);
  642. player.setMuteLength(details.muteLength);
  643. }
  644.  
  645. if (details.magicBook > 0) {
  646. player.getMagic().setMagicBook(details.magicBook);
  647. }
  648.  
  649. if (details.prayerBook > 0) {
  650. player.setPrayerInterface(details.prayerBook);
  651. }
  652.  
  653. if (details.skillGoals != null) {
  654. player.setSkillGoals(details.skillGoals);
  655. }
  656.  
  657. if (details.playerAchievements != null) {
  658. player.getPlayerAchievements().putAll(details.playerAchievements);
  659. }
  660.  
  661. if (details.achievementsPoints > 0) {
  662. player.addAchievementPoints(details.achievementsPoints);
  663. }
  664.  
  665. if (details.expCounter > 0) {
  666. player.addCounterExp(details.expCounter);
  667. }
  668.  
  669. if (details.cluesCompleted != null) {
  670. player.setCluesCompleted(details.cluesCompleted);
  671. }
  672.  
  673. if (details.lastClanChat != null) {
  674. player.lastClanChat = details.lastClanChat;
  675. }
  676.  
  677. // set prayer book
  678.  
  679. player.setPrayerInterface(5608);
  680.  
  681.  
  682. player.setPrestigePoints(details.prestigePoints);
  683.  
  684. if (details.prestiges != null) {
  685. player.setSkillPrestiges(details.prestiges);
  686. }
  687.  
  688. if (details.blowpipe != null) {
  689. player.setToxicBlowpipe(details.blowpipe);
  690. }
  691.  
  692. if (details.seasTrident != null) {
  693. player.setSeasTrident(details.seasTrident);
  694. }
  695.  
  696. if (details.swampTrident != null) {
  697. player.setSwampTrident(details.swampTrident);
  698. }
  699.  
  700. if (details.serpentineHelmet != null) {
  701. player.setSerpentineHelment(details.serpentineHelmet);
  702. }
  703.  
  704. player.getProperties().setDefaults();
  705.  
  706. if (details.playerProperties != null) {
  707. for (Object attribute : details.playerProperties.keySet()) {
  708. player.getAttributes().getAttributes().put(attribute, details.playerProperties.get(attribute));
  709. }
  710. }
  711.  
  712. if (details.unlockedCredits != null) {
  713. player.getUnlockedCredits().addAll(details.unlockedCredits);
  714. }
  715.  
  716.  
  717.  
  718. if (details.quests != null) {
  719. for (Quests attribute : details.quests.keySet()) {
  720. player.getQuestManager().questStages.put(attribute, details.quests.get(attribute));
  721. }
  722. }
  723.  
  724. if (details.pointsReset == false) {
  725. player.setWeaponPoints(0);
  726. player.setMoneyPouch((long) 0);
  727. player.setPestPoints(0);
  728. player.setBountyPoints(0);
  729. player.setskillPoints(0);
  730. player.setpvmPoints(0);
  731. player.setbossPoints(0);
  732. player.setthievePoints(0);
  733. player.setfarmingPoints(0);
  734. player.setwoodcuttingPoints(0);
  735. player.setfiremakingPoints(0);
  736. player.setfishingPoints(0);
  737. player.setSmithingPoints(0);
  738. player.setminingPoints(0);
  739. player.setfletchingPoints(0);
  740. player.setcraftingPoints(0);
  741. player.setherblorePoints(0);
  742. player.setpuroPoints(0);
  743. player.setrunecraftingPoints(0);
  744. player.setprayerPoints(0);
  745. player.setSlayerPoints(0);
  746. player.setCredits(0);
  747. player.setMoneySpent(0);
  748. player.setSufferingCharges(0);
  749. player.setBlackMarks(0);
  750. player.getMagic().setDragonFireShieldCharges(0);
  751. player.setVotePoints(0);
  752. player.setDeaths(0);
  753. player.setKills(0);
  754. player.setRogueKills(0);
  755. player.setRogueRecord(0);
  756. player.setHunterKills(0);
  757. player.setHunterRecord(0);
  758. player.pointsReset = true;
  759. save(player);
  760. }
  761.  
  762. return true;
  763. } finally {
  764. if (reader != null)
  765. try {
  766. reader.close();
  767. } catch (IOException e) {
  768. e.printStackTrace();
  769. }
  770. }
  771. }
  772.  
  773. private final String username;
  774. private final String password;
  775. private final int x;
  776. private final int y;
  777. private final int z;
  778. private final byte rights;
  779. private final String lastKnownUID;
  780. private final int[] cluesCompleted;
  781. private final String yellTitle;
  782. private final PlayerTitle playerTitle;
  783. private final List<PlayerTitle> unlockedTitles;
  784. private final boolean banned;
  785. private final long banLength;
  786. private final long moneyPouch;
  787. private final long jailLength;
  788. private final long shopCollection;
  789. private final String shopMotto;
  790. private final String shopColor;
  791. private final String lastClanChat;
  792. private final boolean muted;
  793. private final boolean isMember;
  794. private final boolean isExtreme;
  795. private final boolean isIron;
  796. private final boolean isUltimateIron;
  797. private final boolean jailed;
  798. private final long muteLength;
  799. private final int fightCavesWave;
  800. private final int magicBook;
  801. private final int prayerBook;
  802. private final boolean retaliate;
  803. private final boolean expLock;
  804. private final short[] gwkc;
  805. private final boolean poisoned;
  806. private final int poisonDmg;
  807. private final String slayerTask;
  808. private final byte slayerAmount;
  809. private final Slayer.SlayerDifficulty slayerDifficulty;
  810. private final short[] skillsLevel;
  811. private final double[] experience;
  812. private final byte gender;
  813. private final int[] appearance;
  814. private final byte[] colours;
  815. private final long left;
  816. private final int skullIcon;
  817. private final byte bright;
  818. private final byte multipleMouse;
  819. private final byte chatEffects;
  820. private final byte splitPrivate;
  821.  
  822. private byte transparentPanel;
  823. private byte transparentChatbox;
  824. private byte sideStones;
  825.  
  826. private final byte acceptAid;
  827. private final boolean pouchPayment;
  828. private final String[] friends;
  829. private final String[] ignores;
  830. private final int yearCreated;
  831. private final int dayCreated;
  832. private final int recoilStage;
  833. private final int spec;
  834. private final Equipment.AttackStyles attackStyle;
  835. private final AttackType attackType;
  836. private final double energy;
  837. private final int lastLoginDay;
  838. private final int lastLoginYear;
  839. private final String host;
  840. private final int votePoints;
  841. private final int pvmPoints;
  842. private final int bossPoints;
  843. private final int thievePoints;
  844. private final int farmingPoints;
  845. private final int woodcuttingPoints;
  846. private final int firemakingPoints;
  847. private final int fishingPoints;
  848. private final int smithingPoints;
  849. private final int miningPoints;
  850. private final int fletchingPoints;
  851. private final int craftingPoints;
  852. private final int herblorePoints;
  853. private final int puroPoints;
  854. private final int runecraftingPoints;
  855. private final int prayerPoints;
  856. private final ItemDegrading.DegradedItem[] degrading;
  857. private final byte dragonFireShieldCharges;
  858. private final int slayerPoints;
  859. private final int musicVolume;
  860. private final int soundVolume;
  861. private final Item[] savedArrows;
  862. private final int deaths;
  863. private final int kills;
  864. private final int rogueKills;
  865. private final int rogueRecord;
  866. private final int hunterKills;
  867. private final int hunterRecord;
  868. private final int credits;
  869. private final int moneySpent;
  870. private final int bountyPoints;
  871. private final int skillPoints;
  872. private long lastLike;
  873. private byte likesGiven;
  874. private int likes, dislikes, profileViews;
  875. private final String fullName;
  876. private final String IP;
  877. private final String emailAddress;
  878. private final String recovery;
  879. private final String pins;
  880. private final boolean ipSet;
  881. private final boolean nameSet;
  882. private final boolean emailSet;
  883. private final boolean recoverySet;
  884. private final boolean running;
  885. private final boolean logPackets;
  886. private final int weaponPoints;
  887. private final int summoningTime;
  888. private final int summoningSpecialAmount;
  889. private final int summoningFamiliar;
  890. private final int rigour;
  891. private final int augury;
  892. private final boolean summoningAttack;
  893. private final int pestPoints;
  894. private final int arenaPoints;
  895. private final int teleblockTime;
  896. private final int blackMarks;
  897. private final double rareDropEP;
  898. private final int rareDropsReceived;
  899. private final int[][] skillGoals;
  900. private final ArrayList<String> lastKilledPlayers;
  901. private final HashMap<AchievementList, Integer> playerAchievements;
  902. private final int achievementsPoints;
  903. private final Set<CreditPurchase> unlockedCredits;
  904. private final boolean[] quickPrayers;
  905. private final HashMap<Quests, Integer> quests;
  906.  
  907. private final HashMap<Object, Object> playerProperties;
  908. private final boolean pointsReset;
  909. private final double expCounter;
  910. private final int prestigePoints;
  911. private final int[] prestiges;
  912. private final ToxicBlowpipe blowpipe;
  913. private final TridentOfTheSeas seasTrident;
  914. private final TridentOfTheSwamp swampTrident;
  915. private final SerpentineHelmet serpentineHelmet;
  916. private final int eloRating;
  917. private final Location recallLocation;
  918. private final boolean boughtLargePlot;
  919. private final boolean boughtMediumPlot;
  920. private final boolean boughtSmallPlot;
  921. private final int sufferingCharges;
  922. private final int raids;
  923.  
  924. public PlayerDetails(Player player) {
  925. username = player.getUsername();
  926. password = player.getPassword();
  927. x = player.getLocation().getX();
  928. y = player.getLocation().getY();
  929. z = player.getLocation().getZ();
  930. rights = ((byte) player.getRights());
  931. rigour = player.getRigour();
  932. augury = player.getAugury();
  933. raids = player.raidCount;
  934. lastKnownUID = player.getUid();
  935. fullName = player.getFullName();
  936. IP = player.getIP();
  937. recovery = player.getRecovery();
  938. emailAddress = player.getEmailAddress();
  939. nameSet = player.nameSet;
  940. ipSet = player.ipSet;
  941. recoverySet = player.recoverySet;
  942. emailSet = player.emailSet;
  943. pins = player.getPin();
  944. credits = player.getCredits();
  945. moneySpent = player.getMoneySpent();
  946. host = player.getClient().getHost();
  947. cluesCompleted = player.getCluesCompleted();
  948. yellTitle = player.getYellTitle();
  949. playerTitle = player.getPlayerTitle();
  950. unlockedTitles = player.unlockedTitles;
  951. lastLike = player.getLastLike();
  952. likesGiven = player.getLikesGiven();
  953. likes = player.getLikes();
  954. dislikes = player.getDislikes();
  955. profileViews = player.getProfileViews();
  956. banned = player.isBanned();
  957. banLength = player.getBanLength();
  958. moneyPouch = player.getMoneyPouch();
  959. jailLength = player.getJailLength();
  960. shopCollection = player.getShopCollection();
  961. shopMotto = player.getShopMotto();
  962. shopColor = player.getShopColor();
  963. muted = player.isMuted();
  964. isMember = player.isMember();
  965. isExtreme = player.isExtreme();
  966. isIron = player.isIron();
  967. isUltimateIron = player.isUltimateIron();
  968. jailed = player.isJailed();
  969. muteLength = player.getMuteLength();
  970. weaponPoints = player.getWeaponPoints();
  971. fightCavesWave = player.getJadDetails().getStage();
  972. magicBook = player.getMagic().getMagicBook();
  973. prayerBook = player.getPrayerInterface();
  974. retaliate = player.isRetaliate();
  975. expLock = player.getSkill().isExpLocked();
  976. gwkc = player.getMinigames().getGWKC();
  977. lastClanChat = player.lastClanChat;
  978. boughtLargePlot = player.hasBoughtLargePlot();
  979. boughtMediumPlot = player.hasBoughtMediumPlot();
  980. boughtSmallPlot = player.hasBoughtSmallPlot();
  981.  
  982. quickPrayers = player.getPrayer().getQuickPrayers();
  983.  
  984. rareDropEP = player.getRareDropEP().getEp();
  985.  
  986. rareDropsReceived = player.getRareDropEP().getReceived();
  987.  
  988. blackMarks = player.getBlackMarks();
  989.  
  990. poisoned = player.isPoisoned();
  991. pouchPayment = player.isPouchPayment();
  992. poisonDmg = player.getPoisonDamage();
  993. slayerTask = player.getSlayer().getTask();
  994. slayerAmount = player.getSlayer().getAmount();
  995. experience = player.getSkill().getExperience();
  996. skillsLevel = player.getSkill().getLevels();
  997. gender = player.getGender();
  998. appearance = (player.getAppearance().clone());
  999. colours = (player.getColors().clone());
  1000. left = player.getSkulling().getLeft();
  1001. skullIcon = player.getSkulling().getSkullIcon();
  1002. spec = player.getSpecialAttack().getAmount();
  1003. attackStyle = player.getEquipment().getAttackStyle();
  1004. attackType = player.getAttackType();
  1005. energy = player.getRunEnergy().getEnergy();
  1006. votePoints = player.getVotePoints();
  1007. eloRating = player.eloRating;
  1008. recallLocation = player.getRecallLocation();
  1009.  
  1010.  
  1011. teleblockTime = player.getTeleblockTime();
  1012.  
  1013. summoningAttack = player.getSummoning().isAttack();
  1014. summoningTime = player.getSummoning().getTime();
  1015. summoningSpecialAmount = player.getSummoning().getSpecialAmount();
  1016. summoningFamiliar = (player.getSummoning().getFamiliarData() != null ? player.getSummoning().getFamiliarData().mob : -1);
  1017.  
  1018. logPackets = player.getClient().isLogPlayer();
  1019.  
  1020. running = player.getRunEnergy().isRunning();
  1021.  
  1022. pestPoints = player.getPestPoints();
  1023. arenaPoints = player.getArenaPoints();
  1024.  
  1025. soundVolume = player.getSoundVolume();
  1026.  
  1027. deaths = player.getDeaths();
  1028. kills = player.getKills();
  1029. rogueKills = player.getRogueKills();
  1030. rogueRecord = player.getRogueRecord();
  1031. hunterKills = player.getHunterKills();
  1032. hunterRecord = player.getHunterRecord();
  1033.  
  1034. lastKilledPlayers = player.getLastKilledPlayers();
  1035.  
  1036. bountyPoints = player.getBountyPoints();
  1037.  
  1038. skillPoints = player.getskillPoints();
  1039.  
  1040. bossPoints = player.getbossPoints();
  1041.  
  1042. pvmPoints = player.getpvmPoints();
  1043.  
  1044. thievePoints = player.getthievePoints();
  1045.  
  1046. farmingPoints = player.getfarmingPoints();
  1047.  
  1048. woodcuttingPoints = player.getwoodcuttingPoints();
  1049.  
  1050. firemakingPoints = player.getfiremakingPoints();
  1051.  
  1052. fishingPoints = player.getfishingPoints();
  1053.  
  1054. smithingPoints = player.getSmithingPoints();
  1055.  
  1056. miningPoints = player.getminingPoints();
  1057.  
  1058. fletchingPoints = player.getfletchingPoints();
  1059.  
  1060. craftingPoints = player.getcraftingPoints();
  1061.  
  1062. herblorePoints = player.getherblorePoints();
  1063.  
  1064. puroPoints = player.getpuroPoints();
  1065.  
  1066. runecraftingPoints = player.getrunecraftingPoints();
  1067.  
  1068. prayerPoints = player.getprayerPoints();
  1069.  
  1070. musicVolume = player.getMusicVolume();
  1071.  
  1072. dragonFireShieldCharges = player.getMagic().getDragonFireShieldCharges();
  1073.  
  1074. degrading = player.getItemDegrading().getDegrading();
  1075.  
  1076. lastLoginDay = player.getLastLoginDay();
  1077. lastLoginYear = player.getLastLoginYear();
  1078.  
  1079. yearCreated = player.getYearCreated();
  1080. dayCreated = player.getDayCreated();
  1081.  
  1082. slayerPoints = player.getSlayerPoints();
  1083.  
  1084. sufferingCharges = player.getSufferingCharges();
  1085.  
  1086. slayerDifficulty = player.getSlayer().getCurrent();
  1087.  
  1088. if (player.getAttributes().get("recoilhits") != null)
  1089. recoilStage = player.getAttributes().getInt("recoilhits");
  1090. else {
  1091. recoilStage = -1;
  1092. }
  1093.  
  1094. bright = player.getScreenBrightness();
  1095. multipleMouse = player.getMultipleMouseButtons();
  1096. chatEffects = player.getChatEffectsEnabled();
  1097. splitPrivate = player.getSplitPrivateChat();
  1098. transparentPanel = player.getTransparentPanel();
  1099. transparentChatbox = player.getTransparentChatbox();
  1100. sideStones = player.getSideStones();
  1101. acceptAid = player.getAcceptAid();
  1102.  
  1103. savedArrows = player.getRanged().getSavedArrows().getItems();
  1104. skillGoals = player.getSkillGoals();
  1105. expCounter = player.getCounterExp();
  1106.  
  1107. playerAchievements = player.getPlayerAchievements();
  1108. achievementsPoints = player.getAchievementsPoints();
  1109.  
  1110. unlockedCredits = player.getUnlockedCredits();
  1111.  
  1112. int k = 0;
  1113. friends = new String[player.getPrivateMessaging().getFriends().size()];
  1114. for (String i : player.getPrivateMessaging().getFriends()) {
  1115. friends[k] = i;
  1116. k++;
  1117. }
  1118.  
  1119. k = 0;
  1120. ignores = new String[player.getPrivateMessaging().getIgnores().size()];
  1121. for (String i : player.getPrivateMessaging().getIgnores()) {
  1122. ignores[k] = i;
  1123. k++;
  1124. }
  1125.  
  1126. prestigePoints = player.getPrestigePoints();
  1127. prestiges = player.getSkillPrestiges();
  1128.  
  1129. blowpipe = player.getToxicBlowpipe();
  1130. seasTrident = player.getSeasTrident();
  1131. swampTrident = player.getSwampTrident();
  1132. serpentineHelmet = player.getSerpentineHelment();
  1133.  
  1134. playerProperties = new HashMap<>();
  1135.  
  1136. for (Object attribute : player.getAttributes().getAttributes().keySet()) {
  1137. if (String.valueOf(attribute).startsWith(PlayerProperties.ATTRIBUTE_KEY)) {
  1138. playerProperties.put(attribute, player.getAttributes().getAttributes().get(attribute));
  1139. }
  1140. }
  1141.  
  1142. pointsReset = true;
  1143.  
  1144. quests = new HashMap<>();
  1145.  
  1146. for (Quests attribute : player.getQuestManager().questStages.keySet()) {
  1147. playerProperties.put(attribute, player.getQuestManager().questStages.get(attribute));
  1148. }
  1149.  
  1150. }
  1151.  
  1152. public void parseDetails() throws Exception {
  1153. BufferedWriter writer = null;
  1154. try {
  1155. writer = new BufferedWriter(new FileWriter("./data/characters/details/" + username + ".json", false));
  1156. writer.write(PlayerSave.GSON.toJson(this));
  1157. writer.flush();
  1158. } finally {
  1159. if (writer != null)
  1160. writer.close();
  1161. }
  1162. }
  1163. }
  1164.  
  1165. public static void main(String[] args) throws FileNotFoundException, IOException {
  1166. GameDefinitionLoader.declare();
  1167. GameDefinitionLoader.loadNpcDefinitions();
  1168. File[] files = new File("./data/characters/details/").listFiles();
  1169. int searches = 0;
  1170. HashMap<String, String> map = new HashMap<>();
  1171. for (File file : files) {
  1172. Player player = new Player();
  1173. player.setUsername(file.getName().replace(".json", ""));
  1174. try {
  1175. if (PlayerDetails.loadDetails(player)) {
  1176.  
  1177. if (player.getLastLoginDay() > 259) {
  1178. if (player.getLastKnownUID() != null && !map.containsKey(player.getLastKnownUID())) {
  1179. map.put(player.getLastKnownUID(), player.getUsername());
  1180. } else {
  1181. System.out.println(player.getUsername() + " " + player.getLastKnownUID());
  1182. }
  1183. searches++;
  1184. }
  1185.  
  1186.  
  1187. }
  1188. } catch (Exception e) {
  1189. e.printStackTrace();
  1190. }
  1191. }
  1192.  
  1193. System.out.println("Searched thorugh " + searches + " files.");
  1194. }
  1195.  
  1196. public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
  1197.  
  1198. public static synchronized boolean load(Player p) throws Exception {
  1199. if (!PlayerDetails.loadDetails(p)) {
  1200. return false;
  1201. }
  1202.  
  1203. if (!PlayerContainer.loadDetails(p)) {
  1204. return false;
  1205. }
  1206.  
  1207. if (!PlayerFarming.loadDetails(p)) {
  1208. return false;
  1209. }
  1210.  
  1211. return true;
  1212. }
  1213.  
  1214. public static synchronized final void save(Player p) {
  1215. try {
  1216. new PlayerDetails(p).parseDetails();
  1217. new PlayerContainer(p).parseDetails(p);
  1218. new PlayerFarming(p).parseDetails(p);
  1219. } catch (Exception e) {
  1220. e.printStackTrace();
  1221. }
  1222. }
  1223. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement