-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
58 lines (55 loc) · 1.97 KB
/
Copy pathPlugin.cs
File metadata and controls
58 lines (55 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using BepInEx;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice.Unity;
using ExitGames.Client.Photon;
using System;
namespace MonkeLovesTux
{
[BepInPlugin("com.narezany.monkelovestux", "Monke Loves Tux", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
try
{
var harmony = new Harmony("com.narezany.monkelovestux");
harmony.PatchAll(typeof(Plugin).Assembly);
Logger.LogInfo("Monke Loves Tux loaded! Forcing Secure WebSockets (WSS) protocol for Photon and Voice.");
}
catch (Exception ex)
{
Logger.LogError($"Error applying Monke Loves Tux patches: {ex}");
}
}
}
[HarmonyPatch(typeof(PhotonNetwork), "ConnectUsingSettings", new Type[] { typeof(AppSettings), typeof(bool) })]
public static class ConnectUsingSettingsPatch
{
[HarmonyPrefix]
public static void Prefix(AppSettings appSettings)
{
if (appSettings != null)
{
UnityEngine.Debug.Log($"[MonkeLovesTux] Forcing WSS for PhotonNetwork. Original Protocol: {appSettings.Protocol}");
appSettings.Protocol = ConnectionProtocol.WebSocketSecure;
appSettings.EnableProtocolFallback = false;
}
}
}
[HarmonyPatch(typeof(VoiceConnection), "ConnectUsingSettings", new Type[] { typeof(AppSettings) })]
public static class VoiceConnectUsingSettingsPatch
{
[HarmonyPrefix]
public static void Prefix(AppSettings appSettings)
{
if (appSettings != null)
{
UnityEngine.Debug.Log($"[MonkeLovesTux] Forcing WSS for PhotonVoice. Original Protocol: {appSettings.Protocol}");
appSettings.Protocol = ConnectionProtocol.WebSocketSecure;
appSettings.EnableProtocolFallback = false;
}
}
}
}