Advertisement
Guest User

Untitled

a guest
Jun 24th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.98 KB | None | 0 0
  1. package me.arrayofc.fadelandscore.profile;
  2.  
  3. import me.arrayofc.fadelandscore.achievement.Achievement;
  4.  
  5. import java.util.*;
  6.  
  7. public class PlayerData {
  8.  
  9. private static final List<PlayerData> all = new ArrayList<>();
  10.  
  11. private final UUID uuid;
  12. private final Statistics stats = new Statistics();
  13. private final AchievementData achData = new AchievementData();
  14.  
  15. public PlayerData(UUID uuid) {
  16. this.uuid = uuid;
  17.  
  18. all.add(this);
  19. }
  20.  
  21. public void remove() {
  22. all.remove(this);
  23. }
  24.  
  25. public UUID getUUID() {
  26. return this.uuid;
  27. }
  28.  
  29. public Statistics getStats() {
  30. return this.stats;
  31. }
  32.  
  33. public AchievementData getAhievementData() {
  34. return this.achData;
  35. }
  36.  
  37. public static List<PlayerData> getAll() {
  38. return all;
  39. }
  40.  
  41. public static PlayerData get(UUID uuid) {
  42. for (int i = 0; i < all.size(); i++)
  43. if (all.get(i).getUUID() == uuid) return all.get(i);
  44. return null;
  45. }
  46.  
  47. public final class Statistics {
  48.  
  49. private int tokens = 0, messagesSent = 0, commandsUsed = 0, loginCount = 0, blocksPlaced = 0, blocksRemoved = 0, deaths = 0, kills = 0;
  50.  
  51. public int getTokens() {
  52. return tokens;
  53. }
  54.  
  55. public void setTokens(int tokens) {
  56. this.tokens = tokens;
  57. }
  58.  
  59. public int getMessagesSent() {
  60. return messagesSent;
  61. }
  62.  
  63. public void setMessagesSent(int messagesSent) {
  64. this.messagesSent = messagesSent;
  65. }
  66.  
  67. public int getCommandsUsed() {
  68. return commandsUsed;
  69. }
  70.  
  71. public void setCommandsUsed(int commandsUsed) {
  72. this.commandsUsed = commandsUsed;
  73. }
  74.  
  75. public int getLoginCount() {
  76. return loginCount;
  77. }
  78.  
  79. public void setLoginCount(int loginCount) {
  80. this.loginCount = loginCount;
  81. }
  82.  
  83. public int getBlocksPlaced() {
  84. return blocksPlaced;
  85. }
  86.  
  87. public void setBlocksPlaced(int blocksPlaced) {
  88. this.blocksPlaced = blocksPlaced;
  89. }
  90.  
  91. public int getBlocksRemoved() {
  92. return blocksRemoved;
  93. }
  94.  
  95. public void setBlocksRemoved(int blocksRemoved) {
  96. this.blocksRemoved = blocksRemoved;
  97. }
  98.  
  99. public int getDeaths() {
  100. return deaths;
  101. }
  102.  
  103. public void setDeaths(int deaths) {
  104. this.deaths = deaths;
  105. }
  106.  
  107. public int getKills() {
  108. return kills;
  109. }
  110.  
  111. public void setKills(int kills) {
  112. this.kills = kills;
  113. }
  114. }
  115.  
  116. public final class AchievementData {
  117.  
  118. private final List<Achievement> achieved = new ArrayList<>();
  119. private final Map<Achievement, Integer> progress = new HashMap<>();
  120.  
  121. public List<Achievement> getAchieved() {
  122. return achieved;
  123. }
  124.  
  125. public Map<Achievement, Integer> getProgressData() {
  126. return this.progress;
  127. }
  128.  
  129. public void progress(Achievement ach) {
  130.  
  131. if (this.achieved.contains(ach)) return;
  132.  
  133. if (ach.getRequirement() > 0) {
  134. int progress = getProgress(ach);
  135.  
  136. if (!(++progress >= ach.getRequirement())) {
  137. this.progress.put(ach, progress);
  138. return;
  139. }
  140.  
  141. this.progress.remove(ach);
  142. }
  143.  
  144. achieved.add(ach);
  145.  
  146.  
  147.  
  148. }
  149.  
  150. public int getProgress(Achievement ach) {
  151. if (ach.getRequirement() <= 0) return 0;
  152. return this.progress.containsKey(ach) ? this.progress.get(ach) : 0;
  153. }
  154.  
  155. //Osäker ifall detta fungerar korrekt då casts kan fucka ibland
  156. public int getProcentProgress(Achievement ach) {
  157. return (int)((double)(getProgress(ach)/ach.getRequirement()) * 100);
  158. }
  159. }
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement