public static void Unlock() { OnPlayerStartConnectingEvent.Unregister(ConnectingHandler); Player.Console.MessageLines(CompactMessages); Logger.Log(LogType.SystemActivity, "&aUpgrade finished!"); Upgrading = false; }
public bool ProcessLogin(string user, string mppass) { LastAction = DateTime.UtcNow; name = user; truename = user; SkinName = user; DisplayName = user; if (Session.ProtocolVersion > Server.VERSION_0030) { Leave(null, "Unsupported protocol version", true); return(false); } if (user.Length < 1 || user.Length > 16) { Leave(null, "Usernames must be between 1 and 16 characters", true); return(false); } if (!user.ContainsAllIn(USERNAME_ALPHABET)) { Leave(null, "Invalid player name", true); return(false); } if (Server.Config.ClassicubeAccountPlus) { name += "+"; } OnPlayerStartConnectingEvent.Call(this, mppass); if (cancelconnecting) { cancelconnecting = false; return(false); } level = Server.mainLevel; Loading = true; // returns false if disconnected during login return(!Socket.Disconnected); }
public override void Unload(bool shutdown) { OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect); OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand); OnChatEvent.Unregister(ChatHandler.HandleOnChat); OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting); OnSentMapEvent.Unregister(MiscHandlers.HandleOnMapSent); OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove); OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick); OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction); OnModActionEvent.Unregister(ModActionHandler.HandleModAction); Server.Background.Cancel(clearTask); }
public override void Load(bool startup) { OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical); OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical); OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical); OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical); OnSentMapEvent.Register(MiscHandlers.HandleOnMapSent, Priority.Critical); OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical); OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical); OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical); OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical); clearTask = Server.Background.QueueRepeat(IPThrottler.CleanupTask, null, TimeSpan.FromMinutes(10)); }
public override void Unload(bool shutdown) { OnPlayerConnectEvent.Unregister(ConnectHandler.HandleConnect); OnPlayerCommandEvent.Unregister(ChatHandler.HandleCommand); OnChatEvent.Unregister(ChatHandler.HandleOnChat); OnPlayerStartConnectingEvent.Unregister(ConnectingHandler.HandleConnecting); OnSentMapEvent.Unregister(MiscHandlers.HandleSentMap); OnPlayerMoveEvent.Unregister(MiscHandlers.HandlePlayerMove); OnPlayerClickEvent.Unregister(MiscHandlers.HandlePlayerClick); OnChangedZoneEvent.Unregister(MiscHandlers.HandleChangedZone); OnEcoTransactionEvent.Unregister(EcoHandlers.HandleEcoTransaction); OnModActionEvent.Unregister(ModActionHandler.HandleModAction); }
public override void Load(bool startup) { OnPlayerConnectEvent.Register(ConnectHandler.HandleConnect, Priority.Critical); OnPlayerCommandEvent.Register(ChatHandler.HandleCommand, Priority.Critical); OnChatEvent.Register(ChatHandler.HandleOnChat, Priority.Critical); OnPlayerStartConnectingEvent.Register(ConnectingHandler.HandleConnecting, Priority.Critical); OnSentMapEvent.Register(MiscHandlers.HandleSentMap, Priority.Critical); OnPlayerMoveEvent.Register(MiscHandlers.HandlePlayerMove, Priority.Critical); OnPlayerClickEvent.Register(MiscHandlers.HandlePlayerClick, Priority.Critical); OnChangedZoneEvent.Register(MiscHandlers.HandleChangedZone, Priority.Critical); OnEcoTransactionEvent.Register(EcoHandlers.HandleEcoTransaction, Priority.Critical); OnModActionEvent.Register(ModActionHandler.HandleModAction, Priority.Critical); }
void HandleLogin(byte[] buffer, int offset) { LastAction = DateTime.UtcNow; if (loggedIn) { return; } byte version = buffer[offset + 1]; if (version != Server.version) { Leave(null, "Wrong version!", true); return; } name = NetUtils.ReadString(buffer, offset + 2); SkinName = name; DisplayName = name; truename = name; if (Server.Config.ClassicubeAccountPlus) { name += "+"; } string mppass = NetUtils.ReadString(buffer, offset + 66); OnPlayerStartConnectingEvent.Call(this, mppass); if (cancelconnecting) { cancelconnecting = false; return; } hasCpe = buffer[offset + 130] == 0x42 && Server.Config.EnableCPE; level = Server.mainLevel; Loading = true; if (Socket.Disconnected) { return; } if (hasCpe) { SendCpeExtensions(); } else { CompleteLoginProcess(); } }
internal bool ProcessLogin(string user, string mppass) { LastAction = DateTime.UtcNow; name = user; truename = user; SkinName = user; DisplayName = user; if (ProtocolVersion > Server.VERSION_0030) { Leave(null, "Unsupported protocol version", true); return(false); } if (user.Length < 1 || user.Length > 16) { Leave(null, "Usernames must be between 1 and 16 characters", true); return(false); } if (!user.ContainsAllIn(USERNAME_ALPHABET)) { Leave(null, "Invalid player name", true); return(false); } if (Server.Config.ClassicubeAccountPlus) { name += "+"; } OnPlayerStartConnectingEvent.Call(this, mppass); if (cancelconnecting) { cancelconnecting = false; return(true); } level = Server.mainLevel; Loading = true; if (Socket.Disconnected) { return(true); } UpdateFallbackTable(); if (hasCpe) { SendCpeExtensions(); } else { CompleteLoginProcess(); } return(true); }
public static void Lock() { Upgrading = true; Logger.Log(LogType.SystemActivity, "Kicking players and unloading levels.."); OnPlayerStartConnectingEvent.Register(ConnectingHandler, Priority.System_Level); Player[] players = PlayerInfo.Online.Items; foreach (Player p in players) { p.Leave("Upgrading BlockDB. Check back later!"); } Level[] levels = LevelInfo.Loaded.Items; foreach (Level lvl in levels) { lvl.Unload(); } Logger.Log(LogType.SystemActivity, "Kicked all players and unloaded levels."); }
int HandleLogin(byte[] buffer, int offset, int left) { // protocol versions < 6 didn't have the usertype field, // hence this two-packet-size-handling monstrosity const int old_size = 1 + 1 + 64 + 64; const int new_size = 1 + 1 + 64 + 64 + 1; // the packet must be at least old_size long if (left < old_size) { return(0); } LastAction = DateTime.UtcNow; ProtocolVersion = buffer[offset + 1]; // check size now that know whether usertype field is included or not int size = ProtocolVersion >= Server.VERSION_0020 ? new_size : old_size; if (left < size) { return(0); } if (loggedIn) { return(size); } name = NetUtils.ReadString(buffer, offset + 2); SkinName = name; DisplayName = name; truename = name; if (ProtocolVersion > Server.VERSION_0030) { Leave(null, "Unsupported protocol version", true); return(-1); } if (name.Length < 1 || name.Length > 16) { Leave(null, "Usernames must be between 1 and 16 characters", true); return(-1); } if (!name.ContainsAllIn(USERNAME_ALPHABET)) { Leave(null, "Invalid player name", true); return(-1); } if (Server.Config.ClassicubeAccountPlus) { name += "+"; } string mppass = NetUtils.ReadString(buffer, offset + 66); OnPlayerStartConnectingEvent.Call(this, mppass); if (cancelconnecting) { cancelconnecting = false; return(size); } // usertype field has different meanings depending on protocol version // Version 7 - 0x42 for CPE supporting client, should be 0 otherwise // Version 6 - should be 0 // Version 5 - field does not exist if (ProtocolVersion >= Server.VERSION_0030) { hasCpe = buffer[offset + 130] == 0x42 && Server.Config.EnableCPE; } level = Server.mainLevel; Loading = true; if (Socket.Disconnected) { return(size); } UpdateFallbackTable(); if (hasCpe) { SendCpeExtensions(); } else { CompleteLoginProcess(); } return(size); }
public override void Unload(bool shutdown) { OnPlayerStartConnectingEvent.Unregister(HandleConnecting); OnConnectionReceivedEvent.Unregister(HandleConnectionReceived); Server.Background.Cancel(clearTask); }
public override void Load(bool startup) { OnPlayerStartConnectingEvent.Register(HandleConnecting, Priority.System_Level); OnConnectionReceivedEvent.Register(HandleConnectionReceived, Priority.System_Level); clearTask = Server.Background.QueueRepeat(CleanupTask, null, TimeSpan.FromMinutes(10)); }