error plugin already inizialized

Discussion in 'Plugin Development' started by 4thegame3, Jul 2, 2014.

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

    4thegame3

    (sorry if my english is wrong)

    i'm getting mad trying to fix my plugin, this is the error

    Code:java
    1. 23.52.23 [SEVERE] Error occurred while enabling TheGamePlugin v1.0 (Is it up to date?)
    2. 23.52.23 java.lang.IllegalArgumentException: Plugin already initialized!
    3. 23.52.23 at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:98) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    4. 23.52.23 at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    5. 23.52.23 at me.TheGame.Main.<init>(Main.java:24) ~[?:?]
    6. 23.52.23 at me.TheGame.Write.<init>(Write.java:12) ~[?:?]
    7. 23.52.23 at me.TheGame.BlockCoord.<init>(BlockCoord.java:23) ~[?:?]
    8. 23.52.23 at me.TheGame.Main.onEnable(Main.java:60) ~[?:?]
    9. 23.52.23 at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:316) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    10. 23.52.23 at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:324) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    11. 23.52.23 at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    12. 23.52.23 at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugin(CraftServer.java:446) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    13. 23.52.23 at org.bukkit.craftbukkit.v1_7_R3.CraftServer.enablePlugins(CraftServer.java:380) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    14. 23.52.23 at net.minecraft.server.v1_7_R3.MinecraftServer.n(MinecraftServer.java:352) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    15. 23.52.23 at net.minecraft.server.v1_7_R3.MinecraftServer.g(MinecraftServer.java:326) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    16. 23.52.23 at net.minecraft.server.v1_7_R3.MinecraftServer.a(MinecraftServer.java:282) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    17. 23.52.23 at net.minecraft.server.v1_7_R3.DedicatedServer.init(DedicatedServer.java:182) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    18. 23.52.23 at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:436) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    19. 23.52.23 at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    20. 23.52.23 Caused by: java.lang.IllegalStateException: Initial initialization
    21. 23.52.23 at org.bukkit.plugin.java.PluginClassLoader.initialize(PluginClassLoader.java:101) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    22. 23.52.23 at org.bukkit.plugin.java.JavaPlugin.<init>(JavaPlugin.java:66) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    23. 23.52.23 at me.TheGame.Main.<init>(Main.java:24) ~[?:?]
    24. 23.52.23 at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:1.7.0_60]
    25. 23.52.23 at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_60]
    26. 23.52.23 at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source) ~[?:1.7.0_60]
    27. 23.52.23 at java.lang.reflect.Constructor.newInstance(Unknown Source) ~[?:1.7.0_60]
    28. 23.52.23 at java.lang.Class.newInstance(Unknown Source) ~[?:1.7.0_60]
    29. 23.52.23 at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:52) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    30. 23.52.23 at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:127) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    31. 23.52.23 at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:328) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    32. 23.52.23 at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    33. 23.52.23 at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugins(CraftServer.java:355) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    34. 23.52.23 at org.bukkit.craftbukkit.v1_7_R3.CraftServer.<init>(CraftServer.java:317) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    35. 23.52.23 at net.minecraft.server.v1_7_R3.PlayerList.<init>(PlayerList.java:68) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    36. 23.52.23 at net.minecraft.server.v1_7_R3.DedicatedPlayerList.<init>(SourceFile:14) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    37. 23.52.23 at net.minecraft.server.v1_7_R3.DedicatedServer.init(DedicatedServer.java:126) ~[craftbukkit.jar:git-Bukkit-1.7.9-R0.1-10-g8688bd4-b3092jnks]
    38. 23.52.23 ... 2 more
    39. 23.52.23 [INFO] Server permissions file permissions.yml is empty, ignoring it
    40.  



    here's the Main
    Code:
    package me.TheGame;
     
    //import java.io.File;
    //import org.bukkit.configuration.file.FileConfiguration;
    //import org.bukkit.configuration.file.YamlConfiguration;
    import java.io.File;
    import java.util.Arrays;
    import java.util.List;
    import java.util.Random;
    import java.util.Set;
     
    import org.bukkit.Bukkit;
    import org.bukkit.Location;
    import org.bukkit.World;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.EntityType;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitTask;
     
    import me.TheGame.*;
     
    public class Main extends JavaPlugin {
        public static Config config;
        Write write;
        public int[] taskList;
        public boolean emptyConfig = false;
        public Util util;
     
     
        public void Reload(){
            util.CloseTasks();
            if (Global.enabled) {
                Start();
            }
        }
       
        public void Start() {
           
            try {
                Global.enabled = true;
                Set<String> s = getConfig().getConfigurationSection("Spawners").getKeys(false);
                String[] strarray = (String[]) s.toArray(new String[s.size()]);
                taskList = new int[s.size()];
                for (int i = 0; strarray.length != i; i++) {
                    int x = getConfig().getInt("Spawners." + strarray[i] + ".TempoSpawn");
                    BukkitTask TaskName = new Run(this, strarray[i]).runTaskTimer(this, x * 20L, x * 20L);
                    taskList[i] = TaskName.getTaskId();
                }
            } catch (Exception exc) {
                this.getLogger().info("WARNING!: Config is empty");
                emptyConfig = true;
            }
        }
     
        public void onEnable() {
            config = new Config(this);
            util = new Util(this);
            getServer().getPluginManager().registerEvents(new BlockCoord(this),this);
            config.createConfig();
            Start();
            Global.enabled = true;
            Global.plugin = this;
            getLogger().info("Enabled!");
           
        }
     
        public void onDisable() {
            util.CloseTasks();
            Global.enabled = false;
            getLogger().info("Disabled!");
        }
     
        public boolean onCommand(CommandSender sender, Command cmd,String CommandLabel, String[] args) {
            Player p = (Player) sender;
            if (CommandLabel.equalsIgnoreCase("zs") && p.isOp()) {
                boolean success = false;
    //            try {
                    if (args[0].equalsIgnoreCase("new")) {
                        if ((!args[1].isEmpty()) && (!args[2].isEmpty()) && (!args[3].isEmpty()) && (!args[4].isEmpty())) {
                            Global.p = p;
                            Global.args[1] = (String) args[1];
                            Global.args[2] = (String) args[2];
                            Global.args[3] = (String) args[3];
                            Global.args[4] = (String) args[4];
                            p.sendMessage("§aClicca sul blocco in cui vuoi generare mobs");
                            Global.CallListener = true;
                            success = true;
                        }
                    }
                if (args[0].equalsIgnoreCase("disable")) {
                    if (Global.enabled) {
                        util.CloseTasks();
                        p.sendMessage("§4Plugin disabilitato");
                        Global.enabled = false;
                    }
                    else {
                        p.sendMessage("§4Plugin gia' disabilitato");
                    }
                    success = true;
                }
                if (args[0].equalsIgnoreCase("enable")) {
                    if (!Global.enabled) {
                        Start();
                        p.sendMessage("§2Plugin abilitato");
                        Global.enabled = true;
                    }
                    else {
                        p.sendMessage("§2Plugin gia' abilitato");
                    }
                    success = true;
                }
                if (args[0].equalsIgnoreCase("reload")) {
                    Reload();
                    p.sendMessage("§2Reload completato");
                    success = true;
                }
     
    //            } catch (Exception exc) {
    //                p.sendMessage("§cSintassi comando errata");
    //            }
                if (!success) {
                    p.sendMessage("§aUsa /zs new §6(nome) (delay) (distanza minima di un player) (tipi di mob separati da virgola)");
                }
            }
            else if (!p.isOp()){
                p.sendMessage("§2Non hai i permessi");
            }
     
            return false;
        }
     
    }
     
     
     
    
    And the class util
    Code:
    package me.TheGame;
     
     
    //import org.bukkit.plugin.java.JavaPlugin;
     
    public class Util{
        public Main plugin;
        public Util(Main p){
            this.plugin = p;
        }
        public void CloseTasks() {
            if (!plugin.emptyConfig && plugin.taskList.length>0 ) {
                for (int i = 0; i < plugin.taskList.length; i++) {
    //                getLogger().info(" " + plugin.taskList[i]);
                    plugin.getServer().getScheduler().cancelTask(plugin.taskList[i]);
                }
            }
        }
    }
    
     
  2. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı Retired Staff

    You have multiple JavaPlugin subclasses.
     
  3. Offline

    fireblast709

  4. Offline

    4thegame3

    Allright, i know the problem, but i dont know how to fix it, i need to inizialize write witout inizialize the superclass main

    Code:
    package me.TheGame;
     
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
     
    import me.TheGame.*;
     
    public class Write extends Main {
     
        Main plugin;
        public Write(Main plugin){
            this.plugin = plugin;
        }
       
        public void Scrivi() {
            Player p = (Player) Global.p;
    //        plugin.getConfig().set("Loc.Name", Global.args[1]);
            plugin.getConfig().set("Spawners."+Global.args[1]+".X", Double.valueOf(Global.X));
            plugin.getConfig().set("Spawners."+Global.args[1]+".Y", Double.valueOf(Global.Y));
            plugin.getConfig().set("Spawners."+Global.args[1]+".Z", Double.valueOf(Global.Z));
            plugin.getConfig().set("Spawners."+Global.args[1]+".Mobs", Global.args[4]);
            plugin.getConfig().set("Spawners."+Global.args[1]+".World", p.getLocation().getWorld().getName());
            plugin.getConfig().set("Spawners."+Global.args[1]+".Dist",Integer.valueOf(Integer.parseInt(Global.args[3])));
            plugin.getConfig().set("Spawners."+Global.args[1]+".TempoSpawn",Integer.valueOf(Integer.parseInt(Global.args[2])));
            plugin.saveConfig();
            p.sendMessage("§aHai settato il punto di spawn dei mob! \n§6I mob spawneranno ogni: " + Global.args[2] + "s. \n§6Distanza minima di un player: " + Global.args[3]);
            Reload();
        }
    }
     
Thread Status:
Not open for further replies.

Share This Page