Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class RankHandler
- {
- private final DaddyRankup dr;
- public final Map<String, DrRank> rankMap = new HashMap<String, DrRank>();
- public ConfigurationSection ranks = this.dr.getConfig().getConfigurationSection("ranks");
- public RankHandler(DaddyRankup daddyrankup){
- this.dr = daddyrankup;
- loadDrRanksFromConfig();
- }
- public Object[] getAllRankupRanks(){
- if(dr.getConfig().contains("ranks")){
- ConfigurationSection ranks = dr.getConfig().getConfigurationSection("ranks");
- return this.ranks.getKeys(false).toArray();
- }
- else{
- dr.sendLog("cant load ranks for some reason !");
- return null;
- }
- }
- //this.dr.getConfig().getConfigurationSection("ranks");
- public boolean loadDrRanksFromConfig()
- {
- Object[] keys = getAllRankupRanks();
- if((keys !=null) && (keys.length > 0)){
- for(Object key : keys){
- ConfigurationSection Sender = ranks.getConfigurationSection(key.toString());
- String ladder = Sender.getString("ladder");
- String message = Sender.getString("message");
- double cost = Sender.getDouble("cost");
- String nextrank = Sender.getString("nextrank");
- int reqrank = Sender.getInt("reqrank");
- try{
- DrRank newDrRank = new DrRank(ladder, message, cost, nextrank, reqrank);
- this.rankMap.put(key.toString(), newDrRank);
- }
- catch(NumberFormatException ex){
- this.dr.sendLog("Failed to Load " + key.toString() + "!");
- break;
- }
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement