Exemplo n.º 1
0
        public static void initialise()
        {
            string rotatorColorConf = ConfigManager.getConfigString("ColonyPlusPlus-Utilities", "rotatingmessages.color");

            if (Enum.IsDefined(typeof(Chat.ChatColour), rotatorColorConf))
            {
                rotatorColor = (Chat.ChatColour)Enum.Parse(typeof(Chat.ChatColour), rotatorColorConf);
            }

            string rotatorStyleConf = ConfigManager.getConfigString("ColonyPlusPlus-Utilities", "rotatingmessages.style");

            if (Enum.IsDefined(typeof(Chat.ChatStyle), rotatorStyleConf))
            {
                rotatorStyle = (Chat.ChatStyle)Enum.Parse(typeof(Chat.ChatStyle), rotatorStyleConf);
            }

            rotatorEnabled = ConfigManager.getConfigBoolean("ColonyPlusPlus-Utilities", "rotatingmessages.enabled");

            rotatorSecondsBetween = ConfigManager.getConfigInt("ColonyPlusPlus-Utilities", "rotatingmessages.interval");

            JSONNode rotatorMessagesConf = ConfigManager.getConfigNode("ColonyPlusPlus-Utilities", "rotatingmessages.list");

            foreach (JSONNode message in rotatorMessagesConf.LoopArray())
            {
                rotatorMessages.Add(message.GetAs <string>());
            }

            nextUpdateTime = nextUpdate();

            Utilities.WriteLog("ColonyPlusPlus-Utilities", String.Format("Rotator is enabled ({0}) with {1} messages playing every {2} seconds. Next update: {3}", rotatorEnabled.ToString(), rotatorMessages.Count, rotatorSecondsBetween, nextUpdateTime));
        }
Exemplo n.º 2
0
        public bool TryDoCommand(Players.Player player, string chat)
        {
            if (ConfigManager.getConfigBoolean("ColonyPlusPlus-Utilities", "chat.enabled"))
            {
                JSONNode chatColors = ConfigManager.getConfigNode("ColonyPlusPlus-Utilities", "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);
                    }
                }


                Chat.ChatColour chatColorEnum = (Chat.ChatColour)Enum.Parse(typeof(Chat.ChatColour), chatColor);
                Chat.ChatStyle  chatStyleEnum = (Chat.ChatStyle)Enum.Parse(typeof(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);
                }

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



            return(true);
        }