コード例 #1
0
        static void DoTP(Player p, string message)
        {
            if (!Hacks.CanUseHacks(p))
            {
                p.Message("%WYou can't teleport to spawners because hacks are disabled in {0}", p.level.ColoredName);
                return;
            }
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to teleport to."); return;
            }
            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S to teleport to.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, message, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            Command.Find("tp").Use(p, "-precise " + (int)(spawner.x * 32) + " " + (int)(spawner.y * 32) + " " + (int)(spawner.z * 32));
        }
コード例 #2
0
 /// <summary> Finds matches within this list for the given name. </summary>
 public string FindMatches(Player p, string name, string type, out int matches)
 {
     lock (locker) {
         return(Matcher.Find(p, name, out matches, names,
                             null, n => n, type, 20));
     }
 }
コード例 #3
0
        internal static DataRow QueryMulti(Player p, string name, string columns)
        {
            string suffix = Database.Backend.CaselessLikeSuffix;

            using (DataTable results = Database.Backend.GetRows("Players", columns,
                                                                "WHERE Name LIKE @0 ESCAPE '#' LIMIT 21" + suffix,
                                                                "%" + name.Replace("_", "#_") + "%")) {
                int matches = 0;
                return(Matcher.Find <DataRow>(p, name, out matches, results.Rows,
                                              r => true, r => r["Name"].ToString(), "players", 20));
            }
        }
コード例 #4
0
ファイル: PlayerInfo.cs プロジェクト: noahjoyce31/MCGalaxy
        public static Player FindMatches(Player pl, string name,
                                         out int matches, bool onlyCanSee = true)
        {
            matches = 0;
            if (!Formatter.ValidName(pl, name, "player"))
            {
                return(null);
            }

            return(Matcher.Find(pl, name, out matches, Online.Items,
                                p => Entities.CanSee(pl, p) || !onlyCanSee,
                                p => p.name, "online players"));
        }
コード例 #5
0
        /// <summary> Matches given name against the names of all online players that the given player can see </summary>
        /// <param name="matches"> Outputs the number of matching players </param>
        /// <returns> A Player instance if exactly one match was found </returns>
        public static Player FindMatches(Player pl, string name, out int matches, bool _useless = false)
        {
            matches = 0;
            if (!Formatter.ValidPlayerName(pl, name))
            {
                return(null);
            }

            // Try to exactly match name first (because names have + at end)
            Player exact = FindExact(name);

            if (exact != null && pl.CanSee(exact))
            {
                matches = 1; return(exact);
            }

            return(Matcher.Find(pl, name, out matches, Online.Items,
                                p => pl.CanSee(p), p => p.name, "online players"));
        }
コード例 #6
0
        static void DoRemove(Player p, string message)
        {
            if (message.CaselessEq("all"))
            {
                if (PluginGoodlyEffects.EffectSpawner.CanEditAny(p))
                {
                    PluginGoodlyEffects.RemoveAllSpawners(p.level, true);
                    p.Message("Removed all spawners from {0}%S.", p.level.ColoredName);
                }
                else
                {
                    p.Message("%WYou cannot remove all spawners unless you are the owner of this map.");
                }
                return;
            }
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to remove."); return;
            }
            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, message, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            if (spawner.EditableBy(p, "remove"))
            {
                p.Message("Removed spawner {0}.", spawner.name);
                PluginGoodlyEffects.RemoveSpawner(spawner, p.level, true);
            }
        }
コード例 #7
0
        static void DoSummon(Player p, string message)
        {
            if (message == "")
            {
                p.Message("%WPlease provide the name of a spawner to summon."); return;
            }
            string[] args        = message.SplitSpaces(2);
            string   spawnerName = args[0];
            bool     precise     = (args.Length > 1) ? args[1].CaselessEq("precise") : false;

            p.Message("precise is {0}", precise);

            if (!PluginGoodlyEffects.spawnersAtLevel.ContainsKey(p.level))
            {
                p.Message("There are no spawners in {0}%S.", p.level.ColoredName);
                return;
            }
            int matches;

            PluginGoodlyEffects.EffectSpawner spawner = Matcher.Find(p, spawnerName, out matches,
                                                                     PluginGoodlyEffects.spawnersAtLevel[p.level],
                                                                     x => true,
                                                                     x => x.name,
                                                                     "effect spawners");
            if (matches > 1 || spawner == null)
            {
                return;
            }
            if (spawner.EditableBy(p, "summon"))
            {
                float diffX = spawner.x - spawner.originX;
                float diffY = spawner.y - spawner.originY;
                float diffZ = spawner.z - spawner.originZ;

                if (precise)
                {
                    spawner.x = (float)(p.Pos.X) / 32f;
                    spawner.y = (float)(p.Pos.Y - Entities.CharacterHeight) / 32f;
                    spawner.z = (float)(p.Pos.Z) / 32f;
                }
                else
                {
                    spawner.x = p.Pos.BlockX;
                    spawner.y = p.Pos.FeetBlockCoords.Y;
                    spawner.z = p.Pos.BlockZ;
                    //center in block
                    spawner.x += 0.5f;
                    spawner.y += 0.5f;
                    spawner.z += 0.5f;
                }

                spawner.originX = spawner.x - diffX;
                spawner.originY = spawner.y - diffY;
                spawner.originZ = spawner.z - diffZ;
                if (precise)
                {
                    p.Message("Summoned spawner {0} to your precise feet position.", spawner.name);
                }
                else
                {
                    p.Message("Summoned spawner {0} to your block position.", spawner.name);
                }
                PluginGoodlyEffects.SpawnersFile.Save(p.level);
            }
        }