コード例 #1
0
        public static string Format(string message, Player p, bool colors = true,
                                    bool tokens = true, bool emotes = true)
        {
            if (colors)
            {
                message = Colors.EscapeColors(message);
            }
            StringBuilder sb = new StringBuilder(message);

            if (colors)
            {
                ParseColors(p, sb);
            }
            if (tokens)
            {
                ChatTokens.Apply(sb, p);
            }
            if (!emotes)
            {
                return(sb.ToString());
            }

            if (p.parseEmotes)
            {
                sb.Replace(":)", "(darksmile)");
                sb.Replace(":D", "(smile)");
                sb.Replace("<3", "(heart)");
            }
            message = EmotesHandler.Replace(sb.ToString());
            message = FullCP437Handler.Replace(message);
            return(message);
        }
コード例 #2
0
        public static string Format(string message, Player p, bool tokens = true, bool emotes = true)
        {
            message = Colors.Escape(message);
            StringBuilder sb = new StringBuilder(message);

            Colors.Cleanup(sb, p.hasTextColors);

            if (tokens)
            {
                ChatTokens.Apply(sb, p);
            }
            if (!emotes)
            {
                return(sb.ToString());
            }

            if (p.parseEmotes)
            {
                sb.Replace(":)", "(darksmile)");
                sb.Replace(":D", "(smile)");
                sb.Replace("<3", "(heart)");
            }
            message = EmotesHandler.Replace(sb.ToString());
            return(message);
        }
コード例 #3
0
ファイル: Server.cs プロジェクト: UnknownShadow200/MCGalaxy
        public static void LoadAllSettings()
        {
            // Unload custom plugins
            List <Plugin> plugins = new List <Plugin>(Plugin.all);

            foreach (Plugin p in plugins)
            {
                if (Plugin.core.Contains(p))
                {
                    continue;
                }
                Plugin.Unload(p, false);
            }

            ZSGame.Instance.infectMessages = ZSConfig.LoadInfectMessages();
            Colors.Load();
            Alias.Load();
            BlockDefinition.LoadGlobal();
            ImagePalette.Load();

            SrvProperties.Load();
            AuthService.ReloadDefault();
            Group.LoadAll();
            CommandPerms.Load();
            Command.InitAll();
            Block.SetBlocks();
            AwardsList.Load();
            PlayerAwards.Load();
            Economy.Load();
            WarpList.Global.Filename = "extra/warps.save";
            WarpList.Global.Load();
            CommandExtraPerms.Load();
            ProfanityFilter.Init();
            Team.LoadList();
            ChatTokens.LoadCustom();
            SrvProperties.FixupOldPerms();
            CpeExtension.LoadDisabledList();

            TextFile announcementsFile = TextFile.Files["Announcements"];

            announcementsFile.EnsureExists();
            announcements = announcementsFile.GetText();

            // Reload custom plugins
            foreach (Plugin p in plugins)
            {
                if (Plugin.core.Contains(p))
                {
                    continue;
                }
                Plugin.Load(p, false);
            }

            OnConfigUpdatedEvent.Call();
        }
コード例 #4
0
ファイル: IRCBot.cs プロジェクト: ProtheanGod/KingMC
        public static string ConvertMessage(string message)
        {
            if (String.IsNullOrEmpty(message.Trim()))
            {
                message = ".";
            }

            message = EmotesHandler.Replace(message);
            message = ChatTokens.ApplyCustom(message);
            message = Colors.ConvertMCToIRC(message.Replace("%S", ResetSignal));
            return(message);
        }
コード例 #5
0
ファイル: IRCBot.cs プロジェクト: Fam0r/MCGalaxy
        public static string ConvertMessage(string message)
        {
            if (String.IsNullOrEmpty(message.Trim()))
            {
                message = ".";
            }
            const string resetSignal = "\x03\x0F";

            message = EmotesHandler.Replace(message);
            message = ChatTokens.ApplyCustom(message);
            message = message.Replace("%S", "&f"); // TODO remove
            message = message.Replace("&S", "&f");
            message = message.Replace("&f", resetSignal);
            message = ToIRCColors(message);
            return(message);
        }
コード例 #6
0
        public static void LoadAllSettings()
        {
            // Unload custom plugins
            List <Plugin> plugins = Plugin.all;

            foreach (Plugin plugin in plugins)
            {
                if (Plugin.core.Contains(plugin))
                {
                    continue;
                }
                plugin.Unload(false);
            }

            zombie.LoadInfectMessages();
            Colors.LoadList();
            Alias.Load();
            BlockDefinition.LoadGlobal();
            ImagePalette.Load();

            SrvProperties.Load();
            Group.InitAll();
            Command.InitAll();
            CommandPerms.Load();
            Block.SetBlocks();
            BlockDefinition.UpdateGlobalBlockProps();
            Awards.Load();
            Economy.Load();
            WarpList.Global.Filename = "extra/warps.save";
            WarpList.Global.Load();
            CommandExtraPerms.Load();
            ProfanityFilter.Init();
            Team.LoadList();
            ChatTokens.LoadCustom();
            SrvProperties.FixupOldPerms();

            // Reload custom plugins
            foreach (Plugin plugin in plugins)
            {
                if (Plugin.core.Contains(plugin))
                {
                    continue;
                }
                plugin.Load(false);
            }
        }
コード例 #7
0
ファイル: IRCBot.cs プロジェクト: Benedani/MCGalaxy
        static string ConvertMessage(string message, bool color)
        {
            if (String.IsNullOrEmpty(message.Trim()))
            {
                message = ".";
            }
            message = EmotesHandler.Replace(message);
            message = FullCP437Handler.Replace(message);
            message = ChatTokens.ApplyCustom(message);
            message = CP437Writer.ConvertToUnicode(message);

            if (color)
            {
                message = Colors.MinecraftToIrcColors(message.Replace("%S", ResetSignal));
            }
            return(message);
        }
コード例 #8
0
        public static void LoadAllSettings()
        {
            zombie.LoadInfectMessages();
            Colors.LoadExtColors();
            Alias.Load();
            Bots.BotsFile.Load();
            BlockDefinition.LoadGlobal();

            SrvProperties.Load("properties/server.properties");
            Updater.Load("properties/update.properties");
            Group.InitAll();
            Command.InitAll();
            GrpCommands.fillRanks();
            Block.SetBlocks();
            Awards.Load();
            Economy.Load();
            WarpList.Global.Load(null);
            CommandOtherPerms.Load();
            ProfanityFilter.Init();
            Team.LoadList();
            ChatTokens.LoadCustom();
            FixupOldPerms();
        }
コード例 #9
0
ファイル: Player.cs プロジェクト: rdebath/MCGalaxy
        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();
            }
        }
コード例 #10
0
        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();
            }
        }
コード例 #11
0
ファイル: Player.cs プロジェクト: ProtheanGod/KingMC
        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();
            }
        }