Error with trying to create a holographic leaderboard

Discussion in 'Plugin Development' started by xpaintall, Aug 12, 2021.

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

    xpaintall

    So basically I'm trying to create a leaderboard that displays the top 10 people who killed the most chickens (lifetime), but it seems like I'm getting an error. Now, I know I horribly messed up somewhere but I don't know where. Also, I'm using the holographic displays API.
    Code:
    public class PointsManager {
    
        TutMain f = TutMain.getPlugin(TutMain.class);
    
        TreeMap<String, Integer> kills = new TreeMap<>();
        FileConfiguration config = f.getConfig();
    
        public void createLeaderboard(Player player) {
            Hologram holo = HologramsAPI.createHologram(f, player.getLocation());
            holo.insertTextLine(0, ChatColor.YELLOW + "LEADERBOARD OF KILLING CHICKENS");
            for (String s : config.getConfigurationSection("Kills.").getKeys(false)) {
                for (int i = 1; i < 11; i++) {
                    Player player1 = Bukkit.getPlayer(s);
                    holo.insertTextLine(i, ChatColor.YELLOW + "" + i + ". " + player1.getDisplayName() + ": " + ChatColor.GREEN + "" + kills.values());
                }
            }
        }
    
    
    }
    this is my PointsGetter class if ur interested

    Code:
    public class PointsGetter implements Listener, CommandExecutor {
    
        TutMain f = TutMain.getPlugin(TutMain.class);
    
    
        @EventHandler
        public void onKill(EntityDeathEvent event) {
            Player player = event.getEntity().getKiller();
            if(event.getEntity() instanceof Chicken) {
                if(event.getEntity().getKiller() == player) {
                    if(!f.getConfig().contains("Kills." + player.getName())) {
                        f.getConfig().set("Kills." + player.getName(), 0);
                    }
                    int kills = f.getConfig().getInt("Kills." + player.getName());
    
                    f.getConfig().set("Kills." + player.getName(), kills+1);
                    player.sendMessage(ChatColor.GREEN + "+1 Kill!");
                    player.playSound(player.getLocation(), Sound.NOTE_PLING, 1, 1);
                }
            }
        }
    
    
        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    
            if(!(sender instanceof Player)) return false;
    
            Player player = (Player) sender;
    
    
            if(cmd.getName().equalsIgnoreCase("points")) {
                int kills = f.getConfig().getInt("Kills." + player.getName());
                player.sendMessage(ChatColor.GREEN + "You have " + kills + " Kills!");
                return true;
            }
    
    
    
    
            return false;
        }
    }
    
     
Thread Status:
Not open for further replies.

Share This Page