Plugin not working

Discussion in 'Plugin Development' started by Enopeee, Jan 20, 2021.

  1. Offline

    Enopeee

    can anyone help me, i am exporting my plugin as jar and putting in a server but it gives an error and does not show up on the plugins list, does anyone know why this could be happening and how to fix it?
    This is the plugin

    here is the code, if there might be an error that might be causing it?
    ```
    Code:
    package me.enesn.hubscoreboard;
    
    import org.bukkit.Bukkit;
    import org.bukkit.Statistic;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.ScoreboardManager;
    import org.bukkit.event.Listener;
    import net.md_5.bungee.api.ChatColor;
    
    public class Main extends JavaPlugin implements Listener {
       
        @Override
        public void onEnable() {
            this.getServer().getPluginManager().registerEvents(this, this);
           
            if (Bukkit.getOnlinePlayers().isEmpty())
                for (Player online : Bukkit.getOnlinePlayers())
                    createBoard(online);
           
        }
        @Override
        public void onDisable() {
           
        }
       
       
        @EventHandler
        public void onJoin(PlayerJoinEvent event) {
            createBoard(event.getPlayer());
        }
       
        public void createBoard(Player player) {
            ScoreboardManager manager = Bukkit.getScoreboardManager();
            Scoreboard board = manager.getNewScoreboard();
            Objective obj = board.registerNewObjective("HubScoreboard-1", "dummy",
                    ChatColor.translateAlternateColorCodes('&', "&a&l<< &2&lEnesN &a&>>"));
            obj.setDisplaySlot(DisplaySlot.SIDEBAR);
            Score score = obj.getScore(ChatColor.BLUE + "=-=-=-=-=-=-=-=-=");
            score.setScore(3);
            Score score2 = obj.getScore(ChatColor.AQUA + "Online Player: " + ChatColor.DARK_AQUA + Bukkit.getOnlinePlayers());
            score2.setScore(2);
            Score score3 = obj.getScore(ChatColor.AQUA + "total kils(mobs): " + ChatColor.DARK_AQUA +
                    player.getStatistic(Statistic.MOB_KILLS));
            score3.setScore(1);
            player.setScoreboard(board);
           
           
       
           
        }
    }
    
     
  2. Offline

    timtower Administrator Administrator Moderator

Share This Page