Showing Players Balance On ScoreBoard

Discussion in 'Plugin Development' started by toxiccoke, Apr 8, 2015.

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

    toxiccoke

    Hi

    So i am working on a plugin were it will show how much money the player has on there scoreboard but for some reason i am getting an error in the console i am not getting errors in my code if anyone could help me out that would be great

    This is the bit i believe is coursing the issue as it is put to null:
    Code:
        public static Economy econ;
    My hole class:
    Code:
        private JavaPlugin plugin;
        public static Economy econ;
        public static EconomyResponse r;
    
        @EventHandler
        public void onJoin(PlayerJoinEvent event) {
            Player player = event.getPlayer();
            showScoreboard(player);
        }
       
         private boolean setupEconomy() {
                if (me.toxiccoke.utils.Main.plugin.getServer().getPluginManager().getPlugin("Vault") == null) {
                    return false;
                }
                RegisteredServiceProvider<Economy> rsp = me.toxiccoke.utils.Main.plugin.getServer().getServicesManager().getRegistration(Economy.class);
                if (rsp == null) {
                    return false;
                }
                econ = rsp.getProvider();
                return econ != null;
            }
        
    
        public void showScoreboard(Player p) {
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            org.bukkit.scoreboard.Scoreboard board = manager.getNewScoreboard();
    
            Objective objective = board.registerNewObjective("test", "dummy");
            objective.setDisplaySlot(DisplaySlot.SIDEBAR);
            objective.setDisplayName(ChatColor.GOLD + "§c§lInferno Network ");
            Score Online = objective.getScore("§6Online");
            Online.setScore(10);
            Score Online1 = objective.getScore("§6> " + p.getServer().getOfflinePlayers().length + "/" + p.getServer().getMaxPlayers());
            Online1.setScore(9);
            Score Balance = objective.getScore("§6Balance");
            Balance.setScore(8);
            Score Balance1 = objective.getScore("§6> $" + econ.getBalance(p.getName()));
            p.setScoreboard(board);
        }
    I am using the vault api
    If u would like anymore information please comment below and i will try and get what u need to help me resolve this issue
    Thanks
    toxiccoke
     
  2. Offline

    Monkey_Swag

    You need to call your setupEconomy method in the onEnable.
     
  3. Offline

    toxiccoke

    ok ill try that now thanks
     
  4. @toxiccoke If that doesn't work, you can easily make your own custom currency here!
     
Thread Status:
Not open for further replies.

Share This Page