Solved [help!] error in the console. but not in local host??

Discussion in 'Spigot Plugin Development' started by _DutchGamernl_, Apr 23, 2017.

  1. Hello.
    i made an plugin but i tried to put it in my open server console but then there's an big error. but on my localhost there's no error ( it's working there).
    i made an actionbar welcome message plugin.
    here's my error:
    Code (Text):
    [09:30:26] [Server thread/ERROR]: Could not load 'plugins/ActionbarWelcomeMessage.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:133) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at org.bukkit.craftbukkit.v1_11_R1.CraftServer.loadPlugins(CraftServer.java:301) [spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:204) [spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:542) [spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at java.lang.Thread.run(Thread.java:745) [?:1.8.0_91]
    Caused by: java.lang.IllegalArgumentException: Plugin already initialized!
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:122) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at main.main.<init>(main.java:11) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_91]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_91]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_91]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_91]
        at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_91]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        ... 6 more
    Caused by: java.lang.IllegalStateException: Initial initialization
        at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:125) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:67) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at main.main.<init>(main.java:11) ~[?:?]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.8.0_91]
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[?:1.8.0_91]
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:1.8.0_91]
        at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[?:1.8.0_91]
        at java.lang.Class.newInstance(Class.java:442) ~[?:1.8.0_91]
        at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:76) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:129) ~[spigot-1.11.2.jar:git-Spigot-7d78b81-d5e7885]
        ... 6 more
    and i think it is because an plugin made it bugged... but wich one?
    here's my plugin list:
    Code (Text):
    AsyncWorldEdit.jar AsyncWorldEditInjector.jar AuctionGUIPlus-1.2.8-SNAPSHOT.jar chestShop(2).jar Citizens(1).jar clearlag.jar CoreProtect_2.14.2.jar EntityLWC(3).jar EssentialsX-2.0.1.jar EssentialsXChat-2.0.1.jar EssentialsXSpawn-2.0.1.jar FarmProtect-v1.8.3.jar FastCraftPlus.jar FeatherBoard(1).jar HolographicDisplays(6).jar HomeGUI.jar KitAdder.jar MVdWPlaceholderAPI.jar Multiverse-Core-2.5(3).jar PermissionsEx-1.23.4(5).jar PickupMoney.jar PlaceholderAPI(8).jar ProtocolLib(5).jar Questioner.jar ServerListPlus-3.4.7-Universal.jar Towny.jar Vault(1).jar gamemode-changer .jar staffchat.jar warpGUI.jar worldedit-bukkit-6.1.2.jar worldguard-6.2.jar
    I made an couple of plugins in this list. (gamemode changer, staffchat)
     
  2. can you show line 11 of main.main?
    Can you specify the "main" field in the plugin.yml of gamemode-changer and staffchat too? (Just the package + classname like you entered, not line 11)
     
  3. Code (Text):
    package main;

    import org.bukkit.Bukkit;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    import actionbar.actionbar;

    public class main extends JavaPlugin {

        public void onEnable(){
            PluginManager pm = Bukkit.getPluginManager();
            pm.registerEvents(new actionbar(null), this);

        }
        public void onDisable(){

        }

    }
     
    this one is it:
    Code (Text):
    public void onEnable(){
    EDIT:
    this is gamemode-changer:

    Code (Text):
    package main;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;

    public class main extends JavaPlugin implements Listener {
     
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
        }
     
        @Override
            public boolean onCommand(CommandSender s, Command cmd, String CommandLabel, String[] args) {
            if (s instanceof Player) {
                Player p = (Player) s;
                if (cmd.getName().equalsIgnoreCase("gamemode")) {
                    if (!p.hasPermission("gamemode.use")) {
                        s.sendMessage("§a[§bGameMode§a] " + ChatColor.RED + "you don't have permissions!");
                        return true;
                    }
                }
                if (args.length == 0) {
                    s.sendMessage("§a[§bGameMode§a] " + ChatColor.RED + "use /gm <0,1,2,3> [player]");
                    return true;
                }
                {
                    if (args.length == 1) {
                        if (args[0].equalsIgnoreCase("1") || args[0].equalsIgnoreCase("c")) {
                            GM.changeGamemode(GM.CREATIVE, p);  
                        }else if (args[0].equalsIgnoreCase("2") || args[0].equalsIgnoreCase("a")) {
                            GM.changeGamemode(GM.ADVENTURE, p);
                        }else if (args[0].equalsIgnoreCase("3") || args[0].equalsIgnoreCase("spec")) {
                            GM.changeGamemode(GM.SPECTATOR, p);
                        }else if (args[0].equalsIgnoreCase("0") || args[0].equalsIgnoreCase("s")) {
                            GM.changeGamemode(GM.SURVIVAL, p);
                        }  
                    }
                    if (!p.hasPermission("gamemode.change")) {
                        s.sendMessage("§a[§bGameMode§a] " + ChatColor.RED + "you don't have permissions!");
                        return true;
                    }
                    if (args.length == 2) {
                        Player target = Bukkit.getServer().getPlayer(args[1]);
                        if (target == null) {
                            s.sendMessage("§a[§bGameMode§a] " + ChatColor.RED + "can't find that player!");
                            return true;
                        }
                        if (args[0].equalsIgnoreCase("1") || args[0].equalsIgnoreCase("c")) {
                            GM.changeGamemode(GM.CREATIVE, target);  
                        }else if (args[0].equalsIgnoreCase("2") || args[0].equalsIgnoreCase("a")) {
                            GM.changeGamemode(GM.ADVENTURE, target);
                        }else if (args[0].equalsIgnoreCase("3") || args[0].equalsIgnoreCase("spec")) {
                            GM.changeGamemode(GM.SPECTATOR, target);
                        }else if (args[0].equalsIgnoreCase("0") || args[0].equalsIgnoreCase("s")) {
                            GM.changeGamemode(GM.SURVIVAL, target);
                        }
                        s.sendMessage("§a[§bGameMode§a] " + ChatColor.AQUA + "you changed the gamemode of: " + target.getDisplayName());
                        }
                }
            }
            return false;
        }
    }
    and this the staffchat:
    Code (Text):
    package chat;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin implements Listener{
     
        public void onEnable() {
            Bukkit.getServer().getPluginManager().registerEvents(this, this);
     
        }      
        public boolean onCommand(CommandSender s, Command cmd,    String label, String[] args) {
            if (s instanceof Player) {
                Player p = (Player) s;
                if (cmd.getName().equalsIgnoreCase("staffchat")) {
                    if (!s.hasPermission("staffchat.use")) {
                        s.sendMessage("§a[§cStaff§3Chat§a] " + ChatColor.RED + "je hebt geen permissies om dit te doen!");
                        return true;
                    }
                    if (args.length == 0) {
                        s.sendMessage("§a[§cStaff§3Chat§a] " + ChatColor.RED + "Sorry, maar dit kunnen we helaas niet sturen naar de andere staff leden, omdat er niks staat!");
                        return true;
                    }
                    if (args.length > 0) {
                        StringBuilder b = new StringBuilder();
                        for (int i = 0; i < args.length; i++) {
                            b.append(" ");
                            b.append(args[i]);
                        }
                        String message = b.toString();
                        for (Player all : Bukkit.getServer().getOnlinePlayers()) {
                            if (all.hasPermission("staffchat.use")) {
                             
                                all.sendMessage("§a[§cStaff§3Chat§a] " + ChatColor.RESET + p.getDisplayName() + ": " + ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', message));
                            }
                        }
                    }
                }
            }
         
            return false;      
        }
     
    }
    EDIT 2:
    I test it right now
     
    #3 _DutchGamernl_, Apr 23, 2017
    Last edited: Apr 23, 2017
  4. You have two plugins with the exact same package and main class name. Bukkit won't accept this.
    Long story short; every plugin should have different package names and different main class names.
    See this as an example for naming packages, and here for general info.
     
  5. it is working right now