CLre/CLre_server/API/MainServer/ModerationEngine.cs

68 lines
2.4 KiB
C#
Raw Normal View History

using System;
using System.Reflection;
using HarmonyLib;
using Svelto.Context;
using Svelto.DataStructures;
using Svelto.ECS;
using User.Server;
namespace CLre_server.API.MainServer
{
class ModerationEngine : Engines.ServerEnginePostBuild
{
public override void Ready()
{
}
public int? FindConnectedPlayerById(string publicId)
{
FieldInfo f = AccessTools.Field(AccessTools.TypeByName("User.Server.AccountExclusiveGroups"), "accountGroup");
ExclusiveGroup accountGroup = (ExclusiveGroup) f.GetValue(null);
ReadOnlyCollectionStruct<AccountIdServerNode> accounts =
entitiesDB.QueryEntityViews<AccountIdServerNode>(accountGroup);
for (int i = 0; i < accounts.Count; i++)
{
if (accounts[i].accountId.publicId.ToString() == publicId)
{
return i;
}
}
return null;
}
public int? FindConnectedPlayerByName(string displayName)
{
FieldInfo f = AccessTools.Field(AccessTools.TypeByName("User.Server.AccountExclusiveGroups"), "accountGroup");
ExclusiveGroup accountGroup = (ExclusiveGroup) f.GetValue(null);
ReadOnlyCollectionStruct<AccountIdServerNode> accounts =
entitiesDB.QueryEntityViews<AccountIdServerNode>(accountGroup);
for (int i = 0; i < accounts.Count; i++)
{
if (String.Equals(accounts[i].accountId.displayName, displayName, StringComparison.InvariantCultureIgnoreCase))
{
return i;
}
}
return null;
}
public Guid? FindConnectedPlayerGuidByName(string displayName)
{
FieldInfo f = AccessTools.Field(AccessTools.TypeByName("User.Server.AccountExclusiveGroups"), "accountGroup");
ExclusiveGroup accountGroup = (ExclusiveGroup) f.GetValue(null);
ReadOnlyCollectionStruct<AccountIdServerNode> accounts =
entitiesDB.QueryEntityViews<AccountIdServerNode>(accountGroup);
for (int i = 0; i < accounts.Count; i++)
{
if (String.Equals(accounts[i].accountId.displayName, displayName, StringComparison.InvariantCultureIgnoreCase))
{
return accounts[i].accountId.publicId;
}
}
return null;
}
}
}