mirror of
https://github.com/anegostudios/vsmodtemplate
synced 2025-07-05 04:44:30 -07:00
Adding VSExampleMods solution
This commit is contained in:
parent
76ca9b8565
commit
ec34f1e343
4 changed files with 173 additions and 0 deletions
53
RedirectLogs.cs
Normal file
53
RedirectLogs.cs
Normal file
|
@ -0,0 +1,53 @@
|
|||
using System;
|
||||
using Vintagestory.API.Client;
|
||||
using Vintagestory.API.Common;
|
||||
using Vintagestory.API.Server;
|
||||
|
||||
namespace VSExampleMods
|
||||
{
|
||||
/// <summary>
|
||||
/// Redirects all log entries into the visual studio output window. Only for your convenience during development and testing.
|
||||
/// </summary>
|
||||
public class RedirectLogs : ModBase
|
||||
{
|
||||
public override ModInfo GetModInfo()
|
||||
{
|
||||
return new ModInfo()
|
||||
{
|
||||
Name = "RedirectLogs",
|
||||
Version = "1.0",
|
||||
GameVersions = new string[] { "1.5+" },
|
||||
Description = "Redirecting logs to VS",
|
||||
Author = "Tyron",
|
||||
Website = "https://github.com/anegostudios/vsmodtemplate"
|
||||
};
|
||||
}
|
||||
|
||||
public override bool ShouldLoad(EnumAppSide side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void StartServerSide(ICoreServerAPI api)
|
||||
{
|
||||
api.Server.Logger.AddListener(OnServerLogEntry);
|
||||
}
|
||||
|
||||
public override void StartClientSide(ICoreClientAPI api)
|
||||
{
|
||||
api.World.Logger.AddListener(OnClientLogEntry);
|
||||
}
|
||||
|
||||
private void OnClientLogEntry(EnumLogType logType, string message, object[] args)
|
||||
{
|
||||
if (logType == EnumLogType.VerboseDebug) return;
|
||||
System.Diagnostics.Debug.WriteLine("[Client " + logType + "] " + message, args);
|
||||
}
|
||||
|
||||
private void OnServerLogEntry(EnumLogType logType, string message, object[] args)
|
||||
{
|
||||
if (logType == EnumLogType.VerboseDebug) return;
|
||||
System.Diagnostics.Debug.WriteLine("[Server " + logType + "] " + message, args);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue