コード例 #1
0
        private void OnChatMessage(int groupId, string message, EnumChatType chattype, string data)
        {
            if (_clientApi?.World?.Player == null)
            {
                return;
            }

            var pos = _clientApi.World.Player.WorldData.CurrentGameMode == EnumGameMode.Creative ? blocksSinceLastSuccessList.LastOrDefault()?.Position : blocksSinceLastSuccessList.ElementAtOrDefault(blocksSinceLastSuccessList.Count - 2 - 1)?.Position;

            if (pos == null || groupId != GlobalConstants.InfoLogChatGroup || !_triggerwords.Any(triggerWord => message.StartsWith(triggerWord)))
            {
                return;
            }

            message = _cleanupRegex.Replace(message, string.Empty);
            var posX = pos.X / _chunksize;
            var posZ = pos.Z / _chunksize;

            _messages.RemoveAll(m => m.X == posX && m.Z == posZ);
            _messages.Add(new ProspectInfo(posX, posZ, message));
            _clientApi.SaveDataFile(Filename, _messages);

            _components.RemoveAll(component =>
            {
                var castComponent = component as ProspectorOverlayMapComponent;
                return(castComponent?.ChunkX == posX && castComponent.ChunkZ == posZ);
            });
            var newComponent = new ProspectorOverlayMapComponent(_clientApi, posX, posZ, message, _colorTexture);

            _components.Add(newComponent);

            blocksSinceLastSuccessList.Clear();
        }
コード例 #2
0
        private void OnChatMessage(int groupId, string message, EnumChatType chattype, string data)
        {
            if (data != null && data.StartsWith("From:") && entity.Pos.SquareDistanceTo(capi.World.Player.Entity.Pos.XYZ) < 20 * 20 && message.Length > 0)
            {
                int entityid = 0;
                int.TryParse(data.Split(new string[] { ":" }, StringSplitOptions.None)[1], out entityid);
                if (entity.EntityId == entityid)
                {
                    string name = GetNameTagName();
                    if (name != null && message.StartsWith(name + ": "))
                    {
                        message = message.Substring((name + ": ").Length);
                    }

                    LoadedTexture tex = capi.Gui.Text.GenTextTexture(
                        message,
                        capi.Render.GetFont(30, ElementGeometrics.StandardFontName, ColorUtil.WhiteArgbDouble),
                        350,
                        new TextBackground()
                    {
                        color = ElementGeometrics.DialogLightBgColor, padding = 3, radius = ElementGeometrics.ElementBGRadius
                    },
                        EnumTextOrientation.Center
                        );

                    messageTextures.Insert(0, new MessageTexture()
                    {
                        tex          = tex,
                        message      = message,
                        receivedTime = capi.World.ElapsedMilliseconds
                    });
                }
            }
        }
コード例 #3
0
        private void OnChatMessage(int groupId, string message, EnumChatType chattype, string data)
        {
            var pos = _clientApi.World.Player.CurrentBlockSelection?.Position ?? _clientApi.World.Player.Entity.Pos.AsBlockPos;

            if (pos == null || groupId != GlobalConstants.InfoLogChatGroup || !message.StartsWith(_triggerword))
            {
                return;
            }

            message = _cleanupRegex.Replace(message, string.Empty);
            var posX = pos.X / _chunksize;
            var posZ = pos.Z / _chunksize;

            _messages.RemoveAll(m => m.X == posX && m.Z == posZ);
            _messages.Add(new ProspectInfo(posX, posZ, message));
            _clientApi.SaveDataFile(Filename, _messages);
        }
コード例 #4
0
        protected void OnChatMessage(int groupId, string message, EnumChatType chattype, string data)
        {
            if (data != null && data.Contains("from:") && entity.Pos.SquareDistanceTo(capi.World.Player.Entity.Pos.XYZ) < 20 * 20 && message.Length > 0)
            {
                int      entityid;
                string[] parts = data.Split(new char[] { ',' }, 2);
                if (parts.Length < 2)
                {
                    return;
                }

                string[] partone = parts[0].Split(new char[] { ':' }, 2);
                string[] parttwo = parts[1].Split(new char[] { ':' }, 2);
                if (partone[0] != "from")
                {
                    return;
                }

                int.TryParse(partone[1], out entityid);
                if (entity.EntityId == entityid)
                {
                    message = parttwo[1];

                    // Crappy fix
                    message = message.Replace("&lt;", "<").Replace("&gt;", ">");

                    LoadedTexture tex = capi.Gui.TextTexture.GenTextTexture(
                        message,
                        new CairoFont(25, GuiStyle.StandardFontName, ColorUtil.WhiteArgbDouble),
                        350,
                        new TextBackground()
                    {
                        FillColor = GuiStyle.DialogLightBgColor, Padding = 3, Radius = GuiStyle.ElementBGRadius
                    },
                        EnumTextOrientation.Center
                        );

                    messageTextures.Insert(0, new MessageTexture()
                    {
                        tex          = tex,
                        message      = message,
                        receivedTime = capi.World.ElapsedMilliseconds
                    });
                }
            }
        }
コード例 #5
0
        public static bool Prefix(string message, EnumChatType chattype)
        {
            bool contains = false;

            if (!ConfigLoader.Config.Echo && chattype == EnumChatType.CommandSuccess)
            {
                foreach (var text in WaypointRelated)
                {
                    contains |= message.Contains(text);
                    if (contains)
                    {
                        break;
                    }
                }
            }
            return(!contains);
        }