Decompiled source of Valheim Stats Project v1.0.1

ValheimStatsProject.dll

Decompiled 2 years ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Threading.Tasks;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ValheimStatsProject")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ValheimStatsProject")]
[assembly: AssemblyTitle("ValheimStatsProject")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace ValheimStatsProject
{
	[BepInPlugin("com.dryzler.valheim.statsproject", "Dryzler's Valheim Stats Project", "1.0.1")]
	public class ValheimMod : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Smelter), "QueueProcessed")]
		private class Smelter_Patch
		{
			private static void Postfix(string ore)
			{
				if (ZNet.instance.GetNrOfPlayers() == 1)
				{
					Ws.doIt("smelter.spawn.ore", ore);
				}
			}
		}

		private readonly Harmony harmony = new Harmony("com.dryzler.valheim.statsproject");

		private void Awake()
		{
			harmony.PatchAll();
		}
	}
	internal class Ws
	{
		private static readonly HttpClient client = new HttpClient();

		public static async Task<bool> doIt(string command, params string[] list)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			dictionary.Add("c", command);
			dictionary.Add("v", "2");
			int num = 0;
			foreach (string value in list)
			{
				num++;
				dictionary.Add("p" + num, value);
			}
			string text = "valheim-stats-project.com";
			try
			{
				FormUrlEncodedContent content = new FormUrlEncodedContent(dictionary);
				await (await client.PostAsync("https://" + text + "/api.php", content)).Content.ReadAsStringAsync();
			}
			catch (Exception ex)
			{
				ex.ToString();
			}
			return true;
		}
	}
}