Development Assistance Null Pointer Exception

Discussion in 'Plugin Help/Development/Requests' started by TheCwispyOne, Oct 11, 2014.

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


    Ok so I made another thread about getting methods from different classes and I kinda fixed my problem but I also kinda didn't.
    1. public class GalaxiesFile {
    3. public Cmds plugin;
    4. public GalaxiesFile(Cmds plugin) {
    5. this.plugin = plugin;
    6. }
    8. public File GalaxiesFile = null;
    9. public FileConfiguration Galaxies = null;
    11. public void reloadGalaxies() {
    12. if (GalaxiesFile == null) {
    13. GalaxiesFile = new File(plugin.getDataFolder(), "Galaxies.yml");
    14. }
    15. Galaxies = YamlConfiguration.loadConfiguration(GalaxiesFile);
    16. }
    18. public FileConfiguration getGalaxies() {
    19. if (Galaxies == null) {
    20. reloadGalaxies();
    21. }
    22. return Galaxies;
    23. }
    25. public void saveGalaxies() {
    26. try {
    28. } catch (IOException e) {
    29. plugin.getLogger().info(ChatColor.RED + "Could not save Galaxies.yml.");
    30. }
    31. }
    32. }

    part of
    1. private GalaxiesFile gfile;
    3. public void onEnable() {
    4. makeDataFolder();
    5. saveDefaultConfig();
    6. gfile.reloadGalaxies();//this is line 32
    7. gfile.saveGalaxies();
    8. new BlockPhysics(this);
    9. PluginManager pm = getServer().getPluginManager();
    10. pm.addPermission(planetwars);
    11. }

    Stack trace:
    [20:56:07 INFO]: [Planet_Wars] Enabling Planet_Wars v1.0
    [20:56:07 ERROR]: Error occurred while enabling Planet_Wars v1.0 (Is it up to date?)
        at thecwispyone.main.Cmds.onEnable( ~[?:?]
        at ~[spigot.jar:git-Spigot-1443]
        at [spigot.jar:git-Spigot-1443]
        at org.bukkit.plugin.SimplePluginManager.enablePlugin( [spigot.jar:git-Spigot-1443]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugin( [spigot.jar:git-Spigot-1443]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.enablePlugins( [spigot.jar:git-Spigot-1443]
        at net.minecraft.server.v1_7_R3.MinecraftServer.n( [spigot.jar:git-Spigot-1443]
        at net.minecraft.server.v1_7_R3.MinecraftServer.g( [spigot.jar:git-Spigot-1443]
        at net.minecraft.server.v1_7_R3.MinecraftServer.a( [spigot.jar:git-Spigot-1443]
        at net.minecraft.server.v1_7_R3.DedicatedServer.init( [spigot.jar:git-Spigot-1443]
        at [spigot.jar:git-Spigot-1443]
        at [spigot.jar:git-Spigot-1443]
    Ok so I'm not sure why it's a null pointer exception. Help?
  2. Offline


    TheCwispyOne You never initialized gfile in which results in it being null by default. You then call a method on the gfile variable resulting in the NullPointerException.
  3. Offline


    Mmarz11 You have a good point there sir :) Maybe I should sleep a bit earlier...

    Mmarz11 Ok so i just tested it out. I did:
    1. private GalaxiesFile gfile;
    2. private Cmds(GalaxiesFile gfile) {
    3. this.gfile = gfile;
    4. }

    I still got no errors in eclipse but now the error in the console is Abnormal Plugin type. Could you show me how I'm supposed to do this?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 14, 2016
    mine-care likes this.
  4. Offline


  5. Offline


    I doesn't give the line of the error. It just says abnormal plugin type.
    Here's the error:
    [10:32:10 ERROR]: Could not load 'plugins/PlanetWars.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Abnormal plugin type
        at<init>( ~[spigot.jar:git-Spigot-1443]
        at ~[spigot.jar:git-Spigot-1443]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin( ~[spigot.jar:git-Spigot-1443]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins( [spigot.jar:git-Spigot-1443]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugins( [spigot.jar:git-Spigot-1443]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.reload( [spigot.jar:git-Spigot-1443]
        at org.bukkit.Bukkit.reload( [spigot.jar:git-Spigot-1443]
        at org.bukkit.command.defaults.ReloadCommand.execute( [spigot.jar:git-Spigot-1443]
        at org.bukkit.command.SimpleCommandMap.dispatch( [spigot.jar:git-Spigot-1443]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchCommand( [spigot.jar:git-Spigot-1443]
        at org.bukkit.craftbukkit.v1_7_R3.CraftServer.dispatchServerCommand( [spigot.jar:git-Spigot-1443]
        at net.minecraft.server.v1_7_R3.DedicatedServer.aB( [spigot.jar:git-Spigot-1443]
        at net.minecraft.server.v1_7_R3.DedicatedServer.v( [spigot.jar:git-Spigot-1443]
        at net.minecraft.server.v1_7_R3.MinecraftServer.u( [spigot.jar:git-Spigot-1443]
        at [spigot.jar:git-Spigot-1443]
        at [spigot.jar:git-Spigot-1443]
    Caused by: java.lang.InstantiationException: thecwispyone.main.Cmds
        at java.lang.Class.newInstance( ~[?:1.8.0]
        at<init>( ~[spigot.jar:git-Spigot-1443]
        ... 15 more
    Caused by: java.lang.NoSuchMethodException: thecwispyone.main.Cmds.<init>()
        at java.lang.Class.getConstructor0( ~[?:1.8.0]
        at java.lang.Class.newInstance( ~[?:1.8.0]
        at<init>( ~[spigot.jar:git-Spigot-1443]
        ... 15 more
  6. Offline


    This is spigot, moved the appropriate forums. Please make sure you are posting in the right sections.
Thread Status:
Not open for further replies.

Share This Page