Error on plugin loading

Discussion in 'Spigot Plugin Development' started by Ppeckc, Oct 11, 2017.

  1. Code (Text):
    org.bukkit.plugin.InvalidPluginException: java.lang.ExceptionInInitializerError
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:326) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:248) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.loadPlugins(CraftServer.java:298) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.reload(CraftServer.java:743) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.Bukkit.reload(Bukkit.java:525) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.command.defaults.ReloadCommand.execute(ReloadCommand.java:25) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand(CraftServer.java:641) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchServerCommand(CraftServer.java:627) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.DedicatedServer.aP(DedicatedServer.java:443) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:678) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:576) [spigot.jar:git-Spigot-596221b-9a1fc1e]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_144]
    Caused by: java.lang.ExceptionInInitializerError
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_144]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_144]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            ... 14 more
    Caused by: java.lang.NullPointerException
            at xyz.blockbyblock.core.BlockByBlock.<clinit>(BlockByBlock.java:14) ~[?:?]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_144]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_144]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot.jar:git-Spigot-596221b-9a1fc1e]
            ... 14 more
    It comes up with that, what is wrong?
     
  2. Could you show your plugin's code aswell?
     
    #2 KaliCode, Oct 11, 2017
    Last edited: Oct 11, 2017
  3. Show your code please, the error is at xyz.blockbyblock.core.BlockByBlock.<clinit>(BlockByBlock.java:14) //line 14
     
  4. Code (Text):
    package xyz.blockbyblock.core.commands;

    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;

    import xyz.blockbyblock.core.BlockByBlock;

    public class commandBBB implements CommandExecutor {

        @Override
        public boolean onCommand(CommandSender s, Command cmd, String label, String[] args) {
            Player p = (Player) s;
           
            if (cmd.getName().equalsIgnoreCase("bbb")) {
                if (p.hasPermission("bbb.use")) {
                   
                    if (args[0] == "reload") {
                        p.sendMessage(ChatColor.translateAlternateColorCodes('&', BlockByBlock.prefix + "&aConfiguration reloaded..."));
                    } else if (args[0] == "info") {
                        p.sendMessage(BlockByBlock.config.getString("info"));
                    } else if (args.length < 0) {
                        p.sendMessage("/bbb <info/reload>");
                    } else if (args[0] != "info" || args[0] != "reload") {
                        p.sendMessage("/bbb <info/reload>");
                    }
                   
                } else if (!(p.hasPermission("bbb.use"))) {
                    p.sendMessage(BlockByBlock.noaccess);
                }
            }
            return false;
        }
       
    }
    Code (Text):
    package xyz.blockbyblock.core;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;

    import xyz.blockbyblock.core.commands.commandBBB;

    public class BlockByBlock extends JavaPlugin {
       
        public static String prefix = ChatColor.translateAlternateColorCodes('&', BlockByBlock.config.getString("prefix") + " ");
        public static String noaccess = ChatColor.translateAlternateColorCodes('&', BlockByBlock.prefix + BlockByBlock.config.getString("noaccess"));
        public static FileConfiguration config = Bukkit.getPluginManager().getPlugin("BBB-Core").getConfig();
       
        public static void send(Player p, String msg) {
            p.sendMessage(msg);
        }
       
        @Override
        public void onEnable() {
            System.out.println("BBB-Core : Enabled!");
           
            getConfig().options().copyDefaults(true);
            saveConfig();
           
            getCommand("bbb").setExecutor(new commandBBB());
        }
       
        @Override
        public void onDisable() {
            System.out.println("BBB-Core : Disabled!");
        }
       
    }
    @Minesuchtiiii
    @KaliCode
     
    #4 Ppeckc, Oct 11, 2017
    Last edited: Oct 11, 2017
  5. Code (Text):
    else if (args.length < 0) { }
    args length can't be less than 0, use == 0
     
  6. Why people use "static" to access methods from PluginManager#getPlugin(name)?
    Code (Text):
    public static FileConfiguration config = Bukkit.getPluginManager().getPlugin("BBB-Core").getConfig();
     
    • Agree Agree x 2
    • Funny Funny x 1
  7. To access it in other classes.
    This way you don't have to give the config as a parameter but you can just do BlockByBlock.config to get the config.
     
  8. Static methods should not be used as getters.
     
    • Like Like x 2