ExperienceAPI.java 48 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152
  1. //package com.gmail.nossr50.api;
  2. //
  3. //import com.gmail.nossr50.api.exceptions.*;
  4. //import com.gmail.nossr50.datatypes.experience.FormulaType;
  5. //import com.gmail.nossr50.datatypes.experience.XPGainReason;
  6. //import com.gmail.nossr50.datatypes.experience.XPGainSource;
  7. //import com.gmail.nossr50.datatypes.player.McMMOPlayer;
  8. //import com.gmail.nossr50.datatypes.player.PlayerProfile;
  9. //import com.gmail.nossr50.datatypes.skills.PrimarySkillType;
  10. //import com.gmail.nossr50.mcMMO;
  11. //import com.gmail.nossr50.skills.child.FamilyTree;
  12. //import com.gmail.nossr50.util.player.UserManager;
  13. //import org.bukkit.block.BlockState;
  14. //import org.bukkit.entity.Player;
  15. //
  16. //import java.util.ArrayList;
  17. //import java.util.Set;
  18. //import java.util.UUID;
  19. //
  20. //public final class ExperienceAPI {
  21. // private ExperienceAPI() {
  22. // }
  23. //
  24. // /**
  25. // * Returns whether given string is a valid type of skill suitable for the
  26. // * other API calls in this class.
  27. // * </br>
  28. // * This function is designed for API usage.
  29. // *
  30. // * @param skillType A string that may or may not be a skill
  31. // * @return true if this is a valid mcMMO skill
  32. // */
  33. // public static boolean isValidSkillType(String skillType) {
  34. // return PrimarySkillType.getSkill(skillType) != null;
  35. // }
  36. //
  37. // /**
  38. // * Grabs the XP multiplier for a player for this specific skill
  39. // * The multiplier will default to 1.0 and will be over written by any XP perks
  40. // *
  41. // * @param player target player
  42. // * @param primarySkillType target skill
  43. // * @return this players personal XP rate for target PrimarySkillType
  44. // */
  45. // public double getPlayersPersonalXPRate(McMMOPlayer player, PrimarySkillType primarySkillType) {
  46. // //First check if the player has ANY of the custom perks
  47. // return player.getPlayerSpecificXPMult(primarySkillType);
  48. // }
  49. //
  50. // /**
  51. // * Returns whether the given skill type string is both valid and not a
  52. // * child skill. (Child skills have no XP of their own, and their level is
  53. // * derived from the parent(s).)
  54. // * </br>
  55. // * This function is designed for API usage.
  56. // *
  57. // * @param skillType the skill to check
  58. // * @return true if this is a valid, non-child mcMMO skill
  59. // */
  60. // public static boolean isNonChildSkill(String skillType) {
  61. // PrimarySkillType skill = PrimarySkillType.getSkill(skillType);
  62. //
  63. // return skill != null && !skill.isChildSkill();
  64. // }
  65. //
  66. // @Deprecated
  67. // public static void addRawXP(Player player, String skillType, int XP) {
  68. // addRawXP(player, skillType, (double) XP);
  69. // }
  70. //
  71. // /**
  72. // * Adds raw XP to the player.
  73. // * </br>
  74. // * This function is designed for API usage.
  75. // *
  76. // * @param player The player to add XP to
  77. // * @param skillType The skill to add XP to
  78. // * @param XP The amount of XP to add
  79. // * @throws InvalidSkillException if the given skill is not valid
  80. // */
  81. // @Deprecated
  82. // public static void addRawXP(Player player, String skillType, double XP) {
  83. // addRawXP(player, skillType, XP, "UNKNOWN");
  84. // }
  85. //
  86. // /**
  87. // * Adds raw XP to the player.
  88. // * </br>
  89. // * This function is designed for API usage.
  90. // *
  91. // * @param player The player to add XP to
  92. // * @param skillType The skill to add XP to
  93. // * @param XP The amount of XP to add
  94. // * @param xpGainReason The reason to gain XP
  95. // * @throws InvalidSkillException if the given skill is not valid
  96. // * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
  97. // */
  98. // public static void addRawXP(Player player, String skillType, double XP, String xpGainReason) {
  99. // addRawXP(player, skillType, XP, xpGainReason, false);
  100. // }
  101. //
  102. // /**
  103. // * Adds raw XP to the player.
  104. // * </br>
  105. // * This function is designed for API usage.
  106. // *
  107. // * @param player The player to add XP to
  108. // * @param skillType The skill to add XP to
  109. // * @param XP The amount of XP to add
  110. // * @param xpGainReason The reason to gain XP
  111. // * @param isUnshared true if the XP cannot be shared with party members
  112. // * @throws InvalidSkillException if the given skill is not valid
  113. // * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
  114. // */
  115. // public static void addRawXP(Player player, String skillType, double XP, String xpGainReason, boolean isUnshared) {
  116. // if (isUnshared) {
  117. // getPlayer(player).beginUnsharedXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
  118. // return;
  119. // }
  120. //
  121. // getPlayer(player).applyXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
  122. // }
  123. //
  124. // /**
  125. // * Adds raw XP to an offline player.
  126. // * </br>
  127. // * This function is designed for API usage.
  128. // *
  129. // * @deprecated We're using double for our XP values now
  130. // * replaced by {@link #addRawXPOffline(String playerName, String skillType, double XP)}
  131. // */
  132. // @Deprecated
  133. // public static void addRawXPOffline(String playerName, String skillType, int XP) {
  134. // addRawXPOffline(playerName, skillType, (double) XP);
  135. // }
  136. //
  137. // /**
  138. // * Adds raw XP to an offline player.
  139. // * </br>
  140. // * This function is designed for API usage.
  141. // *
  142. // * @param playerName The player to add XP to
  143. // * @param skillType The skill to add XP to
  144. // * @param XP The amount of XP to add
  145. // * @throws InvalidSkillException if the given skill is not valid
  146. // * @throws InvalidPlayerException if the given player does not exist in the database
  147. // * @deprecated We're using uuids to get an offline player
  148. // * replaced by {@link #addRawXPOffline(UUID uuid, String skillType, double XP)}
  149. // */
  150. // @Deprecated
  151. // public static void addRawXPOffline(String playerName, String skillType, double XP) {
  152. // addOfflineXP(playerName, getSkillType(skillType), (int) Math.floor(XP));
  153. // }
  154. //
  155. // /**
  156. // * Adds raw XP to an offline player.
  157. // * </br>
  158. // * This function is designed for API usage.
  159. // *
  160. // * @param uuid The UUID of player to add XP to
  161. // * @param skillType The skill to add XP to
  162. // * @param XP The amount of XP to add
  163. // * @throws InvalidSkillException if the given skill is not valid
  164. // * @throws InvalidPlayerException if the given player does not exist in the database
  165. // */
  166. // public static void addRawXPOffline(UUID uuid, String skillType, double XP) {
  167. // addOfflineXP(uuid, getSkillType(skillType), (int) Math.floor(XP));
  168. // }
  169. //
  170. // /**
  171. // * Adds XP to the player, calculates for XP Rate only.
  172. // * </br>
  173. // * This function is designed for API usage.
  174. // *
  175. // * @param player The player to add XP to
  176. // * @param skillType The skill to add XP to
  177. // * @param XP The amount of XP to add
  178. // * @throws InvalidSkillException if the given skill is not valid
  179. // */
  180. // @Deprecated
  181. // public static void addMultipliedXP(Player player, String skillType, int XP) {
  182. // addMultipliedXP(player, skillType, XP, "UNKNOWN");
  183. // }
  184. //
  185. // /**
  186. // * Adds XP to the player, calculates for XP Rate only.
  187. // * </br>
  188. // * This function is designed for API usage.
  189. // *
  190. // * @param player The player to add XP to
  191. // * @param skillType The skill to add XP to
  192. // * @param XP The amount of XP to add
  193. // * @param xpGainReason The reason to gain XP
  194. // * @throws InvalidSkillException if the given skill is not valid
  195. // * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
  196. // */
  197. // public static void addMultipliedXP(Player player, String skillType, int XP, String xpGainReason) {
  198. // getPlayer(player).applyXpGain(getSkillType(skillType), (int) (XP * mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
  199. // }
  200. //
  201. // /**
  202. // * Adds XP to an offline player, calculates for XP Rate only.
  203. // * </br>
  204. // * This function is designed for API usage.
  205. // *
  206. // * @param playerName The player to add XP to
  207. // * @param skillType The skill to add XP to
  208. // * @param XP The amount of XP to add
  209. // * @throws InvalidSkillException if the given skill is not valid
  210. // * @throws InvalidPlayerException if the given player does not exist in the database
  211. // */
  212. // @Deprecated
  213. // public static void addMultipliedXPOffline(String playerName, String skillType, int XP) {
  214. // addOfflineXP(playerName, getSkillType(skillType), (int) (XP * mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()));
  215. // }
  216. //
  217. // /**
  218. // * Adds XP to the player, calculates for XP Rate and skill modifier.
  219. // * </br>
  220. // * This function is designed for API usage.
  221. // *
  222. // * @param player The player to add XP to
  223. // * @param skillType The skill to add XP to
  224. // * @param XP The amount of XP to add
  225. // * @throws InvalidSkillException if the given skill is not valid
  226. // */
  227. // @Deprecated
  228. // public static void addModifiedXP(Player player, String skillType, int XP) {
  229. // addModifiedXP(player, skillType, XP, "UNKNOWN");
  230. // }
  231. //
  232. // /**
  233. // * Adds XP to the player, calculates for XP Rate and skill modifier.
  234. // * </br>
  235. // * This function is designed for API usage.
  236. // *
  237. // * @param player The player to add XP to
  238. // * @param skillType The skill to add XP to
  239. // * @param XP The amount of XP to add
  240. // * @param xpGainReason The reason to gain XP
  241. // * @throws InvalidSkillException if the given skill is not valid
  242. // * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
  243. // */
  244. // public static void addModifiedXP(Player player, String skillType, int XP, String xpGainReason) {
  245. // addModifiedXP(player, skillType, XP, xpGainReason, false);
  246. // }
  247. //
  248. // /**
  249. // * Adds XP to the player, calculates for XP Rate and skill modifier.
  250. // * </br>
  251. // * This function is designed for API usage.
  252. // *
  253. // * @param player The player to add XP to
  254. // * @param skillType The skill to add XP to
  255. // * @param XP The amount of XP to add
  256. // * @param xpGainReason The reason to gain XP
  257. // * @param isUnshared true if the XP cannot be shared with party members
  258. // * @throws InvalidSkillException if the given skill is not valid
  259. // * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
  260. // */
  261. // public static void addModifiedXP(Player player, String skillType, int XP, String xpGainReason, boolean isUnshared) {
  262. // PrimarySkillType skill = getSkillType(skillType);
  263. //
  264. // if (isUnshared) {
  265. // getPlayer(player).beginUnsharedXpGain(skill, (int) (XP / skill.getXpModifier() * mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
  266. // return;
  267. // }
  268. //
  269. // getPlayer(player).applyXpGain(skill, (int) (XP / skill.getXpModifier() * mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()), getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
  270. // }
  271. //
  272. // /**
  273. // * Adds XP to an offline player, calculates for XP Rate and skill modifier.
  274. // * </br>
  275. // * This function is designed for API usage.
  276. // *
  277. // * @param playerName The player to add XP to
  278. // * @param skillType The skill to add XP to
  279. // * @param XP The amount of XP to add
  280. // * @throws InvalidSkillException if the given skill is not valid
  281. // * @throws InvalidPlayerException if the given player does not exist in the database
  282. // */
  283. // @Deprecated
  284. // public static void addModifiedXPOffline(String playerName, String skillType, int XP) {
  285. // PrimarySkillType skill = getSkillType(skillType);
  286. //
  287. // addOfflineXP(playerName, skill, (int) (XP / skill.getXpModifier() * mcMMO.getDynamicSettingsManager().getExperienceManager().getGlobalXpMult()));
  288. // }
  289. //
  290. // /**
  291. // * Adds XP to the player, calculates for XP Rate, skill modifiers, perks, child skills,
  292. // * and party sharing.
  293. // * </br>
  294. // * This function is designed for API usage.
  295. // *
  296. // * @param player The player to add XP to
  297. // * @param skillType The skill to add XP to
  298. // * @param XP The amount of XP to add
  299. // * @throws InvalidSkillException if the given skill is not valid
  300. // */
  301. // @Deprecated
  302. // public static void addXP(Player player, String skillType, int XP) {
  303. // addXP(player, skillType, XP, "UNKNOWN");
  304. // }
  305. //
  306. // /**
  307. // * Adds XP to the player, calculates for XP Rate, skill modifiers, perks, child skills,
  308. // * and party sharing.
  309. // * </br>
  310. // * This function is designed for API usage.
  311. // *
  312. // * @param player The player to add XP to
  313. // * @param skillType The skill to add XP to
  314. // * @param XP The amount of XP to add
  315. // * @param xpGainReason The reason to gain XP
  316. // * @throws InvalidSkillException if the given skill is not valid
  317. // * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
  318. // */
  319. // public static void addXP(Player player, String skillType, int XP, String xpGainReason) {
  320. // addXP(player, skillType, XP, xpGainReason, false);
  321. // }
  322. //
  323. // /**
  324. // * Adds XP to the player, calculates for XP Rate, skill modifiers, perks, child skills,
  325. // * and party sharing.
  326. // * </br>
  327. // * This function is designed for API usage.
  328. // *
  329. // * @param player The player to add XP to
  330. // * @param skillType The skill to add XP to
  331. // * @param XP The amount of XP to add
  332. // * @param xpGainReason The reason to gain XP
  333. // * @param isUnshared true if the XP cannot be shared with party members
  334. // * @throws InvalidSkillException if the given skill is not valid
  335. // * @throws InvalidXPGainReasonException if the given xpGainReason is not valid
  336. // */
  337. // public static void addXP(Player player, String skillType, int XP, String xpGainReason, boolean isUnshared) {
  338. // if (isUnshared) {
  339. // getPlayer(player).beginUnsharedXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
  340. // return;
  341. // }
  342. //
  343. // getPlayer(player).beginXpGain(getSkillType(skillType), XP, getXPGainReason(xpGainReason), XPGainSource.CUSTOM);
  344. // }
  345. //
  346. // /**
  347. // * Get the amount of XP a player has in a specific skill.
  348. // * </br>
  349. // * This function is designed for API usage.
  350. // *
  351. // * @param player The player to get XP for
  352. // * @param skillType The skill to get XP for
  353. // * @return the amount of XP in a given skill
  354. // * @throws InvalidSkillException if the given skill is not valid
  355. // * @throws UnsupportedOperationException if the given skill is a child skill
  356. // */
  357. // public static int getXP(Player player, String skillType) {
  358. // return getPlayer(player).getSkillXpLevel(getNonChildSkillType(skillType));
  359. // }
  360. //
  361. // /**
  362. // * Get the amount of XP an offline player has in a specific skill.
  363. // * </br>
  364. // * This function is designed for API usage.
  365. // *
  366. // * @param playerName The player to get XP for
  367. // * @param skillType The skill to get XP for
  368. // * @return the amount of XP in a given skill
  369. // * @throws InvalidSkillException if the given skill is not valid
  370. // * @throws InvalidPlayerException if the given player does not exist in the database
  371. // * @throws UnsupportedOperationException if the given skill is a child skill
  372. // */
  373. // @Deprecated
  374. // public static int getOfflineXP(String playerName, String skillType) {
  375. // return getOfflineProfile(playerName).getSkillXpLevel(getNonChildSkillType(skillType));
  376. // }
  377. //
  378. // /**
  379. // * Get the amount of XP an offline player has in a specific skill.
  380. // * </br>
  381. // * This function is designed for API usage.
  382. // *
  383. // * @param uuid The player to get XP for
  384. // * @param skillType The skill to get XP for
  385. // * @return the amount of XP in a given skill
  386. // * @throws InvalidSkillException if the given skill is not valid
  387. // * @throws InvalidPlayerException if the given player does not exist in the database
  388. // * @throws UnsupportedOperationException if the given skill is a child skill
  389. // */
  390. // public static int getOfflineXP(UUID uuid, String skillType) {
  391. // return getOfflineProfile(uuid).getSkillXpLevel(getNonChildSkillType(skillType));
  392. // }
  393. //
  394. // /**
  395. // * Get the raw amount of XP a player has in a specific skill.
  396. // * </br>
  397. // * This function is designed for API usage.
  398. // *
  399. // * @param player The player to get XP for
  400. // * @param skillType The skill to get XP for
  401. // * @return the amount of XP in a given skill
  402. // * @throws InvalidSkillException if the given skill is not valid
  403. // * @throws UnsupportedOperationException if the given skill is a child skill
  404. // */
  405. // public static double getXPRaw(Player player, String skillType) {
  406. // return getPlayer(player).getSkillXpLevelRaw(getNonChildSkillType(skillType));
  407. // }
  408. //
  409. // /**
  410. // * Get the raw amount of XP an offline player has in a specific skill.
  411. // * </br>
  412. // * This function is designed for API usage.
  413. // *
  414. // * @param playerName The player to get XP for
  415. // * @param skillType The skill to get XP for
  416. // * @return the amount of XP in a given skill
  417. // * @throws InvalidSkillException if the given skill is not valid
  418. // * @throws InvalidPlayerException if the given player does not exist in the database
  419. // * @throws UnsupportedOperationException if the given skill is a child skill
  420. // */
  421. // @Deprecated
  422. // public static double getOfflineXPRaw(String playerName, String skillType) {
  423. // return getOfflineProfile(playerName).getSkillXpLevelRaw(getNonChildSkillType(skillType));
  424. // }
  425. //
  426. // /**
  427. // * Get the raw amount of XP an offline player has in a specific skill.
  428. // * </br>
  429. // * This function is designed for API usage.
  430. // *
  431. // * @param uuid The player to get XP for
  432. // * @param skillType The skill to get XP for
  433. // * @return the amount of XP in a given skill
  434. // * @throws InvalidSkillException if the given skill is not valid
  435. // * @throws InvalidPlayerException if the given player does not exist in the database
  436. // * @throws UnsupportedOperationException if the given skill is a child skill
  437. // */
  438. // public static double getOfflineXPRaw(UUID uuid, String skillType) {
  439. // return getOfflineProfile(uuid).getSkillXpLevelRaw(getNonChildSkillType(skillType));
  440. // }
  441. //
  442. // /**
  443. // * Get the total amount of XP needed to reach the next level.
  444. // * </br>
  445. // * This function is designed for API usage.
  446. // *
  447. // * @param player The player to get the XP amount for
  448. // * @param skillType The skill to get the XP amount for
  449. // * @return the total amount of XP needed to reach the next level
  450. // * @throws InvalidSkillException if the given skill is not valid
  451. // * @throws UnsupportedOperationException if the given skill is a child skill
  452. // */
  453. // public static int getXPToNextLevel(Player player, String skillType) {
  454. // return getPlayer(player).getXpToLevel(getNonChildSkillType(skillType));
  455. // }
  456. //
  457. // /**
  458. // * Get the total amount of XP an offline player needs to reach the next level.
  459. // * </br>
  460. // * This function is designed for API usage.
  461. // *
  462. // * @param playerName The player to get XP for
  463. // * @param skillType The skill to get XP for
  464. // * @return the total amount of XP needed to reach the next level
  465. // * @throws InvalidSkillException if the given skill is not valid
  466. // * @throws InvalidPlayerException if the given player does not exist in the database
  467. // * @throws UnsupportedOperationException if the given skill is a child skill
  468. // */
  469. // @Deprecated
  470. // public static int getOfflineXPToNextLevel(String playerName, String skillType) {
  471. // return getOfflineProfile(playerName).getXpToLevel(getNonChildSkillType(skillType));
  472. // }
  473. //
  474. // /**
  475. // * Get the total amount of XP an offline player needs to reach the next level.
  476. // * </br>
  477. // * This function is designed for API usage.
  478. // *
  479. // * @param uuid The player to get XP for
  480. // * @param skillType The skill to get XP for
  481. // * @return the total amount of XP needed to reach the next level
  482. // * @throws InvalidSkillException if the given skill is not valid
  483. // * @throws InvalidPlayerException if the given player does not exist in the database
  484. // * @throws UnsupportedOperationException if the given skill is a child skill
  485. // */
  486. // public static int getOfflineXPToNextLevel(UUID uuid, String skillType) {
  487. // return getOfflineProfile(uuid).getXpToLevel(getNonChildSkillType(skillType));
  488. // }
  489. //
  490. // /**
  491. // * Get the amount of XP remaining until the next level.
  492. // * </br>
  493. // * This function is designed for API usage.
  494. // *
  495. // * @param player The player to get the XP amount for
  496. // * @param skillType The skill to get the XP amount for
  497. // * @return the amount of XP remaining until the next level
  498. // * @throws InvalidSkillException if the given skill is not valid
  499. // * @throws UnsupportedOperationException if the given skill is a child skill
  500. // */
  501. // public static int getXPRemaining(Player player, String skillType) {
  502. // PrimarySkillType skill = getNonChildSkillType(skillType);
  503. //
  504. // PlayerProfile profile = getPlayer(player).getProfile();
  505. //
  506. // return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill);
  507. // }
  508. //
  509. // /**
  510. // * Get the amount of XP an offline player has left before leveling up.
  511. // * </br>
  512. // * This function is designed for API usage.
  513. // *
  514. // * @param playerName The player to get XP for
  515. // * @param skillType The skill to get XP for
  516. // * @return the amount of XP needed to reach the next level
  517. // * @throws InvalidSkillException if the given skill is not valid
  518. // * @throws InvalidPlayerException if the given player does not exist in the database
  519. // * @throws UnsupportedOperationException if the given skill is a child skill
  520. // */
  521. // @Deprecated
  522. // public static int getOfflineXPRemaining(String playerName, String skillType) {
  523. // PrimarySkillType skill = getNonChildSkillType(skillType);
  524. // PlayerProfile profile = getOfflineProfile(playerName);
  525. //
  526. // return profile.getXpToLevel(skill) - profile.getSkillXpLevel(skill);
  527. // }
  528. //
  529. // /**
  530. // * Get the amount of XP an offline player has left before leveling up.
  531. // * </br>
  532. // * This function is designed for API usage.
  533. // *
  534. // * @param uuid The player to get XP for
  535. // * @param skillType The skill to get XP for
  536. // * @return the amount of XP needed to reach the next level
  537. // * @throws InvalidSkillException if the given skill is not valid
  538. // * @throws InvalidPlayerException if the given player does not exist in the database
  539. // * @throws UnsupportedOperationException if the given skill is a child skill
  540. // */
  541. // public static double getOfflineXPRemaining(UUID uuid, String skillType) {
  542. // PrimarySkillType skill = getNonChildSkillType(skillType);
  543. // PlayerProfile profile = getOfflineProfile(uuid);
  544. //
  545. // return profile.getXpToLevel(skill) - profile.getSkillXpLevelRaw(skill);
  546. // }
  547. //
  548. // /**
  549. // * Add levels to a skill.
  550. // * </br>
  551. // * This function is designed for API usage.
  552. // *
  553. // * @param player The player to add levels to
  554. // * @param skillType Type of skill to add levels to
  555. // * @param levels Number of levels to add
  556. // * @throws InvalidSkillException if the given skill is not valid
  557. // */
  558. // public static void addLevel(Player player, String skillType, int levels) {
  559. // getPlayer(player).addLevels(getSkillType(skillType), levels);
  560. // }
  561. //
  562. // /**
  563. // * Add levels to a skill for an offline player.
  564. // * </br>
  565. // * This function is designed for API usage.
  566. // *
  567. // * @param playerName The player to add levels to
  568. // * @param skillType Type of skill to add levels to
  569. // * @param levels Number of levels to add
  570. // * @throws InvalidSkillException if the given skill is not valid
  571. // * @throws InvalidPlayerException if the given player does not exist in the database
  572. // */
  573. // @Deprecated
  574. // public static void addLevelOffline(String playerName, String skillType, int levels) {
  575. // PlayerProfile profile = getOfflineProfile(playerName);
  576. // PrimarySkillType skill = getSkillType(skillType);
  577. //
  578. // if (skill.isChildSkill()) {
  579. // Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
  580. //
  581. // for (PrimarySkillType parentSkill : parentSkills) {
  582. // profile.addLevels(parentSkill, (levels / parentSkills.size()));
  583. // }
  584. //
  585. // profile.scheduleAsyncSave();
  586. // return;
  587. // }
  588. //
  589. // profile.addLevels(skill, levels);
  590. // profile.scheduleAsyncSave();
  591. // }
  592. //
  593. // /**
  594. // * Add levels to a skill for an offline player.
  595. // * </br>
  596. // * This function is designed for API usage.
  597. // *
  598. // * @param uuid The player to add levels to
  599. // * @param skillType Type of skill to add levels to
  600. // * @param levels Number of levels to add
  601. // * @throws InvalidSkillException if the given skill is not valid
  602. // * @throws InvalidPlayerException if the given player does not exist in the database
  603. // */
  604. // public static void addLevelOffline(UUID uuid, String skillType, int levels) {
  605. // PlayerProfile profile = getOfflineProfile(uuid);
  606. // PrimarySkillType skill = getSkillType(skillType);
  607. //
  608. // if (skill.isChildSkill()) {
  609. // Set<PrimarySkillType> parentSkills = FamilyTree.getParents(skill);
  610. //
  611. // for (PrimarySkillType parentSkill : parentSkills) {
  612. // profile.addLevels(parentSkill, (levels / parentSkills.size()));
  613. // }
  614. //
  615. // profile.scheduleAsyncSave();
  616. // return;
  617. // }
  618. //
  619. // profile.addLevels(skill, levels);
  620. // profile.scheduleAsyncSave();
  621. // }
  622. //
  623. // /**
  624. // * Get the level a player has in a specific skill.
  625. // * </br>
  626. // * This function is designed for API usage.
  627. // *
  628. // * @param player The player to get the level for
  629. // * @param skillType The skill to get the level for
  630. // * @return the level of a given skill
  631. // * @throws InvalidSkillException if the given skill is not valid
  632. // */
  633. // @Deprecated
  634. // public static int getLevel(Player player, String skillType) {
  635. // return getPlayer(player).getSkillLevel(getSkillType(skillType));
  636. // }
  637. //
  638. // /**
  639. // * Get the level a player has in a specific skill.
  640. // * </br>
  641. // * This function is designed for API usage.
  642. // *
  643. // * @param player The player to get the level for
  644. // * @param skillType The skill to get the level for
  645. // * @return the level of a given skill
  646. // *
  647. // * @throws InvalidSkillException if the given skill is not valid
  648. // */
  649. // public static int getLevel(Player player, PrimarySkillType skillType) {
  650. // return getPlayer(player).getSkillLevel(skillType);
  651. // }
  652. //
  653. // /**
  654. // * Get the level an offline player has in a specific skill.
  655. // * </br>
  656. // * This function is designed for API usage.
  657. // *
  658. // * @param playerName The player to get the level for
  659. // * @param skillType The skill to get the level for
  660. // * @return the level of a given skill
  661. // * @throws InvalidSkillException if the given skill is not valid
  662. // * @throws InvalidPlayerException if the given player does not exist in the database
  663. // */
  664. // @Deprecated
  665. // public static int getLevelOffline(String playerName, String skillType) {
  666. // return getOfflineProfile(playerName).getSkillLevel(getSkillType(skillType));
  667. // }
  668. //
  669. // /**
  670. // * Get the level an offline player has in a specific skill.
  671. // * </br>
  672. // * This function is designed for API usage.
  673. // *
  674. // * @param uuid The player to get the level for
  675. // * @param skillType The skill to get the level for
  676. // * @return the level of a given skill
  677. // * @throws InvalidSkillException if the given skill is not valid
  678. // * @throws InvalidPlayerException if the given player does not exist in the database
  679. // */
  680. // public static int getLevelOffline(UUID uuid, String skillType) {
  681. // return getOfflineProfile(uuid).getSkillLevel(getSkillType(skillType));
  682. // }
  683. //
  684. // /**
  685. // * Gets the power level of a player.
  686. // * </br>
  687. // * This function is designed for API usage.
  688. // *
  689. // * @param player The player to get the power level for
  690. // * @return the power level of the player
  691. // */
  692. // public static int getPowerLevel(Player player) {
  693. // return getPlayer(player).getPowerLevel();
  694. // }
  695. //
  696. // /**
  697. // * Gets the power level of an offline player.
  698. // * </br>
  699. // * This function is designed for API usage.
  700. // *
  701. // * @param playerName The player to get the power level for
  702. // * @return the power level of the player
  703. // * @throws InvalidPlayerException if the given player does not exist in the database
  704. // */
  705. // @Deprecated
  706. // public static int getPowerLevelOffline(String playerName) {
  707. // int powerLevel = 0;
  708. // PlayerProfile profile = getOfflineProfile(playerName);
  709. //
  710. // for (PrimarySkillType type : pluginRef.getSkillTools().NON_CHILD_SKILLS) {
  711. // powerLevel += profile.getSkillLevel(type);
  712. // }
  713. //
  714. // return powerLevel;
  715. // }
  716. //
  717. // /**
  718. // * Gets the power level of an offline player.
  719. // * </br>
  720. // * This function is designed for API usage.
  721. // *
  722. // * @param uuid The player to get the power level for
  723. // * @return the power level of the player
  724. // * @throws InvalidPlayerException if the given player does not exist in the database
  725. // */
  726. // public static int getPowerLevelOffline(UUID uuid) {
  727. // int powerLevel = 0;
  728. // PlayerProfile profile = getOfflineProfile(uuid);
  729. //
  730. // for (PrimarySkillType type : pluginRef.getSkillTools().NON_CHILD_SKILLS) {
  731. // powerLevel += profile.getSkillLevel(type);
  732. // }
  733. //
  734. // return powerLevel;
  735. // }
  736. //
  737. // /**
  738. // * Get the level cap of a specific skill.
  739. // * </br>
  740. // * This function is designed for API usage.
  741. // *
  742. // * @param skillType The skill to get the level cap for
  743. // * @return the level cap of a given skill
  744. // * @throws InvalidSkillException if the given skill is not valid
  745. // */
  746. // public static int getLevelCap(String skillType) {
  747. // return mcMMO.getPlayerLevelingSettings().getSkillLevelCap(getSkillType(skillType));
  748. // }
  749. //
  750. // /**
  751. // * Get the level cap of a specific skill.
  752. // * </br>
  753. // * This function is designed for API usage.
  754. // *
  755. // * @param skillType The skill to get the level cap for
  756. // * @return the level cap of a given skill
  757. // * @throws InvalidSkillException if the given skill is not valid
  758. // */
  759. // public static int getLevelCap(PrimarySkillType skillType) {
  760. // return mcMMO.getPlayerLevelingSettings().getSkillLevelCap(skillType);
  761. // }
  762. //
  763. // /**
  764. // * Checks whether or not a specific skill is level capped
  765. // *
  766. // * @param skillType target skill
  767. // * @return true if the skill has a level cap
  768. // */
  769. // public static boolean isSkillLevelCapped(PrimarySkillType skillType) {
  770. // return mcMMO.getPlayerLevelingSettings().isSkillLevelCapEnabled(skillType);
  771. // }
  772. //
  773. // /**
  774. // * Get the power level cap.
  775. // * </br>
  776. // * This function is designed for API usage.
  777. // *
  778. // * @return the overall power level cap
  779. // */
  780. // public static int getPowerLevelCap() {
  781. // return mcMMO.getPlayerLevelingSettings().getConfigSectionLevelCaps().getPowerLevelSettings().getLevelCap();
  782. // }
  783. //
  784. // /**
  785. // * Get the position on the leaderboard of a player.
  786. // * </br>
  787. // * This function is designed for API usage.
  788. // *
  789. // * @param playerName The name of the player to check
  790. // * @param skillType The skill to check
  791. // * @return the position on the leaderboard
  792. // * @throws InvalidSkillException if the given skill is not valid
  793. // * @throws InvalidPlayerException if the given player does not exist in the database
  794. // * @throws UnsupportedOperationException if the given skill is a child skill
  795. // */
  796. // @Deprecated
  797. // public static int getPlayerRankSkill(String playerName, String skillType) {
  798. // return mcMMO.getDatabaseManager().readRank(mcMMO.p.getServer().getOfflinePlayer(playerName).getName()).get(getNonChildSkillType(skillType));
  799. // }
  800. //
  801. // /**
  802. // * Get the position on the leaderboard of a player.
  803. // * </br>
  804. // * This function is designed for API usage.
  805. // *
  806. // * @param uuid The name of the player to check
  807. // * @param skillType The skill to check
  808. // * @return the position on the leaderboard
  809. // * @throws InvalidSkillException if the given skill is not valid
  810. // * @throws InvalidPlayerException if the given player does not exist in the database
  811. // * @throws UnsupportedOperationException if the given skill is a child skill
  812. // */
  813. // public static int getPlayerRankSkill(UUID uuid, String skillType) {
  814. // return mcMMO.getDatabaseManager().readRank(mcMMO.p.getServer().getOfflinePlayer(uuid).getName()).get(getNonChildSkillType(skillType));
  815. // }
  816. //
  817. // /**
  818. // * Get the position on the power level leaderboard of a player.
  819. // * </br>
  820. // * This function is designed for API usage.
  821. // *
  822. // * @param playerName The name of the player to check
  823. // * @return the position on the power level leaderboard
  824. // * @throws InvalidPlayerException if the given player does not exist in the database
  825. // */
  826. // @Deprecated
  827. // public static int getPlayerRankOverall(String playerName) {
  828. // return mcMMO.getDatabaseManager().readRank(mcMMO.p.getServer().getOfflinePlayer(playerName).getName()).get(null);
  829. // }
  830. //
  831. // /**
  832. // * Get the position on the power level leaderboard of a player.
  833. // * </br>
  834. // * This function is designed for API usage.
  835. // *
  836. // * @param uuid The name of the player to check
  837. // * @return the position on the power level leaderboard
  838. // * @throws InvalidPlayerException if the given player does not exist in the database
  839. // */
  840. // public static int getPlayerRankOverall(UUID uuid) {
  841. // return mcMMO.getDatabaseManager().readRank(mcMMO.p.getServer().getOfflinePlayer(uuid).getName()).get(null);
  842. // }
  843. //
  844. // /**
  845. // * Sets the level of a player in a specific skill type.
  846. // * </br>
  847. // * This function is designed for API usage.
  848. // *
  849. // * @param player The player to set the level of
  850. // * @param skillType The skill to set the level for
  851. // * @param skillLevel The value to set the level to
  852. // * @throws InvalidSkillException if the given skill is not valid
  853. // */
  854. // public static void setLevel(Player player, String skillType, int skillLevel) {
  855. // getPlayer(player).modifySkill(getSkillType(skillType), skillLevel);
  856. // }
  857. //
  858. // /**
  859. // * Sets the level of an offline player in a specific skill type.
  860. // * </br>
  861. // * This function is designed for API usage.
  862. // *
  863. // * @param playerName The player to set the level of
  864. // * @param skillType The skill to set the level for
  865. // * @param skillLevel The value to set the level to
  866. // * @throws InvalidSkillException if the given skill is not valid
  867. // * @throws InvalidPlayerException if the given player does not exist in the database
  868. // */
  869. // @Deprecated
  870. // public static void setLevelOffline(String playerName, String skillType, int skillLevel) {
  871. // getOfflineProfile(playerName).modifySkill(getSkillType(skillType), skillLevel);
  872. // }
  873. //
  874. // /**
  875. // * Sets the level of an offline player in a specific skill type.
  876. // * </br>
  877. // * This function is designed for API usage.
  878. // *
  879. // * @param uuid The player to set the level of
  880. // * @param skillType The skill to set the level for
  881. // * @param skillLevel The value to set the level to
  882. // * @throws InvalidSkillException if the given skill is not valid
  883. // * @throws InvalidPlayerException if the given player does not exist in the database
  884. // */
  885. // public static void setLevelOffline(UUID uuid, String skillType, int skillLevel) {
  886. // getOfflineProfile(uuid).modifySkill(getSkillType(skillType), skillLevel);
  887. // }
  888. //
  889. // /**
  890. // * Sets the XP of a player in a specific skill type.
  891. // * </br>
  892. // * This function is designed for API usage.
  893. // *
  894. // * @param player The player to set the XP of
  895. // * @param skillType The skill to set the XP for
  896. // * @param newValue The value to set the XP to
  897. // * @throws InvalidSkillException if the given skill is not valid
  898. // * @throws UnsupportedOperationException if the given skill is a child skill
  899. // */
  900. // public static void setXP(Player player, String skillType, int newValue) {
  901. // getPlayer(player).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
  902. // }
  903. //
  904. // /**
  905. // * Sets the XP of an offline player in a specific skill type.
  906. // * </br>
  907. // * This function is designed for API usage.
  908. // *
  909. // * @param playerName The player to set the XP of
  910. // * @param skillType The skill to set the XP for
  911. // * @param newValue The value to set the XP to
  912. // * @throws InvalidSkillException if the given skill is not valid
  913. // * @throws InvalidPlayerException if the given player does not exist in the database
  914. // * @throws UnsupportedOperationException if the given skill is a child skill
  915. // */
  916. // @Deprecated
  917. // public static void setXPOffline(String playerName, String skillType, int newValue) {
  918. // getOfflineProfile(playerName).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
  919. // }
  920. //
  921. // /**
  922. // * Sets the XP of an offline player in a specific skill type.
  923. // * </br>
  924. // * This function is designed for API usage.
  925. // *
  926. // * @param uuid The player to set the XP of
  927. // * @param skillType The skill to set the XP for
  928. // * @param newValue The value to set the XP to
  929. // * @throws InvalidSkillException if the given skill is not valid
  930. // * @throws InvalidPlayerException if the given player does not exist in the database
  931. // * @throws UnsupportedOperationException if the given skill is a child skill
  932. // */
  933. // public static void setXPOffline(UUID uuid, String skillType, int newValue) {
  934. // getOfflineProfile(uuid).setSkillXpLevel(getNonChildSkillType(skillType), newValue);
  935. // }
  936. //
  937. // /**
  938. // * Removes XP from a player in a specific skill type.
  939. // * </br>
  940. // * This function is designed for API usage.
  941. // *
  942. // * @param player The player to change the XP of
  943. // * @param skillType The skill to change the XP for
  944. // * @param xp The amount of XP to remove
  945. // * @throws InvalidSkillException if the given skill is not valid
  946. // * @throws UnsupportedOperationException if the given skill is a child skill
  947. // */
  948. // public static void removeXP(Player player, String skillType, int xp) {
  949. // getPlayer(player).removeXp(getNonChildSkillType(skillType), xp);
  950. // }
  951. //
  952. // /**
  953. // * Removes XP from an offline player in a specific skill type.
  954. // * </br>
  955. // * This function is designed for API usage.
  956. // *
  957. // * @param playerName The player to change the XP of
  958. // * @param skillType The skill to change the XP for
  959. // * @param xp The amount of XP to remove
  960. // * @throws InvalidSkillException if the given skill is not valid
  961. // * @throws InvalidPlayerException if the given player does not exist in the database
  962. // * @throws UnsupportedOperationException if the given skill is a child skill
  963. // */
  964. // @Deprecated
  965. // public static void removeXPOffline(String playerName, String skillType, int xp) {
  966. // getOfflineProfile(playerName).removeXp(getNonChildSkillType(skillType), xp);
  967. // }
  968. //
  969. // /**
  970. // * Removes XP from an offline player in a specific skill type.
  971. // * </br>
  972. // * This function is designed for API usage.
  973. // *
  974. // * @param uuid The player to change the XP of
  975. // * @param skillType The skill to change the XP for
  976. // * @param xp The amount of XP to remove
  977. // * @throws InvalidSkillException if the given skill is not valid
  978. // * @throws InvalidPlayerException if the given player does not exist in the database
  979. // * @throws UnsupportedOperationException if the given skill is a child skill
  980. // */
  981. // public static void removeXPOffline(UUID uuid, String skillType, int xp) {
  982. // getOfflineProfile(uuid).removeXp(getNonChildSkillType(skillType), xp);
  983. // }
  984. //
  985. // /**
  986. // * Check how much XP is needed for a specific level with the selected level curve.
  987. // * </br>
  988. // * This function is designed for API usage.
  989. // *
  990. // * @param level The level to get the amount of XP for
  991. // * @throws InvalidFormulaTypeException if the given formulaType is not valid
  992. // */
  993. // public static int getXpNeededToLevel(int level) {
  994. // return mcMMO.getFormulaManager().getXPtoNextLevel(level, mcMMO.getConfigManager().getConfigLeveling().getFormulaType());
  995. // }
  996. //
  997. // /**
  998. // * Check how much XP is needed for a specific level with the provided level curve.
  999. // * </br>
  1000. // * This function is designed for API usage.
  1001. // *
  1002. // * @param level The level to get the amount of XP for
  1003. // * @param formulaType The formula type to get the amount of XP for
  1004. // * @throws InvalidFormulaTypeException if the given formulaType is not valid
  1005. // * @deprecated Discouraged - Most the time you do not want to provide the formula type yourself, use the other method
  1006. // */
  1007. // public static int getXpNeededToLevel(int level, FormulaType formulaType) {
  1008. // return mcMMO.getFormulaManager().getXPtoNextLevel(level, formulaType);
  1009. // }
  1010. //
  1011. // /**
  1012. // * Will add the appropriate type of XP from the block to the player based on the material of the blocks given
  1013. // *
  1014. // * @param blockStates the blocks to reward XP for
  1015. // * @param mcMMOPlayer the target player
  1016. // */
  1017. // public static void addXpFromBlocks(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer) {
  1018. // for (BlockState bs : blockStates) {
  1019. // for (PrimarySkillType skillType : PrimarySkillType.values()) {
  1020. // if (mcMMO.getDynamicSettingsManager().getExperienceManager().getBlockBreakXpValue(skillType, bs.getType()) > 0) {
  1021. // mcMMOPlayer.applyXpGain(skillType, mcMMO.getDynamicSettingsManager().getExperienceManager().getBlockBreakXpValue(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
  1022. // }
  1023. // }
  1024. // }
  1025. // }
  1026. //
  1027. // /**
  1028. // * Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType
  1029. // *
  1030. // * @param blockStates the blocks to reward XP for
  1031. // * @param mcMMOPlayer the target player
  1032. // * @param skillType target primary skill
  1033. // */
  1034. // public static void addXpFromBlocksBySkill(ArrayList<BlockState> blockStates, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
  1035. // for (BlockState bs : blockStates) {
  1036. // if (mcMMO.getDynamicSettingsManager().getExperienceManager().getBlockBreakXpValue(skillType, bs.getType()) > 0) {
  1037. // mcMMOPlayer.applyXpGain(skillType, mcMMO.getDynamicSettingsManager().getExperienceManager().getBlockBreakXpValue(skillType, bs.getType()), XPGainReason.PVE, XPGainSource.SELF);
  1038. // }
  1039. // }
  1040. // }
  1041. //
  1042. // /**
  1043. // * Will add the appropriate type of XP from the block to the player based on the material of the blocks given
  1044. // *
  1045. // * @param blockState The target blockstate
  1046. // * @param mcMMOPlayer The target player
  1047. // */
  1048. // public static void addXpFromBlock(BlockState blockState, McMMOPlayer mcMMOPlayer) {
  1049. // for (PrimarySkillType skillType : PrimarySkillType.values()) {
  1050. // if (mcMMO.getDynamicSettingsManager().getExperienceManager().getBlockBreakXpValue(skillType, blockState.getType()) > 0) {
  1051. // mcMMOPlayer.applyXpGain(skillType, mcMMO.getDynamicSettingsManager().getExperienceManager().getBlockBreakXpValue(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
  1052. // }
  1053. // }
  1054. // }
  1055. //
  1056. // /**
  1057. // * Will add the appropriate type of XP from the block to the player based on the material of the blocks given if it matches the given skillType
  1058. // *
  1059. // * @param blockState The target blockstate
  1060. // * @param mcMMOPlayer The target player
  1061. // * @param skillType target primary skill
  1062. // */
  1063. // public static void addXpFromBlockBySkill(BlockState blockState, McMMOPlayer mcMMOPlayer, PrimarySkillType skillType) {
  1064. // if (mcMMO.getDynamicSettingsManager().getExperienceManager().getBlockBreakXpValue(skillType, blockState.getType()) > 0) {
  1065. // mcMMOPlayer.applyXpGain(skillType, mcMMO.getDynamicSettingsManager().getExperienceManager().getBlockBreakXpValue(skillType, blockState.getType()), XPGainReason.PVE, XPGainSource.SELF);
  1066. // }
  1067. // }
  1068. //
  1069. //
  1070. // // Utility methods follow.
  1071. // private static void addOfflineXP(UUID playerUniqueId, PrimarySkillType skill, int XP) {
  1072. // PlayerProfile profile = getOfflineProfile(playerUniqueId);
  1073. //
  1074. // profile.addXp(skill, XP);
  1075. // profile.save(true);
  1076. // }
  1077. //
  1078. // @Deprecated
  1079. // private static void addOfflineXP(String playerName, PrimarySkillType skill, int XP) {
  1080. // PlayerProfile profile = getOfflineProfile(playerName);
  1081. //
  1082. // profile.addXp(skill, XP);
  1083. // profile.scheduleAsyncSave();
  1084. // }
  1085. //
  1086. // private static PlayerProfile getOfflineProfile(UUID uuid) {
  1087. // PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
  1088. //
  1089. // if (!profile.isLoaded()) {
  1090. // throw new InvalidPlayerException();
  1091. // }
  1092. //
  1093. // return profile;
  1094. // }
  1095. //
  1096. // @Deprecated
  1097. // private static PlayerProfile getOfflineProfile(String playerName) {
  1098. // UUID uuid = mcMMO.p.getServer().getOfflinePlayer(playerName).getUniqueId();
  1099. // PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(uuid);
  1100. //
  1101. // if (!profile.isLoaded()) {
  1102. // throw new InvalidPlayerException();
  1103. // }
  1104. //
  1105. // return profile;
  1106. // }
  1107. //
  1108. // private static PrimarySkillType getSkillType(String skillType) throws InvalidSkillException {
  1109. // PrimarySkillType skill = PrimarySkillType.getSkill(skillType);
  1110. //
  1111. // if (skill == null) {
  1112. // throw new InvalidSkillException(skillType);
  1113. // }
  1114. //
  1115. // return skill;
  1116. // }
  1117. //
  1118. // private static PrimarySkillType getNonChildSkillType(String skillType) throws InvalidSkillException, UnsupportedOperationException {
  1119. // PrimarySkillType skill = getSkillType(skillType);
  1120. //
  1121. // if (skill.isChildSkill()) {
  1122. // throw new UnsupportedOperationException("Child skills do not have XP");
  1123. // }
  1124. //
  1125. // return skill;
  1126. // }
  1127. //
  1128. // private static XPGainReason getXPGainReason(String reason) throws InvalidXPGainReasonException {
  1129. // XPGainReason xpGainReason = XPGainReason.getXPGainReason(reason);
  1130. //
  1131. // if (xpGainReason == null) {
  1132. // throw new InvalidXPGainReasonException();
  1133. // }
  1134. //
  1135. // return xpGainReason;
  1136. // }
  1137. //
  1138. // /**
  1139. // * @param player target player
  1140. // * @return McMMOPlayer for that player if the profile is loaded, otherwise null
  1141. // * @throws McMMOPlayerNotFoundException
  1142. // * @deprecated Use UserManager::getPlayer(Player player) instead
  1143. // */
  1144. // @Deprecated
  1145. // private static McMMOPlayer getPlayer(Player player) throws McMMOPlayerNotFoundException {
  1146. // if (!pluginRef.getUserManager().hasPlayerDataKey(player)) {
  1147. // throw new McMMOPlayerNotFoundException(player);
  1148. // }
  1149. //
  1150. // return pluginRef.getUserManager().getPlayer(player);
  1151. // }
  1152. //}