PageRenderTime 197ms CodeModel.GetById 1ms RepoModel.GetById 1ms app.codeStats 0ms

/src/com/gmail/nossr50/datatypes/PlayerProfile.java

https://github.com/krinsdeath/mcMMO
Java | 1157 lines | 1011 code | 49 blank | 97 comment | 141 complexity | 7911345eca01453f77f9116663321d86 MD5 | raw file
  1. package com.gmail.nossr50.datatypes;
  2. import java.io.BufferedReader;
  3. import java.io.BufferedWriter;
  4. import java.io.FileReader;
  5. import java.io.FileWriter;
  6. import java.util.HashMap;
  7. import java.util.ArrayList;
  8. import java.util.logging.Level;
  9. import java.util.logging.Logger;
  10. import org.bukkit.Bukkit;
  11. import org.bukkit.Location;
  12. import org.bukkit.entity.Player;
  13. import com.gmail.nossr50.config.LoadProperties;
  14. import com.gmail.nossr50.m;
  15. import com.gmail.nossr50.mcMMO;
  16. public class PlayerProfile
  17. {
  18. protected final Logger log = Logger.getLogger("Minecraft");
  19. //HUD
  20. private HUDType hud;
  21. //MISC
  22. private String party, myspawn, myspawnworld, invite;
  23. //TOGGLES
  24. private boolean spoutcraft = false, filling = false, xpbarlocked = false, placedAnvil = false, partyChatMode = false, adminChatMode = false, godMode = false, greenTerraMode, partyChatOnly = false, greenTerraInformed = true, berserkInformed = true, skullSplitterInformed = true, gigaDrillBreakerInformed = true,
  25. superBreakerInformed = true, serratedStrikesInformed = true, treeFellerInformed = true, dead, abilityuse = true, treeFellerMode, superBreakerMode, gigaDrillBreakerMode,
  26. serratedStrikesMode, hoePreparationMode = false, shovelPreparationMode = false, swordsPreparationMode = false, fistsPreparationMode = false, pickaxePreparationMode = false, axePreparationMode = false, skullSplitterMode, berserkMode;
  27. //TIMESTAMPS
  28. //ATS = (Time of) Activation Time Stamp
  29. //DATS = (Time of) Deactivation Time Stamp
  30. private int recentlyHurt = 0, archeryShotATS = 0, berserkATS = 0, berserkDATS = 0, gigaDrillBreakerATS = 0, gigaDrillBreakerDATS = 0,
  31. respawnATS = 0, mySpawnATS = 0, greenTerraATS = 0, greenTerraDATS = 0, superBreakerATS = 0, superBreakerDATS = 0, serratedStrikesATS = 0, serratedStrikesDATS = 0, treeFellerATS = 0, treeFellerDATS = 0,
  32. skullSplitterATS = 0, skullSplitterDATS = 0, hoePreparationATS = 0, axePreparationATS = 0, pickaxePreparationATS = 0, fistsPreparationATS = 0, shovelPreparationATS = 0, swordsPreparationATS = 0;
  33. private SkillType lastgained = null, skillLock = null;
  34. //MySQL STUFF
  35. private int xpbarinc=0, lastlogin=0, userid = 0, bleedticks = 0;
  36. //MAGIC STUFF
  37. private int mana = 0;
  38. private int greenDyeCycleSel = 0, greenDyeCycle = 0, blueDyeCycle = 0, blueDyeCycleSel = 0;
  39. public boolean dyeChanged = false;
  40. private String playername;
  41. //Time to HashMap this shiz
  42. HashMap<SkillType, Integer> skills = new HashMap<SkillType, Integer>(); //Skills and XP
  43. HashMap<SkillType, Integer> skillsXp = new HashMap<SkillType, Integer>(); //Skills and XP
  44. String location = "plugins/mcMMO/FlatFileStuff/mcmmo.users";
  45. public PlayerProfile(Player player)
  46. {
  47. hud = LoadProperties.defaulthud;
  48. //Setup the HashMap for the skills
  49. for(SkillType skillType : SkillType.values())
  50. {
  51. if(skillType != SkillType.ALL)
  52. {
  53. skills.put(skillType, 0);
  54. skillsXp.put(skillType, 0);
  55. }
  56. }
  57. playername = player.getName();
  58. if (LoadProperties.useMySQL)
  59. {
  60. if(!loadMySQL(player)) {
  61. addMySQLPlayer(player);
  62. loadMySQL(player);//This is probably not needed anymore, could just delete
  63. }
  64. } else {
  65. if(!load()) { addPlayer(); }
  66. }
  67. lastlogin = ((Long) (System.currentTimeMillis()/1000)).intValue();
  68. }
  69. public int getLastLogin()
  70. {
  71. return lastlogin;
  72. }
  73. public int getMySQLuserId()
  74. {
  75. return userid;
  76. }
  77. public boolean loadMySQL(Player p)
  78. {
  79. Integer id = 0;
  80. id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + p.getName() + "'");
  81. if(id == 0)
  82. return false;
  83. this.userid = id;
  84. if (id > 0) {
  85. HashMap<Integer, ArrayList<String>> huds = mcMMO.database.Read("SELECT hudtype FROM "+LoadProperties.MySQLtablePrefix+"huds WHERE user_id = " + id);
  86. if(huds.get(1) == null)
  87. {
  88. mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"huds (user_id) VALUES ("+id+")");
  89. } else {
  90. if(huds.get(1).get(0) != null)
  91. {
  92. for(HUDType x : HUDType.values())
  93. {
  94. if(x.toString().equals(huds.get(1).get(0)))
  95. {
  96. hud = x;
  97. }
  98. }
  99. } else {
  100. hud = LoadProperties.defaulthud;
  101. }
  102. }
  103. HashMap<Integer, ArrayList<String>> users = mcMMO.database.Read("SELECT lastlogin, party FROM "+LoadProperties.MySQLtablePrefix+"users WHERE id = " + id);
  104. //lastlogin = Integer.parseInt(users.get(1).get(0));
  105. party = users.get(1).get(1);
  106. HashMap<Integer, ArrayList<String>> spawn = mcMMO.database.Read("SELECT world, x, y, z FROM "+LoadProperties.MySQLtablePrefix+"spawn WHERE user_id = " + id);
  107. myspawnworld = spawn.get(1).get(0);
  108. myspawn = spawn.get(1).get(1) + "," + spawn.get(1).get(2) + "," + spawn.get(1).get(3);
  109. HashMap<Integer, ArrayList<String>> cooldowns = mcMMO.database.Read("SELECT mining, woodcutting, unarmed, herbalism, excavation, swords, axes FROM "+LoadProperties.MySQLtablePrefix+"cooldowns WHERE user_id = " + id);
  110. /*
  111. * I'm still learning MySQL, this is a fix for adding a new table
  112. * its not pretty but it works
  113. */
  114. if(cooldowns.get(1) == null)
  115. {
  116. mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")");
  117. }
  118. else
  119. {
  120. superBreakerDATS = Integer.valueOf(cooldowns.get(1).get(0));
  121. treeFellerDATS = Integer.valueOf(cooldowns.get(1).get(1));
  122. berserkDATS = Integer.valueOf(cooldowns.get(1).get(2));
  123. greenTerraDATS = Integer.valueOf(cooldowns.get(1).get(3));
  124. gigaDrillBreakerDATS = Integer.valueOf(cooldowns.get(1).get(4));
  125. serratedStrikesDATS = Integer.valueOf(cooldowns.get(1).get(5));
  126. skullSplitterDATS = Integer.valueOf(cooldowns.get(1).get(6));
  127. }
  128. HashMap<Integer, ArrayList<String>> stats = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM "+LoadProperties.MySQLtablePrefix+"skills WHERE user_id = " + id);
  129. skills.put(SkillType.TAMING, Integer.valueOf(stats.get(1).get(0)));
  130. skills.put(SkillType.MINING, Integer.valueOf(stats.get(1).get(1)));
  131. skills.put(SkillType.REPAIR, Integer.valueOf(stats.get(1).get(2)));
  132. skills.put(SkillType.WOODCUTTING, Integer.valueOf(stats.get(1).get(3)));
  133. skills.put(SkillType.UNARMED, Integer.valueOf(stats.get(1).get(4)));
  134. skills.put(SkillType.HERBALISM, Integer.valueOf(stats.get(1).get(5)));
  135. skills.put(SkillType.EXCAVATION, Integer.valueOf(stats.get(1).get(6)));
  136. skills.put(SkillType.ARCHERY, Integer.valueOf(stats.get(1).get(7)));
  137. skills.put(SkillType.SWORDS, Integer.valueOf(stats.get(1).get(8)));
  138. skills.put(SkillType.AXES, Integer.valueOf(stats.get(1).get(9)));
  139. skills.put(SkillType.ACROBATICS, Integer.valueOf(stats.get(1).get(10)));
  140. HashMap<Integer, ArrayList<String>> experience = mcMMO.database.Read("SELECT taming, mining, repair, woodcutting, unarmed, herbalism, excavation, archery, swords, axes, acrobatics FROM "+LoadProperties.MySQLtablePrefix+"experience WHERE user_id = " + id);
  141. skillsXp.put(SkillType.TAMING, Integer.valueOf(experience.get(1).get(0)));
  142. skillsXp.put(SkillType.MINING, Integer.valueOf(experience.get(1).get(1)));
  143. skillsXp.put(SkillType.REPAIR, Integer.valueOf(experience.get(1).get(2)));
  144. skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(experience.get(1).get(3)));
  145. skillsXp.put(SkillType.UNARMED, Integer.valueOf(experience.get(1).get(4)));
  146. skillsXp.put(SkillType.HERBALISM, Integer.valueOf(experience.get(1).get(5)));
  147. skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(experience.get(1).get(6)));
  148. skillsXp.put(SkillType.ARCHERY, Integer.valueOf(experience.get(1).get(7)));
  149. skillsXp.put(SkillType.SWORDS, Integer.valueOf(experience.get(1).get(8)));
  150. skillsXp.put(SkillType.AXES, Integer.valueOf(experience.get(1).get(9)));
  151. skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(experience.get(1).get(10)));
  152. return true;
  153. }
  154. else {
  155. return false;
  156. }
  157. }
  158. public void addMySQLPlayer(Player p) {
  159. Integer id = 0;
  160. mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"users (user, lastlogin) VALUES ('" + p.getName() + "'," + System.currentTimeMillis() / 1000 +")");
  161. id = mcMMO.database.GetInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + p.getName() + "'");
  162. mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"cooldowns (user_id) VALUES ("+id+")");
  163. mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"spawn (user_id) VALUES ("+id+")");
  164. mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"skills (user_id) VALUES ("+id+")");
  165. mcMMO.database.Write("INSERT INTO "+LoadProperties.MySQLtablePrefix+"experience (user_id) VALUES ("+id+")");
  166. this.userid = id;
  167. }
  168. public boolean load()
  169. {
  170. try {
  171. //Open the user file
  172. FileReader file = new FileReader(location);
  173. BufferedReader in = new BufferedReader(file);
  174. String line = "";
  175. while((line = in.readLine()) != null)
  176. {
  177. //Find if the line contains the player we want.
  178. String[] character = line.split(":");
  179. if(!character[0].equals(playername)){continue;}
  180. //Get Mining
  181. if(character.length > 1 && m.isInt(character[1]))
  182. skills.put(SkillType.MINING, Integer.valueOf(character[1]));
  183. //Myspawn
  184. if(character.length > 2)
  185. myspawn = character[2];
  186. //Party
  187. if(character.length > 3)
  188. party = character[3];
  189. //Mining XP
  190. if(character.length > 4 && m.isInt(character[4]))
  191. skillsXp.put(SkillType.MINING, Integer.valueOf(character[4]));
  192. if(character.length > 5 && m.isInt(character[5]))
  193. skills.put(SkillType.WOODCUTTING, Integer.valueOf(character[5]));
  194. if(character.length > 6 && m.isInt(character[6]))
  195. skillsXp.put(SkillType.WOODCUTTING, Integer.valueOf(character[6]));
  196. if(character.length > 7 && m.isInt(character[7]))
  197. skills.put(SkillType.REPAIR, Integer.valueOf(character[7]));
  198. if(character.length > 8 && m.isInt(character[8]))
  199. skills.put(SkillType.UNARMED, Integer.valueOf(character[8]));
  200. if(character.length > 9 && m.isInt(character[9]))
  201. skills.put(SkillType.HERBALISM, Integer.valueOf(character[9]));
  202. if(character.length > 10 && m.isInt(character[10]))
  203. skills.put(SkillType.EXCAVATION, Integer.valueOf(character[10]));
  204. if(character.length > 11 && m.isInt(character[11]))
  205. skills.put(SkillType.ARCHERY, Integer.valueOf(character[11]));
  206. if(character.length > 12 && m.isInt(character[12]))
  207. skills.put(SkillType.SWORDS, Integer.valueOf(character[12]));
  208. if(character.length > 13 && m.isInt(character[13]))
  209. skills.put(SkillType.AXES, Integer.valueOf(character[13]));
  210. if(character.length > 14 && m.isInt(character[14]))
  211. skills.put(SkillType.ACROBATICS, Integer.valueOf(character[14]));
  212. if(character.length > 15 && m.isInt(character[15]))
  213. skillsXp.put(SkillType.REPAIR, Integer.valueOf(character[15]));
  214. if(character.length > 16 && m.isInt(character[16]))
  215. skillsXp.put(SkillType.UNARMED, Integer.valueOf(character[16]));
  216. if(character.length > 17 && m.isInt(character[17]))
  217. skillsXp.put(SkillType.HERBALISM, Integer.valueOf(character[17]));
  218. if(character.length > 18 && m.isInt(character[18]))
  219. skillsXp.put(SkillType.EXCAVATION, Integer.valueOf(character[18]));
  220. if(character.length > 19 && m.isInt(character[19]))
  221. skillsXp.put(SkillType.ARCHERY, Integer.valueOf(character[19]));
  222. if(character.length > 20 && m.isInt(character[20]))
  223. skillsXp.put(SkillType.SWORDS, Integer.valueOf(character[20]));
  224. if(character.length > 21 && m.isInt(character[21]))
  225. skillsXp.put(SkillType.AXES, Integer.valueOf(character[21]));
  226. if(character.length > 22 && m.isInt(character[22]))
  227. skillsXp.put(SkillType.ACROBATICS, Integer.valueOf(character[22]));
  228. if(character.length > 23 && m.isInt(character[23]))
  229. myspawnworld = character[23];
  230. if(character.length > 24 && m.isInt(character[24]))
  231. skills.put(SkillType.TAMING, Integer.valueOf(character[24]));
  232. if(character.length > 25 && m.isInt(character[25]))
  233. skillsXp.put(SkillType.TAMING, Integer.valueOf(character[25]));
  234. if(character.length > 26)
  235. berserkDATS = Integer.valueOf(character[26]);
  236. if(character.length > 27)
  237. gigaDrillBreakerDATS = Integer.valueOf(character[27]);
  238. if(character.length > 28)
  239. treeFellerDATS = Integer.valueOf(character[28]);
  240. if(character.length > 29)
  241. greenTerraDATS = Integer.valueOf(character[29]);
  242. if(character.length > 30)
  243. serratedStrikesDATS = Integer.valueOf(character[30]);
  244. if(character.length > 31)
  245. skullSplitterDATS = Integer.valueOf(character[31]);
  246. if(character.length > 32)
  247. superBreakerDATS = Integer.valueOf(character[32]);
  248. if(character.length > 33)
  249. {
  250. for(HUDType x : HUDType.values())
  251. {
  252. if(x.toString().equalsIgnoreCase(character[33]))
  253. {
  254. hud = x;
  255. }
  256. }
  257. }
  258. in.close();
  259. return true;
  260. }
  261. in.close();
  262. } catch (Exception e) {
  263. log.log(Level.SEVERE, "Exception while reading "
  264. + location + " (Are you sure you formatted it correctly?)", e);
  265. }
  266. return false;
  267. }
  268. public void save()
  269. {
  270. Long timestamp = System.currentTimeMillis()/1000; //Convert to seconds
  271. // if we are using mysql save to database
  272. if (LoadProperties.useMySQL)
  273. {
  274. mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"huds SET "
  275. +" hudtype = '"+hud.toString()+"' WHERE user_id = "+this.userid);
  276. mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET lastlogin = " + timestamp.intValue() + " WHERE id = " + this.userid);
  277. mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"users SET party = '"+this.party+"' WHERE id = " +this.userid);
  278. mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"spawn SET world = '" + this.myspawnworld + "', x = " +getX()+", y = "+getY()+", z = "+getZ()+" WHERE user_id = "+this.userid);
  279. mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"cooldowns SET "
  280. +" mining = "+(superBreakerDATS)
  281. +", woodcutting = "+(treeFellerDATS)
  282. +", unarmed = "+(berserkDATS)
  283. +", herbalism = "+(greenTerraDATS)
  284. +", excavation = "+(gigaDrillBreakerDATS)
  285. +", swords = " +(serratedStrikesDATS)
  286. +", axes = "+(skullSplitterDATS)
  287. +" WHERE user_id = "+this.userid);
  288. mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"skills SET "
  289. +" taming = "+skills.get(SkillType.TAMING)
  290. +", mining = "+skills.get(SkillType.MINING)
  291. +", repair = "+skills.get(SkillType.REPAIR)
  292. +", woodcutting = "+skills.get(SkillType.WOODCUTTING)
  293. +", unarmed = "+skills.get(SkillType.UNARMED)
  294. +", herbalism = "+skills.get(SkillType.HERBALISM)
  295. +", excavation = "+skills.get(SkillType.EXCAVATION)
  296. +", archery = " +skills.get(SkillType.ARCHERY)
  297. +", swords = " +skills.get(SkillType.SWORDS)
  298. +", axes = "+skills.get(SkillType.AXES)
  299. +", acrobatics = "+skills.get(SkillType.ACROBATICS)
  300. +" WHERE user_id = "+this.userid);
  301. mcMMO.database.Write("UPDATE "+LoadProperties.MySQLtablePrefix+"experience SET "
  302. +" taming = "+skillsXp.get(SkillType.TAMING)
  303. +", mining = "+skillsXp.get(SkillType.MINING)
  304. +", repair = "+skillsXp.get(SkillType.REPAIR)
  305. +", woodcutting = "+skillsXp.get(SkillType.WOODCUTTING)
  306. +", unarmed = "+skillsXp.get(SkillType.UNARMED)
  307. +", herbalism = "+skillsXp.get(SkillType.HERBALISM)
  308. +", excavation = "+skillsXp.get(SkillType.EXCAVATION)
  309. +", archery = " +skillsXp.get(SkillType.ARCHERY)
  310. +", swords = " +skillsXp.get(SkillType.SWORDS)
  311. +", axes = "+skillsXp.get(SkillType.AXES)
  312. +", acrobatics = "+skillsXp.get(SkillType.ACROBATICS)
  313. +" WHERE user_id = "+this.userid);
  314. } else
  315. {
  316. // otherwise save to flatfile
  317. try {
  318. //Open the file
  319. FileReader file = new FileReader(location);
  320. BufferedReader in = new BufferedReader(file);
  321. StringBuilder writer = new StringBuilder();
  322. String line = "";
  323. //While not at the end of the file
  324. while((line = in.readLine()) != null)
  325. {
  326. //Read the line in and copy it to the output it's not the player
  327. //we want to edit
  328. if(!line.split(":")[0].equalsIgnoreCase(playername))
  329. {
  330. writer.append(line).append("\r\n");
  331. //Otherwise write the new player information
  332. } else {
  333. writer.append(playername + ":");
  334. writer.append(skills.get(SkillType.MINING) + ":");
  335. writer.append(myspawn + ":");
  336. writer.append(party+":");
  337. writer.append(skillsXp.get(SkillType.MINING) + ":");
  338. writer.append(skills.get(SkillType.WOODCUTTING) + ":");
  339. writer.append(skillsXp.get(SkillType.WOODCUTTING) + ":");
  340. writer.append(skills.get(SkillType.REPAIR) + ":");
  341. writer.append(skills.get(SkillType.UNARMED) + ":");
  342. writer.append(skills.get(SkillType.HERBALISM) + ":");
  343. writer.append(skills.get(SkillType.EXCAVATION) + ":");
  344. writer.append(skills.get(SkillType.ARCHERY) + ":");
  345. writer.append(skills.get(SkillType.SWORDS) + ":");
  346. writer.append(skills.get(SkillType.AXES) + ":");
  347. writer.append(skills.get(SkillType.ACROBATICS) + ":");
  348. writer.append(skillsXp.get(SkillType.REPAIR) + ":");
  349. writer.append(skillsXp.get(SkillType.UNARMED) + ":");
  350. writer.append(skillsXp.get(SkillType.HERBALISM) + ":");
  351. writer.append(skillsXp.get(SkillType.EXCAVATION) + ":");
  352. writer.append(skillsXp.get(SkillType.ARCHERY) + ":");
  353. writer.append(skillsXp.get(SkillType.SWORDS) + ":");
  354. writer.append(skillsXp.get(SkillType.AXES) + ":");
  355. writer.append(skillsXp.get(SkillType.ACROBATICS) + ":");
  356. writer.append(myspawnworld+":");
  357. writer.append(skills.get(SkillType.TAMING) + ":");
  358. writer.append(skillsXp.get(SkillType.TAMING) + ":");
  359. //Need to store the DATS of abilities nao
  360. //Berserk, Gigadrillbreaker, Tree Feller, Green Terra, Serrated Strikes, Skull Splitter, Super Breaker
  361. writer.append(String.valueOf(berserkDATS)+":");
  362. writer.append(String.valueOf(gigaDrillBreakerDATS)+":");
  363. writer.append(String.valueOf(treeFellerDATS)+":");
  364. writer.append(String.valueOf(greenTerraDATS)+":");
  365. writer.append(String.valueOf(serratedStrikesDATS)+":");
  366. writer.append(String.valueOf(skullSplitterDATS)+":");
  367. writer.append(String.valueOf(superBreakerDATS)+":");
  368. writer.append(hud.toString()+":");
  369. writer.append("\r\n");
  370. }
  371. }
  372. in.close();
  373. //Write the new file
  374. FileWriter out = new FileWriter(location);
  375. out.write(writer.toString());
  376. out.close();
  377. } catch (Exception e) {
  378. log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e);
  379. }
  380. }
  381. }
  382. public void addPlayer()
  383. {
  384. try {
  385. //Open the file to write the player
  386. FileWriter file = new FileWriter(location, true);
  387. BufferedWriter out = new BufferedWriter(file);
  388. //Add the player to the end
  389. out.append(playername + ":");
  390. out.append(0 + ":"); //mining
  391. out.append(myspawn+":");
  392. out.append(party+":");
  393. out.append(0+":"); //XP
  394. out.append(0+":"); //woodcutting
  395. out.append(0+":"); //woodCuttingXP
  396. out.append(0+":"); //repair
  397. out.append(0+":"); //unarmed
  398. out.append(0+":"); //herbalism
  399. out.append(0+":"); //excavation
  400. out.append(0+":"); //archery
  401. out.append(0+":"); //swords
  402. out.append(0+":"); //axes
  403. out.append(0+":"); //acrobatics
  404. out.append(0+":"); //repairXP
  405. out.append(0+":"); //unarmedXP
  406. out.append(0+":"); //herbalismXP
  407. out.append(0+":"); //excavationXP
  408. out.append(0+":"); //archeryXP
  409. out.append(0+":"); //swordsXP
  410. out.append(0+":"); //axesXP
  411. out.append(0+":"); //acrobaticsXP
  412. out.append(myspawnworld+":");
  413. out.append(0+":"); //taming
  414. out.append(0+":"); //tamingXP
  415. out.append(0+":"); //DATS
  416. out.append(0+":"); //DATS
  417. out.append(0+":"); //DATS
  418. out.append(0+":"); //DATS
  419. out.append(0+":"); //DATS
  420. out.append(0+":"); //DATS
  421. out.append(0+":"); //DATS
  422. out.append(LoadProperties.defaulthud.toString()+":");//HUD
  423. //Add more in the same format as the line above
  424. out.newLine();
  425. out.close();
  426. } catch (Exception e) {
  427. log.log(Level.SEVERE, "Exception while writing to " + location + " (Are you sure you formatted it correctly?)", e);
  428. }
  429. }
  430. public void toggleSpoutEnabled()
  431. {
  432. spoutcraft = !spoutcraft;
  433. }
  434. public boolean isFilling()
  435. {
  436. return filling;
  437. }
  438. public void toggleFilling()
  439. {
  440. filling = !filling;
  441. }
  442. public HUDType getHUDType()
  443. {
  444. return hud;
  445. }
  446. public void setHUDType(HUDType type)
  447. {
  448. hud = type;
  449. }
  450. public boolean getXpBarLocked()
  451. {
  452. return xpbarlocked;
  453. }
  454. public void toggleXpBarLocked()
  455. {
  456. xpbarlocked = !xpbarlocked;
  457. }
  458. public int getXpBarInc()
  459. {
  460. return xpbarinc;
  461. }
  462. public void setXpBarInc(int newvalue)
  463. {
  464. xpbarinc = newvalue;
  465. }
  466. public void setSkillLock(SkillType newvalue)
  467. {
  468. skillLock = newvalue;
  469. }
  470. public SkillType getSkillLock()
  471. {
  472. return skillLock;
  473. }
  474. public void setLastGained(SkillType newvalue)
  475. {
  476. lastgained = newvalue;
  477. }
  478. public SkillType getLastGained()
  479. {
  480. return lastgained;
  481. }
  482. public boolean getAdminChatMode() {return adminChatMode;}
  483. public boolean getPartyChatMode() {return partyChatMode;}
  484. public boolean getGodMode() {return godMode;}
  485. public void togglePlacedAnvil()
  486. {
  487. placedAnvil = !placedAnvil;
  488. }
  489. public Boolean getPlacedAnvil()
  490. {
  491. return placedAnvil;
  492. }
  493. public void toggleAdminChat()
  494. {
  495. adminChatMode = !adminChatMode;
  496. }
  497. public void toggleGodMode()
  498. {
  499. godMode = !godMode;
  500. }
  501. public void togglePartyChat()
  502. {
  503. partyChatMode = !partyChatMode;
  504. }
  505. public void setMana(int newvalue)
  506. {
  507. mana = newvalue;
  508. }
  509. public int getCurrentMana()
  510. {
  511. return mana;
  512. }
  513. public void setDyeChanged(Boolean bool)
  514. {
  515. dyeChanged = bool;
  516. }
  517. public boolean getDyeChanged()
  518. {
  519. return dyeChanged;
  520. }
  521. public void setBlueDyeCycle(int newvalue)
  522. {
  523. blueDyeCycle = newvalue;
  524. }
  525. public int getBlueDyeCycle()
  526. {
  527. return blueDyeCycle;
  528. }
  529. public void setBlueDyeCycleSel(int newvalue)
  530. {
  531. blueDyeCycleSel = newvalue;
  532. }
  533. public int getBlueDyeCycleSel()
  534. {
  535. return blueDyeCycleSel;
  536. }
  537. public void setGreenDyeCycle(int newvalue)
  538. {
  539. greenDyeCycle = newvalue;
  540. }
  541. public int getGreenDyeCycle()
  542. {
  543. return greenDyeCycle;
  544. }
  545. public void setGreenDyeCycleSel(int newvalue)
  546. {
  547. greenDyeCycleSel = newvalue;
  548. }
  549. public int getGreenDyeCycleSel()
  550. {
  551. return greenDyeCycleSel;
  552. }
  553. public boolean isPlayer(String player)
  554. {
  555. return player.equals(playername);
  556. }
  557. public boolean getPartyChatOnlyToggle(){return partyChatOnly;}
  558. public void togglePartyChatOnly(){partyChatOnly = !partyChatOnly;}
  559. public boolean getAbilityUse(){
  560. return abilityuse;
  561. }
  562. public void toggleAbilityUse()
  563. {
  564. abilityuse = !abilityuse;
  565. }
  566. public long getMySpawnATS(){
  567. return mySpawnATS;
  568. }
  569. public void setMySpawnATS(long newvalue)
  570. {
  571. mySpawnATS = (int) (newvalue/1000);
  572. }
  573. public void decreaseBleedTicks()
  574. {
  575. bleedticks--;
  576. }
  577. public Integer getBleedTicks(){
  578. return bleedticks;
  579. }
  580. public void setBleedTicks(Integer newvalue){
  581. bleedticks = newvalue;
  582. }
  583. public void addBleedTicks(Integer newvalue){
  584. bleedticks+=newvalue;
  585. }
  586. /*
  587. * EXPLOIT PREVENTION
  588. */
  589. public long getRespawnATS() {return respawnATS;}
  590. public void setRespawnATS(long newvalue) {respawnATS = (int) (newvalue/1000);}
  591. /*
  592. * ARCHERY NERF STUFF
  593. */
  594. public long getArcheryShotATS() {return archeryShotATS;}
  595. public void setArcheryShotATS(long newvalue) {archeryShotATS = (int) (newvalue/1000);}
  596. /*
  597. * HOE PREPARATION
  598. */
  599. public boolean getHoePreparationMode(){
  600. return hoePreparationMode;
  601. }
  602. public void setHoePreparationMode(Boolean bool){
  603. hoePreparationMode = bool;
  604. }
  605. public long getHoePreparationATS(){
  606. return hoePreparationATS;
  607. }
  608. public void setHoePreparationATS(long newvalue){
  609. hoePreparationATS = (int) (newvalue/1000);
  610. }
  611. /*
  612. * SWORDS PREPARATION
  613. */
  614. public boolean getSwordsPreparationMode(){
  615. return swordsPreparationMode;
  616. }
  617. public void setSwordsPreparationMode(Boolean bool){
  618. swordsPreparationMode = bool;
  619. }
  620. public long getSwordsPreparationATS(){
  621. return swordsPreparationATS;
  622. }
  623. public void setSwordsPreparationATS(long newvalue){
  624. swordsPreparationATS = (int) (newvalue/1000);
  625. }
  626. /*
  627. * SHOVEL PREPARATION
  628. */
  629. public boolean getShovelPreparationMode(){
  630. return shovelPreparationMode;
  631. }
  632. public void setShovelPreparationMode(Boolean bool){
  633. shovelPreparationMode = bool;
  634. }
  635. public long getShovelPreparationATS(){
  636. return shovelPreparationATS;
  637. }
  638. public void setShovelPreparationATS(long newvalue){
  639. shovelPreparationATS = (int) (newvalue/1000);
  640. }
  641. /*
  642. * FISTS PREPARATION
  643. */
  644. public boolean getFistsPreparationMode(){
  645. return fistsPreparationMode;
  646. }
  647. public void setFistsPreparationMode(Boolean bool){
  648. fistsPreparationMode = bool;
  649. }
  650. public long getFistsPreparationATS(){
  651. return fistsPreparationATS;
  652. }
  653. public void setFistsPreparationATS(long newvalue){
  654. fistsPreparationATS = (int) (newvalue/1000);
  655. }
  656. /*
  657. * AXE PREPARATION
  658. */
  659. public boolean getAxePreparationMode(){
  660. return axePreparationMode;
  661. }
  662. public void setAxePreparationMode(Boolean bool){
  663. axePreparationMode = bool;
  664. }
  665. public long getAxePreparationATS(){
  666. return axePreparationATS;
  667. }
  668. public void setAxePreparationATS(long newvalue){
  669. axePreparationATS = (int) (newvalue/1000);
  670. }
  671. /*
  672. * PICKAXE PREPARATION
  673. */
  674. public boolean getPickaxePreparationMode(){
  675. return pickaxePreparationMode;
  676. }
  677. public void setPickaxePreparationMode(Boolean bool){
  678. pickaxePreparationMode = bool;
  679. }
  680. public long getPickaxePreparationATS(){
  681. return pickaxePreparationATS;
  682. }
  683. public void setPickaxePreparationATS(long newvalue){
  684. pickaxePreparationATS = (int) (newvalue/1000);
  685. }
  686. /*
  687. * GREEN TERRA MODE
  688. */
  689. public boolean getGreenTerraInformed() {return greenTerraInformed;}
  690. public void setGreenTerraInformed(Boolean bool){
  691. greenTerraInformed = bool;
  692. }
  693. public boolean getGreenTerraMode(){
  694. return greenTerraMode;
  695. }
  696. public void setGreenTerraMode(Boolean bool){
  697. greenTerraMode = bool;
  698. }
  699. public long getGreenTerraActivatedTimeStamp() {return greenTerraATS;}
  700. public void setGreenTerraActivatedTimeStamp(Long newvalue){
  701. greenTerraATS = (int) (newvalue/1000);
  702. }
  703. public long getGreenTerraDeactivatedTimeStamp() {return greenTerraDATS;}
  704. public void setGreenTerraDeactivatedTimeStamp(Long newvalue){
  705. greenTerraDATS = (int) (newvalue/1000);
  706. save();
  707. }
  708. /*
  709. * BERSERK MODE
  710. */
  711. public boolean getBerserkInformed() {return berserkInformed;}
  712. public void setBerserkInformed(Boolean bool){
  713. berserkInformed = bool;
  714. }
  715. public boolean getBerserkMode(){
  716. return berserkMode;
  717. }
  718. public void setBerserkMode(Boolean bool){
  719. berserkMode = bool;
  720. }
  721. public long getBerserkActivatedTimeStamp() {return berserkATS;}
  722. public void setBerserkActivatedTimeStamp(Long newvalue){
  723. berserkATS = (int) (newvalue/1000);
  724. }
  725. public long getBerserkDeactivatedTimeStamp() {return berserkDATS;}
  726. public void setBerserkDeactivatedTimeStamp(Long newvalue){
  727. berserkDATS = (int) (newvalue/1000);
  728. save();
  729. }
  730. /*
  731. * SKULL SPLITTER
  732. */
  733. public boolean getSkullSplitterInformed() {return skullSplitterInformed;}
  734. public void setSkullSplitterInformed(Boolean bool){
  735. skullSplitterInformed = bool;
  736. }
  737. public boolean getSkullSplitterMode(){
  738. return skullSplitterMode;
  739. }
  740. public void setSkullSplitterMode(Boolean bool){
  741. skullSplitterMode = bool;
  742. }
  743. public long getSkullSplitterActivatedTimeStamp() {return skullSplitterATS;}
  744. public void setSkullSplitterActivatedTimeStamp(Long newvalue){
  745. skullSplitterATS = (int) (newvalue/1000);
  746. }
  747. public long getSkullSplitterDeactivatedTimeStamp() {return skullSplitterDATS;}
  748. public void setSkullSplitterDeactivatedTimeStamp(Long newvalue){
  749. skullSplitterDATS = (int) (newvalue/1000);
  750. save();
  751. }
  752. /*
  753. * SERRATED STRIKES
  754. */
  755. public boolean getSerratedStrikesInformed() {return serratedStrikesInformed;}
  756. public void setSerratedStrikesInformed(Boolean bool){
  757. serratedStrikesInformed = bool;
  758. }
  759. public boolean getSerratedStrikesMode(){
  760. return serratedStrikesMode;
  761. }
  762. public void setSerratedStrikesMode(Boolean bool){
  763. serratedStrikesMode = bool;
  764. }
  765. public long getSerratedStrikesActivatedTimeStamp() {return serratedStrikesATS;}
  766. public void setSerratedStrikesActivatedTimeStamp(Long newvalue){
  767. serratedStrikesATS = (int) (newvalue/1000);
  768. }
  769. public long getSerratedStrikesDeactivatedTimeStamp() {return serratedStrikesDATS;}
  770. public void setSerratedStrikesDeactivatedTimeStamp(Long newvalue){
  771. serratedStrikesDATS = (int) (newvalue/1000);
  772. save();
  773. }
  774. /*
  775. * GIGA DRILL BREAKER
  776. */
  777. public boolean getGigaDrillBreakerInformed() {return gigaDrillBreakerInformed;}
  778. public void setGigaDrillBreakerInformed(Boolean bool){
  779. gigaDrillBreakerInformed = bool;
  780. }
  781. public boolean getGigaDrillBreakerMode(){
  782. return gigaDrillBreakerMode;
  783. }
  784. public void setGigaDrillBreakerMode(Boolean bool){
  785. gigaDrillBreakerMode = bool;
  786. }
  787. public long getGigaDrillBreakerActivatedTimeStamp() {return gigaDrillBreakerATS;}
  788. public void setGigaDrillBreakerActivatedTimeStamp(Long newvalue){
  789. gigaDrillBreakerATS = (int) (newvalue/1000);
  790. }
  791. public long getGigaDrillBreakerDeactivatedTimeStamp() {return gigaDrillBreakerDATS;}
  792. public void setGigaDrillBreakerDeactivatedTimeStamp(Long newvalue){
  793. gigaDrillBreakerDATS = (int) (newvalue/1000);
  794. save();
  795. }
  796. /*
  797. * TREE FELLER STUFF
  798. */
  799. public boolean getTreeFellerInformed() {return treeFellerInformed;}
  800. public void setTreeFellerInformed(Boolean bool){
  801. treeFellerInformed = bool;
  802. }
  803. public boolean getTreeFellerMode(){
  804. return treeFellerMode;
  805. }
  806. public void setTreeFellerMode(Boolean bool){
  807. treeFellerMode = bool;
  808. }
  809. public long getTreeFellerActivatedTimeStamp() {return treeFellerATS;}
  810. public void setTreeFellerActivatedTimeStamp(Long newvalue){
  811. treeFellerATS = (int) (newvalue/1000);
  812. }
  813. public long getTreeFellerDeactivatedTimeStamp() {return treeFellerDATS;}
  814. public void setTreeFellerDeactivatedTimeStamp(Long newvalue){
  815. treeFellerDATS = (int) (newvalue/1000);
  816. save();
  817. }
  818. /*
  819. * MINING
  820. */
  821. public boolean getSuperBreakerInformed() {return superBreakerInformed;}
  822. public void setSuperBreakerInformed(Boolean bool){
  823. superBreakerInformed = bool;
  824. }
  825. public boolean getSuperBreakerMode(){
  826. return superBreakerMode;
  827. }
  828. public void setSuperBreakerMode(Boolean bool){
  829. superBreakerMode = bool;
  830. }
  831. public long getSuperBreakerActivatedTimeStamp() {return superBreakerATS;}
  832. public void setSuperBreakerActivatedTimeStamp(Long newvalue){
  833. superBreakerATS = (int) (newvalue/1000);
  834. }
  835. public long getSuperBreakerDeactivatedTimeStamp() {return superBreakerDATS;}
  836. public void setSuperBreakerDeactivatedTimeStamp(Long newvalue){
  837. superBreakerDATS = (int) (newvalue/1000);
  838. save();
  839. }
  840. public long getRecentlyHurt(){
  841. return recentlyHurt;
  842. }
  843. public void setRecentlyHurt(long newvalue){
  844. recentlyHurt = (int) (newvalue/1000);
  845. }
  846. public void skillUp(SkillType skillType, int newvalue)
  847. {
  848. skills.put(skillType, skills.get(skillType)+newvalue);
  849. save();
  850. }
  851. public Integer getSkillLevel(SkillType skillType)
  852. {
  853. return skills.get(skillType);
  854. }
  855. public Integer getSkillXpLevel(SkillType skillType)
  856. {
  857. return skillsXp.get(skillType);
  858. }
  859. public void resetSkillXp(SkillType skillType)
  860. {
  861. skills.put(skillType, 0);
  862. }
  863. /**
  864. * Adds XP to the player, this ignores skill modifiers
  865. * @param skillType The skill to add XP to
  866. * @param newvalue The amount of XP to add
  867. */
  868. public void addXPOverride(SkillType skillType, int newvalue)
  869. {
  870. if(skillType == SkillType.ALL)
  871. {
  872. for(SkillType x : SkillType.values())
  873. {
  874. if(x == SkillType.ALL)
  875. continue;
  876. skillsXp.put(x, skillsXp.get(x)+newvalue);
  877. }
  878. } else {
  879. int xp = newvalue;
  880. xp=xp*LoadProperties.xpGainMultiplier;
  881. skillsXp.put(skillType, skillsXp.get(skillType)+xp);
  882. lastgained = skillType;
  883. }
  884. }
  885. /**
  886. * Adds XP to the player, this is affected by skill modifiers
  887. * @param skillType The skill to add XP to
  888. * @param newvalue The amount of XP to add
  889. */
  890. public void addXP(SkillType skillType, int newvalue)
  891. {
  892. if(skillType == SkillType.ALL)
  893. {
  894. for(SkillType x : SkillType.values())
  895. {
  896. if(x == SkillType.ALL)
  897. continue;
  898. skillsXp.put(x, skillsXp.get(x)+newvalue);
  899. }
  900. } else {
  901. int xp = newvalue;
  902. switch(skillType)
  903. {
  904. case TAMING:
  905. xp=(int) (xp/LoadProperties.tamingxpmodifier);
  906. break;
  907. case MINING:
  908. xp=(int) (xp/LoadProperties.miningxpmodifier);
  909. break;
  910. case WOODCUTTING:
  911. xp=(int) (xp/LoadProperties.woodcuttingxpmodifier);
  912. break;
  913. case REPAIR:
  914. xp=(int) (xp/LoadProperties.repairxpmodifier);
  915. break;
  916. case HERBALISM:
  917. xp=(int) (xp/LoadProperties.herbalismxpmodifier);
  918. break;
  919. case ACROBATICS:
  920. xp=(int) (xp/LoadProperties.acrobaticsxpmodifier);
  921. break;
  922. case SWORDS:
  923. xp=(int) (xp/LoadProperties.swordsxpmodifier);
  924. break;
  925. case ARCHERY:
  926. xp=(int) (xp/LoadProperties.archeryxpmodifier);
  927. break;
  928. case UNARMED:
  929. xp=(int) (xp/LoadProperties.unarmedxpmodifier);
  930. break;
  931. case EXCAVATION:
  932. xp=(int) (xp/LoadProperties.excavationxpmodifier);
  933. break;
  934. case AXES:
  935. xp=(int) (xp/LoadProperties.axesxpmodifier);
  936. break;
  937. }
  938. xp=xp*LoadProperties.xpGainMultiplier;
  939. skillsXp.put(skillType, skillsXp.get(skillType)+xp);
  940. lastgained = skillType;
  941. }
  942. //save();
  943. }
  944. public void removeXP(SkillType skillType, int newvalue)
  945. {
  946. if(skillType == SkillType.ALL)
  947. {
  948. skillsXp.put(SkillType.TAMING, skillsXp.get(SkillType.TAMING)-newvalue);
  949. skillsXp.put(SkillType.MINING, skillsXp.get(SkillType.MINING)-newvalue);
  950. skillsXp.put(SkillType.WOODCUTTING, skillsXp.get(SkillType.WOODCUTTING)-newvalue);
  951. skillsXp.put(SkillType.REPAIR, skillsXp.get(SkillType.REPAIR)-newvalue);
  952. skillsXp.put(SkillType.HERBALISM, skillsXp.get(SkillType.HERBALISM)-newvalue);
  953. skillsXp.put(SkillType.ACROBATICS, skillsXp.get(SkillType.ACROBATICS)-newvalue);
  954. skillsXp.put(SkillType.SWORDS, skillsXp.get(SkillType.SWORDS)-newvalue);
  955. skillsXp.put(SkillType.ARCHERY, skillsXp.get(SkillType.ARCHERY)-newvalue);
  956. skillsXp.put(SkillType.UNARMED, skillsXp.get(SkillType.UNARMED)-newvalue);
  957. skillsXp.put(SkillType.EXCAVATION, skillsXp.get(SkillType.EXCAVATION)-newvalue);
  958. skillsXp.put(SkillType.AXES, skillsXp.get(SkillType.AXES)-newvalue);
  959. } else {
  960. skillsXp.put(skillType, skillsXp.get(skillType)-newvalue);
  961. }
  962. //save();
  963. }
  964. public void acceptInvite()
  965. {
  966. party = invite;
  967. invite = "";
  968. }
  969. public void modifyInvite(String invitename)
  970. {
  971. invite = invitename;
  972. }
  973. public String getInvite() { return invite; }
  974. public void modifyskill(SkillType skillType, int newvalue)
  975. {
  976. if(skillType == SkillType.ALL)
  977. {
  978. skills.put(SkillType.TAMING, newvalue);
  979. skills.put(SkillType.MINING, newvalue);
  980. skills.put(SkillType.WOODCUTTING, newvalue);
  981. skills.put(SkillType.REPAIR, newvalue);
  982. skills.put(SkillType.HERBALISM, newvalue);
  983. skills.put(SkillType.ACROBATICS, newvalue);
  984. skills.put(SkillType.SWORDS, newvalue);
  985. skills.put(SkillType.ARCHERY, newvalue);
  986. skills.put(SkillType.UNARMED, newvalue);
  987. skills.put(SkillType.EXCAVATION, newvalue);
  988. skills.put(SkillType.AXES, newvalue);
  989. skillsXp.put(SkillType.TAMING, 0);
  990. skillsXp.put(SkillType.MINING, 0);
  991. skillsXp.put(SkillType.WOODCUTTING, 0);
  992. skillsXp.put(SkillType.REPAIR, 0);
  993. skillsXp.put(SkillType.HERBALISM, 0);
  994. skillsXp.put(SkillType.ACROBATICS, 0);
  995. skillsXp.put(SkillType.SWORDS, 0);
  996. skillsXp.put(SkillType.ARCHERY, 0);
  997. skillsXp.put(SkillType.UNARMED, 0);
  998. skillsXp.put(SkillType.EXCAVATION, 0);
  999. skillsXp.put(SkillType.AXES, 0);
  1000. } else {
  1001. skills.put(skillType, newvalue);
  1002. skillsXp.put(skillType, newvalue);
  1003. }
  1004. save();
  1005. }
  1006. public Integer getXpToLevel(SkillType skillType)
  1007. {
  1008. return (int) ((1020+(skills.get(skillType) * 20)));
  1009. }
  1010. //Store the player's party
  1011. public void setParty(String newParty)
  1012. {
  1013. party = newParty;
  1014. save();
  1015. }
  1016. //Retrieve the player's party
  1017. public String getParty() {return party;}
  1018. //Remove party
  1019. public void removeParty() {
  1020. party = null;
  1021. save();
  1022. }
  1023. //Retrieve whether or not the player is in a party
  1024. public boolean inParty()
  1025. {
  1026. if(party != null && !party.equals("") && !party.equals("null")){
  1027. return true;
  1028. } else {
  1029. return false;
  1030. }
  1031. }
  1032. //Retrieve whether or not the player has an invite
  1033. public boolean hasPartyInvite() {
  1034. if(invite != null && !invite.equals("") && !invite.equals("null")){
  1035. return true;
  1036. } else {
  1037. return false;
  1038. }
  1039. }
  1040. public String getMySpawnWorld()
  1041. {
  1042. if(myspawnworld != null && !myspawnworld.equals("") && !myspawnworld.equals("null")){
  1043. return myspawnworld;
  1044. } else {
  1045. return Bukkit.getServer().getWorlds().get(0).toString();
  1046. }
  1047. }
  1048. //Save a users spawn location
  1049. public void setMySpawn(double x, double y, double z, String myspawnworldlocation){
  1050. myspawn = x+","+y+","+z;
  1051. myspawnworld = myspawnworldlocation;
  1052. save();
  1053. }
  1054. public String getX(){
  1055. if(myspawn != null)
  1056. {
  1057. String[] split = myspawn.split(",");
  1058. return split[0];
  1059. }
  1060. else
  1061. return null;
  1062. }
  1063. public String getY(){
  1064. if(myspawn != null)
  1065. {
  1066. String[] split = myspawn.split(",");
  1067. return split[1];
  1068. }
  1069. else
  1070. return null;
  1071. }
  1072. public String getZ(){
  1073. if(myspawn != null)
  1074. {
  1075. String[] split = myspawn.split(",");
  1076. return split[2];
  1077. }
  1078. else
  1079. return null;
  1080. }
  1081. public boolean isDead(){
  1082. return dead;
  1083. }
  1084. public Location getMySpawn(Player player)
  1085. {
  1086. Location loc = null;
  1087. if(myspawn != null)
  1088. {
  1089. if(m.isDouble(getX()) && m.isDouble(getY()) && m.isDouble(getZ()))
  1090. loc = new Location(player.getWorld(),(Double.parseDouble(getX())), Double.parseDouble(getY()), Double.parseDouble(getZ()));
  1091. else
  1092. return null;
  1093. } else
  1094. return null;
  1095. loc.setYaw(0);
  1096. loc.setPitch(0);
  1097. if(loc.getX() != 0 && loc.getY() != 0 && loc.getZ() != 0 && loc.getWorld() != null)
  1098. {
  1099. if(Bukkit.getServer().getWorld(this.getMySpawnWorld()) != null)
  1100. loc.setWorld(Bukkit.getServer().getWorld(this.getMySpawnWorld()));
  1101. else
  1102. loc.setWorld(Bukkit.getServer().getWorlds().get(0));
  1103. return loc;
  1104. } else {
  1105. return null;
  1106. }
  1107. }
  1108. }