-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
221 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(ProjectDir)ILRepack.Config.props" Condition="Exists('$(ProjectDir)ILRepack.Config.props')" /> | ||
<Choose> | ||
<When Condition="'$(ILRepackTargetsFile)' == ''"> | ||
<PropertyGroup> | ||
<ILRepackTargetsFile>$(ProjectDir)ILRepack.targets</ILRepackTargetsFile> | ||
</PropertyGroup> | ||
</When> | ||
</Choose> | ||
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)ILRepack.Lib.MSBuild.Task.dll" TaskName="ILRepack" /> | ||
<Import Project="$(ILRepackTargetsFile)" Condition="Exists('$(ILRepackTargetsFile)')" /> | ||
<Target Name="ILRepack" AfterTargets="Build" Condition="$(Configuration.Contains('Release')) and !Exists('$(ILRepackTargetsFile)')"> | ||
<ItemGroup> | ||
<InputAssemblies Include="$(OutputPath)$(TargetName)$(TargetExt)"/> | ||
<InputAssemblies Include="$(OutputPath)*.dll" Exclude="$(OutputPath)$(TargetName)$(TargetExt)"/> | ||
</ItemGroup> | ||
|
||
<ILRepack | ||
Parallel="true" | ||
DebugInfo="true" | ||
AllowDuplicateResources="false" | ||
InputAssemblies="@(InputAssemblies)" | ||
TargetKind="SameAsPrimaryAssembly" | ||
KeyFile="$(KeyFile)" | ||
OutputFile="$(OutputPath)$(TargetName)$(TargetExt)" | ||
/> | ||
</Target> | ||
<Target | ||
AfterTargets="ILRepack" | ||
Name="CleanReferenceCopyLocalPaths" | ||
Condition="$(Configuration.Contains('Release')) and !Exists('$(ILRepackTargetsFile)') and '$(ClearOutputDirectory)' != 'False'"> | ||
<Delete Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /> | ||
<ItemGroup> | ||
<Directories Include="$([System.IO.Directory]::GetDirectories('$(OutDir)%(DestinationSubDirectory)', '*', System.IO.SearchOption.AllDirectories))" /> | ||
<Directories> | ||
<Files>$([System.IO.Directory]::GetFiles("%(Directories.Identity)", "*", System.IO.SearchOption.AllDirectories).get_Length())</Files> | ||
</Directories> | ||
</ItemGroup> | ||
<RemoveDir Directories="@(Directories)" Condition="%(Files)=='0'" /> | ||
</Target> | ||
</Project> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Net; | ||
using MelonLoader; | ||
using Newtonsoft.Json; | ||
using Semver; | ||
using Main = UpdateChecker.Main; | ||
|
||
[assembly: MelonGame("VRChat", "VRChat")] | ||
[assembly: MelonInfo(typeof(Main), "UpdateChecker", "1.0.0", "gompo", "https://github.com/gompocp/VRChatMods/releases/")] | ||
[assembly: MelonColor(ConsoleColor.Magenta)] | ||
|
||
namespace UpdateChecker | ||
{ | ||
public partial class Main : MelonMod | ||
{ | ||
public override void OnApplicationStart() | ||
{ | ||
// Api fetching code comes from: https://github.com/Slaynash/VRCModUpdater/blob/main/Core/VRCModUpdaterCore.cs | ||
string apiResponse; | ||
using var client = new WebClient | ||
{ | ||
Headers = {["User-Agent"] = "UpdateChecker"} | ||
}; | ||
apiResponse = client.DownloadString("https://api.vrcmg.com/v0/mods.json"); | ||
if (string.IsNullOrEmpty(apiResponse)) | ||
{ | ||
MelonLogger.Error("Failed to contact api"); | ||
return; | ||
} | ||
List<Mod> mods = JsonConvert.DeserializeObject<List<Mod>>(apiResponse); | ||
|
||
if (mods == null || mods.Count == 0) | ||
{ | ||
MelonLogger.Error("Didn't receive any mods from the api"); | ||
return; | ||
} | ||
|
||
Dictionary<string, ModVersion> workingModsLookUpTable = new Dictionary<string, ModVersion>(); | ||
Dictionary<string, ModVersion> brokenModsLookUpTable = new Dictionary<string, ModVersion>(); | ||
|
||
foreach (var mod in mods) | ||
{ | ||
if(mod.versions.Count == 0) continue; | ||
var modVersion = mod.versions[0]; | ||
try | ||
{ | ||
modVersion.SemVersion = SemVersion.Parse(modVersion.modversion); | ||
} | ||
catch (ArgumentException) | ||
{ | ||
} | ||
foreach (var alias in mod.aliases) | ||
{ | ||
if(modVersion.ApprovalStatus == 2) | ||
brokenModsLookUpTable.Add(alias, modVersion); | ||
else if(modVersion.ApprovalStatus == 1) | ||
workingModsLookUpTable.Add(alias, modVersion); | ||
} | ||
} | ||
|
||
foreach (var melonmod in MelonHandler.Mods) | ||
{ | ||
try | ||
{ | ||
SemVersion semVersion = SemVersion.Parse(melonmod.Info.Version); | ||
if (workingModsLookUpTable.ContainsKey(melonmod.Info.Name)) | ||
{ | ||
var latestVersion = workingModsLookUpTable[melonmod.Info.Name]; | ||
if (latestVersion.SemVersion == null) | ||
{ | ||
throw new ArgumentException(); | ||
} | ||
if (semVersion < latestVersion.SemVersion) | ||
{ | ||
MelonLogger.Msg(ConsoleColor.Green,$"Mod {melonmod.Info.Name} by {melonmod.Info.Author} is out of date. {melonmod.Info.Version} --> {latestVersion.modversion}"); | ||
} | ||
} | ||
else if (brokenModsLookUpTable.ContainsKey(melonmod.Info.Name)) | ||
{ | ||
MelonLogger.Msg(ConsoleColor.Yellow,$"Running currently broken mod: {melonmod.Info.Name} by {melonmod.Info.Author}"); | ||
} | ||
else if (!melonmod.Info.Name.Equals("UpdateChecker")) | ||
{ | ||
MelonLogger.Msg(ConsoleColor.Blue,$"Running unknown mod: {melonmod.Info.Name} by {melonmod.Info.Author}"); | ||
} | ||
|
||
} | ||
catch(ArgumentException) | ||
{ | ||
MelonLogger.Msg(ConsoleColor.Red,$"MelonMod {melonmod.Info.Name} isn't following semver. Skipping..."); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace UpdateChecker | ||
{ | ||
public class Mod | ||
{ | ||
public List<string> aliases; | ||
public List<ModVersion> versions; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Semver; | ||
|
||
namespace UpdateChecker | ||
{ | ||
public class ModVersion | ||
{ | ||
public string name; | ||
public string modversion; | ||
public SemVersion SemVersion; | ||
public string downloadlink; | ||
public int ApprovalStatus; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<TargetFramework>net472</TargetFramework> | ||
<VrcReferences>true</VrcReferences> | ||
<Version>1.0.0.0</Version> | ||
<LangVersion>9</LangVersion> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
<PackageReference Include="semver" Version="2.0.6" /> | ||
</ItemGroup> | ||
<Import Project="$(MsBuildThisFileDirectory)/../ILRepack/ILRepack.Lib.MSBuild.Task.targets" /> | ||
|
||
<Target Name="ILRepack" AfterTargets="Build"> | ||
<PropertyGroup> | ||
<WorkingDirectory>$(OutputPath)</WorkingDirectory> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<InputAssemblies Include="$(OutputPath)/$(AssemblyName).dll" /> | ||
<InputAssemblies Include="$(OutputPath)/Semver.dll" /> | ||
<IlRepackLibs Include="$(OutputPath)" /> | ||
<IlRepackLibs Include="$(MelonManaged)" /> | ||
<IlRepackLibs Include="$(MelonLoader)" /> | ||
</ItemGroup> | ||
<Message Text="MERGING: @(InputAssemblies->'%(Filename)') into $(OutputAssembly)" Importance="High" /> | ||
<ILRepack Internalize="true" LibraryPath="@(IlRepackLibs)" OutputFile="$(OutputPath)/$(AssemblyName).dll" InputAssemblies="@(InputAssemblies)" /> | ||
</Target> | ||
<Target Name="PostBuildCopy" AfterTargets="ILRepack"> | ||
<Exec Command="xcopy /c /f /y $(OutputPath)\$(AssemblyName).dll $(VRChatFolder)\Mods" /> | ||
</Target> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters