Advertisement
DTS-MC

Untitled

Oct 28th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1.  
  2.  
  3. public class RankHandler
  4. {
  5. private final DaddyRankup dr;
  6. public final Map<String, DrRank> rankMap = new HashMap<String, DrRank>();
  7. public ConfigurationSection ranks = this.dr.getConfig().getConfigurationSection("ranks");
  8. public RankHandler(DaddyRankup daddyrankup){
  9. this.dr = daddyrankup;
  10. loadDrRanksFromConfig();
  11. }
  12.  
  13. public Object[] getAllRankupRanks(){
  14. if(dr.getConfig().contains("ranks")){
  15. ConfigurationSection ranks = dr.getConfig().getConfigurationSection("ranks");
  16. return this.ranks.getKeys(false).toArray();
  17. }
  18. else{
  19. dr.sendLog("cant load ranks for some reason !");
  20. return null;
  21. }
  22.  
  23. }
  24.  
  25. //this.dr.getConfig().getConfigurationSection("ranks");
  26.  
  27.  
  28. public boolean loadDrRanksFromConfig()
  29. {
  30. Object[] keys = getAllRankupRanks();
  31. if((keys !=null) && (keys.length > 0)){
  32.  
  33. for(Object key : keys){
  34. ConfigurationSection Sender = ranks.getConfigurationSection(key.toString());
  35. String ladder = Sender.getString("ladder");
  36. String message = Sender.getString("message");
  37. double cost = Sender.getDouble("cost");
  38. String nextrank = Sender.getString("nextrank");
  39. int reqrank = Sender.getInt("reqrank");
  40. try{
  41. DrRank newDrRank = new DrRank(ladder, message, cost, nextrank, reqrank);
  42. this.rankMap.put(key.toString(), newDrRank);
  43.  
  44. }
  45. catch(NumberFormatException ex){
  46. this.dr.sendLog("Failed to Load " + key.toString() + "!");
  47.  
  48. break;
  49. }
  50. }
  51.  
  52. }
  53.  
  54. return true;
  55.  
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement