NPE/help at bungeecord plugin messaging.

Discussion in 'Spigot Plugin Development' started by avighnash, May 29, 2016.

  1. Hello! I am using the bungeecord plugin messaging channel so I can get every player online in the network. Here is the code for that:

    Code (Text):
    @Override
        public void onPluginMessageReceived(String channel, Player player, byte[] message) {
            if (!channel.equals("BungeeCord")) {
                return;
            }
            ByteArrayDataInput in = ByteStreams.newDataInput(message);
            String subchannel = in.readUTF();

            if (subchannel.equals("BungeeCord")) {
                ByteArrayDataOutput out = ByteStreams.newDataOutput();
                out.writeUTF("PlayerCount");

                players = in.readInt();

                player.sendPluginMessage(MainClass.getInstance(), "BungeeCord", out.toByteArray());
            }
        }
    but on my scoreboard that has a team that displays the int "players", it shows up as 0.
    Why is this happening?

    also,

    I am making an alternative command for sending the player to different servers (again using bungeecord plugin messaging) and I am kind of confused on what I should do.
    Here is the code:

    Code (Text):
    package us.universalpvp.ae.commands;

    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.messaging.PluginMessageListener;

    import com.google.common.io.ByteArrayDataInput;
    import com.google.common.io.ByteArrayDataOutput;
    import com.google.common.io.ByteStreams;

    import us.universalpvp.ae.MainClass;

    public class LobbyCmd implements CommandExecutor, PluginMessageListener {

        public LobbyCmd() {
        }

        @Override
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (sender instanceof Player) {
                Player p = (Player) sender;
                if (cmd.getName().equalsIgnoreCase("lobby")) {
                    ByteArrayDataOutput out = ByteStreams.newDataOutput();
                    out.writeUTF("ConnectOther");
                    out.writeUTF(p.getName());
                    out.writeUTF("lobby");

                    p.sendPluginMessage(MainClass.getInstance(), "BungeeCord", out.toByteArray());
                }
            }
            return false;
        }

        @Override
        public void onPluginMessageReceived(String channel, Player player, byte[] message) {
            if (!channel.equals("BungeeCord")) {
                return;
            }
            ByteArrayDataInput in = ByteStreams.newDataInput(message);
            String subchannel = in.readUTF();
            if (subchannel.equals("BungeeCord")) {

            }
        }

    }
     
    Thanks!
     
  2. Forgot to add this :p
    Here is the NPE:

    Code (Text):
    [10:43:37 ERROR]: Error occurred while enabling CustomTabList v1.0 (Is it up to date?)
    java.lang.IllegalArgumentException: An objective of name 'the hubboard' already exists
            at org.apache.commons.lang.Validate.isTrue(Validate.java:136) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftScoreboard.registerNewObjective(CraftScoreboard.java:31) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.scoreboard.CraftScoreboard.registerNewObjective(CraftScoreboard.java:1) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at us.universalpvp.te.scoreboard.HubScoreboard.<init>(HubScoreboard.java:34) ~[?:?]
            at us.universalpvp.te.MainClass.onEnable(MainClass.java:81) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.reload(CraftServer.java:741) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.Bukkit.reload(Bukkit.java:535) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:641) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.aO(DedicatedServer.java:412) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:375) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:654) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:557) [spigot.jar:git-Spigot-db6de12-18fbb24]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_91]
    and it is pointed to this in my main class:

    Code (Text):
            this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
            this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new HubScoreboard());
     
    and this in my hub scoreboard class:

    Code (Text):
        final Objective obj = sco.registerNewObjective("the hubboard", "dummy");
     
     
  3. You'll get more help in the Bungeecord Development section :p
     
  4. This is relating to spigot though.
     
  5. But its Bungee too. Use the Bungee section xD
     
  6. Show us the full hub scoreboard class and the entirety of the main class.
     
  7. Code (Text):
    package us.universalpvp.te.scoreboard;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.messaging.PluginMessageListener;
    import org.bukkit.scheduler.BukkitRunnable;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.Team;

    import com.google.common.io.ByteArrayDataInput;
    import com.google.common.io.ByteArrayDataOutput;
    import com.google.common.io.ByteStreams;

    import us.universalpvp.te.MainClass;
    import us.universalpvp.te.utils.ColorScroller;
    import us.universalpvp.te.utils.Vault;

    @SuppressWarnings("deprecation")
    public class HubScoreboard implements Listener, PluginMessageListener {

        public HubScoreboard() {
        }

        private Scoreboard sco = MainClass.getInstance().sb;
        private String rankName = " ";
        private String world = " ";

        final Objective obj = sco.registerNewObjective("the hubboard", "dummy");
        final Team playersTeam = sco.registerNewTeam("Players");
        final Team coinsTeam = sco.registerNewTeam("ugh");
        final Team rankTeam = sco.registerNewTeam("Ranks");
        final Team rankDisplayTeam = sco.registerNewTeam("Ranks Display");
        final Team serverTeam = sco.registerNewTeam("Servers");
        final Team ipTeam = sco.registerNewTeam("IP");

        private int players;

        private Scoreboard setHubBoard() {

            new BukkitRunnable() {

                final ColorScroller displayName = new ColorScroller(ChatColor.AQUA, " UniversalPvP", "", "§f", "", true,
                        false, ColorScroller.ScrollType.FORWARD);

                @Override
                public void run() {

                    obj.setDisplayName(displayName.next());
                    obj.setDisplaySlot(DisplaySlot.SIDEBAR);

                    // SPACER
                    obj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED.toString())).setScore(11);

                    // RANKS
                    rankTeam.setPrefix(ChatColor.WHITE + "Rank:");
                    rankTeam.addEntry(ChatColor.AQUA.toString());

                    obj.getScore(ChatColor.AQUA.toString()).setScore(10);

                    rankDisplayTeam.setPrefix(rankName);
                    rankDisplayTeam.addEntry(ChatColor.DARK_AQUA.toString());

                    obj.getScore(ChatColor.DARK_AQUA.toString()).setScore(9);

                    // SPACER
                    obj.getScore(ChatColor.YELLOW.toString()).setScore(8);

                    // COINS
                    coinsTeam.setPrefix(ChatColor.WHITE + "Coins:");
                    coinsTeam.setSuffix(ChatColor.GREEN + " " + 0);
                    coinsTeam.addEntry(ChatColor.DARK_BLUE.toString());

                    obj.getScore(ChatColor.DARK_BLUE.toString()).setScore(7);

                    // PLAYER COUNT
                    playersTeam.setPrefix(ChatColor.WHITE + "Players:");
                    playersTeam.setSuffix(ChatColor.GREEN + " " + players);
                    playersTeam.addEntry(ChatColor.DARK_GRAY.toString());

                    obj.getScore(ChatColor.DARK_GRAY.toString()).setScore(6);

                    // SPACER
                    obj.getScore(ChatColor.GREEN.toString()).setScore(5);

                    // SERVER
                    serverTeam.setPrefix(ChatColor.WHITE + "Server: ");
                    serverTeam.setSuffix(ChatColor.GREEN + world);
                    serverTeam.addEntry(ChatColor.DARK_GREEN.toString());

                    obj.getScore(ChatColor.DARK_GREEN.toString()).setScore(4);

                    // SPACER
                    obj.getScore(ChatColor.BLUE.toString()).setScore(3);

                    // LINE
                    obj.getScore("---------------").setScore(2);

                    // IP
                    ipTeam.setPrefix(ChatColor.translateAlternateColorCodes('&', "&9&luniver"));
                    ipTeam.setSuffix(ChatColor.translateAlternateColorCodes('&', "&9&lsalpvp.us"));
                    ipTeam.addEntry(ChatColor.DARK_PURPLE.toString());

                    obj.getScore(ChatColor.DARK_PURPLE.toString()).setScore(1);

                }
            }.runTaskTimer(MainClass.getInstance(), 0, 10);

            return sco;

        }

        @EventHandler
        public void onPlayerJoinScoreboard(PlayerJoinEvent e) {

            Player p = e.getPlayer();

            String primaryGroup = Vault.getChat().getPrimaryGroup(p);
            if (primaryGroup.equalsIgnoreCase("default")) {

            } else if (primaryGroup.equalsIgnoreCase("default")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&7Default "));

            } else if (primaryGroup.equalsIgnoreCase("Owner")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&3[Owner]&3 "));

            } else if (primaryGroup.equalsIgnoreCase("Admin")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&c[Admin]&c "));

            } else if (primaryGroup.equalsIgnoreCase("Mod")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&2[Mod]&2 "));

            } else if (primaryGroup.equalsIgnoreCase("Helper")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&1[Helper]&1 "));

            } else if (primaryGroup.equalsIgnoreCase("Build")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&b[Builder]&b "));

            } else if (primaryGroup.equalsIgnoreCase("CoOwner")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&e[Co-Owner]&e "));
            }

            world = p.getWorld().getName().replace("Hub", "Lobby");

            for (Player pl : Bukkit.getOnlinePlayers()) {
                pl.setScoreboard(setHubBoard());
            }

        }

        @Override
        public void onPluginMessageReceived(String channel, Player player, byte[] message) {
            if (!channel.equals("BungeeCord")) {
                return;
            }
            ByteArrayDataInput in = ByteStreams.newDataInput(message);
            String subchannel = in.readUTF();

            if (subchannel.equals("BungeeCord")) {
                ByteArrayDataOutput out = ByteStreams.newDataOutput();
                out.writeUTF("PlayerCount");

                players = in.readInt();

                player.sendPluginMessage(MainClass.getInstance(), "BungeeCord", out.toByteArray());
            }
        }

    }
     
    Code (Text):
    package us.universalpvp.te;

    import org.bukkit.Bukkit;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.Team;

    import net.md_5.bungee.api.ChatColor;
    import us.universalpvp.te.chat.ChatCooldown;
    import us.universalpvp.te.chat.ChatFilter;
    import us.universalpvp.te.chat.ChatFormat;
    import us.universalpvp.te.cosmetics.LobbySelector;
    import us.universalpvp.te.listeners.ActionBarListener;
    import us.universalpvp.te.listeners.PlayerJoinItems;
    import us.universalpvp.te.listeners.SetWorldSpawnListener;
    import us.universalpvp.te.listeners.TablistListener;
    import us.universalpvp.te.listeners.TitleListener;
    import us.universalpvp.te.scoreboard.HubScoreboard;
    import us.universalpvp.te.scoreboard.nametags.NameTags;
    import us.universalpvp.te.tablist.FooterHeader;
    import us.universalpvp.te.tablist.Prefixes;
    import us.universalpvp.te.tablist.Teams;
    import us.universalpvp.te.utils.Vault;

    public class MainClass extends JavaPlugin {

        private Prefixes prefixes = new Prefixes();
        private Teams teams = new Teams();

        public Scoreboard sb = Bukkit.getServer().getScoreboardManager().getNewScoreboard();

        private static MainClass instance;

        public Team OWNER = null;
        public Team ADMIN = null;
        public Team MOD = null;
        public Team YT = null;
        public Team VIP = null;
        public Team HELPER = null;
        public Team BUILD = null;
        public Team CoOWNER = null;
        public Team DEFAULT = null;

        public void onEnable() {

            instance = this;

            saveDefaultConfig();

            teams.registerTheTeams();

            prefixes.theHealth();
            prefixes.setPrefix();
            prefixes.setupPermissions();

            ChatFilter.blocked.add("ass");
            ChatFilter.blocked.add("fuck");
            ChatFilter.blocked.add("shite");
            ChatFilter.blocked.add("hell");

            registerEvents(this, prefixes);
            registerEvents(this, new NameTags());
            registerEvents(this, new ChatFilter());
            registerEvents(this, new ChatFormat());
            registerEvents(this, new FooterHeader());
            registerEvents(this, new ChatCooldown());
            registerEvents(this, new HubScoreboard());
            registerEvents(this, new LobbySelector());
            registerEvents(this, new TitleListener());
            registerEvents(this, new TablistListener());
            registerEvents(this, new ActionBarListener());
            registerEvents(this, new SetWorldSpawnListener());
            registerEvents(this, new PlayerJoinItems());

            Vault.setupChat();
            Vault.setupEconomy();
            Vault.setupPermissions();

            this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
            this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new HubScoreboard());

            if (!Vault.init() == false) {
                return;
            } else {
                System.out.print(ChatColor.RED + "GET CHAT OR GET PERMISSIONS OR GET ECONOMY IS FALSE BEDODODODODODO");
            }

        }

        @Override
        public void onDisable() {

            getLogger().info("Disabled");

            OWNER.unregister();
            ADMIN.unregister();
            MOD.unregister();
            YT.unregister();
            VIP.unregister();
            HELPER.unregister();
            BUILD.unregister();
            CoOWNER.unregister();
            DEFAULT.unregister();

        }

        public static MainClass getInstance() {
            return instance;
        }

        public void registerEvents(org.bukkit.plugin.Plugin plugin, Listener... listeners) {
            for (Listener listener : listeners) {
                this.getServer().getPluginManager().registerEvents(listener, plugin);
            }
        }

    }
     
     
  8. Code (Text):
     this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", new HubScoreboard());
    Code (Text):
     registerEvents(this, new HubScoreboard());
    The class is initialized more than once, causing this to be thrown:
     
    • Like Like x 1
  9. So I should create a static instance of the class HubBoard then use it?
     
    • Funny Funny x 1
  10. No, you should store a reference of it.
     
  11. Like what I did for the teams and prefixes class?
     
  12. That's not an NPE, it's an IllegalArgumentException
     
  13. Oops, wrong thing. Before that I think I was getting an NPE.
     
  14. Also to make your variable, no need to store it anywhere.
    Code (Text):
     HubScoreboard s = new HubScoreboard();
    this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", s);
    registerEvents(this, s);
     
  15. Now I get an NPE at
    Code (Text):
            HubScoreboard board = new HubScoreboard();
     
    and because of
    Code (Text):
        private Scoreboard sco = MainClass.getInstance().sb;
     
    and I think its because of the hub scoreboard class getting initialized twice again. But how would I fix it? I need the second line I showed.
     
  16. That is what I did, I still get an NPE.
     
  17. An NPE or an IllegalArgumentException? Also can you show the new class?
     
  18. Code (Text):
    package us.universalpvp.te.scoreboard;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.messaging.PluginMessageListener;
    import org.bukkit.scheduler.BukkitRunnable;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.Team;

    import com.google.common.io.ByteArrayDataInput;
    import com.google.common.io.ByteArrayDataOutput;
    import com.google.common.io.ByteStreams;

    import us.universalpvp.te.MainClass;
    import us.universalpvp.te.utils.ColorScroller;
    import us.universalpvp.te.utils.Vault;

    @SuppressWarnings("deprecation")
    public class HubScoreboard implements Listener, PluginMessageListener {

        private Scoreboard sco = MainClass.getInstance().sb;
        private String rankName = " ";
        private String world = " ";

        final Objective obj = sco.registerNewObjective("the hubboard", "dummy");
        final Team playersTeam = sco.registerNewTeam("Players");
        final Team coinsTeam = sco.registerNewTeam("ugh");
        final Team rankTeam = sco.registerNewTeam("Ranks");
        final Team rankDisplayTeam = sco.registerNewTeam("Ranks Display");
        final Team serverTeam = sco.registerNewTeam("Servers");
        final Team ipTeam = sco.registerNewTeam("IP");

        private int players;

        public HubScoreboard() {

        }

        private Scoreboard setHubBoard() {

            new BukkitRunnable() {

                final ColorScroller displayName = new ColorScroller(ChatColor.AQUA, " UniversalPvP", "", "§f", "", true,
                        false, ColorScroller.ScrollType.FORWARD);

                @Override
                public void run() {

                    obj.setDisplayName(displayName.next());
                    obj.setDisplaySlot(DisplaySlot.SIDEBAR);

                    // SPACER
                    obj.getScore(Bukkit.getOfflinePlayer(ChatColor.RED.toString())).setScore(11);

                    // RANKS
                    rankTeam.setPrefix(ChatColor.WHITE + "Rank:");
                    rankTeam.addEntry(ChatColor.AQUA.toString());

                    obj.getScore(ChatColor.AQUA.toString()).setScore(10);

                    rankDisplayTeam.setPrefix(rankName);
                    rankDisplayTeam.addEntry(ChatColor.DARK_AQUA.toString());

                    obj.getScore(ChatColor.DARK_AQUA.toString()).setScore(9);

                    // SPACER
                    obj.getScore(ChatColor.YELLOW.toString()).setScore(8);

                    // COINS
                    coinsTeam.setPrefix(ChatColor.WHITE + "Coins:");
                    coinsTeam.setSuffix(ChatColor.GREEN + " " + 0);
                    coinsTeam.addEntry(ChatColor.DARK_BLUE.toString());

                    obj.getScore(ChatColor.DARK_BLUE.toString()).setScore(7);

                    // PLAYER COUNT
                    playersTeam.setPrefix(ChatColor.WHITE + "Players:");
                    playersTeam.setSuffix(ChatColor.GREEN + " " + players);
                    playersTeam.addEntry(ChatColor.DARK_GRAY.toString());

                    obj.getScore(ChatColor.DARK_GRAY.toString()).setScore(6);

                    // SPACER
                    obj.getScore(ChatColor.GREEN.toString()).setScore(5);

                    // SERVER
                    serverTeam.setPrefix(ChatColor.WHITE + "Server: ");
                    serverTeam.setSuffix(ChatColor.GREEN + world);
                    serverTeam.addEntry(ChatColor.DARK_GREEN.toString());

                    obj.getScore(ChatColor.DARK_GREEN.toString()).setScore(4);

                    // SPACER
                    obj.getScore(ChatColor.BLUE.toString()).setScore(3);

                    // LINE
                    obj.getScore("---------------").setScore(2);

                    // IP
                    ipTeam.setPrefix(ChatColor.translateAlternateColorCodes('&', "&9&luniver"));
                    ipTeam.setSuffix(ChatColor.translateAlternateColorCodes('&', "&9&lsalpvp.us"));
                    ipTeam.addEntry(ChatColor.DARK_PURPLE.toString());

                    obj.getScore(ChatColor.DARK_PURPLE.toString()).setScore(1);

                }
            }.runTaskTimer(MainClass.getInstance(), 0, 10);

            return sco;

        }

        @EventHandler
        public void onPlayerJoinScoreboard(PlayerJoinEvent e) {

            Player p = e.getPlayer();

            String primaryGroup = Vault.getChat().getPrimaryGroup(p);
            if (primaryGroup.equalsIgnoreCase("default")) {

            } else if (primaryGroup.equalsIgnoreCase("default")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&7Default "));

            } else if (primaryGroup.equalsIgnoreCase("Owner")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&3[Owner]&3 "));

            } else if (primaryGroup.equalsIgnoreCase("Admin")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&c[Admin]&c "));

            } else if (primaryGroup.equalsIgnoreCase("Mod")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&2[Mod]&2 "));

            } else if (primaryGroup.equalsIgnoreCase("Helper")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&1[Helper]&1 "));

            } else if (primaryGroup.equalsIgnoreCase("Build")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&b[Builder]&b "));

            } else if (primaryGroup.equalsIgnoreCase("CoOwner")) {
                rankName = (ChatColor.translateAlternateColorCodes('&', "&e[Co-Owner]&e "));
            }

            world = p.getWorld().getName().replace("Hub", "Lobby");

            for (Player pl : Bukkit.getOnlinePlayers()) {
                pl.setScoreboard(setHubBoard());
            }

        }

        @Override
        public void onPluginMessageReceived(String channel, Player player, byte[] message) {
            if (!channel.equals("BungeeCord")) {
                return;
            }
            ByteArrayDataInput in = ByteStreams.newDataInput(message);
            String subchannel = in.readUTF();

            if (subchannel.equals("BungeeCord")) {
                ByteArrayDataOutput out = ByteStreams.newDataOutput();
                out.writeUTF("PlayerCount");

                players = in.readInt();

                player.sendPluginMessage(MainClass.getInstance(), "BungeeCord", out.toByteArray());
            }
        }

    }
    Code (Text):
    package us.universalpvp.te;

    import org.bukkit.Bukkit;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.Scoreboard;
    import org.bukkit.scoreboard.Team;

    import net.md_5.bungee.api.ChatColor;
    import us.universalpvp.te.chat.ChatCooldown;
    import us.universalpvp.te.chat.ChatFilter;
    import us.universalpvp.te.chat.ChatFormat;
    import us.universalpvp.te.cosmetics.LobbySelector;
    import us.universalpvp.te.listeners.ActionBarListener;
    import us.universalpvp.te.listeners.PlayerJoinItems;
    import us.universalpvp.te.listeners.SetWorldSpawnListener;
    import us.universalpvp.te.listeners.TablistListener;
    import us.universalpvp.te.listeners.TitleListener;
    import us.universalpvp.te.scoreboard.HubScoreboard;
    import us.universalpvp.te.scoreboard.nametags.NameTags;
    import us.universalpvp.te.tablist.FooterHeader;
    import us.universalpvp.te.tablist.Prefixes;
    import us.universalpvp.te.tablist.Teams;
    import us.universalpvp.te.utils.Vault;

    public class MainClass extends JavaPlugin {

        private Prefixes prefixes = new Prefixes();
        private Teams teams = new Teams();

        public Scoreboard sb = Bukkit.getServer().getScoreboardManager().getNewScoreboard();

        private static MainClass instance;

        public Team OWNER = null;
        public Team ADMIN = null;
        public Team MOD = null;
        public Team YT = null;
        public Team VIP = null;
        public Team HELPER = null;
        public Team BUILD = null;
        public Team CoOWNER = null;
        public Team DEFAULT = null;

        public void onEnable() {

            HubScoreboard board = new HubScoreboard();

            instance = this;

            saveDefaultConfig();

            teams.registerTheTeams();

            prefixes.theHealth();
            prefixes.setPrefix();
            prefixes.setupPermissions();

            ChatFilter.blocked.add("ass");
            ChatFilter.blocked.add("fuck");
            ChatFilter.blocked.add("shite");
            ChatFilter.blocked.add("hell");

            registerEvents(this, prefixes);
            registerEvents(this, new NameTags());
            registerEvents(this, new ChatFilter());
            registerEvents(this, new ChatFormat());
            registerEvents(this, new FooterHeader());
            registerEvents(this, new ChatCooldown());
            registerEvents(this, board);
            registerEvents(this, new LobbySelector());
            registerEvents(this, new TitleListener());
            registerEvents(this, new TablistListener());
            registerEvents(this, new ActionBarListener());
            registerEvents(this, new SetWorldSpawnListener());
            registerEvents(this, new PlayerJoinItems());

            Vault.setupChat();
            Vault.setupEconomy();
            Vault.setupPermissions();

            this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
            this.getServer().getMessenger().registerIncomingPluginChannel(this, "BungeeCord", board);

            if (!Vault.init() == false) {
                return;
            } else {
                System.out.print(ChatColor.RED + "GET CHAT OR GET PERMISSIONS OR GET ECONOMY IS FALSE BEDODODODODODO");
            }

        }

        @Override
        public void onDisable() {

            getLogger().info("Disabled");

            OWNER.unregister();
            ADMIN.unregister();
            MOD.unregister();
            YT.unregister();
            VIP.unregister();
            HELPER.unregister();
            BUILD.unregister();
            CoOWNER.unregister();
            DEFAULT.unregister();

        }

        public static MainClass getInstance() {
            return instance;
        }

        public void registerEvents(org.bukkit.plugin.Plugin plugin, Listener... listeners) {
            for (Listener listener : listeners) {
                this.getServer().getPluginManager().registerEvents(listener, plugin);
            }
        }

    }
     
  19. Where exactly does the crash happen and can you send the actual crash log?