├── .gitattributes ├── .gitignore ├── AdvancedInvites.sln ├── AdvancedInvites ├── AdvancedInviteSystem.cs ├── AdvancedInvites.csproj ├── BuildInfo.cs ├── DebugTesting.cs ├── InviteHandler.cs ├── Localization.cs ├── Notification.ogg ├── Properties │ └── AssemblyInfo.cs ├── SoundPlayer.cs ├── UiButtons.cs ├── UserPermissionHandler.cs ├── Utilities.cs └── WorldPermissionHandler.cs ├── LICENSE └── README.md /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /AdvancedInvites.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30611.23 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AdvancedInvites", "AdvancedInvites\AdvancedInvites.csproj", "{BC5BF2ED-004F-40B7-A968-6A718DB1D581}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Debug|x64.ActiveCfg = Debug|Any CPU 17 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Debug|x64.Build.0 = Debug|Any CPU 18 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Debug|x86.ActiveCfg = Debug|Any CPU 19 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Debug|x86.Build.0 = Debug|Any CPU 20 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Release|Any CPU.ActiveCfg = Release|Any CPU 21 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Release|Any CPU.Build.0 = Release|Any CPU 22 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Release|x64.ActiveCfg = Release|Any CPU 23 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Release|x64.Build.0 = Release|Any CPU 24 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Release|x86.ActiveCfg = Release|Any CPU 25 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581}.Release|x86.Build.0 = Release|Any CPU 26 | EndGlobalSection 27 | GlobalSection(SolutionProperties) = preSolution 28 | HideSolutionNode = FALSE 29 | EndGlobalSection 30 | GlobalSection(ExtensibilityGlobals) = postSolution 31 | SolutionGuid = {602F645F-2511-4CE8-8326-CD31309BF322} 32 | EndGlobalSection 33 | EndGlobal 34 | -------------------------------------------------------------------------------- /AdvancedInvites/AdvancedInviteSystem.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Reflection; 8 | using System.Runtime.InteropServices; 9 | 10 | using MelonLoader; 11 | 12 | using Transmtn.DTO.Notifications; 13 | 14 | using UnhollowerBaseLib; 15 | 16 | using VRC.Core; 17 | 18 | #if DEBUG 19 | using HarmonyLib; 20 | 21 | using UnityEngine; 22 | 23 | #endif 24 | 25 | public sealed class AdvancedInviteSystem : MelonMod 26 | { 27 | 28 | private static bool whitelistEnabled = true; 29 | 30 | private static bool blacklistEnabled = true; 31 | 32 | private static bool joinMeNotifyRequest = true; 33 | 34 | private static bool ignoreBusyStatus; 35 | 36 | private static bool inviteSoundEnabled, inviteRequestSoundEnabled, voteToKickSoundEnabled, friendRequestSoundEnabled; 37 | 38 | private static readonly HashSet HandledNotifications = new HashSet(); 39 | 40 | private static MelonPreferences_Category advInvPreferencesCategory; 41 | 42 | private static AcceptNotificationDelegate acceptNotificationDelegate; 43 | 44 | private static AddNotificationDelegate addNotificationDelegate; 45 | 46 | public override void OnApplicationStart() 47 | { 48 | Utilities.LoggerInstance = LoggerInstance; 49 | advInvPreferencesCategory = MelonPreferences.CreateCategory("AdvancedInvites", "Advanced Invites"); 50 | 51 | advInvPreferencesCategory.CreateEntry("DeleteNotifications", InviteHandler.DeleteNotifications, "Delete Notification After Successful Use"); 52 | advInvPreferencesCategory.CreateEntry("BlacklistEnabled", blacklistEnabled, "Blacklist System"); 53 | advInvPreferencesCategory.CreateEntry("WhitelistEnabled", whitelistEnabled, "Whitelist System"); 54 | advInvPreferencesCategory.CreateEntry("NotificationVolume", .8f, "Notification Volume"); 55 | advInvPreferencesCategory.CreateEntry("JoinMeNotifyRequest", joinMeNotifyRequest, "Join Me Req Notification Sound"); 56 | advInvPreferencesCategory.CreateEntry("IgnoreBusyStatus", ignoreBusyStatus, "Ignore Busy Status"); 57 | 58 | advInvPreferencesCategory.CreateEntry("InviteSoundEnabled", true, "Invite Sound"); 59 | advInvPreferencesCategory.CreateEntry("InviteRequestSoundEnabled", true, "Invite-Request Sound"); 60 | advInvPreferencesCategory.CreateEntry("VoteToKickSoundEnabled", false, "Vote-Kick Sound", true); 61 | advInvPreferencesCategory.CreateEntry("FriendRequestSoundEnabled", false, "Friend-Request Sound", true); 62 | OnPreferencesLoaded(); 63 | 64 | Localization.Load(); 65 | 66 | #if DEBUG 67 | DebugTesting.Test(); 68 | 69 | try 70 | { 71 | MethodInfo sendNotificationMethod = typeof(NotificationManager).GetMethod( 72 | nameof(NotificationManager.Method_Public_Void_String_String_String_String_NotificationDetails_ArrayOf_Byte_0), 73 | BindingFlags.Public | BindingFlags.Instance); 74 | HarmonyInstance.Patch( 75 | sendNotificationMethod, 76 | new HarmonyMethod(typeof(AdvancedInviteSystem).GetMethod(nameof(SendNotificationPatch), BindingFlags.NonPublic | BindingFlags.Static))); 77 | } 78 | catch (Exception e) 79 | { 80 | Utilities.LoggerInstance.Error("Error Patching SendNotification: " + e.Message); 81 | } 82 | 83 | try 84 | { 85 | MethodInfo deleteNotificationMethod = typeof(NotificationManager).GetMethod( 86 | nameof(NotificationManager.Method_Public_Void_Notification_0), 87 | BindingFlags.Public | BindingFlags.Instance); 88 | HarmonyInstance.Patch( 89 | deleteNotificationMethod, 90 | new HarmonyMethod(typeof(AdvancedInviteSystem).GetMethod(nameof(DeleteNotificationPatch), BindingFlags.NonPublic | BindingFlags.Static))); 91 | } 92 | catch (Exception e) 93 | { 94 | MelonLogger.Error("Error Patching DeleteNotification: " + e.Message); 95 | } 96 | #endif 97 | 98 | try 99 | { 100 | MethodInfo acceptNotificationMethod = typeof(NotificationManager).GetMethods(BindingFlags.Public | BindingFlags.Instance).Single( 101 | m => m.GetParameters().Length == 1 102 | && m.GetParameters()[0].ParameterType == typeof(Notification) 103 | && m.Name.IndexOf("PDM", StringComparison.OrdinalIgnoreCase) == -1 104 | && m.XRefScanFor("AcceptNotification for notification:") 105 | && m.XRefScanFor("Could not accept notification because notification details is null")); 106 | acceptNotificationDelegate = Patch(acceptNotificationMethod, GetDetour(nameof(AcceptNotificationPatch))); 107 | } 108 | catch (Exception e) 109 | { 110 | Utilities.LoggerInstance.Error("Error Patching AcceptNotification: " + e.Message); 111 | } 112 | 113 | 114 | try 115 | { 116 | MethodInfo addNotificationMethod = typeof(NotificationManager.ObjectNPrivateSealedNoBoVoNoBoNoBoNoBoNo0).GetMethods(BindingFlags.Public | BindingFlags.Instance).First( 117 | m => m.GetParameters().Length == 1 118 | && m.GetParameters()[0].ParameterType == typeof(Notification)); 119 | addNotificationDelegate = Patch(addNotificationMethod, GetDetour(nameof(AddNotificationPatch))); 120 | } 121 | catch (Exception e) 122 | { 123 | Utilities.LoggerInstance.Error("Error Patching AddNotification: " + e.Message); 124 | } 125 | 126 | 127 | try 128 | { 129 | // Faded to and joined and initialized room 130 | MethodInfo fadeMethod = typeof(VRCUiManager).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).First( 131 | m => m.Name.StartsWith("Method_Public_Void_String_Single_Action_") 132 | && m.Name.IndexOf("PDM", StringComparison.OrdinalIgnoreCase) == -1 133 | && m.GetParameters().Length == 3); 134 | origFadeTo = Patch(fadeMethod, GetDetour(nameof(FadeToPatch))); 135 | } 136 | catch (Exception e) 137 | { 138 | Utilities.LoggerInstance.Error("Error Patching FadeTo: " + e.Message); 139 | } 140 | 141 | UserPermissionHandler.LoadSettings(); 142 | WorldPermissionHandler.LoadSettings(); 143 | 144 | UiButtons.Initialize(); 145 | SoundPlayer.Initialize(); 146 | } 147 | 148 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 149 | private delegate void FadeTo(IntPtr instancePtr, IntPtr fadeNamePtr, float fade, IntPtr actionPtr, IntPtr stackPtr); 150 | 151 | private static FadeTo origFadeTo; 152 | 153 | private static void FadeToPatch(IntPtr instancePtr, IntPtr fadeNamePtr, float fade, IntPtr actionPtr, IntPtr stackPtr) 154 | { 155 | if (instancePtr == IntPtr.Zero) return; 156 | origFadeTo(instancePtr, fadeNamePtr, fade, actionPtr, stackPtr); 157 | 158 | if (!IL2CPP.Il2CppStringToManaged(fadeNamePtr).Equals("BlackFade", StringComparison.Ordinal) 159 | || !fade.Equals(0f) 160 | || RoomManager.field_Internal_Static_ApiWorldInstance_0 == null) return; 161 | 162 | Utilities.CurrentInstanceCached = new Utilities.WorldInstanceCache(RoomManager.field_Internal_Static_ApiWorldInstance_0); 163 | } 164 | 165 | private static unsafe TDelegate Patch(MethodBase originalMethod, IntPtr patchDetour) 166 | { 167 | IntPtr original = *(IntPtr*)(IntPtr)UnhollowerUtils.GetIl2CppMethodInfoPointerFieldForGeneratedMethod(originalMethod).GetValue(null); 168 | MelonUtils.NativeHookAttach((IntPtr)(&original), patchDetour); 169 | return Marshal.GetDelegateForFunctionPointer(original); 170 | } 171 | 172 | private static IntPtr GetDetour(string name) 173 | { 174 | return typeof(AdvancedInviteSystem).GetMethod(name, BindingFlags.NonPublic | BindingFlags.Static)!.MethodHandle.GetFunctionPointer(); 175 | } 176 | 177 | private static void LoadSettings() 178 | { 179 | InviteHandler.DeleteNotifications = advInvPreferencesCategory.GetEntry("DeleteNotifications").Value; 180 | blacklistEnabled = advInvPreferencesCategory.GetEntry("BlacklistEnabled").Value; 181 | whitelistEnabled = advInvPreferencesCategory.GetEntry("WhitelistEnabled").Value; 182 | joinMeNotifyRequest = advInvPreferencesCategory.GetEntry("JoinMeNotifyRequest").Value; 183 | ignoreBusyStatus = advInvPreferencesCategory.GetEntry("IgnoreBusyStatus").Value; 184 | SoundPlayer.Volume = advInvPreferencesCategory.GetEntry("NotificationVolume").Value; 185 | 186 | inviteSoundEnabled = advInvPreferencesCategory.GetEntry("InviteSoundEnabled").Value; 187 | inviteRequestSoundEnabled = advInvPreferencesCategory.GetEntry("InviteRequestSoundEnabled").Value; 188 | voteToKickSoundEnabled = advInvPreferencesCategory.GetEntry("VoteToKickSoundEnabled").Value; 189 | friendRequestSoundEnabled = advInvPreferencesCategory.GetEntry("FriendRequestSoundEnabled").Value; 190 | 191 | // Since floats are weird with this new configuration update it seems to skip the "0." and just earrape you instead 192 | // also limits it to within 0-1 range 193 | if (SoundPlayer.Volume <= 1.0f) return; 194 | 195 | // .45 would turn into 45 (once updated to melonloader 0.3+) which would turn into 4.5 and then back to .45 again 196 | while (advInvPreferencesCategory.GetEntry("NotificationVolume").Value > 1.0f) 197 | advInvPreferencesCategory.GetEntry("NotificationVolume").Value *= .1f; 198 | advInvPreferencesCategory.GetEntry("NotificationVolume").Save(); 199 | } 200 | 201 | public override void OnPreferencesSaved() 202 | { 203 | LoadSettings(); 204 | } 205 | 206 | public override void OnPreferencesLoaded() 207 | { 208 | LoadSettings(); 209 | } 210 | 211 | // For some reason VRChat keeps doing "AddNotification" twice (AllTime and Recent) about once a second 212 | private static IntPtr AddNotificationPatch(IntPtr instancePtr, IntPtr notificationPtr, IntPtr returnedException) 213 | { 214 | if (instancePtr == IntPtr.Zero 215 | || notificationPtr == IntPtr.Zero) return IntPtr.Zero; 216 | 217 | Notification notification = new Notification(notificationPtr); 218 | 219 | #if DEBUG 220 | try 221 | { 222 | Utilities.LoggerInstance.Msg("AddNotification: " + notification.notificationType); 223 | } 224 | catch { } 225 | #endif 226 | 227 | if (notification.id != null && !HandledNotifications.Contains(notification.id)) 228 | { 229 | HandledNotifications.Add(notification.id); 230 | HandleNotification(ref notification); 231 | } 232 | 233 | return addNotificationDelegate(instancePtr, notificationPtr, returnedException); 234 | } 235 | 236 | private static void HandleNotification(ref Notification notification) 237 | { 238 | if (Utilities.GetStreamerMode()) return; 239 | 240 | // Original code doesn't handle much outside worlds so 241 | if (Utilities.CurrentRoom() == null 242 | || Utilities.CurrentWorldInstance() == null) return; 243 | 244 | if (notification.notificationType != null) switch (notification.notificationType.ToLowerInvariant()) 245 | { 246 | case "invite": 247 | #if DEBUG 248 | if (notification.details?.keys != null) 249 | foreach (string key in notification.details?.keys) 250 | { 251 | Utilities.LoggerInstance.Msg("Invite Details Key: " + key); 252 | if (notification.details != null) Utilities.LoggerInstance.Msg("Invite Details Value: " + notification.details[key].ToString()); 253 | } 254 | #endif 255 | 256 | if (APIUser.CurrentUser.statusIsSetToDoNotDisturb 257 | && !ignoreBusyStatus) return; 258 | 259 | string worldId = notification.details?["worldId"].ToString().Split(':')[0]; 260 | if (blacklistEnabled && (UserPermissionHandler.IsBlacklisted(notification.senderUserId) || WorldPermissionHandler.IsBlacklisted(worldId))) 261 | { 262 | Utilities.DeleteNotification(notification); 263 | return; 264 | } 265 | 266 | if (inviteSoundEnabled) 267 | SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.Invite); 268 | break; 269 | 270 | case "requestinvite": 271 | if (blacklistEnabled && UserPermissionHandler.IsBlacklisted(notification.senderUserId)) 272 | { 273 | Utilities.DeleteNotification(notification); 274 | return; 275 | } 276 | 277 | if (APIUser.CurrentUser.statusIsSetToDoNotDisturb 278 | && !ignoreBusyStatus) return; 279 | 280 | if (whitelistEnabled && UserPermissionHandler.IsWhitelisted(notification.senderUserId)) 281 | { 282 | if (!Utilities.AllowedToInvite()) 283 | { 284 | if (inviteRequestSoundEnabled) 285 | SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.InviteRequest); 286 | return; 287 | } 288 | 289 | if (notification.details?.ContainsKey("platform") == true 290 | && !Utilities.IsPlatformCompatibleWithCurrentWorld(notification.details["platform"].ToString())) 291 | { 292 | if (!APIUser.CurrentUser.statusIsSetToJoinMe) 293 | 294 | // Bool's doesn't work and closes the game. just let it through 295 | //Utilities.SendIncompatiblePlatformNotification(__0.senderUserId); 296 | //Utilities.DeleteNotification(__0); 297 | if (inviteRequestSoundEnabled) 298 | SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.InviteRequest); 299 | 300 | return; 301 | } 302 | 303 | // Double Sending 304 | if (!APIUser.CurrentUser.statusIsSetToJoinMe) 305 | { 306 | Utilities.AcceptInviteRequest(notification.senderUserId, notification.senderUsername); 307 | Utilities.DeleteNotification(notification); 308 | } 309 | 310 | if (APIUser.CurrentUser.statusIsSetToJoinMe && joinMeNotifyRequest) 311 | if (inviteRequestSoundEnabled) 312 | SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.InviteRequest); 313 | } 314 | else 315 | { 316 | if (Utilities.AllowedToInvite()) 317 | if (APIUser.CurrentUser.statusIsSetToJoinMe 318 | && !joinMeNotifyRequest) 319 | return; 320 | if (inviteRequestSoundEnabled) 321 | SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.InviteRequest); 322 | } 323 | 324 | return; 325 | 326 | // ReSharper disable StringLiteralTypo 327 | case "votetokick": 328 | if (voteToKickSoundEnabled) 329 | SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.VoteToKick); 330 | break; 331 | 332 | case "friendrequest": 333 | if (friendRequestSoundEnabled) 334 | SoundPlayer.PlayNotificationSound(SoundPlayer.NotificationType.FriendRequest); 335 | break; 336 | 337 | default: 338 | return; 339 | } 340 | } 341 | 342 | private static void AcceptNotificationPatch(IntPtr thisPtr, IntPtr notificationPtr, IntPtr returnedException) 343 | { 344 | try 345 | { 346 | if (thisPtr == IntPtr.Zero 347 | || notificationPtr == IntPtr.Zero) return; 348 | 349 | if (Utilities.GetStreamerMode()) 350 | { 351 | acceptNotificationDelegate(thisPtr, notificationPtr, returnedException); 352 | return; 353 | } 354 | 355 | Notification notification = new Notification(notificationPtr); 356 | 357 | #if DEBUG 358 | try 359 | { 360 | Utilities.LoggerInstance.Msg("AcceptNotification: " + notification.notificationType); 361 | } 362 | catch { } 363 | #endif 364 | 365 | if (notification.notificationType != null && notification.notificationType.Equals("invite", StringComparison.OrdinalIgnoreCase)) 366 | { 367 | InviteHandler.HandleInvite(notification); 368 | return; 369 | } 370 | } 371 | catch (Exception e) 372 | { 373 | Utilities.LoggerInstance.Error($"Exception in accept notification patch: {e}"); 374 | } 375 | 376 | acceptNotificationDelegate(thisPtr, notificationPtr, returnedException); 377 | } 378 | 379 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 380 | private delegate IntPtr AddNotificationDelegate(IntPtr instancePtr, IntPtr notificationPtr, IntPtr returnedException); 381 | 382 | [UnmanagedFunctionPointer(CallingConvention.Cdecl)] 383 | private delegate void AcceptNotificationDelegate(IntPtr thisPtr, IntPtr notification, IntPtr returnedException); 384 | 385 | #if DEBUG 386 | public override void OnUpdate() 387 | { 388 | if (Input.GetKeyDown(KeyCode.P)) Utilities.Request(); 389 | } 390 | 391 | // username, userid, type, custom message, details, pic i guess? 392 | // details doesn't need requestslot if there's no custom message in it. probably safer to not send any 393 | private static bool SendNotificationPatch(string __0, string __1, string __2, string __3, NotificationDetails __4, Il2CppStructArray __5) 394 | { 395 | // Method_Public_Void_String_String_String_String_NotificationDetails_ArrayOf_Byte_0 396 | Utilities.LoggerInstance.Msg("Sending Notification:"); 397 | Utilities.LoggerInstance.Msg($"\tString: {__0}"); 398 | Utilities.LoggerInstance.Msg($"\tString: {__1}"); 399 | Utilities.LoggerInstance.Msg($"\tString: {__2}"); 400 | Utilities.LoggerInstance.Msg($"\tString: {__3}"); 401 | Utilities.LoggerInstance.Msg($"\tDetails: {__4?.ToString()}"); 402 | Utilities.LoggerInstance.Msg($"\tLength: {__5?.Length} Bytes: {__5}"); 403 | Utilities.LoggerInstance.Msg(""); 404 | 405 | return true; 406 | } 407 | 408 | private static bool DeleteNotificationPatch(Notification param_1) 409 | { 410 | // Method_Public_Void_String_String_String_String_NotificationDetails_ArrayOf_Byte_0 411 | MelonLogger.Msg("DeleteNotification:"); 412 | MelonLogger.Msg($"\tnotificationType: {param_1.notificationType}"); 413 | MelonLogger.Msg($"\tsenderUsername: {param_1.senderUsername}"); 414 | MelonLogger.Msg($"\tmessage: {param_1.message}"); 415 | MelonLogger.Msg(""); 416 | 417 | return true; 418 | } 419 | 420 | private static void SetStreamerModePostfix(bool __0) 421 | { 422 | Utilities.LoggerInstance.Msg("Streamer Mode Set To " + __0); 423 | } 424 | #endif 425 | 426 | } 427 | 428 | } -------------------------------------------------------------------------------- /AdvancedInvites/AdvancedInvites.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {BC5BF2ED-004F-40B7-A968-6A718DB1D581} 8 | Library 9 | Properties 10 | AdvancedInvites 11 | AdvancedInvites 12 | v4.7.2 13 | 512 14 | 8 15 | true 16 | F:\SteamLibrary\steamapps\common\VRChat 17 | 18 | 19 | AnyCPU 20 | true 21 | full 22 | false 23 | bin\Debug\ 24 | DEBUG;TRACE 25 | prompt 26 | 4 27 | 28 | 29 | x64 30 | none 31 | true 32 | bin\Release\ 33 | TRACE 34 | prompt 35 | 4 36 | 37 | 38 | 39 | $(VRChatPath)\MelonLoader\0Harmony.dll 40 | False 41 | 42 | 43 | $(VRChatPath)\MelonLoader\Managed\Assembly-CSharp.dll 44 | False 45 | 46 | 47 | $(VRChatPath)\MelonLoader\Managed\Il2Cppmscorlib.dll 48 | False 49 | 50 | 51 | $(VRChatPath)\MelonLoader\Managed\Il2CppSystem.dll 52 | False 53 | 54 | 55 | $(VRChatPath)\MelonLoader\Managed\Il2CppSystem.Core.dll 56 | False 57 | 58 | 59 | $(VRChatPath)\MelonLoader\MelonLoader.dll 60 | 61 | 62 | $(VRChatPath)\MelonLoader\Managed\Newtonsoft.Json.dll 63 | False 64 | 65 | 66 | 67 | $(VRChatPath)\MelonLoader\Managed\System.Net.Http.dll 68 | False 69 | 70 | 71 | $(VRChatPath)\MelonLoader\Tomlet.dll 72 | False 73 | 74 | 75 | $(VRChatPath)\MelonLoader\Managed\Transmtn.dll 76 | False 77 | 78 | 79 | $(VRChatPath)\Mods\UIExpansionKit.dll 80 | False 81 | 82 | 83 | $(VRChatPath)\MelonLoader\Managed\UnhollowerBaseLib.dll 84 | False 85 | 86 | 87 | $(VRChatPath)\MelonLoader\Managed\UnhollowerRuntimeLib.dll 88 | False 89 | 90 | 91 | $(VRChatPath)\MelonLoader\Managed\UnityEngine.AudioModule.dll 92 | False 93 | 94 | 95 | $(VRChatPath)\MelonLoader\Managed\UnityEngine.CoreModule.dll 96 | False 97 | 98 | 99 | $(VRChatPath)\MelonLoader\Managed\UnityEngine.InputLegacyModule.dll 100 | 101 | 102 | $(VRChatPath)\MelonLoader\Managed\UnityEngine.PhysicsModule.dll 103 | False 104 | 105 | 106 | $(VRChatPath)\MelonLoader\Managed\UnityEngine.UnityWebRequestModule.dll 107 | False 108 | 109 | 110 | $(VRChatPath)\MelonLoader\Managed\UnityEngine.UnityWebRequestWWWModule.dll 111 | False 112 | 113 | 114 | $(VRChatPath)\MelonLoader\Managed\VRCCore-Standalone.dll 115 | False 116 | 117 | 118 | $(VRChatPath)\MelonLoader\Managed\VRCSDKBase.dll 119 | False 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 146 | -------------------------------------------------------------------------------- /AdvancedInvites/BuildInfo.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | public static class BuildInfo 5 | { 6 | 7 | public const string Author = "Psychloor"; 8 | 9 | public const string Company = null; 10 | 11 | public const string DownloadLink = "https://github.com/Psychloor/AdvancedInvites/releases"; 12 | 13 | public const string Name = "AdvancedInvites"; 14 | 15 | // 1.2.0 delete notification and single popup for private instances... and the delegates! 16 | // 1.2.1 HideCurrentPopup instead of CloseUi 17 | // 1.2.2 Delete delegate and accesstype 18 | // 1.3.0 Build 1004 fix 19 | // 1.4.0 Black/Whitelist 20 | // 1.4.1 Turn off Blacklist/Whitelist systems 21 | // 1.4.2 Blacklist Worlds too 22 | // 1.4.3 Notification Sounds 23 | // 1.5.0 Update UIX and thanks to it. handle users/worlds in-game. all hail lord Knah 24 | // 1.5.1 Fixed xref scanning for SendNotification 25 | // 1.5.2 Respect Join Me and Do Not Disturb statuses with settings 26 | // 1.5.3 AddNotification patched into dead method only 27 | // 1.5.4 DoNotDisturb/Busy played sound for invites 28 | // 1.6.0 Updated to Build 1063 29 | // 1.6.1 Popupwindow Single to First 30 | // 1.6.2 Some Customization 31 | // 1.6.2.1 Build 1067 Deletion 32 | // 1.6.2.2 Streamer Mode Added 33 | // 1.6.2.3 Regex for localization, cache worldid and instanceidwithtags 34 | // 1.6.2.4 Popup window 1 button sometimes failed 35 | // 1.6.2.5 Reload Audio Files 36 | // 1.6.2.7 build 1095 broke shit /tableflip 37 | // 1.6.3 ML 0.4.0 38 | // 1.6.4 Build 1106 39 | // 1.6.5 instance caching and regions 40 | // 1.6.5.1 https://github.com/Psychloor/AdvancedInvites/issues/7 41 | // 1.6.6 mod assistant doesn't like major minor build release semver and crashes 42 | // 1.6.7 Updated for build 1128, fixed sound loading issue, delete works again 43 | // 1.6.8 Updated for VRC build 1149 44 | // 1.6.9 Updated for VRC build 1151 45 | // 1.6.10 Hopefully fixed NRE 46 | // 1.7.0 Updated for VRC build 1171 47 | // 1.7.1 CreatePortal fixed, mod actually working 48 | public const string Version = "1.7.1"; 49 | 50 | } 51 | 52 | } -------------------------------------------------------------------------------- /AdvancedInvites/DebugTesting.cs: -------------------------------------------------------------------------------- 1 | #if DEBUG 2 | namespace AdvancedInvites 3 | { 4 | using System; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | using System.Reflection; 8 | 9 | using MelonLoader; 10 | using Transmtn.DTO.Notifications; 11 | using UnhollowerRuntimeLib.XrefScans; 12 | 13 | internal static class DebugTesting 14 | { 15 | 16 | internal static void Test() 17 | { 18 | /* 19 | foreach (MethodInfo methodInfo in typeof(NotificationManager).GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly).Where( 20 | m => m.ReturnType == typeof(void) 21 | && m.GetParameters().Length == 2 22 | && m.GetParameters()[0].ParameterType == typeof(Notification) 23 | && m.GetParameters()[1].ParameterType.IsEnum)) 24 | { 25 | methodInfo.XrefDump(); 26 | }*/ 27 | 28 | /*var properties = typeof(VRCInputManager).GetProperties(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly).Where(p => p.PropertyType == typeof(VRCInputManager.ObjectNPublicObTyStTFuT2Fu2ObUnique)); 29 | foreach (var property in properties) 30 | { 31 | VRCInputManager.ObjectNPublicObTyStTFuT2Fu2ObUnique setting = 32 | (VRCInputManager.ObjectNPublicObTyStTFuT2Fu2ObUnique)property.GetGetMethod().Invoke(null, null); 33 | if (setting.field_Public_String_0.IndexOf("STREAMER", StringComparison.OrdinalIgnoreCase) != -1) 34 | { 35 | setting.prop_EnumNPublicSealedvaUnCoHeToTaThShPeVoUnique_0 == VRCInputManager.EnumNPublicSealedvaUnCoHeToTaThShPeVoUnique.StreamerModeEnabled 36 | } 37 | }*/ 38 | 39 | /* 40 | MelonLogger.Msg("Checking For Add"); 41 | foreach (MethodInfo methodInfo in typeof(NotificationManager.ObjectNPrivateSealedNoBoVoNoBoNoBoNoBoNo0).GetMethods(BindingFlags.Public | BindingFlags.Instance)) 42 | { 43 | if (methodInfo.Name.StartsWith("Method_Internal_Boolean") 44 | && methodInfo.GetParameters().Length == 1 45 | && methodInfo.GetParameters()[0].ParameterType == typeof(Notification)) 46 | { 47 | try 48 | { 49 | methodInfo.XrefDump(); 50 | } 51 | catch (Exception e) 52 | { 53 | MelonLogger.Warning(e.Message); 54 | } 55 | } 56 | } 57 | 58 | var addMethod = typeof(NotificationManager.ObjectNPrivateSealedNoBoVoNoBoNoBoNoBoNo0).GetMethod("Method_Internal_Boolean_Notification_PDM_0", BindingFlags.Public | BindingFlags.Instance); 59 | MelonLogger.Msg("Types using add"); 60 | HashSet collectedTypes = new HashSet(); 61 | foreach (XrefInstance instance in XrefScanner.UsedBy(addMethod)) 62 | { 63 | if (instance.Type == XrefType.Method) 64 | { 65 | var resolved = instance.TryResolve(); 66 | if (resolved == null) continue; 67 | if (collectedTypes.Contains(resolved.DeclaringType?.ToString())) continue; 68 | collectedTypes.Add(resolved.DeclaringType?.ToString()); 69 | MelonLogger.Msg(resolved.DeclaringType?.ToString()); 70 | } 71 | } 72 | 73 | MelonLogger.Msg("Checking For Delete"); 74 | foreach (MethodInfo methodInfo in typeof(NotificationManager).GetMethods(BindingFlags.Public | BindingFlags.Instance)) 75 | { 76 | if (methodInfo.Name.StartsWith("Method_Public_Void") 77 | && methodInfo.GetParameters().Length == 1 78 | && methodInfo.GetParameters()[0].ParameterType == typeof(Notification)) 79 | { 80 | methodInfo.XrefDump(); 81 | } 82 | } 83 | 84 | var deleteMethod = typeof(NotificationManager).GetMethod("Method_Public_Void_Notification_0", BindingFlags.Public | BindingFlags.Instance); 85 | MelonLogger.Msg("Types using delete0"); 86 | collectedTypes = new HashSet(); 87 | foreach (XrefInstance instance in XrefScanner.UsedBy(deleteMethod)) 88 | { 89 | if (instance.Type == XrefType.Method) 90 | { 91 | var resolved = instance.TryResolve(); 92 | if (resolved == null) continue; 93 | if (collectedTypes.Contains(resolved.DeclaringType?.ToString())) continue; 94 | collectedTypes.Add(resolved.DeclaringType?.ToString()); 95 | MelonLogger.Msg(resolved.DeclaringType?.ToString()); 96 | } 97 | } 98 | 99 | deleteMethod = typeof(NotificationManager).GetMethod("Method_Public_Void_Notification_6", BindingFlags.Public | BindingFlags.Instance); 100 | MelonLogger.Msg("Types using delete6"); 101 | collectedTypes = new HashSet(); 102 | foreach (XrefInstance instance in XrefScanner.UsedBy(deleteMethod)) 103 | { 104 | if (instance.Type == XrefType.Method) 105 | { 106 | var resolved = instance.TryResolve(); 107 | if (resolved == null) continue; 108 | if (collectedTypes.Contains(resolved.DeclaringType?.ToString())) continue; 109 | collectedTypes.Add(resolved.DeclaringType?.ToString()); 110 | MelonLogger.Msg(resolved.DeclaringType?.ToString()); 111 | } 112 | } 113 | 114 | */ 115 | 116 | 117 | /*MelonLogger.Msg("Finding Streamermode"); 118 | foreach (PropertyInfo property in typeof(VRCInputManager).GetProperties(BindingFlags.Public | BindingFlags.Static)) 119 | { 120 | if (property.PropertyType == typeof(bool)) 121 | { 122 | property.GetSetMethod().XrefDump(); 123 | } 124 | }*/ 125 | } 126 | 127 | public static void DumpTypesUsedBy(this MethodBase methodBase) 128 | { 129 | if (methodBase == null) return; 130 | 131 | MelonLogger.Msg("Types used by method: " + methodBase.Name); 132 | var usedTypes = new HashSet(); 133 | foreach (XrefInstance instance in XrefScanner.UsedBy(methodBase)) 134 | if (instance.Type == XrefType.Method) 135 | { 136 | MethodBase resolved = instance.TryResolve(); 137 | if (resolved == null) continue; 138 | if (usedTypes.Contains(resolved.DeclaringType?.ToString())) continue; 139 | usedTypes.Add(resolved.DeclaringType?.ToString()); 140 | MelonLogger.Msg(resolved.DeclaringType?.ToString()); 141 | } 142 | } 143 | 144 | internal static void XrefDump(this MethodBase methodBase) 145 | { 146 | MelonLogger.Msg("Scanning Method: " + methodBase.Name); 147 | foreach (XrefInstance instance in XrefScanner.XrefScan(methodBase)) 148 | switch (instance.Type) 149 | { 150 | case XrefType.Global: 151 | MelonLogger.Msg($"\tGlobal Instance: {instance.ReadAsObject()?.ToString()}"); 152 | break; 153 | case XrefType.Method: 154 | MethodBase resolved = instance.TryResolve(); 155 | if (resolved == null) 156 | MelonLogger.Msg("\tNull Method Instance"); 157 | else 158 | MelonLogger.Msg($"\tMethod Instance: {resolved.DeclaringType?.Name} {resolved.Name}"); 159 | break; 160 | } 161 | 162 | MelonLogger.Msg(""); 163 | } 164 | } 165 | 166 | } 167 | #endif -------------------------------------------------------------------------------- /AdvancedInvites/InviteHandler.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | using System; 5 | 6 | using Transmtn.DTO.Notifications; 7 | 8 | using UnityEngine; 9 | 10 | using VRC.Core; 11 | using VRC.SDKBase; 12 | 13 | public static class InviteHandler 14 | { 15 | 16 | public static bool DeleteNotifications; 17 | 18 | private static Notification currentNotification; 19 | 20 | // for the current notification being handled 21 | private static string worldId, instanceIdWithTags; 22 | 23 | public static void HandleInvite(Notification notification) 24 | { 25 | currentNotification = notification; 26 | worldId = notification.details["worldId"].ToString().Split(':')[0]; 27 | 28 | // hmm it gets sent but it's not included when accepting an invite..... 29 | if (notification.details.ContainsKey("instanceId")) 30 | { 31 | string[] instanceIdDetails = notification.details["instanceId"].ToString().Split(':'); 32 | instanceIdWithTags = instanceIdDetails.Length > 0 ? instanceIdDetails[1] : instanceIdDetails[0]; 33 | } 34 | else 35 | { 36 | instanceIdWithTags = notification.details["worldId"].ToString().Split(':')[1]; 37 | } 38 | 39 | InstanceAccessType accessType = Utilities.GetAccessType(instanceIdWithTags); 40 | Utilities.InstanceRegion region = Utilities.GetInstanceRegion(instanceIdWithTags); 41 | 42 | var worldName = notification.details["worldName"].ToString(); 43 | string instanceType = Utilities.GetAccessName(accessType); 44 | 45 | switch (accessType) 46 | { 47 | case InstanceAccessType.Public: 48 | case InstanceAccessType.FriendsOfGuests: 49 | case InstanceAccessType.InvitePlus: 50 | Utilities.ShowPopupWindow( 51 | Localization.GetTitle(notification.senderUsername, worldName, instanceType, Utilities.RegionToName(region)), 52 | Localization.GetPublicPopup(notification.senderUsername, worldName, instanceType, Utilities.RegionToName(region)), 53 | Localization.GetJoinButton(), 54 | JoinYourself, 55 | Localization.GetDropPortalButton(), 56 | DropPortal); 57 | break; 58 | 59 | case InstanceAccessType.FriendsOnly: 60 | case InstanceAccessType.InviteOnly: 61 | Utilities.ShowPopupWindow( 62 | Localization.GetTitle(notification.senderUsername, worldName, instanceType, Utilities.RegionToName(region)), 63 | Localization.GetPrivatePopup(notification.senderUsername, worldName, instanceType, Utilities.RegionToName(region)), 64 | Localization.GetJoinButton(), 65 | JoinYourself); 66 | break; 67 | 68 | default: 69 | Utilities.ShowAlert("Error Getting AccessType", "Did you accept a message?"); 70 | break; 71 | } 72 | } 73 | 74 | private static void DropPortal() 75 | { 76 | // Fetch the world to know it exists and also needed for the world tags during the portal creation stage 77 | API.Fetch( 78 | worldId, 79 | 80 | // On Success which it'll be if valid vanilla invite 81 | new Action( 82 | container => 83 | { 84 | Utilities.HideCurrentPopup(); 85 | ApiWorld apiWorld = container.Model.Cast(); 86 | ApiWorldInstance apiWorldInstance = new ApiWorldInstance(apiWorld, instanceIdWithTags); 87 | 88 | Transform playerTransform = Utilities.GetLocalPlayerTransform(); 89 | 90 | // CreatePortal (before il2cpp) 91 | bool created = Utilities.CreatePortal(apiWorld, apiWorldInstance, playerTransform.position, playerTransform.forward, 92 | Utilities.ShowErrorReason); 93 | if (created && DeleteNotifications) 94 | Utilities.DeleteNotification(currentNotification); 95 | }), 96 | 97 | // On Failure 98 | new Action(container => Utilities.ShowAlert("Error Fetching World", container.Error))); 99 | } 100 | 101 | private static void JoinYourself() 102 | { 103 | Utilities.HideCurrentPopup(); 104 | 105 | if (DeleteNotifications) 106 | Utilities.DeleteNotification(currentNotification); 107 | 108 | Networking.GoToRoom($"{worldId}:{instanceIdWithTags}"); 109 | } 110 | 111 | } 112 | 113 | } -------------------------------------------------------------------------------- /AdvancedInvites/Localization.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | using System; 5 | using System.IO; 6 | using System.Text; 7 | 8 | using Il2CppSystem.Text.RegularExpressions; 9 | 10 | using MelonLoader; 11 | 12 | using Newtonsoft.Json; 13 | 14 | public static class Localization 15 | { 16 | 17 | private const string FilePath = "UserData/AdvancedInvites/Localization.json"; 18 | 19 | private static LocalizedText localizedText; 20 | 21 | private static Regex userRegex, worldRegex, instanceRegex, regionRegex; 22 | 23 | public static void Load() 24 | { 25 | localizedText = new LocalizedText(); 26 | if (!Directory.Exists("UserData")) Directory.CreateDirectory("UserData"); 27 | if (!Directory.Exists("UserData/AdvancedInvites")) Directory.CreateDirectory("UserData/AdvancedInvites"); 28 | 29 | if (!File.Exists(FilePath)) 30 | { 31 | Utilities.LoggerInstance.Msg("Localization File Not Found. Creating It"); 32 | File.WriteAllText(FilePath, JsonConvert.SerializeObject(localizedText, Formatting.Indented), Encoding.UTF8); 33 | } 34 | 35 | /*if (File.GetLastWriteTime(FilePath).Date < new DateTime(2021, 6, 23)) 36 | { 37 | Utilities.LoggerInstance.Msg("Old localization found, resetting it"); 38 | File.WriteAllText(FilePath, JsonConvert.SerializeObject(localizedText, Formatting.Indented), Encoding.UTF8); 39 | }*/ 40 | 41 | try 42 | { 43 | localizedText = JsonConvert.DeserializeObject( 44 | File.ReadAllText(FilePath, Encoding.UTF8), 45 | new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }); 46 | } 47 | catch (Exception e) 48 | { 49 | Utilities.LoggerInstance.Error("Error Loading Localization, loading defaults:\n" + e); 50 | localizedText = new LocalizedText(); 51 | } 52 | 53 | userRegex = new Regex("@Username", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); 54 | worldRegex = new Regex("@WorldName", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); 55 | instanceRegex = new Regex("@InstanceType", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); 56 | regionRegex = new Regex("@Region", RegexOptions.CultureInvariant | RegexOptions.IgnoreCase); 57 | } 58 | 59 | public static string GetTitle(string username, string worldName, string instanceType, string region) 60 | { 61 | return ReplaceAllTags(localizedText.Title, username, worldName, instanceType, region); 62 | } 63 | 64 | public static string GetPublicPopup(string username, string worldName, string instanceType, string region) 65 | { 66 | return ReplaceAllTags(localizedText.PublicPopup, username, worldName, instanceType, region); 67 | } 68 | 69 | public static string GetPrivatePopup(string username, string worldName, string instanceType, string region) 70 | { 71 | return ReplaceAllTags(localizedText.PrivatePopup, username, worldName, instanceType, region); 72 | } 73 | 74 | // Just because some people might forget it's Case-SensiTivE 75 | private static string ReplaceAllTags(string text, string username, string worldName, string instanceType, string region) 76 | { 77 | text = userRegex.Replace(text, username); 78 | text = worldRegex.Replace(text, worldName); 79 | text = regionRegex.Replace(text, region); 80 | return instanceRegex.Replace(text, instanceType); 81 | } 82 | 83 | public static string GetJoinButton() 84 | { 85 | return localizedText.JoinButton; 86 | } 87 | 88 | public static string GetDropPortalButton() 89 | { 90 | return localizedText.DropPortalButton; 91 | } 92 | 93 | private class LocalizedText 94 | { 95 | 96 | [JsonProperty(Order = 5)] 97 | public string DropPortalButton = "Drop Portal"; 98 | 99 | [JsonProperty(Order = 0)] 100 | public string Info = @"Tags to use: @Username, @WorldName, @InstanceType, and @Region. for a new line type \n and if you need a tab then type \t"; 101 | 102 | [JsonProperty(Order = 4)] 103 | public string JoinButton = "Join Yourself"; 104 | 105 | [JsonProperty(Order = 3)] 106 | public string PrivatePopup = 107 | "You have officially been invited to:\n@WorldName\nInstance Type: @InstanceType\nRegion: @Region\nPrivate Instance so can't drop a portal"; 108 | 109 | [JsonProperty(Order = 2)] 110 | public string PublicPopup = 111 | "You have officially been invited to:\n@WorldName\nInstance Type: @InstanceType\nRegion: @Region\nWanna go by yourself or drop a portal for the lads?"; 112 | 113 | [JsonProperty(Order = 1)] 114 | public string Title = "Invitation from @Username"; 115 | 116 | } 117 | 118 | } 119 | 120 | } -------------------------------------------------------------------------------- /AdvancedInvites/Notification.ogg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Psychloor/AdvancedInvites/26ce0a1ed11ba2294cf9d2b1c513a599e90b6780/AdvancedInvites/Notification.ogg -------------------------------------------------------------------------------- /AdvancedInvites/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | using AdvancedInvites; 6 | 7 | using MelonLoader; 8 | 9 | using BuildInfo = AdvancedInvites.BuildInfo; 10 | 11 | // General Information about an assembly is controlled through the following 12 | // set of attributes. Change these attribute values to modify the information 13 | // associated with an assembly. 14 | [assembly: AssemblyTitle(BuildInfo.Name)] 15 | [assembly: AssemblyDescription("")] 16 | [assembly: AssemblyConfiguration("")] 17 | [assembly: AssemblyCompany("")] 18 | [assembly: AssemblyProduct("AdvancedInvites")] 19 | [assembly: AssemblyCopyright("Copyright © 2020")] 20 | [assembly: AssemblyTrademark("")] 21 | [assembly: AssemblyCulture("")] 22 | 23 | // Setting ComVisible to false makes the types in this assembly not visible 24 | // to COM components. If you need to access a type in this assembly from 25 | // COM, set the ComVisible attribute to true on that type. 26 | [assembly: ComVisible(false)] 27 | 28 | // The following GUID is for the ID of the typelib if this project is exposed to COM 29 | [assembly: Guid("BC5BF2ED-004F-40B7-A968-6A718DB1D581")] 30 | 31 | // Version information for an assembly consists of the following four values: 32 | // 33 | // Major Version 34 | // Minor Version 35 | // Build Number 36 | // Revision 37 | // 38 | // You can specify all the values or you can default the Build and Revision Numbers 39 | // by using the '*' as shown below: 40 | // [assembly: AssemblyVersion("1.0.*")] 41 | [assembly: AssemblyVersion(BuildInfo.Version)] 42 | [assembly: AssemblyFileVersion(BuildInfo.Version)] 43 | 44 | [assembly: MelonInfo(typeof(AdvancedInviteSystem), BuildInfo.Name, BuildInfo.Version, BuildInfo.Author, BuildInfo.DownloadLink)] 45 | [assembly: MelonGame("VRChat", "VRChat")] 46 | [assembly: MelonColor(ConsoleColor.Magenta)] -------------------------------------------------------------------------------- /AdvancedInvites/SoundPlayer.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | using System; 5 | using System.Collections; 6 | using System.Collections.Generic; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Reflection; 10 | 11 | using MelonLoader; 12 | 13 | using UnityEngine; 14 | using UnityEngine.Networking; 15 | 16 | using Object = UnityEngine.Object; 17 | 18 | public class SoundPlayer 19 | { 20 | 21 | public enum NotificationType 22 | { 23 | 24 | Default, 25 | 26 | Invite, 27 | 28 | InviteRequest, 29 | 30 | FriendRequest, 31 | 32 | VoteToKick 33 | 34 | } 35 | 36 | private const string AudioResourceFolder = "UserData/AdvancedInvites/"; 37 | 38 | private static SoundPlayer instance; 39 | 40 | public static float Volume; 41 | 42 | private readonly Dictionary audioClipDictionary; 43 | 44 | private GameObject audioGameObject; 45 | 46 | private AudioSource audioSource; 47 | 48 | private SoundPlayer() 49 | { 50 | audioClipDictionary = new Dictionary(); 51 | } 52 | 53 | private static string GetAudioPath(NotificationType notificationType) 54 | { 55 | return Path.GetFullPath(Path.Combine(AudioResourceFolder, $"{notificationType}.ogg")); 56 | } 57 | 58 | public static void PlayNotificationSound(NotificationType notificationType) 59 | { 60 | if (instance == null 61 | || instance.audioSource == null) return; 62 | if (instance.audioSource.isPlaying) return; 63 | 64 | instance.audioSource.outputAudioMixerGroup = null; 65 | 66 | if (notificationType != NotificationType.Default 67 | && instance.audioClipDictionary.ContainsKey(notificationType) 68 | && instance.audioClipDictionary[notificationType].loadState == AudioDataLoadState.Loaded) 69 | instance.audioSource.PlayOneShot(instance.audioClipDictionary[notificationType], Volume); 70 | else if (instance.audioClipDictionary.ContainsKey(NotificationType.Default) 71 | && instance.audioClipDictionary[NotificationType.Default].loadState == AudioDataLoadState.Loaded) 72 | instance.audioSource.PlayOneShot(instance.audioClipDictionary[NotificationType.Default], Volume); 73 | } 74 | 75 | internal static IEnumerator LoadNotificationSounds() 76 | { 77 | // in case we're reloading 78 | if (instance.audioClipDictionary.Count > 0) 79 | { 80 | foreach (NotificationType notificationType in instance.audioClipDictionary.Keys) 81 | Object.DestroyImmediate(instance.audioClipDictionary[notificationType]); 82 | 83 | // Give it a little time to update 84 | yield return new WaitForSeconds(.2f); 85 | instance.audioClipDictionary.Clear(); 86 | } 87 | 88 | Utilities.LoggerInstance.Msg("Loading Notification Sound(s)"); 89 | 90 | // Legacy Convert 91 | if (File.Exists(Path.GetFullPath(Path.Combine(AudioResourceFolder, "Notification.ogg")))) 92 | { 93 | Utilities.LoggerInstance.Msg("Found old notification file. renaming to Default.ogg"); 94 | File.Move(Path.GetFullPath(Path.Combine(AudioResourceFolder, "Notification.ogg")), GetAudioPath(NotificationType.Default)); 95 | } 96 | 97 | if (!File.Exists(GetAudioPath(NotificationType.Default))) 98 | { 99 | Utilities.LoggerInstance.Msg("Default Notification sound not found. Creating default one"); 100 | try 101 | { 102 | using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("AdvancedInvites.Notification.ogg"); 103 | if (stream != null) 104 | { 105 | using FileStream fs = new FileStream(GetAudioPath(NotificationType.Default), FileMode.Create); 106 | stream.CopyTo(fs); 107 | fs.Close(); 108 | stream.Close(); 109 | } 110 | else 111 | { 112 | Utilities.LoggerInstance.Error("Failed to open Resource Stream for Notification.ogg"); 113 | } 114 | } 115 | catch (Exception e) 116 | { 117 | Utilities.LoggerInstance.Error("Something went wrong writing the default notification file to UserData/AdvancedInvites Folder:\n" + e); 118 | yield break; 119 | } 120 | } 121 | 122 | // look through all types and see if the soundfile exists 123 | foreach (string name in Enum.GetNames(typeof(NotificationType)).Where( 124 | name => File.Exists(GetAudioPath((NotificationType)Enum.Parse(typeof(NotificationType), name))))) 125 | yield return LoadAudioClip((NotificationType)Enum.Parse(typeof(NotificationType), name)); 126 | } 127 | 128 | // Thanks Loukylor and Knah 129 | private static IEnumerator LoadAudioClip(NotificationType notificationType) 130 | { 131 | UnityWebRequest request = UnityWebRequest.Get(GetAudioPath(notificationType)); 132 | request.SendWebRequest(); 133 | while (!request.isDone) 134 | yield return null; 135 | 136 | AudioClip audioClip = WebRequestWWW.InternalCreateAudioClipUsingDH(request.downloadHandler, request.url, false, false, AudioType.UNKNOWN); 137 | 138 | request.Dispose(); 139 | 140 | if (audioClip.loadState == AudioDataLoadState.Loaded) 141 | { 142 | instance.audioClipDictionary.Add(notificationType, audioClip); 143 | instance.audioClipDictionary[notificationType].hideFlags = HideFlags.HideAndDontSave; 144 | Utilities.LoggerInstance.Msg($"{notificationType} Notification Sound Loaded"); 145 | } 146 | else if (audioClip.loadState == AudioDataLoadState.Failed) 147 | { 148 | Utilities.LoggerInstance.Error($"Failed To Load {notificationType} Notification Sound"); 149 | } 150 | } 151 | 152 | public static void Initialize() 153 | { 154 | if (instance != null) return; 155 | 156 | instance = new SoundPlayer(); 157 | instance.audioGameObject = new GameObject { hideFlags = HideFlags.HideAndDontSave }; 158 | instance.audioSource = instance.audioGameObject.AddComponent(); 159 | instance.audioSource.hideFlags = HideFlags.HideAndDontSave; 160 | instance.audioSource.dopplerLevel = 0f; 161 | instance.audioSource.spatialBlend = 0f; 162 | instance.audioSource.spatialize = false; 163 | 164 | MelonCoroutines.Start(LoadNotificationSounds()); 165 | } 166 | 167 | } 168 | 169 | } -------------------------------------------------------------------------------- /AdvancedInvites/UiButtons.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | using MelonLoader; 5 | 6 | using UIExpansionKit.API; 7 | 8 | using UnityEngine; 9 | 10 | using VRC.Core; 11 | using VRC.UI; 12 | 13 | public static class UiButtons 14 | { 15 | 16 | private static APIUser CurrentSelectedUser => QuickMenu.prop_QuickMenu_0.field_Private_APIUser_0; 17 | 18 | private static APIUser CurrentSocialUser => Object.FindObjectOfType()?.field_Private_APIUser_0; 19 | 20 | public static void Initialize() 21 | { 22 | // Quickmenu 23 | ICustomLayoutedMenu userQuickMenuPage = ExpansionKitApi.GetExpandedMenu(ExpandedMenu.UserQuickMenu); 24 | userQuickMenuPage.AddSimpleButton("AdvancedInvites\nBlacklist", () => BlacklistUser(CurrentSelectedUser)); 25 | userQuickMenuPage.AddSimpleButton("AdvancedInvites\nWhitelist", () => WhitelistUser(CurrentSelectedUser)); 26 | 27 | // User Details menu 28 | ICustomLayoutedMenu userDetailsMenuPage = ExpansionKitApi.GetExpandedMenu(ExpandedMenu.UserDetailsMenu); 29 | userDetailsMenuPage.AddSimpleButton("AdvancedInvites\nBlacklist", () => BlacklistUser(CurrentSocialUser)); 30 | userDetailsMenuPage.AddSimpleButton("AdvancedInvites\nWhitelist", () => WhitelistUser(CurrentSocialUser)); 31 | 32 | // Social menu 33 | ExpansionKitApi.GetExpandedMenu(ExpandedMenu.SocialMenu).AddSimpleButton("AdvancedInvites\nRemove...", ShowUsers); 34 | 35 | // Worlds Menu 36 | ExpansionKitApi.GetExpandedMenu(ExpandedMenu.WorldMenu).AddSimpleButton("AdvancedInvites\nRemove...", ShowWorlds); 37 | 38 | // World Details menu 39 | ExpansionKitApi.GetExpandedMenu(ExpandedMenu.WorldDetailsMenu).AddSimpleButton("AdvancedInvites\nBlacklist", BlacklistWorld); 40 | 41 | // Settings Menu 42 | ExpansionKitApi.GetExpandedMenu(ExpandedMenu.SettingsMenu).AddSimpleButton( 43 | "AdvancedInvites\nReload Sounds", 44 | () => MelonCoroutines.Start(SoundPlayer.LoadNotificationSounds())); 45 | } 46 | 47 | private static void ShowUsers() 48 | { 49 | ICustomShowableLayoutedMenu userPermissionsPopup = ExpansionKitApi.CreateCustomFullMenuPopup(LayoutDescription.WideSlimList); 50 | 51 | if (UserPermissionHandler.BlacklistedUsers.Count > 0) 52 | { 53 | userPermissionsPopup.AddLabel("Blacklisted Users"); 54 | foreach (UserPermissionHandler.PermissionEntry blacklistedUser in UserPermissionHandler.BlacklistedUsers) 55 | userPermissionsPopup.AddSimpleButton( 56 | blacklistedUser.DisplayName, 57 | () => 58 | { 59 | userPermissionsPopup.Hide(); 60 | UserPermissionHandler.RemoveFromBlacklist(blacklistedUser.UserId); 61 | UserPermissionHandler.SaveSettings(); 62 | ShowUsers(); 63 | }); 64 | 65 | userPermissionsPopup.AddSpacer(); 66 | } 67 | 68 | if (UserPermissionHandler.WhitelistedUsers.Count > 0) 69 | { 70 | userPermissionsPopup.AddLabel("Whitelisted Users"); 71 | foreach (UserPermissionHandler.PermissionEntry whitelistedUser in UserPermissionHandler.WhitelistedUsers) 72 | userPermissionsPopup.AddSimpleButton( 73 | whitelistedUser.DisplayName, 74 | () => 75 | { 76 | userPermissionsPopup.Hide(); 77 | UserPermissionHandler.RemoveFromWhitelist(whitelistedUser.UserId); 78 | UserPermissionHandler.SaveSettings(); 79 | ShowUsers(); 80 | }); 81 | 82 | userPermissionsPopup.AddSpacer(); 83 | } 84 | 85 | userPermissionsPopup.AddSimpleButton("Close", () => userPermissionsPopup.Hide()); 86 | userPermissionsPopup.Show(); 87 | } 88 | 89 | private static void ShowWorlds() 90 | { 91 | ICustomShowableLayoutedMenu worldsPermissionsPopup = ExpansionKitApi.CreateCustomFullMenuPopup(LayoutDescription.WideSlimList); 92 | 93 | if (WorldPermissionHandler.BlacklistedWorlds.Count > 0) 94 | { 95 | worldsPermissionsPopup.AddLabel("Blacklisted Worlds"); 96 | foreach (WorldPermissionHandler.PermissionEntry blacklistedWorld in WorldPermissionHandler.BlacklistedWorlds) 97 | worldsPermissionsPopup.AddSimpleButton( 98 | blacklistedWorld.WorldName, 99 | () => 100 | { 101 | worldsPermissionsPopup.Hide(); 102 | WorldPermissionHandler.RemoveFromBlacklist(blacklistedWorld.WorldId); 103 | WorldPermissionHandler.SaveSettings(); 104 | ShowWorlds(); 105 | }); 106 | 107 | worldsPermissionsPopup.AddSpacer(); 108 | } 109 | 110 | worldsPermissionsPopup.AddSimpleButton("Close", () => worldsPermissionsPopup.Hide()); 111 | worldsPermissionsPopup.Show(); 112 | } 113 | 114 | private static void BlacklistWorld() 115 | { 116 | ApiWorld currentWorld = Object.FindObjectOfType()?.field_Private_ApiWorld_0; 117 | if (currentWorld == null) return; 118 | 119 | if (WorldPermissionHandler.IsBlacklisted(currentWorld.id)) 120 | { 121 | WorldPermissionHandler.RemoveFromBlacklist(currentWorld.id); 122 | Utilities.LoggerInstance.Msg($"{currentWorld.name} removed from blacklist"); 123 | Utilities.QueueHudMessage($"{currentWorld.name} removed from blacklist"); 124 | } 125 | else 126 | { 127 | WorldPermissionHandler.AddToBlacklist(currentWorld); 128 | Utilities.LoggerInstance.Msg($"{currentWorld.name} added to blacklist"); 129 | Utilities.QueueHudMessage($"{currentWorld.name} added to blacklist"); 130 | } 131 | 132 | WorldPermissionHandler.SaveSettings(); 133 | } 134 | 135 | private static void BlacklistUser(APIUser user) 136 | { 137 | if (user == null) return; 138 | 139 | if (UserPermissionHandler.IsBlacklisted(user.id)) 140 | { 141 | UserPermissionHandler.RemoveFromBlacklist(user.id); 142 | Utilities.LoggerInstance.Msg($"{user.displayName} removed from blacklist"); 143 | Utilities.QueueHudMessage($"{user.displayName} removed from blacklist"); 144 | } 145 | else 146 | { 147 | if (UserPermissionHandler.IsWhitelisted(user.id)) UserPermissionHandler.RemoveFromWhitelist(user.id); 148 | UserPermissionHandler.AddToBlacklist(user); 149 | Utilities.LoggerInstance.Msg($"{user.displayName} added to blacklist"); 150 | Utilities.QueueHudMessage($"{user.displayName} added to blacklist"); 151 | } 152 | 153 | UserPermissionHandler.SaveSettings(); 154 | } 155 | 156 | private static void WhitelistUser(APIUser user) 157 | { 158 | if (user == null) return; 159 | 160 | if (UserPermissionHandler.IsWhitelisted(user.id)) 161 | { 162 | UserPermissionHandler.RemoveFromWhitelist(user.id); 163 | Utilities.LoggerInstance.Msg($"{user.displayName} removed from whitelist"); 164 | Utilities.QueueHudMessage($"{user.displayName} removed from whitelist"); 165 | } 166 | else 167 | { 168 | if (UserPermissionHandler.IsBlacklisted(user.id)) UserPermissionHandler.RemoveFromBlacklist(user.id); 169 | UserPermissionHandler.AddToWhitelist(user); 170 | Utilities.LoggerInstance.Msg($"{user.displayName} added to whitelist"); 171 | Utilities.QueueHudMessage($"{user.displayName} added to whitelist"); 172 | } 173 | 174 | UserPermissionHandler.SaveSettings(); 175 | } 176 | 177 | } 178 | 179 | } -------------------------------------------------------------------------------- /AdvancedInvites/UserPermissionHandler.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Text; 8 | 9 | using Newtonsoft.Json; 10 | 11 | using VRC.Core; 12 | 13 | public static class UserPermissionHandler 14 | { 15 | 16 | private const string BlacklistedPath = "UserData/AdvancedInvites/Blacklisted.json"; 17 | 18 | private const string WhitelistedPath = "UserData/AdvancedInvites/Whitelisted.json"; 19 | 20 | internal static readonly List BlacklistedUsers = new List(); 21 | 22 | internal static readonly List WhitelistedUsers = new List(); 23 | 24 | internal static bool IsBlacklisted(string userId) 25 | { 26 | foreach (PermissionEntry blacklistedUser in BlacklistedUsers) 27 | if (blacklistedUser.UserId.Equals(userId, StringComparison.OrdinalIgnoreCase)) 28 | return true; 29 | 30 | return false; 31 | } 32 | 33 | internal static bool IsWhitelisted(string userId) 34 | { 35 | foreach (PermissionEntry whitelistedUser in WhitelistedUsers) 36 | if (whitelistedUser.UserId.Equals(userId, StringComparison.OrdinalIgnoreCase)) 37 | return true; 38 | 39 | return false; 40 | } 41 | 42 | internal static void AddToBlacklist(APIUser apiUser) 43 | { 44 | if (IsBlacklisted(apiUser.id)) return; 45 | BlacklistedUsers.Add(new PermissionEntry { DisplayName = apiUser.displayName, UserId = apiUser.id }); 46 | } 47 | 48 | internal static void RemoveFromBlacklist(string userId) 49 | { 50 | if (!IsBlacklisted(userId)) return; 51 | BlacklistedUsers.RemoveAll(entry => entry.UserId.Equals(userId, StringComparison.OrdinalIgnoreCase)); 52 | } 53 | 54 | internal static void AddToWhitelist(APIUser apiUser) 55 | { 56 | if (IsWhitelisted(apiUser.id)) return; 57 | WhitelistedUsers.Add(new PermissionEntry { DisplayName = apiUser.displayName, UserId = apiUser.id }); 58 | } 59 | 60 | internal static void RemoveFromWhitelist(string userId) 61 | { 62 | if (!IsWhitelisted(userId)) return; 63 | WhitelistedUsers.RemoveAll(entry => entry.UserId.Equals(userId, StringComparison.OrdinalIgnoreCase)); 64 | } 65 | 66 | internal static void LoadSettings() 67 | { 68 | if (!Directory.Exists("UserData")) Directory.CreateDirectory("UserData"); 69 | if (!Directory.Exists("UserData/AdvancedInvites")) Directory.CreateDirectory("UserData/AdvancedInvites"); 70 | 71 | if (!File.Exists(BlacklistedPath)) 72 | File.WriteAllText(BlacklistedPath, "[]", Encoding.UTF8); 73 | if (!File.Exists(WhitelistedPath)) 74 | File.WriteAllText(WhitelistedPath, "[]", Encoding.UTF8); 75 | 76 | JsonConvert.PopulateObject( 77 | File.ReadAllText(BlacklistedPath, Encoding.UTF8), 78 | BlacklistedUsers, 79 | new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }); 80 | 81 | JsonConvert.PopulateObject( 82 | File.ReadAllText(WhitelistedPath, Encoding.UTF8), 83 | WhitelistedUsers, 84 | new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }); 85 | } 86 | 87 | public static void SaveSettings() 88 | { 89 | File.WriteAllText(BlacklistedPath, JsonConvert.SerializeObject(BlacklistedUsers, Formatting.Indented), Encoding.UTF8); 90 | File.WriteAllText(WhitelistedPath, JsonConvert.SerializeObject(WhitelistedUsers, Formatting.Indented), Encoding.UTF8); 91 | } 92 | 93 | internal class PermissionEntry 94 | { 95 | 96 | [JsonProperty("DisplayName")] 97 | public string DisplayName; 98 | 99 | [JsonProperty("UserID")] 100 | public string UserId; 101 | 102 | } 103 | 104 | } 105 | 106 | } -------------------------------------------------------------------------------- /AdvancedInvites/Utilities.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | using System; 5 | using System.Linq; 6 | using System.Reflection; 7 | 8 | using MelonLoader; 9 | 10 | using Transmtn.DTO.Notifications; 11 | 12 | using UnhollowerBaseLib; 13 | 14 | using UnhollowerRuntimeLib.XrefScans; 15 | 16 | using UnityEngine; 17 | 18 | using VRC; 19 | using VRC.Core; 20 | using VRC.UI; 21 | 22 | using Boolean = Il2CppSystem.Boolean; 23 | 24 | public static class Utilities 25 | { 26 | 27 | 28 | public enum InstanceRegion 29 | { 30 | 31 | US, 32 | 33 | EU, 34 | 35 | JP 36 | 37 | } 38 | 39 | public static InstanceRegion GetInstanceRegion(string tags) 40 | { 41 | if (tags.IndexOf("region(eu)", StringComparison.OrdinalIgnoreCase) != -1) return InstanceRegion.EU; 42 | return tags.IndexOf("region(jp)", StringComparison.OrdinalIgnoreCase) != -1 ? InstanceRegion.JP : InstanceRegion.US; 43 | } 44 | 45 | public static string RegionToName(InstanceRegion region) 46 | { 47 | return region switch 48 | { 49 | InstanceRegion.US => "USA", 50 | InstanceRegion.EU => "Europe", 51 | InstanceRegion.JP => "Japan", 52 | _ => throw new ArgumentOutOfRangeException(nameof(region), region, null) 53 | }; 54 | } 55 | 56 | //public delegate bool StreamerModeDelegate(); 57 | 58 | public delegate VRCUiManager VRCUiManagerDelegate(); 59 | 60 | private static CreatePortalDelegate ourCreatePortalDelegate; 61 | 62 | private static DeleteNotificationDelegate ourDeleteNotificationDelegate; 63 | 64 | private static ShowAlertDelegate ourShowAlertDelegate; 65 | 66 | private static ShowPopupWindowBothDelegate ourShowPopupWindowBothDelegate; 67 | 68 | private static ShowPopupWindowSingleDelegate ourShowPopupWindowSingleDelegate; 69 | 70 | private static VRCUiManagerDelegate ourVRCUiManagerDelegate; 71 | 72 | private static SendNotificationDelegate ourSendNotificationDelegate; 73 | 74 | /* public static StreamerModeDelegate GetStreamerMode 75 | { 76 | get 77 | { 78 | if (ourStreamerModeDelegate != null) return ourStreamerModeDelegate; 79 | 80 | PropertyInfo streamerModeProperty = typeof(VRCInputManager).GetProperties(BindingFlags.Public | BindingFlags.Static).First( 81 | property => property.PropertyType == typeof(bool) 82 | && XrefScanner.XrefScan(property.GetSetMethod()).Any( 83 | xref => xref.Type == XrefType.Global && xref.ReadAsObject()?.ToString().IndexOf("STREAMER", StringComparison.OrdinalIgnoreCase) != -1)); 84 | 85 | ourStreamerModeDelegate = (StreamerModeDelegate)Delegate.CreateDelegate(typeof(StreamerModeDelegate), streamerModeProperty.GetGetMethod()); 86 | return ourStreamerModeDelegate; 87 | } 88 | }*/ 89 | 90 | private static SendNotificationDelegate SendNotification 91 | { 92 | get 93 | { 94 | if (ourSendNotificationDelegate != null) return ourSendNotificationDelegate; 95 | 96 | foreach (MethodInfo method in typeof(NotificationManager).GetMethods(BindingFlags.Public | BindingFlags.Instance)) 97 | { 98 | if (method.IsAbstract 99 | || method.IsVirtual) continue; 100 | if (!method.HasParameters( 101 | typeof(string), 102 | typeof(string), 103 | typeof(string), 104 | typeof(string), 105 | typeof(NotificationDetails), 106 | typeof(Il2CppStructArray))) continue; 107 | 108 | if (!XrefScanner.UsedBy(method).Any( 109 | instance => instance.Type == XrefType.Method 110 | && instance.TryResolve()?.ReflectedType?.Equals(typeof(PageUserInfo)) == true)) continue; 111 | 112 | ourSendNotificationDelegate = (SendNotificationDelegate)Delegate.CreateDelegate( 113 | typeof(SendNotificationDelegate), 114 | NotificationManager.prop_NotificationManager_0, 115 | method); 116 | return ourSendNotificationDelegate; 117 | } 118 | 119 | MelonLogger.Error("Failed to find SendNotification Method"); 120 | return null; 121 | } 122 | } 123 | 124 | public static VRCUiManagerDelegate GetVRCUiManager 125 | { 126 | get 127 | { 128 | if (ourVRCUiManagerDelegate != null) return ourVRCUiManagerDelegate; 129 | MethodInfo vrcUiManagerInstance = typeof(VRCUiManager).GetMethods().First(x => x.ReturnType == typeof(VRCUiManager)); 130 | ourVRCUiManagerDelegate = (VRCUiManagerDelegate)Delegate.CreateDelegate(typeof(VRCUiManagerDelegate), vrcUiManagerInstance); 131 | return ourVRCUiManagerDelegate; 132 | } 133 | } 134 | 135 | private static CreatePortalDelegate GetCreatePortalDelegate 136 | { 137 | get 138 | { 139 | if (ourCreatePortalDelegate != null) return ourCreatePortalDelegate; 140 | MethodInfo portalMethod = typeof(PortalInternal).GetMethods(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly).First( 141 | m => m.ReturnType == typeof(bool) 142 | && m.HasParameters(typeof(ApiWorld), typeof(ApiWorldInstance), typeof(Vector3), typeof(Vector3)) 143 | && m.XRefScanFor("admin_dont_allow_portal")); 144 | ourCreatePortalDelegate = (CreatePortalDelegate)Delegate.CreateDelegate(typeof(CreatePortalDelegate), portalMethod); 145 | return ourCreatePortalDelegate; 146 | } 147 | } 148 | 149 | private static DeleteNotificationDelegate GetDeleteNotificationDelegate 150 | { 151 | get 152 | { 153 | if (ourDeleteNotificationDelegate != null) return ourDeleteNotificationDelegate; 154 | 155 | // Appears to be NotificationManager.Method_Public_Void_Notification_1(notification); 156 | foreach (MethodInfo method in typeof(NotificationManager).GetMethods(BindingFlags.Public | BindingFlags.Instance)) 157 | { 158 | // First some pre-filtering before x-referencing it 159 | if (!method.Name.StartsWith("Method_Public_Void_")) continue; 160 | if (method.GetParameters().Length != 1) continue; 161 | if (method.GetParameters()[0].ParameterType != typeof(Notification)) continue; 162 | 163 | // So far it's mostly always had voteToKick in it for special case 164 | if (!method.XRefScanFor("voteToKick")) continue; 165 | 166 | // Notification Manager count seems to be at least 3 of 167 | if (method.XRefScanMethodCount(null, nameof(MonoBehaviourPublicObApAcApStAcBoStBoObUnique)) < 1 168 | || method.XRefScanMethodCount(null, nameof(NotificationManager)) < 3) continue; 169 | 170 | // The real one is used by the quick menu and itself 171 | if (!XrefScanner.UsedBy(method).Any( 172 | instance => instance.Type == XrefType.Method && instance.TryResolve()?.DeclaringType == typeof(NotificationManager))) continue; 173 | if (!XrefScanner.UsedBy(method).Any( 174 | instance => instance.Type == XrefType.Method && instance.TryResolve()?.DeclaringType == typeof(Object1Public1TeBo1TeStOb1DaStUnique))) 175 | continue; 176 | 177 | // Well seems to be the right one, let's grab it 178 | ourDeleteNotificationDelegate = (DeleteNotificationDelegate)Delegate.CreateDelegate( 179 | typeof(DeleteNotificationDelegate), 180 | NotificationManager.field_Private_Static_NotificationManager_0, 181 | method); 182 | return ourDeleteNotificationDelegate; 183 | } 184 | 185 | return null; 186 | } 187 | } 188 | 189 | private static ShowAlertDelegate GetShowAlertDelegate 190 | { 191 | get 192 | { 193 | if (ourShowAlertDelegate != null) return ourShowAlertDelegate; 194 | MethodInfo alertMethod = typeof(VRCUiPopupManager).GetMethods(BindingFlags.Public | BindingFlags.Instance) 195 | .First(m => m.GetParameters().Length == 3 && m.XRefScanFor("Popups/AlertPopup")); 196 | ourShowAlertDelegate = (ShowAlertDelegate)Delegate.CreateDelegate( 197 | typeof(ShowAlertDelegate), 198 | VRCUiPopupManager.field_Private_Static_VRCUiPopupManager_0, 199 | alertMethod); 200 | return ourShowAlertDelegate; 201 | } 202 | } 203 | 204 | private static ShowPopupWindowBothDelegate GetShowPopupWindowBothDelegate 205 | { 206 | get 207 | { 208 | if (ourShowPopupWindowBothDelegate != null) return ourShowPopupWindowBothDelegate; 209 | MethodInfo popupV2Method = typeof(VRCUiPopupManager).GetMethods(BindingFlags.Public | BindingFlags.Instance).First( 210 | m => m.Name.IndexOf("pdm", StringComparison.OrdinalIgnoreCase) == -1 211 | && m.GetParameters().Length == 7 212 | && m.XRefScanFor("Popups/StandardPopupV2")); 213 | 214 | ourShowPopupWindowBothDelegate = (ShowPopupWindowBothDelegate)Delegate.CreateDelegate( 215 | typeof(ShowPopupWindowBothDelegate), 216 | VRCUiPopupManager.field_Private_Static_VRCUiPopupManager_0, 217 | popupV2Method); 218 | return ourShowPopupWindowBothDelegate; 219 | } 220 | } 221 | 222 | private static ShowPopupWindowSingleDelegate GetShowPopupWindowSingleDelegate 223 | { 224 | get 225 | { 226 | if (ourShowPopupWindowSingleDelegate != null) return ourShowPopupWindowSingleDelegate; 227 | MethodInfo popupV2Method = typeof(VRCUiPopupManager).GetMethods(BindingFlags.Public | BindingFlags.Instance).First( 228 | m => m.GetParameters().Length == 5 229 | && m.Name.IndexOf("pdm", StringComparison.OrdinalIgnoreCase) == -1 230 | && m.XRefScanFor("Popups/StandardPopupV2") 231 | 232 | // Loukylor told me about this 233 | && XrefScanner.UsedBy(m).Any( 234 | xref => xref.Type == XrefType.Method 235 | && xref.TryResolve()?.Name.IndexOf("OpenSaveSearchPopup", StringComparison.OrdinalIgnoreCase) != -1)); 236 | 237 | ourShowPopupWindowSingleDelegate = (ShowPopupWindowSingleDelegate)Delegate.CreateDelegate( 238 | typeof(ShowPopupWindowSingleDelegate), 239 | VRCUiPopupManager.field_Private_Static_VRCUiPopupManager_0, 240 | popupV2Method); 241 | return ourShowPopupWindowSingleDelegate; 242 | } 243 | } 244 | 245 | public static MelonLogger.Instance LoggerInstance { get; set; } 246 | 247 | //private static StreamerModeDelegate ourStreamerModeDelegate; 248 | 249 | public static bool GetStreamerMode() 250 | { 251 | return VRCInputManager.Method_Public_Static_Boolean_InputSetting_0( 252 | VRCInputManager.InputSetting.StreamerModeEnabled); 253 | } 254 | 255 | #if DEBUG 256 | public static void Request() 257 | { 258 | NotificationDetails details = new NotificationDetails(); 259 | details.Add("platform", Tools.Platform); 260 | 261 | SendNotification(APIUser.CurrentUser.displayName, APIUser.CurrentUser.id, "requestInvite", string.Empty, details); 262 | } 263 | #endif 264 | 265 | public static ApiWorld CurrentRoom() 266 | { 267 | return RoomManager.field_Internal_Static_ApiWorld_0; 268 | } 269 | 270 | public static ApiWorldInstance CurrentWorldInstance() 271 | { 272 | return RoomManager.field_Internal_Static_ApiWorldInstance_0; 273 | } 274 | 275 | public static void QueueHudMessage(string msg) 276 | { 277 | GetVRCUiManager().field_Private_List_1_String_0.Add(msg); 278 | } 279 | 280 | public static InstanceAccessType GetAccessType(string tags) 281 | { 282 | if (tags.IndexOf("hidden", StringComparison.OrdinalIgnoreCase) >= 0) return InstanceAccessType.FriendsOfGuests; 283 | if (tags.IndexOf("friends", StringComparison.OrdinalIgnoreCase) >= 0) return InstanceAccessType.FriendsOnly; 284 | if (tags.IndexOf("request", StringComparison.OrdinalIgnoreCase) >= 0) return InstanceAccessType.InvitePlus; 285 | return tags.IndexOf("private", StringComparison.OrdinalIgnoreCase) >= 0 ? InstanceAccessType.InviteOnly : InstanceAccessType.Public; 286 | } 287 | 288 | public static string GetAccessName(InstanceAccessType accessType) 289 | { 290 | return accessType switch 291 | { 292 | InstanceAccessType.Public => "Public", 293 | InstanceAccessType.FriendsOfGuests => "Friends+", 294 | InstanceAccessType.FriendsOnly => "Friends Only", 295 | InstanceAccessType.InviteOnly => "Invite Only", 296 | InstanceAccessType.InvitePlus => "Invite+", 297 | _ => throw new ArgumentOutOfRangeException(nameof(accessType), accessType, "what the fuck happened?") 298 | }; 299 | } 300 | 301 | public static bool IsPlatformCompatibleWithCurrentWorld(string platform) 302 | { 303 | if (CurrentRoom() == null) return false; 304 | if (string.IsNullOrEmpty(platform)) return false; // true or false? supposed to be included at least 305 | 306 | return CurrentRoom().supportedPlatforms switch 307 | { 308 | ApiModel.SupportedPlatforms.StandaloneWindows => Tools.Platform.Equals(platform, StringComparison.OrdinalIgnoreCase), 309 | ApiModel.SupportedPlatforms.Android => Tools.Platform.Equals(platform, StringComparison.OrdinalIgnoreCase), 310 | ApiModel.SupportedPlatforms.All => true, 311 | _ => true 312 | }; 313 | } 314 | 315 | 316 | public static void AcceptInviteRequest(string receiverUserId, string receiverUserName) 317 | { 318 | ApiWorld currentRoom = CurrentRoom(); 319 | ApiWorldInstance currentInstance = CurrentWorldInstance(); 320 | NotificationDetails details = new NotificationDetails(); 321 | 322 | if (string.IsNullOrEmpty(currentInstance.instanceId)) 323 | { 324 | details.Add("worldId", $"{currentRoom.id}"); 325 | details.Add("instanceId", $"{currentRoom.id}"); 326 | } 327 | else 328 | { 329 | details.Add("worldId", $"{currentRoom.id}:{currentInstance.instanceId}"); 330 | details.Add("instanceId", $"{currentRoom.id}:{currentInstance.instanceId}"); 331 | } 332 | 333 | //details.Add("rsvp", new Boolean { m_value = true }.BoxIl2CppObject()); // Doesn't work for some reason 334 | details.Add("worldName", currentRoom.name); 335 | 336 | SendNotification(receiverUserName, receiverUserId, "invite", string.Empty, details); 337 | } 338 | 339 | // Since stuff bugs out if you do boxed booleans this will remain here unused till i might figure out something (or someone else does) 340 | public static void SendIncompatiblePlatformNotification(string receiverUserId, string receiverUserName) 341 | { 342 | NotificationDetails details = new NotificationDetails(); 343 | details.Add("incompatible", new Boolean { m_value = true }.BoxIl2CppObject()); 344 | details.Add("rsvp", new Boolean { m_value = true }.BoxIl2CppObject()); 345 | 346 | SendNotification(receiverUserName, receiverUserId, "invite", string.Empty, details); 347 | } 348 | 349 | public static bool AllowedToInvite() 350 | { 351 | // Instance owner 352 | if (CurrentInstanceCached.OwnerId?.Equals(APIUser.CurrentUser.id, StringComparison.Ordinal) == true) return true; 353 | return CurrentInstanceCached.AccessType switch 354 | { 355 | InstanceAccessType.Public => true, 356 | InstanceAccessType.FriendsOfGuests => true, 357 | InstanceAccessType.InvitePlus => true, 358 | 359 | // Not instance owner/not mutual friend so no 360 | InstanceAccessType.FriendsOnly => false, 361 | InstanceAccessType.InviteOnly => false, 362 | _ => false 363 | }; 364 | } 365 | 366 | public static bool CreatePortal(ApiWorld apiWorld, ApiWorldInstance apiWorldInstance, Vector3 position, Vector3 forward, Action errorReasonCallback) 367 | { 368 | return GetCreatePortalDelegate(apiWorld, apiWorldInstance, position, forward, errorReasonCallback); 369 | } 370 | 371 | public static void ShowErrorReason(string error) 372 | { 373 | Utilities.ShowAlert("Error Creating Portal", error); 374 | } 375 | 376 | internal static IntPtr GetFunctionPointer(string methodName) 377 | { 378 | return typeof(Utilities).GetMethod(methodName, System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.DeclaredOnly | System.Reflection.BindingFlags.Static)!.MethodHandle.GetFunctionPointer(); 379 | } 380 | 381 | public static void DeleteNotification(Notification notification) 382 | { 383 | try 384 | { 385 | GetDeleteNotificationDelegate(notification); 386 | } 387 | catch (Exception e) 388 | { 389 | MelonLogger.Warning( 390 | "Couldn't find the delete notification method. it'll still work, just delete the notification yourself after or let it get auto-deleted by vrchat itself"); 391 | MelonLogger.Error(e); 392 | } 393 | } 394 | 395 | public static Transform GetLocalPlayerTransform() 396 | { 397 | return VRCPlayer.field_Internal_Static_VRCPlayer_0.transform; 398 | } 399 | 400 | public static void HideCurrentPopup() 401 | { 402 | GetVRCUiManager().HideScreen("POPUP"); 403 | } 404 | 405 | public static void ShowAlert(string title, string content, float timeOut = 10f) 406 | { 407 | GetShowAlertDelegate(title, content, timeOut); 408 | } 409 | 410 | public static void ShowPopupWindow( 411 | string title, 412 | string content, 413 | string button1, 414 | Action action, 415 | string button2, 416 | Action action2, 417 | Action onCreated = null) 418 | { 419 | GetShowPopupWindowBothDelegate(title, content, button1, action, button2, action2, onCreated); 420 | } 421 | 422 | public static void ShowPopupWindow(string title, string content, string button1, Action action, Action onCreated = null) 423 | { 424 | GetShowPopupWindowSingleDelegate(title, content, button1, action, onCreated); 425 | } 426 | public static bool XRefScanFor(this MethodBase methodBase, string searchTerm) 427 | { 428 | return XrefScanner.XrefScan(methodBase).Any( 429 | xref => xref.Type == XrefType.Global && xref.ReadAsObject()?.ToString().IndexOf(searchTerm, StringComparison.OrdinalIgnoreCase) >= 0); 430 | } 431 | 432 | private static bool HasParameters(this MethodBase methodBase, params Type[] types) 433 | { 434 | ParameterInfo[] parameters = methodBase.GetParameters(); 435 | int typesLength = types.Length; 436 | if (parameters.Length < typesLength) return false; 437 | 438 | for (var i = 0; i < typesLength; ++i) 439 | if (parameters[i].ParameterType != types[i]) 440 | return false; 441 | 442 | return true; 443 | } 444 | 445 | private static bool XRefScanForMethod(this MethodBase methodBase, string methodName = null, string parentType = null, bool ignoreCase = true) 446 | { 447 | if (!string.IsNullOrEmpty(methodName) 448 | || !string.IsNullOrEmpty(parentType)) 449 | return XrefScanner.XrefScan(methodBase).Any( 450 | xref => 451 | { 452 | if (xref.Type != XrefType.Method) return false; 453 | 454 | var found = false; 455 | MethodBase resolved = xref.TryResolve(); 456 | if (resolved == null) return false; 457 | 458 | if (!string.IsNullOrEmpty(methodName)) 459 | { 460 | found = !string.IsNullOrEmpty(resolved.Name) 461 | && resolved.Name.IndexOf(methodName, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) >= 0; 462 | if (!found) return false; 463 | } 464 | 465 | if (!string.IsNullOrEmpty(parentType)) 466 | found = !string.IsNullOrEmpty(resolved.ReflectedType?.Name) 467 | && resolved.ReflectedType.Name.IndexOf( 468 | parentType, 469 | ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) 470 | >= 0; 471 | 472 | return found; 473 | }); 474 | MelonLogger.Warning($"XRefScanForMethod \"{methodBase}\" has all null/empty parameters. Returning false"); 475 | return false; 476 | } 477 | 478 | private static int XRefScanMethodCount(this MethodBase methodBase, string methodName = null, string parentType = null, bool ignoreCase = true) 479 | { 480 | if (!string.IsNullOrEmpty(methodName) 481 | || !string.IsNullOrEmpty(parentType)) 482 | return XrefScanner.XrefScan(methodBase).Count( 483 | xref => 484 | { 485 | if (xref.Type != XrefType.Method) return false; 486 | 487 | var found = false; 488 | MethodBase resolved = xref.TryResolve(); 489 | if (resolved == null) return false; 490 | 491 | if (!string.IsNullOrEmpty(methodName)) 492 | { 493 | found = !string.IsNullOrEmpty(resolved.Name) 494 | && resolved.Name.IndexOf(methodName, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) >= 0; 495 | if (!found) return false; 496 | } 497 | 498 | if (!string.IsNullOrEmpty(parentType)) 499 | found = !string.IsNullOrEmpty(resolved.ReflectedType?.Name) 500 | && resolved.ReflectedType.Name.IndexOf( 501 | parentType, 502 | ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal) 503 | >= 0; 504 | 505 | return found; 506 | }); 507 | MelonLogger.Warning($"XRefScanMethodCount \"{methodBase}\" has all null/empty parameters. Returning -1"); 508 | return -1; 509 | } 510 | 511 | internal readonly struct WorldInstanceCache 512 | { 513 | 514 | public string InstanceId { get; } 515 | 516 | public string OwnerId { get; } 517 | 518 | public InstanceAccessType AccessType { get; } 519 | 520 | public WorldInstanceCache(ApiWorldInstance instance) 521 | { 522 | InstanceId = instance.instanceId; 523 | OwnerId = instance.ownerId; 524 | AccessType = instance.type; 525 | } 526 | 527 | } 528 | 529 | internal static WorldInstanceCache CurrentInstanceCached; 530 | 531 | private delegate void SendNotificationDelegate( 532 | string receiverUserName, 533 | string receiverUserId, 534 | string notificationType, 535 | string message, 536 | NotificationDetails notificationDetails, 537 | Il2CppStructArray picDataIGuess = null); 538 | 539 | private delegate bool CreatePortalDelegate(ApiWorld apiWorld, ApiWorldInstance apiWorldInstance, Vector3 position, Vector3 forward, Il2CppSystem.Action errorReasonCallback = null); 540 | 541 | private delegate void DeleteNotificationDelegate(Notification notification); 542 | 543 | private delegate void ShowAlertDelegate(string title, string content, float timeOut); 544 | 545 | private delegate void ShowPopupWindowBothDelegate( 546 | string title, 547 | string content, 548 | string button1, 549 | Il2CppSystem.Action action, 550 | string button2, 551 | Il2CppSystem.Action action2, 552 | Il2CppSystem.Action onCreated = null); 553 | 554 | private delegate void ShowPopupWindowSingleDelegate( 555 | string title, 556 | string content, 557 | string button, 558 | Il2CppSystem.Action action, 559 | Il2CppSystem.Action onCreated = null); 560 | 561 | } 562 | 563 | } -------------------------------------------------------------------------------- /AdvancedInvites/WorldPermissionHandler.cs: -------------------------------------------------------------------------------- 1 | namespace AdvancedInvites 2 | { 3 | 4 | using System; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Text; 8 | 9 | using Newtonsoft.Json; 10 | 11 | using VRC.Core; 12 | 13 | public static class WorldPermissionHandler 14 | { 15 | 16 | private const string BlacklistedPath = "UserData/AdvancedInvites/BlacklistedWorlds.json"; 17 | 18 | internal static readonly List BlacklistedWorlds = new List(); 19 | 20 | internal static bool IsBlacklisted(string worldId) 21 | { 22 | foreach (PermissionEntry blacklistedWorld in BlacklistedWorlds) 23 | if (blacklistedWorld.WorldId.Equals(worldId, StringComparison.OrdinalIgnoreCase)) 24 | return true; 25 | 26 | return false; 27 | } 28 | 29 | internal static void AddToBlacklist(ApiWorld apiWorld) 30 | { 31 | if (IsBlacklisted(apiWorld.id)) return; 32 | BlacklistedWorlds.Add(new PermissionEntry { WorldName = apiWorld.name, WorldId = apiWorld.id }); 33 | } 34 | 35 | internal static void RemoveFromBlacklist(string worldId) 36 | { 37 | if (!IsBlacklisted(worldId)) return; 38 | BlacklistedWorlds.RemoveAll(entry => entry.WorldId.Equals(worldId, StringComparison.OrdinalIgnoreCase)); 39 | } 40 | 41 | internal static void LoadSettings() 42 | { 43 | if (!Directory.Exists("UserData")) Directory.CreateDirectory("UserData"); 44 | if (!Directory.Exists("UserData/AdvancedInvites")) Directory.CreateDirectory("UserData/AdvancedInvites"); 45 | 46 | if (!File.Exists(BlacklistedPath)) 47 | File.WriteAllText(BlacklistedPath, "[]", Encoding.UTF8); 48 | 49 | JsonConvert.PopulateObject( 50 | File.ReadAllText(BlacklistedPath, Encoding.UTF8), 51 | BlacklistedWorlds, 52 | new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }); 53 | } 54 | 55 | public static void SaveSettings() 56 | { 57 | File.WriteAllText(BlacklistedPath, JsonConvert.SerializeObject(BlacklistedWorlds, Formatting.Indented), Encoding.UTF8); 58 | } 59 | 60 | internal class PermissionEntry 61 | { 62 | 63 | [JsonProperty("WorldID")] 64 | public string WorldId; 65 | 66 | [JsonProperty("WorldName")] 67 | public string WorldName; 68 | 69 | } 70 | 71 | } 72 | 73 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AdvancedInvites 2 | Allows you to choose between going yourself to the invite you got or drop a portal 3 | to the instance you got invited to. 4 | Doesn't let you drop a portal if it's Friends only or Private(Invite) only. 5 | 6 | You can also delete notifications after successful use. (Settings) 7 | 8 | Notification sound taken from: http://freesoundeffect.net/sound/musical-game-elements-05-sound-effect 9 | 10 | # Black/Whitelist system 11 | All blacklisted people can't send you any invites or request at all. 12 | All whitelisted people automatically get their invite requests accepted unless they're on another platform or you're not the instance creator of a private world. 13 | 14 | Can also blacklist specific worlds and toggle all black/whitelisting systems 15 | 16 | # Customization 17 | Can have different Notification Sounds for invites and Invite Requests. 18 | Just name the files either Invite.ogg or InviteRequest.ogg depending on what you want to override. 19 | For just default all in one just change the Default.ogg File 20 | 21 | It'll also create a Localization.json file where you can customize the text for each popup. 22 | Any of the text's except buttons can have @Username, @WorldName, @InstanceType, and @Region 23 | 24 | ![Popup once you accept an invite](https://i.imgur.com/2J0TMxi.png) 25 | --------------------------------------------------------------------------------