Exemple #1
0
        public static void Init()
        {
            if (Configuration.ConfigManager.GetConfigBooleanOrDefault(NewColonyAPIEntry.ModName, "rotatingmessages.enabled", false) == true)
            {
                rotatorEnabled = true;

                string rotatorColorConf = Configuration.ConfigManager.GetConfigStringOrDefault(NewColonyAPIEntry.ModName, "rotatingmessages.color", "yellow");
                if (Enum.IsDefined(typeof(Helpers.Chat.ChatColour), rotatorColorConf))
                {
                    rotatorColor = (Helpers.Chat.ChatColour)Enum.Parse(typeof(Helpers.Chat.ChatColour), rotatorColorConf);
                }

                string rotatorStyleConf = Configuration.ConfigManager.GetConfigStringOrDefault(NewColonyAPIEntry.ModName, "rotatingmessages.style", "bolditalic");
                if (Enum.IsDefined(typeof(Helpers.Chat.ChatColour), rotatorStyleConf))
                {
                    rotatorStyle = (Helpers.Chat.ChatStyle)Enum.Parse(typeof(Helpers.Chat.ChatStyle), rotatorStyleConf);
                }

                rotatorSecondsBetween = Configuration.ConfigManager.GetConfigIntOrDefault(NewColonyAPIEntry.ModName, "rotatingmessages.interval", 900);

                JSONNode rotatingMessagesConf = Configuration.ConfigManager.GetConfigNode(NewColonyAPIEntry.ModName, "rotatingmessages.list");
                foreach (JSONNode message in rotatingMessagesConf.LoopArray())
                {
                    rotatorMessages.Add(message.GetAs <string>());
                }

                nextUpdateTime = NextUpdate();

                Helpers.Logging.WriteLog(NewColonyAPIEntry.ModName, string.Format("Rotator is enabled with {0} messages playing every {1} seconds. Next update: {2}",
                                                                                  rotatorMessages.Count,
                                                                                  rotatorSecondsBetween,
                                                                                  nextUpdateTime), Helpers.Logging.LogType.Loading);
            }
        }
        public bool TryDoCommand(Players.Player player, string chat)
        {
            if (ConfigManager.getConfigBoolean("chat.enabled"))
            {
                JSONNode chatColors = ConfigManager.getConfigNode("chat.colors");
                string   chatColor  = "white";
                string   chatStyle  = "normal";
                string   playerPerm = "";
                string   chatPrefix = "";

                foreach (JSONNode perm in chatColors.LoopArray())
                {
                    string permName = "somesuperspecificplaceholderstringthatwillneverexist";
                    perm.TryGetAs <string>("permissionstring", out permName);

                    if (PermissionsManager.HasPermission(player, permName))
                    {
                        // this player is in this group
                        playerPerm = permName;
                        perm.TryGetAs <string>("color", out chatColor);
                        perm.TryGetAs <string>("style", out chatStyle);
                        perm.TryGetAs <string>("prefix", out chatPrefix);
                    }
                }


                Helpers.Chat.ChatColour chatColorEnum = (Helpers.Chat.ChatColour)Enum.Parse(typeof(Helpers.Chat.ChatColour), chatColor);
                Helpers.Chat.ChatStyle  chatStyleEnum = (Helpers.Chat.ChatStyle)Enum.Parse(typeof(Helpers.Chat.ChatStyle), chatStyle);

                string message = "";
                if (chatPrefix != "")
                {
                    message = String.Format("[{0}] {1}: {2}", chatPrefix, player.Name, chat);
                }
                else
                {
                    message = String.Format("{0}: {1}", player.Name, chat);
                }

                Helpers.Chat.sendToAll(message, chatColorEnum, chatStyleEnum);
            }
            else
            {
                Helpers.Chat.sendToAll(String.Format("{0}: {1}", player.Name, chat), Helpers.Chat.ChatColour.white);
            }



            return(true);
        }
Exemple #3
0
        public bool TryDoCommand(Players.Player player, string chat, List <string> splits)
        {
            if (chat.StartsWith("/"))
            {
                return(false);
            }

            JSONNode chatColors = Configuration.ConfigManager.GetConfigNode(NewColonyAPIEntry.ModName, "chat.colors");
            string   chatColor  = "white";
            string   chatStyle  = "normal";
            string   playerPerm = "";
            string   chatPrefix = "";

            foreach (JSONNode perm in chatColors.LoopArray())
            {
                if (perm.TryGetAs("permissionstring", out string perName))
                {
                    if (Helpers.Player.ExactPermission(player, perName))
                    {
                        playerPerm = perName;
                        perm.TryGetAs("color", out chatColor);
                        perm.TryGetAs("style", out chatStyle);
                        perm.TryGetAs("prefix", out chatPrefix);
                        break;
                    }
                }
            }
            Helpers.Chat.ChatColour chatColourEnum = (Helpers.Chat.ChatColour)Enum.Parse(typeof(Helpers.Chat.ChatColour), chatColor);
            Helpers.Chat.ChatStyle  chatStyleEnum  = (Helpers.Chat.ChatStyle)Enum.Parse(typeof(Helpers.Chat.ChatStyle), chatStyle);
            if (chatPrefix == "")
            {
                Helpers.Chat.SendToAll(Helpers.Chat.BuildMessage(string.Format("[{0}] {1}", player.Name, chat), chatColourEnum, chatStyleEnum));
            }
            else
            {
                if (player.ID == NetworkID.Server)
                {
                    Helpers.Chat.SendToAll(Helpers.Chat.BuildMessage(string.Format("[{0}] [{1}] {2}", chatPrefix, "Server", chat), chatColourEnum, chatStyleEnum));
                }
                else
                {
                    Helpers.Chat.SendToAll(Helpers.Chat.BuildMessage(string.Format("[{0}] [{1}] {2}", chatPrefix, player.Name, chat), chatColourEnum, chatStyleEnum));
                }
            }

            return(true);
        }
Exemple #4
0
 public static void WriteLog(string message, Helpers.Chat.ChatColour color, Helpers.Chat.ChatStyle style)
 {
     Pipliz.Log.Write(Helpers.Chat.buildMessage("[ColonyPlusPlus]: " + message, color, style));
 }