Example #1
0
        protected override void ForceJsonFileUpdate()
        {
            base.ForceJsonFileUpdate();
            McMod mcMod = SessionContext.SelectedMod;

            CodeGenerationService.RegenerateInitScript(SourceCodeLocator.SoundEvents(mcMod.ModInfo.Name, mcMod.Organization).ClassName, mcMod, Explorer.Folders.Files);
        }
Example #2
0
 public void RegenerateSourceCode(McMod mcMod)
 {
     foreach (ScriptCodeGenerator generator in ReflectionHelper.EnumerateSubclasses <ScriptCodeGenerator>(false, mcMod))
     {
         generator.RegenerateScript();
     }
 }
Example #3
0
 public ScriptCodeGenerator(McMod mcMod)
 {
     McMod                 = mcMod;
     Modname               = mcMod.ModInfo.Name;
     ModnameLower          = Modname.ToLower();
     Organization          = mcMod.Organization;
     SourceRootPackageName = $"com.{Organization}.{ModnameLower}";
 }
Example #4
0
        public void CreateCustomScript <T>(McMod mcMod, T element)
        {
            CustomScriptGenerator <T> generator = ReflectionHelper.EnumerateSubclasses <CustomScriptGenerator <T> >(false, mcMod, element).FirstOrDefault();

            if (generator != null)
            {
                generator.RegenerateScript();
            }
        }
 protected void CreateCommand(object sender, ItemEditedEventArgs <Command> e)
 {
     if (e.Result)
     {
         McMod mod = SessionContext.SelectedMod;
         CodeGenerationService.CreateCustomScript(mod, e.ActualItem);
     }
     new FileInfo(tempFilePath).Delete();
 }
Example #6
0
        public void Compile(McMod mcMod)
        {
            string           modPath = ModPaths.ModRootFolder(mcMod.ModInfo.Name);
            ProcessStartInfo psi     = new ProcessStartInfo {
                FileName  = "CMD.EXE",
                Arguments = $"/K cd \"{modPath}\" & gradlew build"
            };

            Process.Start(psi);
        }
Example #7
0
 public void RegenerateInitScript <T>(string className, McMod mcMod, IEnumerable <T> repository)
 {
     foreach (ScriptCodeGenerator generator in ReflectionHelper.EnumerateSubclasses <InitVariablesCodeGenerator <T> >(false, mcMod, repository))
     {
         if (string.Compare(generator.ScriptLocator.ClassName, className) == 0)
         {
             generator.RegenerateScript();
             break;
         }
     }
 }
Example #8
0
 public void RegenerateScript(string className, McMod mcMod)
 {
     foreach (ScriptCodeGenerator generator in ReflectionHelper.EnumerateSubclasses <ScriptCodeGenerator>(false, mcMod))
     {
         if (string.Compare(generator.ScriptLocator.ClassName, className) == 0)
         {
             generator.RegenerateScript();
             break;
         }
     }
 }
Example #9
0
        private void ToggleLaunchSelection(McMod mcMod)
        {
            bool isSelected = SessionContext.SelectedMods.Contains(mcMod);

            if (isSelected)
            {
                SessionContext.SelectedMods.Remove(mcMod);
                mcMod.PropertyChanged -= Mod_PropertyChanged;
            }
            else
            {
                SessionContext.SelectedMods.Add(mcMod);
                mcMod.PropertyChanged += Mod_PropertyChanged;
            }
        }
Example #10
0
        /// <summary> Run mod depends on mod.LanuchSetup </summary>
        public void Run(McMod mcMod)
        {
            switch (mcMod.LaunchSetup)
            {
            case LaunchSetup.Client:
                RunClient(mcMod);
                break;

            case LaunchSetup.Server:
                RunServer(mcMod);
                break;

            default:
                RunClient(mcMod);
                break;
            }
        }
Example #11
0
        /// <summary> Ignore LanuchSetup and run server for this mod </summary>
        public void RunServer(McMod mcMod)
        {
            string   modPath  = ModPaths.ModRootFolder(mcMod.ModInfo.Name);
            string   eulaPath = Path.Combine(modPath, "run", "eula.txt");
            FileInfo eulaFile = new FileInfo(eulaPath);

            if (!eulaFile.Exists)
            {
                eulaFile.Directory.Create();
                string eulaMessage =
                    $@"#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#{DateTime.UtcNow}
eula = true";
                File.WriteAllText(eulaPath, eulaMessage);
            }

            ProcessStartInfo psi = new ProcessStartInfo {
                FileName  = "CMD.EXE",
                Arguments = $"/K cd \"{modPath}\" & gradlew runServer"
            };

            Process.Start(psi);
        }
Example #12
0
        protected void RegenerateRecipes()
        {
            McMod mod = SessionContext.SelectedMod;

            CodeGenerationService.RegenerateInitScript(SourceCodeLocator.Recipes(mod.ModInfo.Name, mod.Organization).ClassName, mod, Explorer.Folders.Files[0].Files);
        }
 public ItemBasesCodeGenerator(McMod mcMod) : base(mcMod) =>
 private void RunSelectedMod(McMod mcMod) => modBuilder.Run(mcMod);
Example #15
0
 public ModelCodeGenerator(McMod mcMod) : base(mcMod) =>
 public CustomCommandCodeGenerator(McMod mcMod, Command command) : base(mcMod, command) => ScriptLocator = SourceCodeLocator.CustomCommand(mcMod.ModInfo.Name, mcMod.Organization, command.ClassName);
Example #17
0
 // Writes to FmgModInfo file
 public static void ExportMod(ISerializer <McMod> serializer, McMod mcMod) => File.WriteAllText(ModPaths.FmgModInfoFile(mcMod.ModInfo.Name), serializer.Serialize(mcMod));
 public CustomScriptGenerator(McMod mcMod, T element) : base(mcMod) => Element = element;
Example #19
0
 public CommandCodeGenerator(McMod mcMod) : this(mcMod, Enumerable.Empty <Command>())
 {
 }
Example #20
0
 public BlockCodeGenerator(McMod mcMod, IEnumerable <Block> elements) : base(mcMod, elements) => ScriptLocator = SourceCodeLocator.Blocks(Modname, Organization);
Example #21
0
 public BlockCodeGenerator(McMod mcMod) : this(mcMod, Enumerable.Empty <Block>())
 {
 }
Example #22
0
 public ModHookCodeGenerator(McMod mcMod) : base(mcMod) => ScriptLocator = SourceCodeLocator.Hook(mcMod.ModInfo.Name, mcMod.Organization);
 protected override bool TryGetModFromPath(string path, out McMod mcMod)
 {
     mcMod = ModHelper.ImportMod(modSerializer, path);
     return(mcMod != null);
 }
Example #24
0
 public ProxyCodeGenerator(McMod mcMod) : base(mcMod) =>
Example #25
0
 public CommandCodeGenerator(McMod mcMod, IEnumerable <Command> elements) : base(mcMod, elements) => ScriptLocator = SourceCodeLocator.Commands(Modname, Organization);
Example #26
0
 public SoundCodeGenerator(McMod mcMod) : this(mcMod, Enumerable.Empty <SoundEvent>())
 {
 }
Example #27
0
 public InitVariablesCodeGenerator(McMod mcMod, IEnumerable <T> elements = null) : base(mcMod) => Elements = elements;
Example #28
0
 public SoundCodeGenerator(McMod mcMod, IEnumerable <SoundEvent> elements) : base(mcMod, elements) => ScriptLocator = SourceCodeLocator.SoundEvents(Modname, Organization);
Example #29
0
 public ManagerCodeGenerator(McMod mcMod) : base(mcMod) => ScriptLocator = SourceCodeLocator.Manager(Modname, Organization);
Example #30
0
 public void RegenerateScript <TScriptGenerator>(McMod mcMod) where TScriptGenerator : IScriptCodeGenerator => ReflectionHelper.CreateInstance <TScriptGenerator>(mcMod).RegenerateScript();