Advertisement
Guest User

PLayersave

a guest
Aug 3rd, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 46.67 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. player.setLastLoginDay(Utility.getDayOfYear());
  367. player.setLastLoginYear(Utility.getYear());
  368.  
  369. } finally {
  370. if (reader != null) {
  371. reader.close();
  372. }
  373. }
  374.  
  375. return true;
  376. }
  377.  
  378. private final Item[] bank;
  379. private final int[] tabAmounts;
  380. private final Item[] inventory;
  381. private final Item[] equipment;
  382. private final Item[] bobInventory;
  383. private final Item[] shopItems;
  384. private final int[] shopPrices;
  385. private final byte[] pouches;
  386.  
  387. public PlayerContainer(Player player) {
  388. bank = player.getBank().getItems();
  389. tabAmounts = player.getBank().getTabAmounts();
  390. inventory = player.getInventory().getItems();
  391. equipment = player.getEquipment().getItems();
  392. bobInventory = (player.getSummoning().isFamilarBOB() ? player.getSummoning().getContainer().getItems() : null);
  393. shopItems = player.getPlayerShop().getItems();
  394. shopPrices = player.getPlayerShop().getPrices();
  395. pouches = player.getPouches();
  396. }
  397.  
  398. public void parseDetails(Player player) throws IOException {
  399. BufferedWriter writer = new BufferedWriter(new FileWriter("./data/characters/containers/" + player.getUsername() + ".json", false));
  400. try {
  401. writer.write(PlayerSave.GSON.toJson(this));
  402. writer.flush();
  403. } finally {
  404. writer.close();
  405. }
  406. }
  407. }
  408.  
  409. public static final class PlayerDetails {
  410.  
  411. public static boolean loadDetails(Player player) throws Exception {
  412. BufferedReader reader = null;
  413. try {
  414. File file = new File("./data/characters/details/" + NameUtil.uppercaseFirstLetter(player.getUsername()) + ".json");
  415.  
  416. if (!file.exists()) {
  417. return false;
  418. }
  419.  
  420. reader = new BufferedReader(new FileReader(file));
  421.  
  422. PlayerDetails details = PlayerSave.GSON.fromJson(reader, PlayerDetails.class);
  423. player.setUsername(details.username);
  424. player.setPassword(details.password);
  425. player.getLocation().setAs(new Location(details.x, details.y, details.z));
  426. player.setRights(details.rights);
  427.  
  428. if (details.lastKnownUID != null) {
  429. player.setLastKnownUID(details.lastKnownUID);
  430. }
  431.  
  432. player.setYellTitle(details.yellTitle);
  433. player.setPlayerTitle(details.playerTitle);
  434.  
  435. if (details.unlockedTitles != null && !details.unlockedTitles.isEmpty()) {
  436. player.unlockedTitles.addAll(details.unlockedTitles);
  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. player.getClient().setLogPlayer(details.logPackets);
  463. player.getRunEnergy().setRunning(details.running);
  464. player.setTeleblockTime(details.teleblockTime);
  465. player.getRareDropEP().setEp(details.rareDropEP);
  466. player.getRareDropEP().setReceived(details.rareDropsReceived);
  467. player.setLastKilledPlayers(details.lastKilledPlayers);
  468. player.setPin(details.pins);
  469. player.setIP(details.IP);
  470. player.setEmailAddress(details.emailAddress);
  471. player.setFullName(details.fullName);
  472. player.setRecovery(details.recovery);
  473. player.ipSet = details.ipSet;
  474. player.nameSet = details.nameSet;
  475. player.recoverySet = details.recoverySet;
  476. player.emailSet = details.emailSet;
  477. player.setCredits(details.credits);
  478. player.setMoneySpent(details.moneySpent);
  479.  
  480. //Set actual points first
  481. player.setMoneyPouch(details.moneyPouch);
  482. player.setBountyPoints(details.bountyPoints);
  483. player.setskillPoints(details.skillPoints);
  484. player.settriviaPoints(details.triviaPoints);
  485. player.setpvmPoints(details.pvmPoints);
  486. player.setbossPoints(details.bossPoints);
  487. player.setthievePoints(details.thievePoints);
  488. player.setfarmingPoints(details.farmingPoints);
  489. player.setwoodcuttingPoints(details.woodcuttingPoints);
  490. player.setfiremakingPoints(details.firemakingPoints);
  491. player.setfishingPoints(details.fishingPoints);
  492. player.setSmithingPoints(details.smithingPoints);
  493. player.setminingPoints(details.miningPoints);
  494. player.setfletchingPoints(details.fletchingPoints);
  495. player.setcraftingPoints(details.craftingPoints);
  496. player.setherblorePoints(details.herblorePoints);
  497. player.setpuroPoints(details.puroPoints);
  498. player.setrunecraftingPoints(details.runecraftingPoints);
  499. player.setprayerPoints(details.prayerPoints);
  500. player.setSlayerPoints(details.slayerPoints);
  501. player.setSufferingCharges(details.sufferingCharges);
  502. player.setBlackMarks(details.blackMarks);
  503. player.getMagic().setDragonFireShieldCharges(details.dragonFireShieldCharges);
  504. player.setVotePoints(details.votePoints);
  505. player.setDeaths(details.deaths);
  506. player.setKills(details.kills);
  507. player.setRogueKills(details.rogueKills);
  508. player.setRogueRecord(details.rogueRecord);
  509. player.setHunterKills(details.hunterKills);
  510. player.setHunterRecord(details.hunterRecord);
  511. player.setWeaponPoints(details.weaponPoints);
  512.  
  513. player.setMusicVolume((byte) details.musicVolume);
  514. player.setSoundVolume((byte) details.soundVolume);
  515.  
  516. if (details.degrading != null) {
  517. player.getItemDegrading().setDegrading(details.degrading);
  518. }
  519.  
  520. if (details.savedArrows != null) {
  521. player.getRanged().getSavedArrows().setItems(details.savedArrows);
  522. }
  523.  
  524. if(details.eloRating != 0) {
  525. player.eloRating = details.eloRating;
  526. }
  527.  
  528. else
  529. player.eloRating = EloRatingSystem.DEFAULT_ELO_START_RATING;
  530. player.setRecallLocation(details.recallLocation);
  531. player.setWantTrivia(details.wantsTrivia);
  532. player.setTriviaNotification(details.triviaNotification);
  533. if (details.attackStyle != null) {
  534. player.getEquipment().setAttackStyle(details.attackStyle);
  535. }
  536. if (details.attackType != null) {
  537. player.setAttackType(details.attackType);
  538. }
  539. if (details.recoilStage != -1) {
  540. player.getAttributes().set("recoilhits", Integer.valueOf(details.recoilStage));
  541. }
  542.  
  543. player.getSkulling().setLeft(details.left);
  544. if (player.getSkulling().isSkulled()) {
  545. player.getSkulling().setSkullIcon(player, details.skullIcon);
  546. }
  547. if (details.host != null) {
  548. player.getClient().setHost(details.host);
  549. }
  550. if (details.slayerDifficulty != null) {
  551. player.getSlayer().setCurrent(details.slayerDifficulty);
  552. }
  553. player.setUltimateIron(details.isUltimateIron);
  554. player.setMember(details.isMember);
  555. player.setIron(details.isIron);
  556. player.setExtreme(details.isExtreme);
  557. player.setYearCreated(details.yearCreated);
  558. player.setDayCreated(details.dayCreated);
  559.  
  560. player.setBoughtLargePlot(details.boughtLargePlot);
  561. player.setBoughtMediumPlot(details.boughtMediumPlot);
  562. player.setBoughtSmallPlot(details.boughtSmallPlot);
  563.  
  564. player.setLastLoginDay(details.lastLoginDay);
  565. player.setLastLoginYear(details.lastLoginYear);
  566. player.setScreenBrightness(details.bright);
  567. player.setMultipleMouseButtons(details.multipleMouse);
  568. player.setChatEffects(details.chatEffects);
  569. player.setSplitPrivateChat(details.splitPrivate);
  570. player.setTransparentPanel(details.transparentPanel);
  571. player.setTransparentChatbox(details.transparentChatbox);
  572. player.setSideStones(details.sideStones);
  573. player.setAcceptAid(details.acceptAid);
  574. player.getJadDetails().setStage(details.fightCavesWave);
  575. if (details.friends != null) {
  576. for (String i : details.friends) {
  577. player.getPrivateMessaging().getFriends().add(i);
  578. }
  579. }
  580.  
  581. if (details.ignores != null) {
  582. for (String i : details.ignores) {
  583. player.getPrivateMessaging().getIgnores().add(i);
  584. }
  585. }
  586.  
  587. if ((details.poisonDmg > 0) && (details.poisoned)) {
  588. player.poison(details.poisonDmg);
  589. }
  590.  
  591. player.setPouchPayment(details.pouchPayment);
  592.  
  593. player.setGender(details.gender);
  594.  
  595. if (details.appearance != null) {
  596. for (int i = 0; i < details.appearance.length; i++)
  597. player.getAppearance()[i] = details.appearance[i];
  598. }
  599. if (details.colours != null) {
  600. for (int i = 0; i < details.colours.length; i++)
  601. player.getColors()[i] = details.colours[i];
  602. }
  603. if (details.experience != null) {
  604. for (int i = 0; i < details.experience.length; i++) {
  605. player.getSkill().getExperience()[i] = details.experience[i];
  606. }
  607. }
  608. if (details.skillsLevel != null) {
  609. for (int i = 0; i < details.skillsLevel.length; i++) {
  610. player.getLevels()[i] = details.skillsLevel[i];
  611. }
  612. }
  613. if (details.experience != null) {
  614. for (int i = 0; i < details.experience.length; i++) {
  615. player.getMaxLevels()[i] = player.getSkill().getLevelForExperience(i, details.experience[i]);
  616. }
  617. }
  618.  
  619. if (details.gwkc != null) {
  620. player.getMinigames().setGWKC(details.gwkc);
  621. }
  622.  
  623. boolean banned = details.banned;
  624. boolean muted = details.muted;
  625. boolean jailed = details.jailed;
  626.  
  627. if ((banned) && (TimeUnit.MILLISECONDS.toSeconds(details.banLength - System.currentTimeMillis()) > 0 || details.banLength == -1)) {
  628. player.setBanned(true);
  629. player.setBanLength(details.banLength);
  630. }
  631.  
  632. if ((jailed) && (TimeUnit.MILLISECONDS.toSeconds(details.jailLength - System.currentTimeMillis()) > 0 || details.jailLength == -1)) {
  633. player.setJailed(true);
  634. player.setJailLength(details.jailLength);
  635. }
  636.  
  637. if ((muted) && (TimeUnit.MILLISECONDS.toSeconds(details.muteLength - System.currentTimeMillis()) > 0 || details.muteLength == -1)) {
  638. player.setMuted(true);
  639. player.setMuteLength(details.muteLength);
  640. }
  641.  
  642. if (details.magicBook > 0) {
  643. player.getMagic().setMagicBook(details.magicBook);
  644. }
  645.  
  646. if (details.prayerBook > 0) {
  647. player.setPrayerInterface(details.prayerBook);
  648. }
  649.  
  650. if (details.skillGoals != null) {
  651. player.setSkillGoals(details.skillGoals);
  652. }
  653.  
  654. if (details.playerAchievements != null) {
  655. player.getPlayerAchievements().putAll(details.playerAchievements);
  656. }
  657.  
  658. if (details.achievementsPoints > 0) {
  659. player.addAchievementPoints(details.achievementsPoints);
  660. }
  661.  
  662. if (details.expCounter > 0) {
  663. player.addCounterExp(details.expCounter);
  664. }
  665.  
  666. if (details.cluesCompleted != null) {
  667. player.setCluesCompleted(details.cluesCompleted);
  668. }
  669.  
  670. if (details.lastClanChat != null) {
  671. player.lastClanChat = details.lastClanChat;
  672. }
  673.  
  674. // set prayer book
  675.  
  676. player.setPrayerInterface(5608);
  677.  
  678. if (details.quickPrayers != null) {
  679. player.getPrayer().setQuickPrayers(details.quickPrayers);
  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. if (details.quickPrayers != null) {
  717. player.getPrayer().setQuickPrayers(details.quickPrayers);
  718. }
  719.  
  720. if (details.quests != null) {
  721. for (Quests attribute : details.quests.keySet()) {
  722. player.getQuestManager().questStages.put(attribute, details.quests.get(attribute));
  723. }
  724. }
  725.  
  726. if (details.pointsReset == false) {
  727. player.setWeaponPoints(0);
  728. player.setMoneyPouch((long) 0);
  729. player.setPestPoints(0);
  730. player.setBountyPoints(0);
  731. player.setskillPoints(0);
  732. player.settriviaPoints(0);
  733. player.setpvmPoints(0);
  734. player.setbossPoints(0);
  735. player.setthievePoints(0);
  736. player.setfarmingPoints(0);
  737. player.setwoodcuttingPoints(0);
  738. player.setfiremakingPoints(0);
  739. player.setfishingPoints(0);
  740. player.setSmithingPoints(0);
  741. player.setminingPoints(0);
  742. player.setfletchingPoints(0);
  743. player.setcraftingPoints(0);
  744. player.setherblorePoints(0);
  745. player.setpuroPoints(0);
  746. player.setrunecraftingPoints(0);
  747. player.setprayerPoints(0);
  748. player.setSlayerPoints(0);
  749. player.setCredits(0);
  750. player.setMoneySpent(0);
  751. player.setSufferingCharges(0);
  752. player.setBlackMarks(0);
  753. player.getMagic().setDragonFireShieldCharges(0);
  754. player.setVotePoints(0);
  755. player.setDeaths(0);
  756. player.setKills(0);
  757. player.setRogueKills(0);
  758. player.setRogueRecord(0);
  759. player.setHunterKills(0);
  760. player.setHunterRecord(0);
  761. player.pointsReset = true;
  762. save(player);
  763. }
  764.  
  765. return true;
  766. } finally {
  767. if (reader != null)
  768. try {
  769. reader.close();
  770. } catch (IOException e) {
  771. e.printStackTrace();
  772. }
  773. }
  774. }
  775.  
  776. private final String username;
  777. private final String password;
  778. private final int x;
  779. private final int y;
  780. private final int z;
  781. private final byte rights;
  782. private final String lastKnownUID;
  783. private final int[] cluesCompleted;
  784. private final String yellTitle;
  785. private final PlayerTitle playerTitle;
  786. private final List<PlayerTitle> unlockedTitles;
  787. private final boolean banned;
  788. private final long banLength;
  789. private final long moneyPouch;
  790. private final long jailLength;
  791. private final long shopCollection;
  792. private final String shopMotto;
  793. private final String shopColor;
  794. private final String lastClanChat;
  795. private final boolean muted;
  796. private final boolean isMember;
  797. private final boolean isExtreme;
  798. private final boolean isIron;
  799. private final boolean isUltimateIron;
  800. private final boolean jailed;
  801. private final long muteLength;
  802. private final int fightCavesWave;
  803. private final int magicBook;
  804. private final int prayerBook;
  805. private final boolean retaliate;
  806. private final boolean expLock;
  807. private final short[] gwkc;
  808. private final boolean poisoned;
  809. private final int poisonDmg;
  810. private final String slayerTask;
  811. private final byte slayerAmount;
  812. private final Slayer.SlayerDifficulty slayerDifficulty;
  813. private final short[] skillsLevel;
  814. private final double[] experience;
  815. private final byte gender;
  816. private final int[] appearance;
  817. private final byte[] colours;
  818. private final long left;
  819. private final int skullIcon;
  820. private final byte bright;
  821. private final byte multipleMouse;
  822. private final byte chatEffects;
  823. private final byte splitPrivate;
  824.  
  825. private byte transparentPanel;
  826. private byte transparentChatbox;
  827. private byte sideStones;
  828.  
  829. private final byte acceptAid;
  830. private final boolean pouchPayment;
  831. private final String[] friends;
  832. private final String[] ignores;
  833. private final int yearCreated;
  834. private final int dayCreated;
  835. private final int recoilStage;
  836. private final int spec;
  837. private final Equipment.AttackStyles attackStyle;
  838. private final AttackType attackType;
  839. private final double energy;
  840. private final int lastLoginDay;
  841. private final int lastLoginYear;
  842. private final String host;
  843. private final int votePoints;
  844. private final int triviaPoints;
  845. private final int pvmPoints;
  846. private final int bossPoints;
  847. private final int thievePoints;
  848. private final int farmingPoints;
  849. private final int woodcuttingPoints;
  850. private final int firemakingPoints;
  851. private final int fishingPoints;
  852. private final int smithingPoints;
  853. private final int miningPoints;
  854. private final int fletchingPoints;
  855. private final int craftingPoints;
  856. private final int herblorePoints;
  857. private final int puroPoints;
  858. private final int runecraftingPoints;
  859. private final int prayerPoints;
  860. private final ItemDegrading.DegradedItem[] degrading;
  861. private final byte dragonFireShieldCharges;
  862. private final int slayerPoints;
  863. private final int musicVolume;
  864. private final int soundVolume;
  865. private final Item[] savedArrows;
  866. private final boolean wantsTrivia;
  867. private final boolean triviaNotification;
  868. private final int deaths;
  869. private final int kills;
  870. private final int rogueKills;
  871. private final int rogueRecord;
  872. private final int hunterKills;
  873. private final int hunterRecord;
  874. private final int credits;
  875. private final int moneySpent;
  876. private final int bountyPoints;
  877. private final int skillPoints;
  878. private long lastLike;
  879. private byte likesGiven;
  880. private int likes, dislikes, profileViews;
  881. private final String fullName;
  882. private final String IP;
  883. private final String emailAddress;
  884. private final String recovery;
  885. private final String pins;
  886. private final boolean ipSet;
  887. private final boolean nameSet;
  888. private final boolean emailSet;
  889. private final boolean recoverySet;
  890. private final boolean running;
  891. private final boolean logPackets;
  892. private final int weaponPoints;
  893. private final int summoningTime;
  894. private final int summoningSpecialAmount;
  895. private final int summoningFamiliar;
  896. private final boolean summoningAttack;
  897. private final int pestPoints;
  898. private final int arenaPoints;
  899. private final int teleblockTime;
  900. private final int blackMarks;
  901. private final double rareDropEP;
  902. private final int rareDropsReceived;
  903. private final int[][] skillGoals;
  904. private final ArrayList<String> lastKilledPlayers;
  905. private final HashMap<AchievementList, Integer> playerAchievements;
  906. private final int achievementsPoints;
  907. private final Set<CreditPurchase> unlockedCredits;
  908. private final boolean[] quickPrayers;
  909. private final HashMap<Quests, Integer> quests;
  910.  
  911. private final HashMap<Object, Object> playerProperties;
  912. private final boolean pointsReset;
  913. private final double expCounter;
  914. private final int prestigePoints;
  915. private final int[] prestiges;
  916. private final ToxicBlowpipe blowpipe;
  917. private final TridentOfTheSeas seasTrident;
  918. private final TridentOfTheSwamp swampTrident;
  919. private final SerpentineHelmet serpentineHelmet;
  920. private final int eloRating;
  921. private final Location recallLocation;
  922. private final boolean boughtLargePlot;
  923. private final boolean boughtMediumPlot;
  924. private final boolean boughtSmallPlot;
  925. private final int sufferingCharges;
  926.  
  927. public PlayerDetails(Player player) {
  928. username = player.getUsername();
  929. password = player.getPassword();
  930. x = player.getLocation().getX();
  931. y = player.getLocation().getY();
  932. z = player.getLocation().getZ();
  933. rights = ((byte) player.getRights());
  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. triviaPoints = player.gettriviaPoints();
  1041.  
  1042. bossPoints = player.getbossPoints();
  1043.  
  1044. pvmPoints = player.getpvmPoints();
  1045.  
  1046. thievePoints = player.getthievePoints();
  1047.  
  1048. farmingPoints = player.getfarmingPoints();
  1049.  
  1050. woodcuttingPoints = player.getwoodcuttingPoints();
  1051.  
  1052. firemakingPoints = player.getfiremakingPoints();
  1053.  
  1054. fishingPoints = player.getfishingPoints();
  1055.  
  1056. smithingPoints = player.getSmithingPoints();
  1057.  
  1058. miningPoints = player.getminingPoints();
  1059.  
  1060. fletchingPoints = player.getfletchingPoints();
  1061.  
  1062. craftingPoints = player.getcraftingPoints();
  1063.  
  1064. herblorePoints = player.getherblorePoints();
  1065.  
  1066. puroPoints = player.getpuroPoints();
  1067.  
  1068. runecraftingPoints = player.getrunecraftingPoints();
  1069.  
  1070. prayerPoints = player.getprayerPoints();
  1071.  
  1072. musicVolume = player.getMusicVolume();
  1073.  
  1074. dragonFireShieldCharges = player.getMagic().getDragonFireShieldCharges();
  1075.  
  1076. degrading = player.getItemDegrading().getDegrading();
  1077.  
  1078. lastLoginDay = player.getLastLoginDay();
  1079. lastLoginYear = player.getLastLoginYear();
  1080.  
  1081. yearCreated = player.getYearCreated();
  1082. dayCreated = player.getDayCreated();
  1083.  
  1084. slayerPoints = player.getSlayerPoints();
  1085.  
  1086. sufferingCharges = player.getSufferingCharges();
  1087.  
  1088. slayerDifficulty = player.getSlayer().getCurrent();
  1089.  
  1090. if (player.getAttributes().get("recoilhits") != null)
  1091. recoilStage = player.getAttributes().getInt("recoilhits");
  1092. else {
  1093. recoilStage = -1;
  1094. }
  1095.  
  1096. bright = player.getScreenBrightness();
  1097. multipleMouse = player.getMultipleMouseButtons();
  1098. chatEffects = player.getChatEffectsEnabled();
  1099. splitPrivate = player.getSplitPrivateChat();
  1100. transparentPanel = player.getTransparentPanel();
  1101. transparentChatbox = player.getTransparentChatbox();
  1102. sideStones = player.getSideStones();
  1103. acceptAid = player.getAcceptAid();
  1104.  
  1105. savedArrows = player.getRanged().getSavedArrows().getItems();
  1106. skillGoals = player.getSkillGoals();
  1107. expCounter = player.getCounterExp();
  1108.  
  1109. wantsTrivia = player.isWantTrivia();
  1110. triviaNotification = player.isTriviaNotification();
  1111.  
  1112. playerAchievements = player.getPlayerAchievements();
  1113. achievementsPoints = player.getAchievementsPoints();
  1114.  
  1115. unlockedCredits = player.getUnlockedCredits();
  1116.  
  1117. int k = 0;
  1118. friends = new String[player.getPrivateMessaging().getFriends().size()];
  1119. for (String i : player.getPrivateMessaging().getFriends()) {
  1120. friends[k] = i;
  1121. k++;
  1122. }
  1123.  
  1124. k = 0;
  1125. ignores = new String[player.getPrivateMessaging().getIgnores().size()];
  1126. for (String i : player.getPrivateMessaging().getIgnores()) {
  1127. ignores[k] = i;
  1128. k++;
  1129. }
  1130.  
  1131. prestigePoints = player.getPrestigePoints();
  1132. prestiges = player.getSkillPrestiges();
  1133.  
  1134. blowpipe = player.getToxicBlowpipe();
  1135. seasTrident = player.getSeasTrident();
  1136. swampTrident = player.getSwampTrident();
  1137. serpentineHelmet = player.getSerpentineHelment();
  1138.  
  1139. playerProperties = new HashMap<>();
  1140.  
  1141. for (Object attribute : player.getAttributes().getAttributes().keySet()) {
  1142. if (String.valueOf(attribute).startsWith(PlayerProperties.ATTRIBUTE_KEY)) {
  1143. playerProperties.put(attribute, player.getAttributes().getAttributes().get(attribute));
  1144. }
  1145. }
  1146.  
  1147. pointsReset = true;
  1148.  
  1149. quests = new HashMap<>();
  1150.  
  1151. for (Quests attribute : player.getQuestManager().questStages.keySet()) {
  1152. playerProperties.put(attribute, player.getQuestManager().questStages.get(attribute));
  1153. }
  1154.  
  1155. }
  1156.  
  1157. public void parseDetails() throws Exception {
  1158. BufferedWriter writer = null;
  1159. try {
  1160. writer = new BufferedWriter(new FileWriter("./data/characters/details/" + username + ".json", false));
  1161. writer.write(PlayerSave.GSON.toJson(this));
  1162. writer.flush();
  1163. } finally {
  1164. if (writer != null)
  1165. writer.close();
  1166. }
  1167. }
  1168. }
  1169.  
  1170. public static void main(String[] args) throws FileNotFoundException, IOException {
  1171. GameDefinitionLoader.declare();
  1172. GameDefinitionLoader.loadNpcDefinitions();
  1173. File[] files = new File("./data/characters/details/").listFiles();
  1174. int searches = 0;
  1175. HashMap<String, String> map = new HashMap<>();
  1176. for (File file : files) {
  1177. Player player = new Player();
  1178. player.setUsername(file.getName().replace(".json", ""));
  1179. try {
  1180. if (PlayerDetails.loadDetails(player)) {
  1181.  
  1182. if (player.getLastLoginDay() > 259) {
  1183. if (player.getLastKnownUID() != null && !map.containsKey(player.getLastKnownUID())) {
  1184. map.put(player.getLastKnownUID(), player.getUsername());
  1185. } else {
  1186. System.out.println(player.getUsername() + " " + player.getLastKnownUID());
  1187. }
  1188. searches++;
  1189. }
  1190.  
  1191.  
  1192. }
  1193. } catch (Exception e) {
  1194. e.printStackTrace();
  1195. }
  1196. }
  1197.  
  1198. System.out.println("Searched thorugh " + searches + " files.");
  1199. }
  1200.  
  1201. public static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
  1202.  
  1203. public static synchronized boolean load(Player p) throws Exception {
  1204. if (!PlayerDetails.loadDetails(p)) {
  1205. return false;
  1206. }
  1207.  
  1208. if (!PlayerContainer.loadDetails(p)) {
  1209. return false;
  1210. }
  1211.  
  1212. if (!PlayerFarming.loadDetails(p)) {
  1213. return false;
  1214. }
  1215.  
  1216. return true;
  1217. }
  1218.  
  1219. public static synchronized final void save(Player p) {
  1220. try {
  1221. new PlayerDetails(p).parseDetails();
  1222. new PlayerContainer(p).parseDetails(p);
  1223. new PlayerFarming(p).parseDetails(p);
  1224. } catch (Exception e) {
  1225. e.printStackTrace();
  1226. }
  1227. }
  1228. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement