コード例 #1
0
 public static void Unlock()
 {
     OnPlayerStartConnectingEvent.Unregister(ConnectingHandler);
     Player.Console.MessageLines(CompactMessages);
     Logger.Log(LogType.SystemActivity, "&aUpgrade finished!");
     Upgrading = false;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
 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));
 }
コード例 #5
0
ファイル: CorePlugin.cs プロジェクト: rdebath/MCGalaxy
        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);
        }
コード例 #6
0
ファイル: CorePlugin.cs プロジェクト: rdebath/MCGalaxy
        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);
        }
コード例 #7
0
ファイル: Player.Login.cs プロジェクト: Metastruct/MCGalaxy
        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();
            }
        }
コード例 #8
0
        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);
        }
コード例 #9
0
        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.");
        }
コード例 #10
0
        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);
        }
コード例 #11
0
ファイル: IPThrottler.cs プロジェクト: rdebath/MCGalaxy
 public override void Unload(bool shutdown)
 {
     OnPlayerStartConnectingEvent.Unregister(HandleConnecting);
     OnConnectionReceivedEvent.Unregister(HandleConnectionReceived);
     Server.Background.Cancel(clearTask);
 }
コード例 #12
0
ファイル: IPThrottler.cs プロジェクト: rdebath/MCGalaxy
 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));
 }