public async Task BroadcastAsync(IUser sender, string message, API.Drawing.Color?color = null, params object[] arguments) { await BroadcastAsync(sender, Players.Select(d => d.GetUser()), message, color, arguments); logger.LogInformation("[Broadcast] " + message); }
public async Task InitAsync(IRuntime runtime) { //Fix CodePage 437 not supported ZipConstants.DefaultCodePage = System.Text.Encoding.UTF8.CodePage; // Another possible workaround: // new I18N.West(); BaseLogger.SkipTypeFromLogging(typeof(UnturnedPlayerManager)); ApplyTlsWorkaround(); this.runtime = runtime; rocketGameObject = new GameObject(); Object.DontDestroyOnLoad(rocketGameObject); container = runtime.Container; eventManager = container.Resolve <IEventBus>(); playerManager = (UnturnedPlayerManager)container.Resolve <IUserManager>("host"); ModuleTranslations = container.Resolve <ITranslationCollection>(); logger = container.Resolve <ILogger>(); logger.LogInformation("Loading Rocket Unturned Implementation..."); container.RegisterSingletonType <AutomaticSaveWatchdog, AutomaticSaveWatchdog>(); container.Resolve <AutomaticSaveWatchdog>().Start(); LoadTranslations(); Provider.onServerHosted += OnServerHosted; if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) { rocketGameObject.SetActive(false); // deactivate object so it doesn't run Awake until all properties were set var console = rocketGameObject.AddComponent <UnturnedConsolePipe>(); console.Logger = logger; rocketGameObject.SetActive(true); // reactivate object } SteamChannel.onTriggerSend += TriggerSend; Provider.onCheckValid += OnCheckValid; Provider.onServerConnected += OnPlayerConnected; Provider.onServerDisconnected += OnPlayerDisconnected; DamageTool.playerDamaged += OnPlayerDamaged; Provider.onServerShutdown += OnServerShutdown; ChatManager.onChatted += (SteamPlayer player, EChatMode mode, ref Color color, ref bool isRich, string message, ref bool isVisible) => { UnturnedPlayer p = (UnturnedPlayer)playerManager.GetPlayerByIdAsync(player.playerID.steamID.m_SteamID.ToString()).GetAwaiter().GetResult(); UnturnedPlayerChatEvent @event = new UnturnedPlayerChatEvent(p, mode, color, isRich, message, !isVisible); eventManager.Emit(this, @event); color = @event.Color; isRich = @event.IsRichText; isVisible = [email protected]; }; CommandWindow.onCommandWindowOutputted += (text, color) => logger.LogNative(text?.ToString()); }
public void Init(IRuntime runtime) { this.runtime = runtime; rocketGameObject = new GameObject(); Object.DontDestroyOnLoad(rocketGameObject); container = runtime.Container; eventManager = container.Resolve <IEventManager>(); playerManager = (UnturnedPlayerManager)container.Resolve <IUserManager>("game"); ModuleTranslations = container.Resolve <ITranslationCollection>(); logger = container.Resolve <ILogger>(); logger.LogInformation("Loading Rocket Unturned Implementation..."); container.RegisterSingletonType <AutomaticSaveWatchdog, AutomaticSaveWatchdog>(); container.Resolve <AutomaticSaveWatchdog>().Start(); LoadTranslations(); Provider.onServerHosted += OnServerHosted; if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) { rocketGameObject.SetActive(false); // deactivate object so it doesn't run Awake until all properties were set var console = rocketGameObject.AddComponent <UnturnedConsolePipe>(); console.Logger = logger; rocketGameObject.SetActive(true); // reactivate object } SteamChannel.onTriggerSend += TriggerSend; Provider.onCheckValid += OnCheckValid; Provider.onServerConnected += OnPlayerConnected; Provider.onServerDisconnected += OnPlayerDisconnected; DamageTool.playerDamaged += OnPlayerDamaged; Provider.onServerShutdown += OnServerShutdown; ChatManager.onChatted += (SteamPlayer player, EChatMode mode, ref Color color, ref bool isRich, string message, ref bool isVisible) => { UnturnedPlayer p = (UnturnedPlayer)playerManager.GetOnlinePlayerById(player.playerID.steamID.m_SteamID.ToString()); UnturnedPlayerChatEvent @event = new UnturnedPlayerChatEvent(p, mode, color, isRich, message, !isVisible); eventManager.Emit(this, @event); color = @event.Color; isRich = @event.IsRichText; isVisible = [email protected]; }; CommandWindow.onCommandWindowOutputted += (text, color) => logger.LogNative(text?.ToString()); }
public override void Log(ILogMessage message) { var level = message.Level; string prefix = "[NuGet] "; var text = prefix + message.Message; switch (level) { case LogLevel.Debug: logger.LogDebug(text); break; case LogLevel.Verbose: logger.LogTrace(text); break; case LogLevel.Information: logger.LogInformation(text); break; case LogLevel.Minimal: logger.LogInformation(text); break; case LogLevel.Warning: logger.LogWarning(text); break; case LogLevel.Error: logger.LogError(text); break; default: throw new ArgumentOutOfRangeException(nameof(level), level, null); } }
public void Broadcast(IUser sender, string message, Rocket.API.Drawing.Color?color = null, params object[] arguments) { Broadcast(sender, Players, message, color, arguments); logger.LogInformation("[Broadcast] " + message); }