private void UnmuteCommand(PlayerSession session, string command, string[] args) { if (permission.UserHasPermission(session.SteamId.ToString(), "admintools.mute") || permission.UserHasPermission(session.SteamId.ToString(), "admintools.all") || session.IsAdmin) { if (args.Length != 1) { hurt.SendChatMessage(session, null, Msg("mutefail", session.SteamId.ToString())); return; } PlayerSession person = GetSession(args[0]); if (person == null) { hurt.SendChatMessage(session, null, Msg("playernotfound", session.SteamId.ToString()).Replace("{Player}", args[0])); } else { ChatManagerServer ChatMgr = Singleton <ChatManagerServer> .Instance; ulong ID = (ulong)person.SteamId; hurt.BroadcastChat(null, Msg("unmuted", session.SteamId.ToString()).Replace("{Player}", person.Identity.Name)); ChatMgr.Unmute(ID); if ((bool)Config["ShowConsoleMsg"]) { Puts(session.Identity.Name + " unmuted " + person.Identity.Name); } } } else { hurt.SendChatMessage(session, null, Msg("nopermission", session.SteamId.ToString())); } }
private void SessionChanged(ITorchSession session, TorchSessionState state) { ServerRunning = state == TorchSessionState.Loaded; switch (state) { case TorchSessionState.Loaded: IsRunning = true; MP = Torch.CurrentSession.Managers.GetManager <MultiplayerManagerBase>(); ChatManager = Torch.CurrentSession.Managers.GetManager <ChatManagerServer>(); PluginManager Plugins = Torch.CurrentSession.Managers.GetManager <PluginManager>(); BlockLimiterConnection(Plugins); GridBackupConnection(Plugins); Tracker.ServerStarted(Config.FolderDirectory); if (Config.GridMarketEnabled) { Market.InitilizeComms(ChatManager, MP); } AutoHangarStamp = DateTime.Now; break; case TorchSessionState.Unloading: PluginDispose(); break; } }
private void SessionChanged(ITorchSession session, TorchSessionState state) { switch (state) { case TorchSessionState.Loaded: _multibase = Torch.CurrentSession.Managers.GetManager <IMultiplayerManagerBase>(); if (_multibase != null) { _multibase.PlayerJoined += _multibase_PlayerJoined; MyEntities.OnEntityAdd += MyEntities_OnEntityAdd; _multibase.PlayerLeft += _multibase_PlayerLeft; } else { Log.Warn("No join/leave manager loaded!"); } _chatmanager = Torch.CurrentSession.Managers.GetManager <ChatManagerServer>(); if (_chatmanager != null) { _chatmanager.MessageRecieved += MessageRecieved; } else { Log.Warn("No chat manager loaded!"); } Log.Warn("Starting Discord Bridge!"); DDBridge = new DiscordBridge(this); //send status if (Config.UseStatus) { StartTimer(); } break; case TorchSessionState.Unloading: if (DDBridge != null) { if (Config.Stopped.Length > 0) { DDBridge.SendStatusMessage(null, Config.Stopped); } DDBridge.Stopdiscord(); } Log.Warn("Discord Bridge Unloaded!"); Dispose(); break; default: // ignore break; } }
public void LoadSEDB() { ReflectEssentials(); if (Config.BotToken.Length <= 0) { Log.Error("No BOT token set, plugin will not work at all! Add your bot TOKEN, save and restart torch."); return; } if (_sessionManager == null) { _sessionManager = Torch.Managers.GetManager <TorchSessionManager>(); if (_sessionManager == null) { Log.Warn("No session manager loaded!"); } else { _sessionManager.SessionStateChanged += SessionChanged; } } if (Torch.CurrentSession != null) { if (_multibase == null) { _multibase = Torch.CurrentSession.Managers.GetManager <IMultiplayerManagerBase>(); if (_multibase == null) { Log.Warn("No join/leave manager loaded!"); } else { _multibase.PlayerJoined += _multibase_PlayerJoined; _multibase.PlayerLeft += _multibase_PlayerLeft; MyEntities.OnEntityAdd += MyEntities_OnEntityAdd; } } if (_chatmanager == null) { _chatmanager = Torch.CurrentSession.Managers.GetManager <ChatManagerServer>(); if (_chatmanager == null) { Log.Warn("No chat manager loaded!"); } else { _chatmanager.MessageRecieved += MessageRecieved; } } InitPost(); } else if (Config.PreLoad) { InitPost(); } }
public void InitilizeComms(ChatManagerServer ChatServer, MultiplayerManagerBase Multiplayer) { Comms = new Comms(this); Comms.RegisterHandlers(); _ChatManager = ChatServer; _MP = Multiplayer; //initilize PlayerWatcher MP.PlayerJoined += MP_PlayerJoined; MP.PlayerLeft += MP_PlayerLeft; }
public void Login(User user) { if (state == State.LOGIN) { authWindow.Destroy(); chatManagerServer = new ChatManagerServer(); chatWindows = new Dictionary <Guid, Chat>(); usersWindow = new Users(user); usersWindow.Show(); state = State.USERS; } }
public static void SendMessageTemp(string author, string message, Color color) { Logger _chatLog = LogManager.GetLogger("Chat"); ScriptedChatMsg scriptedChatMsg1 = new ScriptedChatMsg(); scriptedChatMsg1.Author = author; scriptedChatMsg1.Text = message; scriptedChatMsg1.Font = "White"; scriptedChatMsg1.Color = color; scriptedChatMsg1.Target = 0L; ScriptedChatMsg scriptedChatMsg2 = scriptedChatMsg1; MyMultiplayerBase.SendScriptedChatMessage(ref scriptedChatMsg2); _chatLog.Info($"{author} (to {ChatManagerServer.GetMemberName(0)}): {message}"); }
public Chat(Guid guid, User src) : base(Gtk.WindowType.Toplevel) { this.guid = guid; this.src = src; this.dest = new Dictionary <User, IChat>(); this.tags = new List <string>(); this.chatManagerServer = new ChatManagerServer(); this.Build(); message.GrabFocus(); AddTags(); Refresh(WindowManager.getInstance().usersWindow.online); }
/// <summary> /// Renames the player to specified name /// <param name="session"></param> /// <param name="name"></param> /// </summary> public void Rename(PlayerSession session, string name) { //name = name.Substring(0, 32); name = ChatManagerServer.CleanupGeneral(name); if (string.IsNullOrEmpty(name.Trim())) { name = "Unnamed"; } // Chat/display name session.Identity.Name = name; session.Identity.Name = name; session.WorldPlayerEntity.GetComponent <HurtMonoBehavior>().RPC("UpdateName", uLink.RPCMode.All, name); SteamGameServer.BUpdateUserData(session.SteamId, name, 0); // Overhead name // TODO: Implement when possible //var displayProxyName = session.WorldPlayerEntity.GetComponent<DisplayProxyName>(); //displayProxyName.UpdateName(name); }
/// <summary> /// Renames the player to specified name /// <param name="session"></param> /// <param name="name"></param> /// </summary> public void Rename(PlayerSession session, string name) { // Clean up and set if empty name = ChatManagerServer.CleanupGeneral(name); if (string.IsNullOrEmpty(name.Trim())) { name = "Unnamed"; } // Set chat/display name session.Identity.Name = name; session.WorldPlayerEntity.RPC("UpdateName", uLink.RPCMode.OthersExceptOwnerBuffered, name); // Update name with Steam SteamGameServer.BUpdateUserData(session.SteamId, name, 0); // Update name with Oxide session.IPlayer.Name = name; permission.UpdateNickname(session.Identity.SteamId.ToString(), name); }
/// <inheritdoc /> public override void Dispose() { if (_multibase != null) { _multibase.PlayerJoined -= _multibase_PlayerJoined; MyEntities.OnEntityAdd -= MyEntities_OnEntityAdd; _multibase.PlayerLeft -= _multibase_PlayerLeft; } if (_sessionManager != null) { _sessionManager.SessionStateChanged -= SessionChanged; } _sessionManager = null; if (_chatmanager != null) { _chatmanager.MessageRecieved -= MessageRecieved; } _chatmanager = null; StopTimer(); }
private void SessionChanged(ITorchSession session, TorchSessionState state) { if (Config.BotToken.Length == 0) { return; } switch (state) { case TorchSessionState.Loading: ConnectDiscord(); client.DefaultRequestHeaders.TryAddWithoutValidation("Authorization", Config.APIPassword); break; case TorchSessionState.Loaded: _multibase = Torch.CurrentSession.Managers.GetManager <IMultiplayerManagerBase>(); if (_multibase != null) { _multibase.PlayerJoined += _multibase_PlayerJoined; MyEntities.OnEntityAdd += MyEntities_OnEntityAdd; _multibase.PlayerLeft += _multibase_PlayerLeft; } else { Log.Warn("No join/leave manager loaded!"); } _chatmanager = Torch.CurrentSession.Managers.GetManager <ChatManagerServer>(); if (_chatmanager == null) { Log.Warn("No chat manager loaded!"); } Log.Warn("Starting Discord role manager!"); break; case TorchSessionState.Unloading: if (_multibase != null) { _multibase.PlayerJoined -= _multibase_PlayerJoined; MyEntities.OnEntityAdd -= MyEntities_OnEntityAdd; _multibase.PlayerLeft -= _multibase_PlayerLeft; } if (_discord != null) { _discord.DisconnectAsync(); } _conecting.Clear(); _linkIds.Clear(); break; case TorchSessionState.Unloaded: Log.Info("Discord role manager unloaded!"); break; default: // ignore break; } }