Solved Please help URGENT

Discussion in 'General Help' started by DividedByZero, Nov 8, 2015.

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

    DividedByZero

    Ok so I am working on a minigame network and this issue has literally made me scratch my head all day. I am a pretty advanced programmer and I am able to debug almost everything but this has me confused.

    First, my network run PERFECTLY no issues when I setup all the bungee cord server on my machine which is how I test the programs before I update my dedicated servers. My minigame network has 6 dedicated 12gb servers (1 for each area of the network eg. Hub, Minigames, etc.) but my hub plugin throws an error on my dedicated server when i copy the EXACT file from my machine which works perfectly no errors.

    here is the stack trace.
    Code:
    java.lang.NullPointerException
            at dev.sakura.sakurahub.Commands.HubCommandManager.<init>(HubCommandManager.java:13) ~[?:?]
            at dev.sakura.sakurahub.SakuraHub.startupManagers(SakuraHub.java:25) ~[?:?]
            at dev.sakura.sakurahub.SakuraHub.onEnable(SakuraHub.java:17) ~[?:?]
            at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:321) ~[spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:340) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:405) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugin(CraftServer.java:357) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.enablePlugins(CraftServer.java:317) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.s(MinecraftServer.java:414) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.k(MinecraftServer.java:378) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.a(MinecraftServer.java:333) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:263) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigot_server.jar:git-Spigot-5f38d38-18fbb24]
            at java.lang.Thread.run(Thread.java:745) [?:1.8.0_66]
    
    I was thinking that it had to do with database issues or java versions incompaditbilty but I made sure to compile all my programs with the same java version my servers are running (java 1.7 build 79).

    I need help asap to stay on track with development.
     
  2. Offline

    567legodude

    @DividedByZero There are gonna be those stupid people that ask you to post your code.
    Seriously though, we can't help without knowing what could cause it.
     
  3. Offline

    teej107

    Really? I find that hard to believe because the Exception that is thrown is one of, if not, the easiest exception to prevent.
    Anyways, BungeeCord isn't supported on Bukkit forums. Get support on Spigot.
     
  4. Offline

    DividedByZero

    Having some issues with my git. In the meantime here is the class the error is poiting to.

    Code:
    package dev.sakura.sakurahub.Hub;
    
    import java.io.File;
    import java.util.ArrayList;
    import java.util.Iterator;
    
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.GameMode;
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
    import dev.sakura.Config.ConfigManager;
    import dev.sakura.Config.SakuraConfig;
    import dev.sakura.PlayerData.PlayerData;
    import dev.sakura.PlayerManager.RankConvert;
    import dev.sakura.sakurahub.SakuraHub;
    import dev.sakura.sakurahub.Libs.WorldHandlers;
    
    public class HubManager {
        private static HubManager instance;
       
        public HubManager() {
            instance = this;
           
            this.loadHubs();
        }
       
        public static HubManager get() {
            return instance;
        }
       
        private ArrayList<Hub> hubs = new ArrayList<Hub>();
       
        public Hub getHub(int id) {
            Iterator<Hub> it = hubs.iterator();
            while(it.hasNext()) {
                Hub hub = it.next();
                if(hub.getId() == id) {
                    return hub;
                }
            }
            return null;
        }
       
        public Hub getHub(Player player) {
            Iterator<Hub> it = hubs.iterator();
            while(it.hasNext()) {
                Hub hub = it.next();
                if(hub.containsPlayer(player)) {
                    return hub;
                }
            }
            return null;
        }
       
        public void joinHub(final Player player, int hubid) {
            int hid;
           
            if(hubid == -1) {
                hid = (int) Math.ceil(Math.random()*hubs.size());
            }
            else {
                hid = hubid;
            }
           
            Hub hub = this.getHub(hid);
            hub.join(player);
           
            Location spawn = hub.getSpawn();
            spawn.setWorld(Bukkit.getWorld(hub.getServerName()+"_hub"));
           
            player.teleport(spawn);
           
            SakuraHub.plugin.getServer().getScheduler().scheduleSyncDelayedTask(SakuraHub.plugin, new Runnable() {
                @Override
                public void run() {
                    player.setGameMode(GameMode.ADVENTURE);
                }
            }, 10L);
            player.setCompassTarget(hub.getSpawn());
            player.setPlayerListName(RankConvert.get().RankToPrefix(PlayerData.get().getPlayer(player).getRank())+""+player.getName());
            player.setDisplayName(RankConvert.get().RankToPrefix(PlayerData.get().getPlayer(player).getRank())+""+player.getName());
            player.setHealth(20);
            player.setFoodLevel(20);
        }
       
        public void leaveHub(Player player) {
            Hub hub = this.getHub(player);
           
            if(hub == null) {
                return;
            }
           
            hub.leave(player);
        }
       
        public void loadHubs() {
            hubs = new ArrayList<Hub>();
           
            SakuraConfig config = ConfigManager.get().fetchClass("/hubs/hubs.yml");
           
            for(String id : config.getConfig().getConfigurationSection("hubs").getKeys(false)) {
                int i = Integer.parseInt(id);
                Hub h = new Hub(i);
                hubs.add(h);
               
                Bukkit.getServer().dispatchCommand(SakuraHub.plugin.getServer().getConsoleSender(), "mv delete "+h.getServerName()+"_hub");
                Bukkit.getServer().dispatchCommand(SakuraHub.plugin.getServer().getConsoleSender(), "mv confirm");
               
                WorldHandlers.get().copyWorld(new File("worlds_backup/hub_world"), new File(h.getServerName()+"_hub"));
               
                Bukkit.getServer().dispatchCommand(SakuraHub.plugin.getServer().getConsoleSender(), "mv import "+h.getServerName()+"_hub NORMAL");
            }
           
            for(Player p : Bukkit.getOnlinePlayers()) {
                p.kickPlayer(ChatColor.RED+""+ChatColor.BOLD+"WARNING"+ChatColor.RESET+"\n"+ChatColor.YELLOW+"This server was forced to reset. Please reconnect.");
            }
        }
    }
    
    Like i said this code runs perfectly on my computer but on the dedicated servers it throws that error.
     
  5. Offline

    567legodude

    @DividedByZero You should show the HubCommandManager class. That is where the error happened.
     
  6. Offline

    DividedByZero

    HubCommandManager.class
    Code:
    package dev.sakura.sakurahub.Commands;
    
    import dev.sakura.Commands.CommandManager;
    import dev.sakura.sakurahub.Hub.Commands.Command_sethub;
    
    public class HubCommandManager {
        public static HubCommandManager get() {
            return new HubCommandManager();
        }
       
        public HubCommandManager() {
            CommandManager manager = CommandManager.get();
            manager.addCommand(new Command_sethub());
        }
    }
    Command_sethub.class
    Code:
    package dev.sakura.sakurahub.Hub.Commands;
    
    import org.bukkit.ChatColor;
    import org.bukkit.Location;
    import org.bukkit.entity.Player;
    
    import dev.sakura.Commands.SakuraCommand;
    import dev.sakura.Config.ConfigManager;
    import dev.sakura.Config.SakuraConfig;
    import dev.sakura.Libs.ConfigLocation;
    
    public class Command_sethub extends SakuraCommand {
        public Command_sethub() {
            super("sethub","developer");
        }
       
        private void setHub(Player player, String hubid, String serverName) {
            Location loc = player.getLocation();
            SakuraConfig config = ConfigManager.get().fetchClass("/hubs/hubs.yml");
           
            config.getConfig().set("hubs."+hubid+".serverName", serverName);
            config.getConfig().set("hubs."+hubid+".id", hubid);
            config.getConfig().set("hubs."+hubid+".maxPlayers", 50);
            config.saveConfig();
           
            ConfigLocation.get().LocationToConfig("hubs."+hubid+".spawn", "/hubs/hubs.yml", loc);
        }
       
        @Override
        public void command(Player player, String command, String[] args) {
            if(args.length == 1) {
                player.sendMessage(ChatColor.YELLOW+"========== "+ChatColor.BLUE+""+ChatColor.BOLD+"Command Help "+ChatColor.RESET+""+ChatColor.YELLOW+"==========");
            } else {
                this.setHub(player, args[1], args[2]);
                player.sendMessage(ChatColor.GREEN+""+ChatColor.BOLD+"SUCCESS> "+ChatColor.RESET+""+ChatColor.GRAY+"You have setup a hub with the ID: "+args[1]+" and a server name: "+args[2]+".");
            }
        }
    }
    http://prntscr.com/90nnzz

    This is what confuses me. They are the exact same on both ends in terms of files. Plugin Versions etc..

    i think i know. I think my SakuraLibs plugin is getting enabled after my SakuraHub plugin. which SakuraHub depends on it to handle all commands, listeners, configs, etc

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Nov 8, 2015
  7. Offline

    567legodude

    @DividedByZero The CommandManager class is null, which is why the error came.
     
  8. Offline

    DividedByZero

    Yeh command manager is from SakuraLibs plugin. Its weird because it works fine on my computer. It must be the plugin is calling that before the other plugin is fully loaded. Ill try and add a 1 tick delay to the plugin loading.
     
  9. Offline

    567legodude

    @DividedByZero If you depend on the other plugin, it should load before this one tries to load. No need for delay.
     
  10. Offline

    DividedByZero

    Omg, i am an idot. Lol this may sound really embarressing but I was saving the SakuraHub plugin as SakuraLibs and uploading the wrong plugin jar lol. I am sorry to bug you. Thanks for the help anyway. Programming for 12 hours straight is probably not good for the brain. Im off to get some sleep. Thanks man.
     
Thread Status:
Not open for further replies.

Share This Page