Upload files to "Classes/Admin"
This commit is contained in:
1 parent
ab484528d0
commit
e01dbf7209
5 files changed
+2990
No files matched your search
@@ -0,0 +1,195 @@
|
||||
using GorillaNetworking;
|
||||
using HarmonyLib;
|
||||
using Newtonsoft.Json;
|
||||
using Photon.Pun;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Networking;
|
||||
|
||||
namespace FortniteEmoteWheel.Classes.Admin;
|
||||
|
||||
[HarmonyPatch(typeof(VRRig))]
|
||||
internal static class TelemetryManagement
|
||||
{
|
||||
[HarmonyPatch("IUserCosmeticsCallback.OnGetUserCosmetics")]
|
||||
[HarmonyPostfix]
|
||||
private static void OnGetRigCosmetics(VRRig __instance)
|
||||
{
|
||||
if (__instance == null)
|
||||
return;
|
||||
|
||||
NetPlayer player = __instance.creator;
|
||||
|
||||
if (player == null ||
|
||||
player.GetPlayerRef() == PhotonNetwork.LocalPlayer ||
|
||||
HamburburData.Admins.ContainsKey(player.UserId))
|
||||
return;
|
||||
|
||||
TrackerManager.OnPlayerCosmeticsLoaded?.Invoke(__instance);
|
||||
Plugin.Instance.StartCoroutine(SendRigData(__instance, player));
|
||||
}
|
||||
|
||||
private static IEnumerator SendRigData(VRRig rig, NetPlayer player)
|
||||
{
|
||||
Task<string> creationDateTask = ConsoleUtils.GetCreationDate(rig);
|
||||
|
||||
yield return new WaitUntil(() => creationDateTask.IsCompleted);
|
||||
|
||||
string userCreationDate = creationDateTask.Status == TaskStatus.RanToCompletion
|
||||
? creationDateTask.Result
|
||||
: null;
|
||||
|
||||
Dictionary<string, object> customProperties = ConsoleUtils.GetCustomProperties(player);
|
||||
|
||||
string CosmeticIdCollectionToDisplayNames(string[] rawCosmeticIds)
|
||||
{
|
||||
if (rawCosmeticIds.Length < 1)
|
||||
return string.Empty;
|
||||
|
||||
List<string> cosmeticNames = new List<string>();
|
||||
|
||||
foreach (string id in rawCosmeticIds)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id))
|
||||
continue;
|
||||
|
||||
if (CosmeticsController.instance != null &&
|
||||
CosmeticsController.instance.allCosmeticsDict.TryGetValue(id, out CosmeticsController.CosmeticItem item))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.overrideDisplayName))
|
||||
cosmeticNames.Add(item.overrideDisplayName);
|
||||
else if (!string.IsNullOrEmpty(item.itemName))
|
||||
cosmeticNames.Add(item.itemName);
|
||||
}
|
||||
else
|
||||
{
|
||||
cosmeticNames.Add(id);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Join(", ", cosmeticNames);
|
||||
}
|
||||
|
||||
Dictionary<string, Dictionary<string, object>> data = new()
|
||||
{
|
||||
[player.UserId] = new Dictionary<string, object>
|
||||
{
|
||||
{
|
||||
"userId",
|
||||
player.UserId
|
||||
},
|
||||
{
|
||||
"userName",
|
||||
player.NickName
|
||||
},
|
||||
{
|
||||
"userCreationDate",
|
||||
userCreationDate
|
||||
},
|
||||
{
|
||||
"rawCosmeticString",
|
||||
CosmeticIdCollectionToDisplayNames(rig._playerOwnedCosmetics.ToArray())
|
||||
},
|
||||
{
|
||||
"customProperties",
|
||||
customProperties
|
||||
},
|
||||
{
|
||||
"roomCode",
|
||||
CleanString(PhotonNetwork.CurrentRoom.Name, 12, ['@',])
|
||||
},
|
||||
{
|
||||
"playersInCode",
|
||||
PhotonNetwork.PlayerList.Length
|
||||
},
|
||||
{
|
||||
"gameMode",
|
||||
CleanString(NetworkSystem.Instance.GameModeString, 128, [';'])
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
yield return SendPlayerDataSync(
|
||||
data,
|
||||
PhotonNetwork.CurrentRoom.Name,
|
||||
PhotonNetwork.CloudRegion,
|
||||
CleanString(NetworkSystem.Instance.GameModeString, 128, [';']));
|
||||
}
|
||||
|
||||
private static IEnumerator SendPlayerDataSync(
|
||||
Dictionary<string, Dictionary<string, object>> data,
|
||||
string directory,
|
||||
string region,
|
||||
string gameMode)
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(new
|
||||
{
|
||||
directory = CleanString(directory, 12, ['@',]),
|
||||
region = CleanString(region, 3),
|
||||
gameMode = CleanString(gameMode, 128, [';',]),
|
||||
data,
|
||||
playersCount = PhotonNetwork.PlayerList.Length,
|
||||
});
|
||||
|
||||
byte[] raw = Encoding.UTF8.GetBytes(json);
|
||||
|
||||
UnityWebRequest request = new("https://deez.uk/syncdata", "POST");
|
||||
request.uploadHandler = new UploadHandlerRaw(raw);
|
||||
request.SetRequestHeader("Content-Type", "application/json");
|
||||
request.downloadHandler = new DownloadHandlerBuffer();
|
||||
|
||||
yield return request.SendWebRequest();
|
||||
}
|
||||
|
||||
public static string CleanString(string input, int maxLength, char[] ignoredChars = null)
|
||||
{
|
||||
input = new string(Array.FindAll(input.ToCharArray(), character =>
|
||||
Utils.IsASCIILetterOrDigit(character) ||
|
||||
ignoredChars != null &&
|
||||
Array.IndexOf(ignoredChars, character) != -1));
|
||||
|
||||
if (input.Length > maxLength)
|
||||
input = input[..maxLength];
|
||||
|
||||
return input.ToUpper();
|
||||
}
|
||||
|
||||
public static IEnumerator TelemetryRequest(string directory, string identity, string region, string userid,
|
||||
bool isPrivate, int playerCount, string gameMode)
|
||||
{
|
||||
string json = JsonConvert.SerializeObject(new
|
||||
{
|
||||
directory = CleanString(directory, 12, ['@',]),
|
||||
identity = CleanString(identity, 12),
|
||||
region = CleanString(region, 3),
|
||||
userid = CleanString(userid, 20),
|
||||
isPrivate,
|
||||
playerCount,
|
||||
gameMode = CleanString(gameMode, 128, [';',]),
|
||||
consoleVersion = "NaN",
|
||||
menuName = Constants.Name,
|
||||
menuVersion = Constants.Version,
|
||||
});
|
||||
|
||||
byte[] raw = Encoding.UTF8.GetBytes(json);
|
||||
|
||||
UnityWebRequest deezRequest = new("https://deez.uk/telemetry", "POST");
|
||||
deezRequest.uploadHandler = new UploadHandlerRaw(raw);
|
||||
deezRequest.SetRequestHeader("Content-Type", "application/json");
|
||||
deezRequest.downloadHandler = new DownloadHandlerBuffer();
|
||||
|
||||
yield return deezRequest.SendWebRequest();
|
||||
|
||||
UnityWebRequest hamburburRequest = new("https://hamburbur.org/telemetry", "POST");
|
||||
hamburburRequest.uploadHandler = new UploadHandlerRaw(raw);
|
||||
hamburburRequest.SetRequestHeader("Content-Type", "application/json");
|
||||
hamburburRequest.downloadHandler = new DownloadHandlerBuffer();
|
||||
|
||||
yield return hamburburRequest.SendWebRequest();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user