public void createNewJar()
    {
        GameObject newJar        = Instantiate(jarPrefab);
        JarManager newJarManager = newJar.GetComponent <JarManager>();

        newJarManager.mainPanel = mainPanel;

        newJarManager.storage    = storage;
        newJarManager.traitDB    = storage.traitDB;
        newJarManager.propertyDB = propertyDB;

        newJarManager.initializeJar();

        newJarManager.jarUIManager = tabManager.createNewJarUI();
        newJarManager.instatiateUIConnections();

        newJarManager.addFliesManager    = addFliesManager;
        newJarManager.flySelectorManager = flySelectorManager;

        newJarManager.jarCustomizerManager = jarCustomizerManager;

        newJarManager.dialoguePopup = dialoguePopup;
    }
示例#2
0
        /// <summary>
        /// Starts the manager
        /// </summary>
        public static void Init() {
            if (_isRunning) throw new ArgumentException("manager is already running");

            Logger.Write(LogType.Info, "starting mcmultiserver manager");

            //check environment
            if (System.Environment.OSVersion.Platform.ToString().ToLower() == "unix") {
                Logger.Write(LogType.Info, "unix operating system detected");
                _isWin32 = false;
            } else { Logger.Write(LogType.Info, ".NET framework detected"); }

            //Load Settings & Check Directories
            Settings.Load();
            Paths.CheckDirectories();

            //load jar manager up and check for updates.
            if (Settings.UseJarManager) {
                try {
                    JarManager.Init();
                } catch {
                    Logger.Write(LogType.Error, "jar manager encountered an error, ignoring jar setup");
                }
            } else {
                Logger.Write(LogType.Info, "jar manager has been disabled, all jar files must be updated manually");
            }

            //Loading database
            Database.SetDatabase(Settings.Database);

            //throw an error when the database hits one when starting up.
            try {
                Database.Init();
            } catch { throw; }

            //now checking for java, otherwise java-path in the config must NOT be empty
            if (Settings.CheckInstalledJava) {
                if (_isWin32) {
                    if (Util.Win32.HasInstalledJava()) {
                        if (Util.Win32.CheckVersion() != null) {
                            Logger.Write(LogType.Info, "this windows server is using an installed Java {0} instance", Util.Win32.CheckVersion());
                            if (!Util.Win32.IsValidJRE(Util.Win32.CheckVersion())) {
                                Logger.Write(LogType.Warning, "the detected version of java is unsupported. refer to documentation for information");
                            }
                            Logger.Write(LogType.Info, "installed java Location: {0}", Util.Win32.JREPath());
                            Paths.JVMInstance = new Util.JavaInstance("DEFAULT_JRE", Util.Win32.JREPath());
                        }
                    } else {
                        Logger.Write(LogType.Warning, "java cannot be found! if you have java, please set it in mcms.conf");
                    }
                } else {
                    Logger.Write(LogType.Warning, "java autodetect is currently not supported in Unix like systems, setting defaults");
                    Paths.JVMInstance = new JavaInstance("DEFAULT_JRE", "/usr/bin/");
                }
            } else {
                Logger.Write("java autochecker disabled, configuring java path from settings...");
            }

			//We are up and running, mostly.
            _isRunning = true;
            

            Logger.Write(LogType.Info, "{0} MB of the {1} MB max allocated memory has been used", GetAllocatedMemory(), Settings.MaxMemoryAllocation);
            if (GetAllocatedMemory() > Settings.MaxMemoryAllocation) {
                Logger.Write(LogType.Warning, "loaded allocated memory from the servers is over the max memory set, please remove a server or two before starting.");
            }

            //load all node data.
            ServerProperties[] srvproplist = Database.GetAllServers();
            if (srvproplist.Length != 0) {
                foreach (ServerProperties prop in srvproplist) {
                    //make sure that if an unclean shutdown occured that all processes are killed. will change if possible to a normal shutdown.
                    if (File.Exists(Paths.ServerDirectory + "/" + prop.ServerID.ToString() + "/minecraft.pid")) {
                        try {
                            int procid = Convert.ToInt32(File.ReadAllText(Paths.ServerDirectory + "/" + prop.ServerID.ToString() + "/minecraft.pid"));
                            File.Delete(Paths.ServerDirectory + "/" + prop.ServerID.ToString() + "/minecraft.pid");

                            System.Diagnostics.Process proc = System.Diagnostics.Process.GetProcessById(procid);

                            if (proc != null) {
                                Logger.Write(LogType.Warning, "unclean shutdown detected for server '{0}', shutting down process", prop.ServerID);
                                proc.Kill();
                            }
                            
                        } catch { }
                    }
                    AddServer(prop.ServerID);
                    if (Settings.AutoStart) {
                        if (!AllServers.GetServer(prop.ServerID).IsRunning) {
                            StartServer(prop.ServerID);
                        }
                    }
                }
            }

            //We are done here.
            Logger.Write(LogType.Info, "manager has finished setting up");
        }