mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Detect and store the list of forge mods.
This commit is contained in:
parent
f67a3e3384
commit
7cc87d8e71
6 changed files with 119 additions and 21 deletions
70
MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs
Executable file
70
MinecraftClient/Protocol/Handlers/Forge/ForgeInfo.cs
Executable file
|
|
@ -0,0 +1,70 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MinecraftClient.Protocol.Handlers.Forge
|
||||
{
|
||||
/// <summary>
|
||||
/// Contains information about a modded server install.
|
||||
/// </summary>
|
||||
public class ForgeInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an individual forge mod.
|
||||
/// </summary>
|
||||
public class ForgeMod
|
||||
{
|
||||
public ForgeMod(String ModID, String Version)
|
||||
{
|
||||
this.ModID = ModID;
|
||||
this.Version = Version;
|
||||
}
|
||||
|
||||
public readonly String ModID;
|
||||
public readonly String Version;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return ModID + " v" + Version;
|
||||
}
|
||||
}
|
||||
|
||||
public List<ForgeMod> Mods;
|
||||
|
||||
/// <summary>
|
||||
/// Create a new ForgeInfo from the given data.
|
||||
/// </summary>
|
||||
/// <param name="data">The modinfo JSON tag.</param>
|
||||
internal ForgeInfo(Json.JSONData data)
|
||||
{
|
||||
// Example ModInfo (with spacing):
|
||||
|
||||
// "modinfo": {
|
||||
// "type": "FML",
|
||||
// "modList": [{
|
||||
// "modid": "mcp",
|
||||
// "version": "9.05"
|
||||
// }, {
|
||||
// "modid": "FML",
|
||||
// "version": "8.0.99.99"
|
||||
// }, {
|
||||
// "modid": "Forge",
|
||||
// "version": "11.14.3.1512"
|
||||
// }, {
|
||||
// "modid": "rpcraft",
|
||||
// "version": "Beta 1.3 - 1.8.0"
|
||||
// }]
|
||||
// }
|
||||
|
||||
this.Mods = new List<ForgeMod>();
|
||||
foreach (Json.JSONData mod in data.Properties["modList"].DataArray)
|
||||
{
|
||||
String modid = mod.Properties["modid"].StringValue;
|
||||
String version = mod.Properties["version"].StringValue;
|
||||
|
||||
this.Mods.Add(new ForgeMod(modid, version));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue