コード例 #1
0
        public static void Publish(LifecycleOptions options)
        {
            Logo.Print();
            ApplySettings(options);

            IMinecraftInstance instance = Packsly.Launcher.GetInstance(options.InstanceId);

            instance.Load();
            logger.Debug($"Dispatching lifecycle events specified by command line arguments: {string.Join(", ", options.Events)}");
            Packsly.Lifecycle.EventBus.Publish(instance, options.Events);
            instance.Save();
        }
コード例 #2
0
        private static IMinecraftInstance CreateMinecraftInstnace(string instanceId, ModpackDefinition modpackDefinition)
        {
            IMinecraftInstance instance = Packsly.Launcher.CreateInstance(instanceId, modpackDefinition);

            // Set base minecraft instance properties
            instance.Name             = modpackDefinition.Name;
            instance.MinecraftVersion = modpackDefinition.MinecraftVersion;
            instance.Icon.Source      = modpackDefinition.Icon;
            logger.Debug($"Setting minecraft instance properties id={instance.Id} name={instance.Name} mc={instance.MinecraftVersion} icon={instance.Icon.Source}");

            // Load defaults
            instance.Load();

            // Save adapters defined in modpack along with configuration to packsly instance config file
            foreach (KeyValuePair <string, object> adapterDefinition in modpackDefinition.Adapters)
            {
                string adapterName     = adapterDefinition.Key;
                object adapterSettings = adapterDefinition.Value;

                logger.Debug($"Setting adapter config for {adapterName} for minecraft instance {instance.Id}");
                instance.PackslyConfig.Adapters.SetConfigFor(adapterName, adapterSettings);
            }

            // Configure instance using compatible environment settings
            foreach (KeyValuePair <string, object> environmentEntry in modpackDefinition.Environments)
            {
                string name = environmentEntry.Key;
                if (name != Packsly.Launcher.Name)
                {
                    continue;
                }

                string settings = environmentEntry.Value.ToString();
                logger.Debug($"Configuring minecraft instance {instance.Id} from modpack environment settings: {settings}");
                instance.Configure(settings);
                break;
            }

            return(instance);
        }