public override void Load(bool startup) { command = new CmdCustomModel(); Command.Register(command); OnPlayerConnectEvent.Register(OnPlayerConnect, Priority.Low); OnPlayerDisconnectEvent.Register(OnPlayerDisconnect, Priority.Low); OnJoiningLevelEvent.Register(OnJoiningLevel, Priority.Low); OnJoinedLevelEvent.Register(OnJoinedLevel, Priority.Low); OnSendingModelEvent.Register(OnSendingModel, Priority.Low); OnPlayerCommandEvent.Register(OnPlayerCommand, Priority.Low); // OnEntitySpawnedEvent.Register(OnEntitySpawned, Priority.Low); Directory.CreateDirectory(PublicModelsDirectory); Directory.CreateDirectory(PersonalModelsDirectory); int numModels = CreateMissingCCModels(false); int numPersonalModels = CreateMissingCCModels(true); Logger.Log( LogType.SystemActivity, "CustomModels Loaded with {0} Models and {1} Personal Models", numModels, numPersonalModels ); // initialize because of a late plugin load foreach (Player p in PlayerInfo.Online.Items) { SentCustomModels.TryAdd(p.name, new HashSet <string>(StringComparer.OrdinalIgnoreCase)); ModelNameToIdForPlayer.TryAdd(p.name, new ConcurrentDictionary <string, byte>(StringComparer.OrdinalIgnoreCase)); } }
public override void Unload(bool shutdown) { SentCustomModels.Clear(); ModelNameToIdForPlayer.Clear(); OnPlayerConnectEvent.Unregister(OnPlayerConnect); OnPlayerDisconnectEvent.Unregister(OnPlayerDisconnect); OnJoiningLevelEvent.Unregister(OnJoiningLevel); OnJoinedLevelEvent.Unregister(OnJoinedLevel); OnSendingModelEvent.Unregister(OnSendingModel); OnPlayerCommandEvent.Unregister(OnPlayerCommand); // OnEntitySpawnedEvent.Unregister(OnEntitySpawned); if (command != null) { Command.Unregister(command); command = null; } }
public override void Unload(bool shutdown) { if (dc != null) { dc.Dispose(); } if (!registered) { return; } OnPlayerConnectEvent.Unregister(PlayerConnect); OnPlayerDisconnectEvent.Unregister(PlayerDisconnect); OnPlayerChatEvent.Unregister(PlayerChat); OnPlayerCommandEvent.Unregister(PlayerCommand); OnMessageReceivedEvent.Unregister(DiscordMessage); Command.Unregister(Command.Find("DiscordBot")); }
public override void Load(bool startup) { config.LoadConfig(); if (config.Token == "" || config.ChannelID == "") { Logger.Log(LogType.Warning, "Invalid config! Please setup the Discord bot in discord.properties! (plugin reload required)"); return; } dc = new Discord.Discord(config.Token, config.ChannelID); OnPlayerConnectEvent.Register(PlayerConnect, Priority.Low); OnPlayerDisconnectEvent.Register(PlayerDisconnect, Priority.Low); OnPlayerChatEvent.Register(PlayerChat, Priority.Low); OnPlayerCommandEvent.Register(PlayerCommand, Priority.Low); OnModActionEvent.Register(ModAction, Priority.Low); OnMessageReceivedEvent.Register(DiscordMessage, Priority.Low); Command.Register(new CmdDiscordBot()); registered = true; }
void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false) { if (leftServer || IsSuper) { return; } leftServer = true; CriticalTasks.Clear(); ZoneIn = null; // Disconnected before sent handshake if (name == null) { if (Socket != null) { Socket.Close(); } Logger.Log(LogType.UserActivity, "{0} disconnected.", IP); return; } Server.reviewlist.Remove(name); try { if (Socket.Disconnected) { PlayerInfo.Online.Remove(this); return; } if (weapon != null) { weapon.Disable(); } if (chatMsg != null) { chatMsg = Colors.Escape(chatMsg); } discMsg = Colors.Escape(discMsg); string kickPacketMsg = ChatTokens.Apply(discMsg, this); Session.SendKick(kickPacketMsg, sync); Socket.Disconnected = true; ZoneIn = null; if (isKick) { TimesBeenKicked++; } if (!loggedIn) { PlayerInfo.Online.Remove(this); Logger.Log(LogType.UserActivity, "{0} ({1}) disconnected. ({2})", truename, IP, discMsg); return; } Entities.DespawnEntities(this, false); ShowDisconnectInChat(chatMsg, isKick); SaveStats(); PlayerInfo.Online.Remove(this); OnPlayerDisconnectEvent.Call(this, discMsg); level.AutoUnload(); Dispose(); } catch (Exception e) { Logger.LogError("Error disconnecting player", e); } finally { Socket.Close(); } }
public override void Unload(bool shutdown) { OnPlayerDisconnectEvent.Unregister(LeaveServer); Command.Unregister(Command.Find("Party")); }
public override void Load(bool startup) { OnPlayerDisconnectEvent.Register(LeaveServer, Priority.High); Command.Register(new CmdParty()); }
public override void Unload(bool shutdown) { Command.Unregister(Command.Find("Lottery")); OnPlayerDisconnectEvent.Unregister(HandlePlayerDisconnect); }
public override void Load(bool startup) { Command.Register(new CmdLottery()); OnPlayerDisconnectEvent.Register(HandlePlayerDisconnect, Priority.High); }
public void LeaveServer(string kickMsg, string discMsg, bool sync = false) { if (discMsg != null) { discMsg = Colors.EscapeColors(discMsg); } if (kickMsg != null) { kickMsg = Colors.EscapeColors(kickMsg); } OnPlayerDisconnectEvent.Call(this, discMsg ?? kickMsg); //Umm...fixed? if (name == "") { if (socket != null) { CloseSocket(); } connections.Remove(this); SaveUndo(this); disconnected = true; return; } Server.reviewlist.Remove(name); try { if (disconnected) { CloseSocket(); connections.Remove(this); return; } // FlyBuffer.Clear(); disconnected = true; SaveIgnores(); pingTimer.Stop(); pingTimer.Dispose(); afkTimer.Stop(); afkTimer.Dispose(); muteTimer.Stop(); muteTimer.Dispose(); timespent.Stop(); timespent.Dispose(); afkCount = 0; afkStart = DateTime.Now; Server.afkset.Remove(name); isFlying = false; aiming = false; SendKick(kickMsg, sync); if (!loggedIn) { connections.Remove(this); RemoveFromPending(); Server.s.Log(ip + " disconnected."); return; } Server.zombie.PlayerLeftServer(this); if (Game.team != null) { Game.team.RemoveMember(this); } Server.Countdown.PlayerLeftServer(this); TntWarsGame tntwarsgame = TntWarsGame.GetTntWarsGame(this); if (tntwarsgame != null) { tntwarsgame.Players.Remove(tntwarsgame.FindPlayer(this)); tntwarsgame.SendAllPlayersMessage("TNT Wars: " + color + name + Server.DefaultColor + " has left TNT Wars!"); } Entities.GlobalDespawn(this, false, true); if (discMsg != null) { if (!hidden) { string leavem = "&c- " + FullName + " %S" + discMsg; if ((Server.guestLeaveNotify && group.Permission <= LevelPermission.Guest) || group.Permission > LevelPermission.Guest) { Player[] players = PlayerInfo.Online.Items; foreach (Player pl in players) { Player.SendMessage(pl, leavem); } } } Server.s.Log(name + "disconnected (" + discMsg + ")."); } else { totalKicked++; SendChatFrom(this, "&c- " + color + prefix + DisplayName + " %Skicked (" + kickMsg + "%S).", false); Server.s.Log(name + " kicked (" + kickMsg + ")."); } try { save(); } catch (Exception e) { Server.ErrorLog(e); } PlayerInfo.Online.Remove(this); Server.s.PlayerListUpdate(); if (name != null) { left[name.ToLower()] = ip; } if (PlayerDisconnect != null) { PlayerDisconnect(this, discMsg ?? kickMsg); } if (Server.AutoLoad && level.unload && !level.IsMuseum && IsAloneOnCurrentLevel()) { level.Unload(true); } Dispose(); } catch (Exception e) { Server.ErrorLog(e); } finally { CloseSocket(); } }
void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false) { if (leftServer) { return; } leftServer = true; CriticalTasks.Clear(); ZoneIn = null; // Disconnected before sent handshake if (name == null) { if (Socket != null) { Socket.Close(); } Logger.Log(LogType.UserActivity, "{0} disconnected.", ip); return; } Server.reviewlist.Remove(name); try { if (Socket.Disconnected) { PlayerInfo.Online.Remove(this); return; } // FlyBuffer.Clear(); LastAction = DateTime.UtcNow; IsAfk = false; isFlying = false; if (weapon != null) { weapon.Disable(); } if (chatMsg != null) { chatMsg = Colors.Escape(chatMsg); } discMsg = Colors.Escape(discMsg); string kickPacketMsg = ChatTokens.Apply(discMsg, this); Send(Packet.Kick(kickPacketMsg, hasCP437), sync); Socket.Disconnected = true; ZoneIn = null; if (isKick) { TimesBeenKicked++; } if (!loggedIn) { PlayerInfo.Online.Remove(this); string user = name + " (" + ip + ")"; Logger.Log(LogType.UserActivity, "{0} disconnected. ({1})", user, discMsg); return; } Entities.DespawnEntities(this, false); ShowDisconnectInChat(chatMsg, isKick); save(); PlayerInfo.Online.Remove(this); OnPlayerDisconnectEvent.Call(this, discMsg); level.AutoUnload(); Dispose(); } catch (Exception e) { Logger.LogError("Error disconnecting player", e); } finally { Socket.Close(); } }
void LeaveServer(string chatMsg, string discMsg, bool isKick, bool sync = false) { if (leftServer) { return; } leftServer = true; CriticalTasks.Clear(); //Umm...fixed? if (name == null || name.Length == 0) { if (Socket != null) { CloseSocket(); } connections.Remove(this); disconnected = true; Logger.Log(LogType.UserActivity, "{0} disconnected.", ip); return; } Server.reviewlist.Remove(name); try { if (disconnected) { CloseSocket(); connections.Remove(this); PlayerInfo.Online.Remove(this); return; } // FlyBuffer.Clear(); LastAction = DateTime.UtcNow; IsAfk = false; isFlying = false; aiming = false; if (chatMsg != null) { chatMsg = Colors.Escape(chatMsg); } discMsg = Colors.Escape(discMsg); string kickPacketMsg = ChatTokens.Apply(discMsg, this); Send(Packet.Kick(kickPacketMsg, hasCP437), sync); disconnected = true; if (isKick) { TimesBeenKicked++; } if (!loggedIn) { connections.Remove(this); RemoveFromPending(); PlayerInfo.Online.Remove(this); string user = name + " (" + ip + ")"; Logger.Log(LogType.UserActivity, "{0} disconnected. ({1})", user, discMsg); return; } if (Game.team != null) { Game.team.RemoveMember(this); } TntWarsGame tntwarsgame = TntWarsGame.GameIn(this); if (tntwarsgame != null) { tntwarsgame.Players.Remove(tntwarsgame.FindPlayer(this)); tntwarsgame.SendAllPlayersMessage("TNT Wars: " + ColoredName + " %Shas left TNT Wars!"); } Entities.DespawnEntities(this, false); ShowDisconnectInChat(chatMsg, isKick); save(); PlayerInfo.Online.Remove(this); Server.PlayerListUpdate(); OnPlayerDisconnectEvent.Call(this, discMsg); if (ServerConfig.AutoLoadMaps && level.Config.AutoUnload && !level.IsMuseum && !level.HasPlayers()) { level.Unload(true); } Dispose(); } catch (Exception e) { Logger.LogError(e); } finally { CloseSocket(); } }