Alright so just a straight forward rundown of my problem is that I'm using Code (Text): String map_name = plugin.getConfig().getString("Maps." + storage.current_map + ".name"); for getting a name of the current map integer with a String. Now, where it confuses me is the fact it gives me a java.lang.NullPointerException if anyone knows why it's causing this, please do let me know. Thanks.
plugin could be null storage.current_map could be null, the return value from getConfig() could be null. Do null checks
1. Code brackets are square brackets, and not diamond brackets 2. Your naming conventions are strange. Use lowerCamelCase 3. Plugin could potentially be null EDIT: Damn I got sniped real hard there
Since you guys have been saying "plugin" could be null. I'm using this Code (Text): public static me.xfrogx.Main plugin; public StartGame(me.xfrogx.Main m) { plugin = m; } for getting the main in plugin for the string.
Code (Text): public class storage implements Listener{ public static me.xfrogx.Main plugin; public storage(me.xfrogx.Main m) { plugin = m; } public static HashMap<Player, UUID> Blue = new HashMap<Player, UUID>(); public static HashMap<Player, UUID> Red = new HashMap<Player, UUID>(); public static HashMap<Player, UUID> Spec = new HashMap<Player, UUID>(); public static String yes = "yes"; public static String no = "no"; public static int red_wool = 10; public static int blue_wool = 10; public static int current_map = 1; public static int next_map = 2; public static int prev_map = 0; public static int countdown = 30; public static HashMap<String, Boolean> lobby = new HashMap<String, Boolean>(); public static HashMap<String, Boolean> starting = new HashMap<String, Boolean>(); public static HashMap<String, Boolean> in_game = new HashMap<String, Boolean>(); public static HashMap<String, Boolean> end_game = new HashMap<String, Boolean>(); public static HashMap<String, Boolean> won = new HashMap<String, Boolean>(); } that's the whole class storage.
Code (Text): at java.lang.Thread.run(Unknown Source) [?:1.8.0_77] Caused by: java.lang.NullPointerException at me.xfrogx.Game.StartGame.startGame(StartGame.java:43) ~[?:?] at me.xfrogx.Cmds.StartCMD.onCommand(StartCMD.java:33) ~[?:?] at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[1.9.2.jar:git-Spigot-e6f93f4-d884ab3] ... 15 more
It says that the error is being caused at StartCMD line 33, as well as the line you already showed us. What is it?
Code (Text): if (cmd.getName().equalsIgnoreCase("start")) { if (p.hasPermission("server.owner")) { // Start.StartGame(p); // called when command is ran \\ Bukkit.broadcastMessage("TTT"); StartGame.startGame(); } } That's line 33 of the StartCMD.
I think I might've found the error, not too sure. But could it possibly be the fact that I'm making a string using an integer?