Development Assistance Essentials Eco Error

Discussion in 'Plugin Help/Development/Requests' started by lespauls19, Feb 21, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    lespauls19

    I'm currently making an improved balance top plugin that does not take an hour to load 5000+ users. My issue is getting balances
    Code:
    Code:
    package lp.pl.baltop;
    
    import java.util.ArrayList;
    import java.util.Collections;
    import java.util.HashMap;
    import java.util.Map;
    import java.util.Map.Entry;
    import java.util.Set;
    import java.util.logging.Logger;
    
    import net.md_5.bungee.api.ChatColor;
    import net.milkbowl.vault.economy.Economy;
    
    import org.bukkit.Bukkit;
    import org.bukkit.OfflinePlayer;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Baltop extends JavaPlugin {
    
        public final Logger logger = Logger.getLogger("Minecraft");
        static Economy econ = null;
    
        public void onEnable() {
            if (!setupEconomy()) {
                this.logger.severe(String.format(
                        "[%s] - Disabled due to no Vault dependency found!",
                        new Object[] { getDescription().getName() }));
                getServer().getPluginManager().disablePlugin(this);
                return;
            }
        }
    
        public void onDisable() {
    
        }
    
        private boolean setupEconomy() {
            if (getServer().getPluginManager().getPlugin("Vault") == null) {
                Bukkit.getServer().getPlayer("lespauls19").sendMessage("error");
                return false;
            }
            RegisteredServiceProvider<Economy> rsp = getServer()
                    .getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                Bukkit.getServer().getPlayer("lespauls19").sendMessage("error");
                return false;
            }
            econ = rsp.getProvider();
            return econ != null;
        }
    
        public boolean onCommand(CommandSender sender, Command command,
                String label, String[] args) {
    
            Player player = (Player) sender;
            if (label.equalsIgnoreCase("moneytop")) {
                player.sendMessage(ChatColor.YELLOW + entryByIndex(balList().size()).split(",")[1]
                        + ": " + "$" + entryByIndex(balList().size()).split(",")[0]);
            }
    
            return true;
    
        }
    
        public static ArrayList<String> balList() {
    
            ArrayList<String> fullList = new ArrayList<String>();
            ArrayList<String> sortedList = new ArrayList<String>();
            for (OfflinePlayer p : Bukkit.getServer().getOfflinePlayers()) {
                if (econ.hasAccount(p)) {
                    fullList.add(econ.getBalance(p)+","+p.getName());
                }
            }      
            try{
                    while(!fullList.isEmpty()){   
                        String topBalAndIndex = "0.00,null";
                       for(String s : fullList){
                           if(Double.parseDouble(s.split(",")[0]) >= Double.parseDouble(topBalAndIndex.split(",")[0])){
                                topBalAndIndex = Double.parseDouble(s.split(",")[0]) + "," + s.split(",")[1];
                           }
                      }
                          sortedList.add(topBalAndIndex);
                          fullList.remove(topBalAndIndex);
        }
            }catch(Exception e){
                e.printStackTrace();
                return null;
            }
            return sortedList;
        }
       
        public static String entryByIndex(int index){
            return balList().get(index-1);
        }
    
    }
    Stack trace:
    http://pastebin.com/Ez0Lynki

    Any help would be appreciated
     
  2. Offline

    FerusGrim

    The fact that you're spacing consists of literal spaces and not tab-characters, yet your indentation is that screwed up bothers me a little.

    Also, this belongs in the Bukkit Alternatives section.
     
  3. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives.
     
  4. Offline

    lespauls19

    It's messy I know.

    I'm also getting this
    21.02 12:34:25 [Server] ERROR org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
    21.02 12:34:25 [Server] ERROR lp.pl.baltop.Baltop.onCommand(Baltop.java:62)
    21.02 12:34:25 [Server] ERROR lp.pl.baltop.Baltop.balList(Baltop.java:81)
    21.02 12:34:25 [Server] ERROR java.lang.Double.parseDouble(Unknown Source)
    21.02 12:34:25 [Server] ERROR sun.misc.FloatingDecimal.doubleValue(FloatingDecimal.java:1554)
    21.02 12:34:25 [Server] ERROR sun.misc.FloatingDecimal.multPow52(FloatingDecimal.java:193)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 13, 2016
Thread Status:
Not open for further replies.

Share This Page