private static bool IsInterceptedMultiplayer(Multiplayer multiplayer) { if (multiplayer == null) { ModEntry.Log("IsInterceptedMultiplayer: null", StardewModdingAPI.LogLevel.Trace); return(false); } ModEntry.Log("IsInterceptedMultiplayer called on: " + multiplayer.GetType().Name, StardewModdingAPI.LogLevel.Trace); if (multiplayer is InterceptingMultiplayer) { ModEntry.Log("IsInterceptedMultiplayer: true", StardewModdingAPI.LogLevel.Trace); return(true); } // Since other mods can also write a multiplayer wrapper, // we recursively check fields for an instance of our class. // (Otherwise we might create an infinite loop.) foreach (var field in multiplayer.GetType().GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)) { if (IsMultiplayerType(field.GetType())) { ModEntry.Log("IsInterceptedMultiplayer, nested field: " + field.Name, StardewModdingAPI.LogLevel.Trace); if (IsInterceptedMultiplayer(field.GetValue(multiplayer) as Multiplayer)) { return(true); } } } ModEntry.Log("IsInterceptedMultiplayer: false", StardewModdingAPI.LogLevel.Trace); return(false); }