use reactor static logging pattern

This commit is contained in:
XtraCube committed 2025-10-14 14:37:20 -04:00
1 parent cb794c3fc2
commit 6503bbecb7
33 files changed
+111 -110

No files matched your search

+2 -2
View File
@@ -34,7 +34,7 @@ public static class MiraEventManager
}
catch (Exception ex)
{
Logger<MiraApiPlugin>.Error($"Error invoking event handler for {typeof(T).Name}: {ex.ToString()}");
Error($"Error invoking event handler for {typeof(T).Name}: {ex.ToString()}");
}
}
@@ -63,7 +63,7 @@ public static class MiraEventManager
}
catch (Exception ex)
{
Logger<MiraApiPlugin>.Error($"Error invoking event handler for {type.Name}: {ex.ToString()}");
Error($"Error invoking event handler for {type.Name}: {ex.ToString()}");
}
}
+2 -2
View File
@@ -30,13 +30,13 @@ public static class GameOverManager
if (gameOverType.IsAbstract)
{
Logger<MiraApiPlugin>.Error("The type must not be abstract.");
Error("The type must not be abstract.");
return false;
}
if (gameOverType.GetConstructor(Type.EmptyTypes) == null)
{
Logger<MiraApiPlugin>.Error("The type must have a parameterless constructor.");
Error("The type must have a parameterless constructor.");
return false;
}
+4 -4
View File
@@ -37,7 +37,7 @@ public static class CustomGameModeManager
return;
}
Logger<MiraApiPlugin>.Error($"No gamemode with id {id} found!");
Error($"No gamemode with id {id} found!");
}
/// <summary>
@@ -48,7 +48,7 @@ public static class CustomGameModeManager
{
if (!typeof(CustomGameMode).IsAssignableFrom(gameModeType))
{
Logger<MiraApiPlugin>.Warning($"{gameModeType.Name} does not inherit CustomGameMode!");
Warning($"{gameModeType.Name} does not inherit CustomGameMode!");
return;
}
@@ -56,13 +56,13 @@ public static class CustomGameModeManager
if (modeObj is not CustomGameMode gameMode)
{
Logger<MiraApiPlugin>.Error($"Failed to create instance of {gameModeType.Name}");
Error($"Failed to create instance of {gameModeType.Name}");
return;
}
if (GameModes.Any(x => x.Key == gameMode.Id))
{
Logger<MiraApiPlugin>.Error($"ID for gamemode {gameMode.Name} already exists!");
Error($"ID for gamemode {gameMode.Name} already exists!");
return;
}
+6 -6
View File
@@ -39,7 +39,7 @@ public static class ModdedOptionsManager
if (TypeToGroup.ContainsKey(type))
{
Logger<MiraApiPlugin>.Error($"Group {type.Name} already exists.");
Error($"Group {type.Name} already exists.");
return false;
}
@@ -60,13 +60,13 @@ public static class ModdedOptionsManager
{
if (!TypeToGroup.TryGetValue(type, out var group))
{
Logger<MiraApiPlugin>.Error($"Failed to get group for {type.Name}");
Error($"Failed to get group for {type.Name}");
return;
}
if (property.GetValue(group) is not IModdedOption option)
{
Logger<MiraApiPlugin>.Error($"Failed to get option for {property.Name}");
Error($"Failed to get option for {property.Name}");
return;
}
@@ -81,13 +81,13 @@ public static class ModdedOptionsManager
{
if (OptionAttributes.ContainsKey(property))
{
Logger<MiraApiPlugin>.Error($"Property {property.Name} already has an attribute registered.");
Error($"Property {property.Name} already has an attribute registered.");
return;
}
if (!TypeToGroup.TryGetValue(type, out var group))
{
Logger<MiraApiPlugin>.Error($"Failed to get group for {type.Name}");
Error($"Failed to get group for {type.Name}");
return;
}
@@ -95,7 +95,7 @@ public static class ModdedOptionsManager
if (option == null)
{
Logger<MiraApiPlugin>.Error($"Failed to get option for {property.Name}");
Error($"Failed to get option for {property.Name}");
return;
}
@@ -125,7 +125,7 @@ public abstract class ModdedOption<T> : IModdedOption
{
if (ConfigDefinition is null)
{
Logger<MiraApiPlugin>.Error($"Attempted to save {Title} to preset, but ConfigDefinition is null.");
Error($"Attempted to save {Title} to preset, but ConfigDefinition is null.");
return;
}
Bind(presetConfig);
@@ -147,7 +147,7 @@ public abstract class ModdedOption<T> : IModdedOption
}
else
{
Logger<MiraApiPlugin>.Error($"Attempted to load {Title} from preset, but ConfigDefinition is not found in preset.");
Error($"Attempted to load {Title} from preset, but ConfigDefinition is not found in preset.");
}
}
+1 -1
View File
@@ -233,7 +233,7 @@ public abstract class CustomActionButton
return;
}
this.Location = location;
Location = location;
if (!moveButton)
{
+3 -3
View File
@@ -26,11 +26,11 @@ public static class KeybindManager
try
{
var instance = KeybindUtils.RewiredInputManager!;
foreach (var keybind in KeybindManager.Keybinds)
foreach (var keybind in Keybinds)
{
if (instance.userData.actions.ToArray().Any(x => x.name == keybind.Id))
{
Logger<MiraApiPlugin>.Warning($"Keybind of id {keybind.Id} already exists. Skipping it");
Warning($"Keybind of id {keybind.Id} already exists. Skipping it");
continue;
}
@@ -44,7 +44,7 @@ public static class KeybindManager
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Error while registering keybinds in Rewired: {e}");
Error($"Error while registering keybinds in Rewired: {e}");
}
}
@@ -24,7 +24,7 @@ public static class LocalSettingsManager
if (TypeToTab.ContainsKey(type))
{
Logger<MiraApiPlugin>.Error($"Local settings tab {type.Name} already exists.");
Error($"Local settings tab {type.Name} already exists.");
return false;
}
+2 -1
View File
@@ -1,4 +1,5 @@
using BepInEx;
global using static Reactor.Utilities.Logger<MiraAPI.MiraApiPlugin>;
using BepInEx;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using MiraAPI.PluginLoading;
+11 -11
View File
@@ -47,7 +47,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
_player = GetComponent<PlayerControl>();
if (_player == null)
{
Logger<MiraApiPlugin>.Error("ModifierComponent could not find PlayerControl on the same GameObject.");
Error("ModifierComponent could not find PlayerControl on the same GameObject.");
Destroy(this);
return;
}
@@ -77,7 +77,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Error while deactivating modifier {modifier.ModifierName}: {e.ToString()}");
Error($"Error while deactivating modifier {modifier.ModifierName}: {e.ToString()}");
}
Modifiers.Remove(modifier);
@@ -95,7 +95,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Error while activating modifier {modifier.ModifierName}: {e.ToString()}");
Error($"Error while activating modifier {modifier.ModifierName}: {e.ToString()}");
}
if (modifier is TimedModifier { AutoStart: true } timer)
@@ -122,7 +122,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Error while (fixed) updating modifier {modifier.ModifierName}: {e.ToString()}");
Error($"Error while (fixed) updating modifier {modifier.ModifierName}: {e.ToString()}");
}
}
@@ -153,7 +153,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Error while updating modifier {modifier.ModifierName}: {e.ToString()}");
Error($"Error while updating modifier {modifier.ModifierName}: {e.ToString()}");
}
}
}
@@ -336,7 +336,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
var modifier = modifiers.FirstOrDefault();
if (modifier is null)
{
Logger<MiraApiPlugin>.Error($"Cannot remove modifier {type.Name} because it is not active.");
Error($"Cannot remove modifier {type.Name} because it is not active.");
return;
}
@@ -352,7 +352,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
{
if (!ActiveModifiers.Contains(modifier))
{
Logger<MiraApiPlugin>.Error($"Cannot remove modifier {modifier.ModifierName} because it is not active on this player.");
Error($"Cannot remove modifier {modifier.ModifierName} because it is not active on this player.");
return;
}
@@ -382,7 +382,7 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
var modifier = GetModifier(uniqueId);
if (modifier == null)
{
Logger<MiraApiPlugin>.Error($"Cannot remove modifier with unique id {uniqueId} because it is not active.");
Error($"Cannot remove modifier with unique id {uniqueId} because it is not active.");
return;
}
@@ -412,19 +412,19 @@ public class ModifierComponent(IntPtr cppPtr) : MonoBehaviour(cppPtr)
// TODO: Make a proper synchronization system.
if (LobbyBehaviour.Instance)
{
Logger<MiraApiPlugin>.Warning($"Modifiers added in the lobby won't sync to new players!");
Warning($"Modifiers added in the lobby won't sync to new players!");
}
var id = modifier.TypeId;
if (modifier.Unique && ActiveModifiers.Find(x => x.TypeId == id) != null)
{
Logger<MiraApiPlugin>.Error($"Player already has modifier with id {id}!");
Error($"Player already has modifier with id {id}!");
return null;
}
if (ActiveModifiers.Contains(modifier))
{
Logger<MiraApiPlugin>.Error($"Player already has this modifier!");
Error($"Player already has this modifier!");
return null;
}
+1 -1
View File
@@ -83,7 +83,7 @@ public static class ModifierExtensions
var modifier = target.GetModifier(typeId, predicate);
if (modifier is null)
{
Logger<MiraApiPlugin>.Error($"Player {target.PlayerId} does not have modifier with type ID {typeId}.");
Error($"Player {target.PlayerId} does not have modifier with type ID {typeId}.");
return;
}
+4 -4
View File
@@ -97,7 +97,7 @@ public static class ModifierManager
if (modifierType.GetConstructor(Type.EmptyTypes) == null)
{
Logger<MiraApiPlugin>.Error($"Game Modifier {modifierType.FullName} does not have a parameterless constructor!");
Error($"Game Modifier {modifierType.FullName} does not have a parameterless constructor!");
return false;
}
@@ -137,7 +137,7 @@ public static class ModifierManager
var validPlayers = plrs.Where(x => IsGameModifierValid(x, modifier, modifier.TypeId)).ToList();
if (validPlayers.Count == 0)
{
Logger<MiraApiPlugin>.Warning($"No valid players for modifier {modifier.ModifierName}");
Warning($"No valid players for modifier {modifier.ModifierName}");
continue;
}
@@ -158,7 +158,7 @@ public static class ModifierManager
if (candidates.Count == 0)
{
Logger<MiraApiPlugin>.Warning(
Warning(
$"No available players for modifier {modifier.ModifierName} at assignment {i + 1}");
break;
}
@@ -166,7 +166,7 @@ public static class ModifierManager
var plr = candidates.Random();
if (plr == null)
{
Logger<MiraApiPlugin>.Warning($"Valid player for modifier {modifier.ModifierName} disappeared");
Warning($"Valid player for modifier {modifier.ModifierName} disappeared");
continue;
}
+1 -1
View File
@@ -80,7 +80,7 @@ public abstract class TimedModifier : BaseModifier
{
if (TimerActive)
{
Logger<MiraApiPlugin>.Error("Can't start a timer that has already been started.");
Error("Can't start a timer that has already been started.");
return;
}
+2 -2
View File
@@ -50,7 +50,7 @@ public class CustomGameOverRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<
{
if (!gameOver.VerifyCondition(innerNetObject, [.. data.Winners]))
{
Logger<MiraApiPlugin>.Info($"Game over condition not met for {gameOver.GetType().Name}");
Info($"Game over condition not met for {gameOver.GetType().Name}");
return;
}
@@ -64,7 +64,7 @@ public class CustomGameOverRpc(MiraApiPlugin plugin, uint id) : PlayerCustomRpc<
else
{
CustomGameOver.Instance = null;
Logger<MiraApiPlugin>.Error($"Unknown game over reason: {data.Reason}");
Error($"Unknown game over reason: {data.Reason}");
}
}
}
+1 -1
View File
@@ -178,7 +178,7 @@ public static class CustomMurderRpc
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Error with kill animation: {e.ToString()}");
Error($"Error with kill animation: {e.ToString()}");
}
}
@@ -41,7 +41,7 @@ public static class ReportBodyEventPatch
var source = AmongUsClient.Instance.FindObjectByNetId<PlayerControl>(reportBodyMessage.rpcObjectNetId);
if (source == null)
{
Logger<MiraApiPlugin>.Error("Failed to find source player for RpcReportDeadBodyMessage with NetId: " + reportBodyMessage.rpcObjectNetId);
Error("Failed to find source player for RpcReportDeadBodyMessage with NetId: " + reportBodyMessage.rpcObjectNetId);
return true;
}
+1 -1
View File
@@ -18,7 +18,7 @@ public static class ButtonResetPatches
}
catch (System.Exception ex)
{
Logger<MiraApiPlugin>.Error($"Error resetting cooldown and effect for button {customActionButton.GetType().Name}: {ex}");
Error($"Error resetting cooldown and effect for button {customActionButton.GetType().Name}: {ex}");
}
if (customActionButton.UsesMode == ButtonUsesMode.PerRound)
+2 -2
View File
@@ -109,7 +109,7 @@ public static class HudManagerPatches
}
catch (System.Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to create custom button {button.GetType().Name}: {e}");
Error($"Failed to create custom button {button.GetType().Name}: {e}");
}
}
@@ -171,7 +171,7 @@ public static class HudManagerPatches
}
catch (System.Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to set custom button {button.GetType().Name} active: {e}");
Error($"Failed to set custom button {button.GetType().Name} active: {e}");
}
}
}
+3 -3
View File
@@ -52,7 +52,7 @@ public static class IntroCutscenePatches
var introCutscene = wrapper.Instance;
Logger<MiraApiPlugin>.Info("IntroCutscene ShowRole reached");
Info("IntroCutscene ShowRole reached");
var @event = new IntroRoleRevealEvent(introCutscene);
MiraEventManager.InvokeEvent(@event);
}
@@ -96,7 +96,7 @@ public static class IntroCutscenePatches
if (onDestroy != null)
{
_usedFallback = false;
Logger<MiraApiPlugin>.Info("Using OnDestroy for IntroCutsceneDestroyPatch");
Info("Using OnDestroy for IntroCutsceneDestroyPatch");
return onDestroy;
}
@@ -124,7 +124,7 @@ public static class IntroCutscenePatches
}
Logger<MiraApiPlugin>.Info("IntroCutscene ended");
Info("IntroCutscene ended");
MiraEventManager.InvokeEvent(new IntroEndEvent(introCutscene));
@@ -117,7 +117,7 @@ internal static class GamePresetsTabPatches
// ReSharper disable once InconsistentNaming
public static void Postfix()
{
Logger<MiraApiPlugin>.Error("OnDisable called");
Error("OnDisable called");
if (_saveButton)
{
@@ -155,7 +155,7 @@ internal static class GamePresetsTabPatches
var prefab = GameSettingMenu.Instance.GameSettingsButton;
if (prefab == null)
{
Logger<MiraApiPlugin>.Error("GameSettingsButton prefab is null");
Error("GameSettingsButton prefab is null");
return;
}
@@ -318,10 +318,10 @@ internal static class GamePresetsTabPatches
private static void Refresh()
{
Logger<MiraApiPlugin>.Error("Refreshing presets");
Error("Refreshing presets");
if (GameSettingMenuPatches.SelectedMod == null)
{
Logger<MiraApiPlugin>.Error("Selected mod is null, cannot refresh presets");
Error("Selected mod is null, cannot refresh presets");
return;
}
lock (Lock)
@@ -392,7 +392,7 @@ public static class RoleSettingMenuPatches
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Warning(e);
Warning(e);
}
roleSetting.UpdateValuesAndText(GameOptionsManager.Instance.CurrentGameOptions.RoleOptions);
@@ -466,7 +466,7 @@ public static class RoleSettingMenuPatches
{
if (role is not ICustomRole customRole)
{
Logger<MiraApiPlugin>.Error($"Role {role.NiceName} is not a custom role.");
Error($"Role {role.NiceName} is not a custom role.");
return;
}
@@ -560,7 +560,7 @@ public static class RoleSettingMenuPatches
{
if (role is not ICustomRole customRole)
{
Logger<MiraApiPlugin>.Error($"Role {role.NiceName} is not a custom role.");
Error($"Role {role.NiceName} is not a custom role.");
return null;
}
+1 -1
View File
@@ -145,7 +145,7 @@ internal static class PlayerControlPatches
}
catch (System.Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to update custom button {button.GetType().Name}: {e}");
Error($"Failed to update custom button {button.GetType().Name}: {e}");
}
}
}
@@ -51,7 +51,7 @@ public static class RoleOptionsCollectionPatch
var chance = customRole.GetChance();
if (chance == null)
{
Logger<MiraApiPlugin>.Error($"Chance is null, defaulting to zero.");
Error($"Chance is null, defaulting to zero.");
chance = 0;
}
@@ -81,7 +81,7 @@ public static class RoleOptionsCollectionPatch
var count = customRole.GetCount();
if (count == null)
{
Logger<MiraApiPlugin>.Error($"Count is null, defaulting to zero.");
Error($"Count is null, defaulting to zero.");
count = 0;
}
+23 -23
View File
@@ -70,14 +70,14 @@ public sealed class MiraPluginManager
if (!method.IsStatic)
{
Logger<MiraApiPlugin>.Error($"Event method {method.Name} in {type.Name} must be static.");
Error($"Event method {method.Name} in {type.Name} must be static.");
continue;
}
var parameters = method.GetParameters();
if (parameters.Length != 1 || !parameters[0].ParameterType.IsSubclassOf(typeof(MiraEvent)))
{
Logger<MiraApiPlugin>.Error($"Invalid event registration method {method.Name} in {type.Name}");
Error($"Invalid event registration method {method.Name} in {type.Name}");
continue;
}
@@ -131,7 +131,7 @@ public sealed class MiraPluginManager
info.SavePublicCollections();
PresetManager.CreateDefaultPreset(info);
PresetManager.LoadPresets(info);
Logger<MiraApiPlugin>.Info($"Registering mod {pluginInfo.Metadata.GUID} with Mira API.");
Info($"Registering mod {pluginInfo.Metadata.GUID} with Mira API.");
};
IL2CPPChainloader.Instance.Finished += PaletteManager.RegisterAllColors;
IL2CPPChainloader.Instance.Finished += () =>
@@ -167,7 +167,7 @@ public sealed class MiraPluginManager
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to register game over {type.Name}: {e}");
Error($"Failed to register game over {type.Name}: {e}");
return false;
}
}
@@ -190,7 +190,7 @@ public sealed class MiraPluginManager
{
if (property.GetMethod?.IsStatic == true)
{
Logger<MiraApiPlugin>.Error($"Option property {property.Name} in {type.Name} must not be static.");
Error($"Option property {property.Name} in {type.Name} must not be static.");
continue;
}
@@ -211,14 +211,14 @@ public sealed class MiraPluginManager
foreach (var field in type.GetFields().Where(f => f.FieldType.IsAssignableTo(typeof(IModdedOption))))
{
Logger<MiraApiPlugin>.Error($"{field.Name} is a field, not a property. Use properties for options.");
Error($"{field.Name} is a field, not a property. Use properties for options.");
}
return true;
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to register options for {type.Name}: {e.ToString()}");
Error($"Failed to register options for {type.Name}: {e.ToString()}");
}
return false;
}
@@ -235,7 +235,7 @@ public sealed class MiraPluginManager
if (!ModList.GetById(pluginInfo.PluginId).IsRequiredOnAllClients)
{
Logger<MiraApiPlugin>.Error("Custom roles are only supported on all clients.");
Error("Custom roles are only supported on all clients.");
return false;
}
@@ -244,7 +244,7 @@ public sealed class MiraPluginManager
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to register role for {type.Name}: {e}");
Error($"Failed to register role for {type.Name}: {e}");
}
return false;
}
@@ -260,7 +260,7 @@ public sealed class MiraPluginManager
if (!type.IsStatic())
{
Logger<MiraApiPlugin>.Error($"Color class {type.Name} must be static.");
Error($"Color class {type.Name} must be static.");
return;
}
@@ -273,7 +273,7 @@ public sealed class MiraPluginManager
if (property.GetValue(null) is not CustomColor color)
{
Logger<MiraApiPlugin>.Error($"Color property {property.Name} in {type.Name} is not a CustomColor.");
Error($"Color property {property.Name} in {type.Name} is not a CustomColor.");
continue;
}
@@ -282,12 +282,12 @@ public sealed class MiraPluginManager
foreach (var field in type.GetFields().Where(f => f.FieldType.IsAssignableTo(typeof(CustomColor))))
{
Logger<MiraApiPlugin>.Error($"{field.Name} is a field, not a property. Use properties for colors.");
Error($"{field.Name} is a field, not a property. Use properties for colors.");
}
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to register color class {type.Name}: {e}");
Error($"Failed to register color class {type.Name}: {e}");
}
}
@@ -299,7 +299,7 @@ public sealed class MiraPluginManager
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to register modifier {type.Name}: {e}");
Error($"Failed to register modifier {type.Name}: {e}");
return false;
}
}
@@ -312,7 +312,7 @@ public sealed class MiraPluginManager
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to register button {type.Name}: {e}");
Error($"Failed to register button {type.Name}: {e}");
}
return false;
@@ -355,13 +355,13 @@ public sealed class MiraPluginManager
if (property.GetMethod?.IsStatic == true)
{
Logger<MiraApiPlugin>.Error($"Option property {property.Name} in {type.Name} must not be static.");
Error($"Option property {property.Name} in {type.Name} must not be static.");
continue;
}
if (property.GetValue(tabInstance) is not ConfigEntryBase configEntry)
{
Logger<MiraApiPlugin>.Error($"Option property {property.Name} in {type.Name} has to be a config entry.");
Error($"Option property {property.Name} in {type.Name} has to be a config entry.");
continue;
}
@@ -376,14 +376,14 @@ public sealed class MiraPluginManager
foreach (var field in type.GetFields().Where(f => f.FieldType.IsAssignableTo(typeof(ConfigEntryBase)) && f.GetCustomAttribute<LocalSettingAttribute>() != null))
{
Logger<MiraApiPlugin>.Error($"{field.Name} is a field, not a property. Use properties for local settings.");
Error($"{field.Name} is a field, not a property. Use properties for local settings.");
}
return true;
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to register options for {type.Name}: {e.ToString()}");
Error($"Failed to register options for {type.Name}: {e.ToString()}");
}
return false;
@@ -400,7 +400,7 @@ public sealed class MiraPluginManager
if (!type.IsStatic())
{
Logger<MiraApiPlugin>.Error($"Keybinds class {type.Name} must be static.");
Error($"Keybinds class {type.Name} must be static.");
return;
}
@@ -413,7 +413,7 @@ public sealed class MiraPluginManager
if (property.GetValue(null) is not MiraKeybind keybind)
{
Logger<MiraApiPlugin>.Error($"Keybind property {property.Name} in {type.Name} is not a MiraKeybind.");
Error($"Keybind property {property.Name} in {type.Name} is not a MiraKeybind.");
continue;
}
@@ -430,12 +430,12 @@ public sealed class MiraPluginManager
foreach (var field in type.GetFields().Where(f => f.FieldType.IsAssignableTo(typeof(MiraKeybind))))
{
Logger<MiraApiPlugin>.Error($"{field.Name} is a field, not a property. Use properties for keybinds.");
Error($"{field.Name} is a field, not a property. Use properties for keybinds.");
}
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error($"Failed to register keybind class {type.Name}: {e}");
Error($"Failed to register keybind class {type.Name}: {e}");
}
}
}
+1 -1
View File
@@ -70,7 +70,7 @@ public static class PresetManager
foreach (var file in Directory.GetFiles(pluginPresetPath, "*.cfg"))
{
var fileName = Path.GetFileName(file);
Logger<MiraApiPlugin>.Info($"Loading preset file {fileName}");
Info($"Loading preset file {fileName}");
var presetName = Path.GetFileNameWithoutExtension(file);
var presetConfig = new ConfigFile(file, false)
{
+3 -3
View File
@@ -108,7 +108,7 @@ public static class CustomRoleManager
{
if (!(typeof(RoleBehaviour).IsAssignableFrom(roleType) && typeof(ICustomRole).IsAssignableFrom(roleType)))
{
Logger<MiraApiPlugin>.Error($"{roleType.Name} does not inherit from RoleBehaviour or ICustomRole.");
Error($"{roleType.Name} does not inherit from RoleBehaviour or ICustomRole.");
return null;
}
@@ -168,7 +168,7 @@ public static class CustomRoleManager
if (useTaskHint && !overridesTaskText)
{
Logger<MiraApiPlugin>.Error($"Role {customRole.RoleName} is using RoleHintType.TaskHint but does not override SpawnTaskHeader!");
Error($"Role {customRole.RoleName} is using RoleHintType.TaskHint but does not override SpawnTaskHeader!");
}
CustomRoles.Add(roleId, roleBehaviour);
@@ -298,7 +298,7 @@ public static class CustomRoleManager
}
catch (Exception e)
{
Logger<MiraApiPlugin>.Error(e);
Error(e);
}
}
+3 -3
View File
@@ -156,7 +156,7 @@ public interface ICustomRole : IOptionable
{
if (!Configuration.CanModifyChance)
{
Logger<MiraApiPlugin>.Error($"Cannot modify chance for role: {RoleName}");
Error($"Cannot modify chance for role: {RoleName}");
return;
}
@@ -166,7 +166,7 @@ public interface ICustomRole : IOptionable
return;
}
Logger<MiraApiPlugin>.Error($"Error getting chance configuration for role: {RoleName}");
Error($"Error getting chance configuration for role: {RoleName}");
}
/// <summary>
@@ -181,7 +181,7 @@ public interface ICustomRole : IOptionable
return;
}
Logger<MiraApiPlugin>.Error($"Error getting count configuration for role: {RoleName}");
Error($"Error getting count configuration for role: {RoleName}");
}
/// <summary>
+10 -10
View File
@@ -33,7 +33,7 @@ public static class AddressablesLoader
{
if (_isInitialized)
{
Logger<MiraApiPlugin>.Error("AddressablesLoader has already been initialized, cannot register more catalogs.");
Error("AddressablesLoader has already been initialized, cannot register more catalogs.");
return;
}
@@ -48,7 +48,7 @@ public static class AddressablesLoader
{
if (_isInitialized)
{
Logger<MiraApiPlugin>.Error("AddressablesLoader has already been initialized, cannot register more keys for hats.");
Error("AddressablesLoader has already been initialized, cannot register more keys for hats.");
return;
}
@@ -63,7 +63,7 @@ public static class AddressablesLoader
{
if (_isInitialized)
{
Logger<MiraApiPlugin>.Error("AddressablesLoader has already been initialized, cannot register more keys for skins.");
Error("AddressablesLoader has already been initialized, cannot register more keys for skins.");
return;
}
@@ -79,7 +79,7 @@ public static class AddressablesLoader
{
if (_isInitialized)
{
Logger<MiraApiPlugin>.Error("AddressablesLoader has already been initialized, cannot register more keys for nameplates.");
Error("AddressablesLoader has already been initialized, cannot register more keys for nameplates.");
return;
}
@@ -95,7 +95,7 @@ public static class AddressablesLoader
{
if (_isInitialized)
{
Logger<MiraApiPlugin>.Error("AddressablesLoader has already been initialized, cannot register more keys for visors.");
Error("AddressablesLoader has already been initialized, cannot register more keys for visors.");
return;
}
@@ -106,7 +106,7 @@ public static class AddressablesLoader
{
if (_isInitialized)
{
Logger<MiraApiPlugin>.Error("AddressablesLoader has already been initialized.");
Error("AddressablesLoader has already been initialized.");
return;
}
@@ -129,10 +129,10 @@ public static class AddressablesLoader
// Check for errors
if (catalogOperation.Status != AsyncOperationStatus.Succeeded)
{
Logger<MiraApiPlugin>.Error($"Failed to load catalog {location}.");
Error($"Failed to load catalog {location}.");
}
Logger<MiraApiPlugin>.Info($"Loaded addressables {location}.");
Info($"Loaded addressables {location}.");
LoadedLocations.Add(location);
}
@@ -193,7 +193,7 @@ public static class AddressablesLoader
}
catch
{
Logger<MiraApiPlugin>.Error($"Failed to find tag {tag}");
Error($"Failed to find tag {tag}");
}
}
return behaviours;
@@ -214,7 +214,7 @@ public static class AddressablesLoader
}
catch
{
Logger<MiraApiPlugin>.Error($"Failed to find tag {tag}");
Error($"Failed to find tag {tag}");
}
}
return behaviours;
@@ -38,7 +38,7 @@ public class LoadableAddressableAsset<T>(string uid) : LoadableAsset<T> where T
var remoteReference = new AssetReference(uid);
if (!GC.TryStartNoGCRegion(4096, true)) Logger<MiraApiPlugin>.Error("Could not start NoGCRegion of size 4kb, there is the possibility of injected unmanaged classes being garbage collected as per BepInEx/Il2CppInterop/issues/40");
if (!GC.TryStartNoGCRegion(4096, true)) Error("Could not start NoGCRegion of size 4kb, there is the possibility of injected unmanaged classes being garbage collected as per BepInEx/Il2CppInterop/issues/40");
LoadedAsset = remoteReference.LoadAssetAsync<T>().WaitForCompletion();
if (LoadedAsset == null)
@@ -45,7 +45,7 @@ public class LoadableAddressableAssets<T>(string key) where T : UnityEngine.Obje
var locations = Addressables.LoadResourceLocationsAsync(key).WaitForCompletion();
if (!GC.TryStartNoGCRegion(4096, true)) Logger<MiraApiPlugin>.Error("Could not start NoGCRegion of size 4kb, there is the possibility of injected unmanaged classes being garbage collected as per BepInEx/Il2CppInterop/issues/40");
if (!GC.TryStartNoGCRegion(4096, true)) Error("Could not start NoGCRegion of size 4kb, there is the possibility of injected unmanaged classes being garbage collected as per BepInEx/Il2CppInterop/issues/40");
var assetsIList = Addressables.LoadAssetsAsync<T>(locations, null, false).WaitForCompletion();
if (assetsIList == null)
+3 -3
View File
@@ -29,13 +29,13 @@ public static class Extensions
if (count == null)
{
Logger<MiraApiPlugin>.Error("Couldn't get role count for NetData, defaulting to zero.");
Error("Couldn't get role count for NetData, defaulting to zero.");
count = 0;
}
if (chance == null)
{
Logger<MiraApiPlugin>.Error("Couldn't get role chance for NetData, defaulting to zero.");
Error("Couldn't get role chance for NetData, defaulting to zero.");
chance = 0;
}
@@ -398,7 +398,7 @@ public static class Extensions
if (length > chunkSize)
{
Logger<MiraApiPlugin>.Info($"NetData length is greater than chunk size: {length} > {chunkSize}");
Info($"NetData length is greater than chunk size: {length} > {chunkSize}");
continue;
}
+5 -5
View File
@@ -49,18 +49,18 @@ public static class Helpers
if (showRoleStateMachine == null)
{
Logger<MiraApiPlugin>.Error($"Failed to find {methodName} state machine for {typeName}");
Error($"Failed to find {methodName} state machine for {typeName}");
return null;
}
var moveNext = AccessTools.Method(showRoleStateMachine, "MoveNext");
if (moveNext == null)
{
Logger<MiraApiPlugin>.Error($"Failed to find MoveNext method for {typeName}.{methodName}");
Error($"Failed to find MoveNext method for {typeName}.{methodName}");
return null;
}
Logger<MiraApiPlugin>.Info($"Found {methodName}.MoveNext");
Info($"Found {methodName}.MoveNext");
return moveNext;
}
@@ -139,7 +139,7 @@ public static class Helpers
return true;
default:
{
var num = UnityEngine.Random.RandomRangeInt(1, 101);
var num = Random.RandomRangeInt(1, 101);
return num <= probability;
}
}
@@ -500,7 +500,7 @@ public static class Helpers
public static string RandomString(int length, string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
{
return new string(Enumerable.Repeat(chars, length)
.Select(s => s[UnityEngine.Random.RandomRangeInt(0, s.Length)]).ToArray());
.Select(s => s[Random.RandomRangeInt(0, s.Length)]).ToArray());
}
/// <summary>
+1 -1
View File
@@ -224,7 +224,7 @@ public static class VotingUtils
var playerById = GameData.Instance.GetPlayerById(vote.Voter);
if (playerById == null)
{
Logger<MiraApiPlugin>.Error($"Couldn't find player info for voter: {vote.Voter}");
Error($"Couldn't find player info for voter: {vote.Voter}");
}
else if (i == 0 && vote.Suspect == SkipVoteId)
{