Unofficial CardLife revival project, pronounced like "celery"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ModerationEngine.cs 2.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using System;
  2. using System.Reflection;
  3. using HarmonyLib;
  4. using Svelto.Context;
  5. using Svelto.DataStructures;
  6. using Svelto.ECS;
  7. using User.Server;
  8. namespace CLre_server.API.MainServer
  9. {
  10. class ModerationEngine : Engines.ServerEnginePostBuild
  11. {
  12. public override void Ready()
  13. {
  14. }
  15. public int? FindConnectedPlayerById(string publicId)
  16. {
  17. FieldInfo f = AccessTools.Field(AccessTools.TypeByName("User.Server.AccountExclusiveGroups"), "accountGroup");
  18. ExclusiveGroup accountGroup = (ExclusiveGroup) f.GetValue(null);
  19. ReadOnlyCollectionStruct<AccountIdServerNode> accounts =
  20. entitiesDB.QueryEntityViews<AccountIdServerNode>(accountGroup);
  21. for (int i = 0; i < accounts.Count; i++)
  22. {
  23. if (accounts[i].accountId.publicId.ToString() == publicId)
  24. {
  25. return i;
  26. }
  27. }
  28. return null;
  29. }
  30. public int? FindConnectedPlayerByName(string displayName)
  31. {
  32. FieldInfo f = AccessTools.Field(AccessTools.TypeByName("User.Server.AccountExclusiveGroups"), "accountGroup");
  33. ExclusiveGroup accountGroup = (ExclusiveGroup) f.GetValue(null);
  34. ReadOnlyCollectionStruct<AccountIdServerNode> accounts =
  35. entitiesDB.QueryEntityViews<AccountIdServerNode>(accountGroup);
  36. for (int i = 0; i < accounts.Count; i++)
  37. {
  38. if (String.Equals(accounts[i].accountId.displayName, displayName, StringComparison.InvariantCultureIgnoreCase))
  39. {
  40. return i;
  41. }
  42. }
  43. return null;
  44. }
  45. public Guid? FindConnectedPlayerGuidByName(string displayName)
  46. {
  47. FieldInfo f = AccessTools.Field(AccessTools.TypeByName("User.Server.AccountExclusiveGroups"), "accountGroup");
  48. ExclusiveGroup accountGroup = (ExclusiveGroup) f.GetValue(null);
  49. ReadOnlyCollectionStruct<AccountIdServerNode> accounts =
  50. entitiesDB.QueryEntityViews<AccountIdServerNode>(accountGroup);
  51. for (int i = 0; i < accounts.Count; i++)
  52. {
  53. if (String.Equals(accounts[i].accountId.displayName, displayName, StringComparison.InvariantCultureIgnoreCase))
  54. {
  55. return accounts[i].accountId.publicId;
  56. }
  57. }
  58. return null;
  59. }
  60. }
  61. }