Beispiel #1
0
        public async Task PluginsAsync()
        {
            var message = new ChatMessage
            {
                Text = $"{ChatColor.Gold}List of plugins: ",
            };

            var messages = new List <ChatMessage>();

            foreach (var pls in Context.Server.PluginManager.Plugins)
            {
                messages.Add(new ChatMessage
                {
                    Text       = ChatColor.DarkGreen + pls.Info.Name + $"{ChatColor.Reset}, ",
                    ClickEvent = new TextComponent {
                        Action = ETextAction.open_url, Value = pls.Info.ProjectUrl
                    }
                });
            }

            if (messages.Count > 0)
            {
                message.AddExtra(messages);
            }

            Console.WriteLine(message.ToString());

            await Context.Player.SendMessageAsync(message);

            //await Context.Player.SendMessageAsync(pls);
        }
        public async Task PluginsAsync(CommandContext Context)
        {
            var srv         = (Server)Context.Server;
            var sender      = Context.Sender;
            var pluginCount = srv.PluginManager.Plugins.Count;
            var message     = new ChatMessage
            {
                Text = $"{ChatColor.Reset}List of plugins ({ChatColor.Gold}{pluginCount}{ChatColor.Reset}): ",
            };

            var messages = new List <ChatMessage>();

            for (int i = 0; i < pluginCount; i++)
            {
                var pluginContainer = srv.PluginManager.Plugins[i];
                var info            = pluginContainer.Info;

                var plugin       = new ChatMessage();
                var colorByState = pluginContainer.Loaded || pluginContainer.IsReady ? HexColor.Green : HexColor.Red;

                plugin.Text  = pluginContainer.Info.Name;
                plugin.Color = colorByState;

                plugin.HoverEvent = new HoverComponent {
                    Action = EHoverAction.ShowText, Contents = $"{colorByState}{info.Name}{ChatColor.Reset}\nVersion: {colorByState}{info.Version}{ChatColor.Reset}\nAuthor(s): {colorByState}{info.Authors}{ChatColor.Reset}"
                };
                if (pluginContainer.Info.ProjectUrl != null)
                {
                    plugin.ClickEvent = new ClickComponent {
                        Action = EClickAction.OpenUrl, Value = pluginContainer.Info.ProjectUrl.AbsoluteUri
                    }
                }
                ;

                messages.Add(plugin);

                messages.Add(new ChatMessage
                {
                    Text = $"{ChatColor.Reset}{(i + 1 < srv.PluginManager.Plugins.Count ? ", " : "")}"
                });
            }
            if (messages.Count > 0)
            {
                message.AddExtra(messages);
            }
            else
            {
                message.Text = $"{ChatColor.Gold}There is no plugins installed{ChatColor.Reset}";
            }

            await sender.SendMessageAsync(message);
        }
        public async Task PluginsAsync(ObsidianContext Context)
        {
            var srv         = (Server)Context.Server;
            var player      = (Player)Context.Player;
            var pluginCount = srv.PluginManager.Plugins.Count;
            var message     = new ChatMessage
            {
                Text = $"{ChatColor.Reset}List of plugins ({ChatColor.Gold}{pluginCount}{ChatColor.Reset}): ",
            };

            var messages = new List <ChatMessage>();

            for (int i = 0; i < pluginCount; i++)
            {
                var pluginContainer = srv.PluginManager.Plugins[i];
                var info            = pluginContainer.Info;

                var plugin       = new ChatMessage();
                var colorByState = pluginContainer.Loaded || pluginContainer.IsReady ? ChatColor.DarkGreen : ChatColor.DarkRed;
                plugin.Text = colorByState + pluginContainer.Info.Name;

                plugin.HoverEvent = new TextComponent {
                    Action = ETextAction.ShowText, Value = $"{colorByState}{info.Name}{ChatColor.Reset}\nVersion: {colorByState}{info.Version}{ChatColor.Reset}\nAuthor(s): {colorByState}{info.Authors}{ChatColor.Reset}"
                };
                if (pluginContainer.Info.ProjectUrl != null)
                {
                    plugin.ClickEvent = new TextComponent {
                        Action = ETextAction.OpenUrl, Value = pluginContainer.Info.ProjectUrl.AbsoluteUri
                    }
                }
                ;

                messages.Add(plugin);

                messages.Add(new ChatMessage
                {
                    Text = $"{ChatColor.Reset}{(i + 1 < srv.PluginManager.Plugins.Count ? ", " : "")}"
                });
            }
            if (messages.Count > 0)
            {
                message.AddExtra(messages);
            }

            await player.SendMessageAsync(message);
        }
Beispiel #4
0
        public async Task ChatDeleteAsync(ObsidianContext Context, EChatDeleteArguments arg0)
        {
            var player = Context.Player;

            var chatMessage = new ChatMessage();

            switch (arg0)
            {
            case EChatDeleteArguments.Delete:
            case EChatDeleteArguments.Clear:
            case EChatDeleteArguments.C:
                var clr_msg = Globals.Config.Messages.Clear.Split("{0}");
                chatMessage = new ChatMessage();
                chatMessage.AddExtra(new ChatMessage {
                    Text = $"{clr_msg[0]}"
                });
                //chatMessage.AddExtra(new ChatMessage { Text = $"{ChatColor.Gray}Chat successfully deleted by " });
                var user = new ChatMessage
                {
                    Text       = $"{ChatColor.Red}{player.Username}{ChatColor.Gray}",
                    HoverEvent = new TextComponent
                    {
                        Action = ETextAction.ShowText,
                        Value  = $"{DateTime.Now.ToShortDateString()}"
                    }
                };
                chatMessage.AddExtra(user);
                chatMessage.AddExtra(new ChatMessage {
                    Text = $"{clr_msg[1]}"
                });
                //chatMessage.AddExtra(new ChatMessage { Text = $"{ChatColor.Gray}." });

                await Context.Server.BroadcastAsync(JsonConvert.SerializeObject(chatMessage));

                break;

            case EChatDeleteArguments.Help:
                #region Command list
                var cmds = new Dictionary <String, String>();
                cmds.Add("help", "Shows this list.");
                cmds.Add("clear", "Clears the chat.");
                cmds.Add("delete", "Clears the chat.");
                cmds.Add("reload", "Reload plugin configuration.");
                #endregion

                chatMessage = new ChatMessage();
                chatMessage.AddExtra(new ChatMessage {
                    Text = $"{Globals.Config.Prefix}{ChatColor.Gray}Plugin commands:"
                });

                #region Build per command message.
                for (int i = 0; i < cmds.Count; i++)
                {
                    var cmd        = cmds.ToArray()[i];
                    var cmdargname = new ChatMessage
                    {
                        Text       = $"{ChatColor.Red}/chatdelete {cmd.Key}{ChatColor.Reset} ",
                        HoverEvent = new TextComponent
                        {
                            Action = ETextAction.ShowText,
                            Value  = $"{DateTime.Now.ToShortDateString()}"
                        }
                    };
                    chatMessage.AddExtra(cmdargname);
                    var cmdargdesc = new ChatMessage
                    {
                        Text       = $"{ChatColor.Gray}{cmd.Value}{ChatColor.Reset}\n",
                        HoverEvent = new TextComponent
                        {
                            Action = ETextAction.ShowText,
                            Value  = $"{DateTime.Now.ToShortDateString()}"
                        }
                    };
                    chatMessage.AddExtra(cmdargdesc);
                }
                #endregion

                break;

            case EChatDeleteArguments.Reload:


                break;

            default:
                break;
            }
        }