From efe3828c782f2d66a7587281a72dd4ee176b4ac0 Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 30 May 2016 20:40:58 +1000 Subject: [PATCH] Remove the rarely used /search commands. --- Commands/CommandKeywords.cs | 299 ------------------------------ Commands/Information/CmdSearch.cs | 26 +-- MCGalaxy_.csproj | 1 - Server/Server.Tasks.cs | 1 - 4 files changed, 1 insertion(+), 326 deletions(-) delete mode 100644 Commands/CommandKeywords.cs diff --git a/Commands/CommandKeywords.cs b/Commands/CommandKeywords.cs deleted file mode 100644 index f6606cf35..000000000 --- a/Commands/CommandKeywords.cs +++ /dev/null @@ -1,299 +0,0 @@ -/* - Copyright 2011 MCForge - - Dual-licensed under the Educational Community License, Version 2.0 and - the GNU General Public License, Version 3 (the "Licenses"); you may - not use this file except in compliance with the Licenses. You may - obtain a copy of the Licenses at - - http://www.opensource.org/licenses/ecl2.php - http://www.gnu.org/licenses/gpl-3.0.html - - Unless required by applicable law or agreed to in writing, - software distributed under the Licenses are distributed on an "AS IS" - BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - or implied. See the Licenses for the specific language governing - permissions and limitations under the Licenses. - */ -using System; -using System.Collections.Generic; -using MCGalaxy.Commands.Building; -using MCGalaxy.Commands.Moderation; -using MCGalaxy.Commands.World; -using MCGalaxy.Games; - -namespace MCGalaxy.Commands { - - public sealed class CommandKeywords { - public static List all = new List(); - public string CmdName; - public string[] Keywords; - const StringComparison comp = StringComparison.OrdinalIgnoreCase; - - public CommandKeywords(Command cmd, string key) { - CmdName = cmd.name; - string keyword = key + " " + cmd.name + " " + cmd.type; - if (cmd.shortcut.Length > 3) { keyword += " " + cmd.shortcut; } - Keywords = keyword.Split(' '); - all.Add(this); - } - - public static void SetKeyWords() { - new CommandKeywords((new CmdAbort()), "command action mode"); - new CommandKeywords((new CmdAbout()), "info block history grief"); - new CommandKeywords((new CmdAdminChat()), "admin chat opchat"); - new CommandKeywords((new CmdAfk()), "away dnd"); - new CommandKeywords((new CmdAgree()), "accept yes rules"); - new CommandKeywords((new CmdAka()), "nick reset user name"); - new CommandKeywords((new CmdAlive()), "life health living"); - new CommandKeywords((new CmdAllowGuns()), "allow gun missile shoot boom terrorism"); - new CommandKeywords((new CmdAscend()), "up level block move player"); - new CommandKeywords((new CmdAward()), "reward trophy price"); - new CommandKeywords((new CmdAwards()), "price list trophy info"); - new CommandKeywords((new CmdAwardMod()), "trophy add del price"); - new CommandKeywords((new CmdBalance()), "cash " + Server.moneys); - new CommandKeywords((new CmdBan()), "kick mod punish"); - new CommandKeywords((new CmdBanEdit()), "reason edit ban"); - new CommandKeywords((new CmdBanInfo()), "info ban details"); - new CommandKeywords((new CmdBanip()), "ip ban kick mod punish"); - new CommandKeywords((new CmdBind()), "block replace"); - new CommandKeywords((new CmdBlockDB()), "about block change remove del"); - new CommandKeywords((new CmdBlocks()), "block info list"); - new CommandKeywords((new CmdBlockSet()), "rank mod block"); - new CommandKeywords((new CmdBlockSpeed()), "block speed mod setting"); - new CommandKeywords((new CmdBotAdd()), "bot add mod fun"); - new CommandKeywords((new CmdBotAI()), "bot ai add del remove"); - new CommandKeywords((new CmdBotRemove()), "bot remove del"); - new CommandKeywords((new CmdBots()), "bot list ai"); - new CommandKeywords((new CmdBotSet()), "set bot ai"); - new CommandKeywords((new CmdBotSummon()), "summon bot"); - new CommandKeywords((new CmdC4()), "tnt c4 explosion"); - new CommandKeywords((new CmdChain()), "grab block mushroom brown"); - new CommandKeywords((new CmdChangeLog()), "MCGalaxy change log"); - new CommandKeywords((new CmdClick()), "block use"); - new CommandKeywords((new CmdClones()), "clone ip player info"); - new CommandKeywords((new CmdCmdBind()), "bind cmd command shortcut"); - new CommandKeywords((new CmdCmdSet()), "set rank cmd command"); - new CommandKeywords((new CmdColor()), "user name"); - new CommandKeywords((new CmdCopy()), "clipboard blocks save"); - new CommandKeywords((new CmdCopyLVL()), "copy lvl level map"); - new CommandKeywords((new CmdCountdown()), "count down"); - new CommandKeywords((new CmdCrashServer()), "error stop server"); - new CommandKeywords((new CmdCTF()), "capture flag"); - new CommandKeywords((new CmdCuboid()), "box set area block"); - new CommandKeywords((new CmdDelete()), "del mode"); - new CommandKeywords((new CmdDeleteLvl()), "delete remove level lvl"); - new CommandKeywords((new CmdDemote()), "rank lower"); - new CommandKeywords((new CmdDevs()), "dev MCGalaxy forgeware forgecraft"); - new CommandKeywords((new CmdDisagree()), "no rules"); - new CommandKeywords((new CmdDescend()), "down below"); - new CommandKeywords((new CmdDisInfect()), "infect player"); - new CommandKeywords((new CmdDraw()), "cone sphere pyramid create"); - new CommandKeywords((new CmdDrill()), "dig distance"); - new CommandKeywords((new CmdEconomy()), "money cash " + Server.moneys); - new CommandKeywords((new CmdEmote()), "smiley emoticon"); - new CommandKeywords((new CmdEndRound()), "end round game"); - new CommandKeywords((new CmdExplode()), "explosion boom"); - new CommandKeywords((new CmdFakePay()), "fake troll pay " + Server.moneys); - new CommandKeywords((new CmdFakeRank()), "rank mod fake troll"); - new CommandKeywords((new CmdFaq()), "freq ask question"); - new CommandKeywords((new CmdFill()), "cuboid edit"); - new CommandKeywords((new CmdFixGrass()), "grass fix"); - new CommandKeywords((new CmdFlipHead()), "head fix flip troll"); - new CommandKeywords((new CmdFlipHeads()), "head fix flip troll"); - new CommandKeywords((new CmdFly()), "air ctf glass carpet"); - new CommandKeywords((new CmdFollow()), "posses impersonate"); - new CommandKeywords((new CmdFreeze()), "ice move player"); - new CommandKeywords((new CmdGarbage()), "memory clean unused"); - new CommandKeywords((new CmdGive()), "money pay " + Server.moneys); - new CommandKeywords((new CmdGlobalCLS()), "clear global chat"); - new CommandKeywords((new CmdGoto()), "level lvl change map"); - new CommandKeywords((new CmdGun()), "shoot boom terrorism missile"); - new CommandKeywords((new CmdHackRank()), "fake rank color set mod"); - new CommandKeywords((new CmdHacks()), "hack fake"); - new CommandKeywords((new CmdHelp()), "info commands cmd list"); - new CommandKeywords((new CmdHide()), "hidden show invisible"); - new CommandKeywords((new CmdHigh5()), "high 5 fun"); - new CommandKeywords((new CmdHighlight()), "mod high light block change history"); - new CommandKeywords((new CmdHollow()), "block create"); - new CommandKeywords((new CmdIgnore()), "abort chat player"); - new CommandKeywords((new CmdImport()), "dat imp extra"); - new CommandKeywords((new CmdImageprint()), "jpg bmp gif png image print"); - new CommandKeywords((new CmdInfect()), "virus inf"); - new CommandKeywords((new CmdInfected()), "infect player list"); - new CommandKeywords((new CmdServerInfo()), "server detail"); - new CommandKeywords((new CmdInvincible()), "god life inf"); - new CommandKeywords((new CmdJail()), "prison punish"); - new CommandKeywords((new CmdJoker()), "joke troll fun"); - new CommandKeywords((new CmdKick()), "moderate ban player"); - new CommandKeywords((new CmdKickban()), "kick ban moderate"); - new CommandKeywords((new CmdKill()), "die player murder"); - new CommandKeywords((new CmdKillPhysics()), "kill physics level"); - new CommandKeywords((new CmdLastCmd()), "cmd command last info"); - new CommandKeywords((new CmdLavaSurvival()), "lava surv"); - new CommandKeywords((new CmdLevels()), "level map info list"); - new CommandKeywords((new CmdLimit()), "lim moderate type"); - new CommandKeywords((new CmdLine()), "draw block paint"); - new CommandKeywords((new CmdLoad()), "level map lvl"); - new CommandKeywords((new CmdLockdown()), "lock down level map lvl player"); - new CommandKeywords((new CmdLoginMessage()), "login msg message"); - new CommandKeywords((new CmdLogoutMessage()), "logout quit exit stop msg message"); - new CommandKeywords((new CmdLowlag()), "low less lag"); - new CommandKeywords((new CmdMain()), "default map level lvl"); - new CommandKeywords((new CmdMap()), "level lvl info edit"); - new CommandKeywords((new CmdMapInfo()), "map info"); - new CommandKeywords((new CmdMaze()), "labyrint create"); - new CommandKeywords((new CmdMe()), "do action"); - new CommandKeywords((new CmdMeasure()), "meas block length distance"); - new CommandKeywords((new CmdMessageBlock()), "message block msg"); - new CommandKeywords((new CmdMissile()), "gun missil"); - new CommandKeywords((new CmdMode()), "block place"); - new CommandKeywords((new CmdModerate()), "chat enable disable allow disallow"); - new CommandKeywords((new CmdMove()), "player pos"); - new CommandKeywords((new CmdMoveAll()), "move all player pos"); - new CommandKeywords((new CmdMuseum()), "musea map lvl level"); - new CommandKeywords((new CmdMute()), "voice chat player"); - new CommandKeywords((new CmdNewLvl()), "new add lvl level map"); - new CommandKeywords((new CmdNews()), "info latest"); - new CommandKeywords((new CmdOHide()), "hide rank player invisible"); - new CommandKeywords((new CmdOpChat()), "private chat op"); - new CommandKeywords((new CmdOpRules()), "op rules info"); - new CommandKeywords((new CmdOpStats()), "stats op info"); - new CommandKeywords((new CmdOutline()), "out line layer"); - new CommandKeywords((new CmdOverseer()), "over see map level lvl"); - new CommandKeywords((new CmdOZone()), "zone map lvl level entire"); - new CommandKeywords((new CmdP2P()), "tp tele port player move"); - new CommandKeywords((new CmdPaint()), "mode block place"); - new CommandKeywords((new CmdPaste()), "copy clipboard out"); - new CommandKeywords((new CmdPatrol()), "teleport random"); - new CommandKeywords((new CmdPause()), "physics reset"); - new CommandKeywords((new CmdPay()), "money give " + Server.moneys); - new CommandKeywords((new CmdPlayerEditDB()), "player block limit mod edit"); - new CommandKeywords((new CmdPCount()), "player online total number count"); - new CommandKeywords((new CmdPCreate()), "create add new plugin"); - new CommandKeywords((new CmdPerbuildMax()), "perm build max rank"); - new CommandKeywords((new CmdPermissionBuild()), "perm build rank"); - new CommandKeywords((new CmdPermissionVisit()), "perm visit rank"); - new CommandKeywords((new CmdPervisitMax()), "perm visit max rank"); - new CommandKeywords((new CmdPhysics()), "block move"); - new CommandKeywords((new CmdPlace()), "block pos"); - new CommandKeywords((new CmdPlayerCLS()), "clear del player chat"); - new CommandKeywords((new CmdPlayers()), "player list info"); - new CommandKeywords((new CmdPortal()), "teleport tp move transport"); - new CommandKeywords((new CmdPossess()), "imp control"); - new CommandKeywords((new CmdPromote()), "rank up"); - new CommandKeywords((new CmdPyramid()), "egypt pyram piram sand"); - new CommandKeywords((new CmdQueue()), "zombie"); - new CommandKeywords((new CmdRagequit()), "rage quit exit stop leave"); - new CommandKeywords((new CmdRainbow()), "rain bow dash"); - new CommandKeywords((new CmdRankInfo()), "rank info display"); - new CommandKeywords((new CmdRankMsg()), "rank msg edit set"); - new CommandKeywords((new CmdRedo()), "undo edit block change"); - new CommandKeywords((new CmdReload()), "level lvl map"); - new CommandKeywords((new CmdReferee()), "enable disable ref mode"); - new CommandKeywords((new CmdRenameLvl()), "rename lvl level map"); - new CommandKeywords((new CmdRepeat()), "rep again"); - new CommandKeywords((new CmdReplace()), "block level lvl map"); - new CommandKeywords((new CmdReplaceAll()), "all block replace lvl level map"); - new CommandKeywords((new CmdReplaceNot()), "not replace block level lvl map"); - new CommandKeywords((new CmdReport()), "rep alert"); - new CommandKeywords((new CmdRestart()), "start again over new"); - new CommandKeywords((new CmdRestartPhysics()), "restart physics"); - new CommandKeywords((new CmdRestore()), "old rest copy"); - new CommandKeywords((new CmdRestoreSelection()), "restore select"); - new CommandKeywords((new CmdReveal()), "show"); - new CommandKeywords((new CmdReview()), "view look judge"); - new CommandKeywords((new CmdRide()), "drive train"); - new CommandKeywords((new CmdRoll()), "dice gamble"); - new CommandKeywords((new CmdRules()), "read prot"); - new CommandKeywords((new CmdSave()), "store load"); - new CommandKeywords((new CmdSay()), "speak broad cast"); - new CommandKeywords((new CmdSearch()), "find block command player rank"); - new CommandKeywords((new CmdSeen()), "saw last user"); - new CommandKeywords((new CmdServerInfo()), "report server"); - new CommandKeywords((new CmdServer()), "setting option"); - new CommandKeywords((new CmdSetRank()), "rank set user player"); - new CommandKeywords((new CmdSetspawn()), "spawn set map level lvl"); - new CommandKeywords((new CmdShutdown()), "shut down stop exit quit"); - new CommandKeywords((new CmdSlap()), "slam facepalm"); - new CommandKeywords((new CmdSpawn()), "level lvl map player user"); - new CommandKeywords((new CmdSpheroid()), "sphere"); - new CommandKeywords((new CmdSpin()), "rotate"); - new CommandKeywords((new CmdSPlace()), "measure place"); - new CommandKeywords((new CmdStatic()), "toggle mode"); - new CommandKeywords((new CmdSummon()), "move teleport tp player user"); - new CommandKeywords((new CmdTake()), "get money"); - new CommandKeywords((new CmdTColor()), "title color set"); - new CommandKeywords((new CmdTempBan()), "temp ban"); - new CommandKeywords((new CmdTempRank()), "temp rank"); - new CommandKeywords((new CmdTime()), "server"); - new CommandKeywords((new CmdTimer()), "count down"); - new CommandKeywords((new CmdTitle()), "set user"); - new CommandKeywords((new CmdTnt()), "c4 explo"); - new CommandKeywords((new CmdTntWars()), "tnt war c4 explo"); - new CommandKeywords((new CmdTopTen()), "top ten user"); - new CommandKeywords((new CmdTp()), "teleport move player user"); - new CommandKeywords((new CmdTpZone()), "tp zone teleport"); - new CommandKeywords((new CmdTree()), "log"); - new CommandKeywords((new CmdTrust()), "allow agree"); - new CommandKeywords((new CmdUnban()), "undo ban kick mod"); - new CommandKeywords((new CmdUnbanip()), "undo ban ip kick mod"); - new CommandKeywords((new CmdUndo()), "redo action block change"); - new CommandKeywords((new CmdUnflood()), "flood un restore"); - new CommandKeywords((new CmdUnload()), "load un map level lvl"); - new CommandKeywords((new CmdUnloaded()), "map level lvl list"); - new CommandKeywords((new CmdViewRanks()), "list info ban show rank view user player"); - new CommandKeywords((new CmdVIP()), "list add remove del"); - new CommandKeywords((new CmdVoice()), "speak moderate"); - new CommandKeywords((new CmdVote()), "yes no "); - new CommandKeywords((new CmdVoteKick()), "vote kick"); - new CommandKeywords((new CmdVoteResults()), "vote result"); - new CommandKeywords((new CmdWarn()), "kick user"); - new CommandKeywords((new CmdWarp()), "move teleport tp pos"); - new CommandKeywords((new CmdWaypoint()), "way point"); - new CommandKeywords((new CmdWhisper()), "tell private"); - new CommandKeywords((new CmdWhitelist()), "white list allow acces server"); - new CommandKeywords((new CmdWhoip()), "who ip info"); - new CommandKeywords((new CmdWhois()), "who player info"); - new CommandKeywords((new CmdWrite()), "block text"); - new CommandKeywords((new CmdWriteText()), "block text"); - new CommandKeywords((new CmdXban()), "ban undo admin mod"); - new CommandKeywords((new CmdXJail()), "extra jail undo"); - new CommandKeywords((new CmdXmute()), "mute extra"); - new CommandKeywords((new CmdZombieGame()), "zombie game"); - new CommandKeywords((new CmdZone()), "area"); - } - - public void Addcustom(Command cmd, string keywords) { - new CommandKeywords(cmd, keywords); - } - - public static string[] Find(string word) { - if (word == "") return null; - List list = new List(); - - foreach (CommandKeywords ckw in CommandKeywords.all) - foreach (string key in ckw.Keywords) - { - if (key == "" || key.IndexOf(word, comp) < 0) continue; - list.Add(ckw.CmdName); break; - } - return list.Count == 0 ? null : list.ToArray(); - } - - public static string[] Find(string[] words) { - List list = new List(); - - foreach (CommandKeywords ckw in CommandKeywords.all) - foreach (string key in ckw.Keywords) - { - for (int i = 0; i < words.Length; i++) { - if (key == "" || key.IndexOf(words[i], comp) < 0) continue; - if (!list.Contains(ckw.CmdName)) list.Add(ckw.CmdName); - break; - } - } - return list.Count == 0 ? null : list.ToArray(); - } - } -} diff --git a/Commands/Information/CmdSearch.cs b/Commands/Information/CmdSearch.cs index 307d18175..b58355790 100644 --- a/Commands/Information/CmdSearch.cs +++ b/Commands/Information/CmdSearch.cs @@ -35,9 +35,7 @@ namespace MCGalaxy.Commands { args[0] = args[0].ToLower(); string keyword = args[1]; - if (args[0] == "cmd" || args[0] == "cmds" || args[0] == "command" || args[0] == "commands") { - SearchCommands(p, keyword); - } else if (args[0] == "block" || args[0] == "blocks") { + if (args[0] == "block" || args[0] == "blocks") { SearchBlocks(p, keyword); } else if (args[0] == "rank" || args[0] == "ranks") { SearchRanks(p, keyword); @@ -52,27 +50,6 @@ namespace MCGalaxy.Commands { } } - static void SearchCommands(Player p, string keyword) { - if (keyword.Length <= 2) { - Player.Message(p, "You need to enter at least three characters to search for."); return; - } - string[] keywords = keyword.Split(' '); - string[] found = keywords.Length == 1 ? - CommandKeywords.Find(keyword) : CommandKeywords.Find(keywords); - if (found == null) { - Player.Message(p, "No commands found matching keyword(s): '" + keyword + "'"); return; - } - - StringBuilder cmds = new StringBuilder(); - bool mode = true; - Player.Message(p, "&bCommands found: "); - foreach (string cmd in found) { - cmds.Append(mode ? "%S, &9" : "%S, &2").Append(cmd); - mode = !mode; - } - Player.Message(p, cmds.ToString(4, cmds.Length - 4)); - } - static void SearchBlocks(Player p, string keyword) { StringBuilder blocks = new StringBuilder(); bool mode = true; @@ -141,7 +118,6 @@ namespace MCGalaxy.Commands { } public override void Help(Player p) { - Player.Message(p, "&b/search &2commands &a &e- finds commands with those keywords"); Player.Message(p, "&b/search &2blocks &a &e- finds blocks with that keyword"); Player.Message(p, "&b/search &2ranks &a &e- finds blocks with that keyword"); Player.Message(p, "&b/search &2players &a &e- find players with that keyword"); diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index b508e0de2..201398e31 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -180,7 +180,6 @@ - diff --git a/Server/Server.Tasks.cs b/Server/Server.Tasks.cs index a15fbb394..5f2b4fd72 100644 --- a/Server/Server.Tasks.cs +++ b/Server/Server.Tasks.cs @@ -177,7 +177,6 @@ namespace MCGalaxy { Log("Finished setting up server, finding classicube.net url.."); ServerSetupFinished = true; Checktimer.StartTimer(); - Commands.CommandKeywords.SetKeyWords(); try { if (Server.lava.startOnStartup)