|
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- 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;
- }
- }
- }
|