From b0ee528cb3c5ab5432247c4198d1fc158708326e Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Fri, 1 Jul 2016 17:12:56 +1000 Subject: [PATCH] Combine /pass, /setpass, and /resetpass into one command. --- Commands/Bots/CmdBotSet.cs | 2 +- Commands/CPE/CmdModel.cs | 2 +- Commands/CPE/CmdSkin.cs | 2 +- Commands/Chat/CmdChatRoom.cs | 8 +- Commands/Chat/CmdColor.cs | 2 +- Commands/Chat/CmdNick.cs | 2 +- Commands/Chat/CmdTColor.cs | 2 +- Commands/Chat/CmdTitle.cs | 2 +- Commands/Command.Helpers.cs | 2 +- Commands/Economy/CmdEconomy.cs | 2 +- Commands/Fun/CmdTeam.cs | 2 +- Commands/Information/CmdRules.cs | 2 +- Commands/Moderation/CmdHide.cs | 2 +- Commands/Moderation/CmdReview.cs | 6 +- Commands/Moderation/CmdZone.cs | 6 +- Commands/World/CmdMain.cs | 2 +- Commands/World/CmdMap.cs | 2 +- Commands/World/CmdReload.cs | 2 +- Commands/building/CmdUndo.cs | 4 +- Commands/other/CmdPass.cs | 188 ++++++++++++++++--------------- Commands/other/CmdReport.cs | 8 +- Commands/other/CmdResetPass.cs | 61 ---------- Commands/other/CmdSetPass.cs | 78 ------------- Commands/other/CmdTnt.cs | 8 +- Commands/other/CmdWarp.cs | 6 +- MCGalaxy_.csproj | 2 - Player/Player.Handlers.cs | 17 ++- 27 files changed, 145 insertions(+), 277 deletions(-) delete mode 100644 Commands/other/CmdResetPass.cs delete mode 100644 Commands/other/CmdSetPass.cs diff --git a/Commands/Bots/CmdBotSet.cs b/Commands/Bots/CmdBotSet.cs index 0ed83b38a..41c1909d9 100644 --- a/Commands/Bots/CmdBotSet.cs +++ b/Commands/Bots/CmdBotSet.cs @@ -60,7 +60,7 @@ namespace MCGalaxy.Commands { BotsFile.UpdateBot(bot); return; } else if (ai == "kill") { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can toggle a bot's killer instinct."); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can toggle a bot's killer instinct."); return; } bot.kill = !bot.kill; if (p != null) Chat.GlobalChatLevel(p, bot.ColoredName + "%S's kill instinct: " + bot.kill, false); Server.s.Log(bot.name + "'s kill instinct: " + bot.kill); diff --git a/Commands/CPE/CmdModel.cs b/Commands/CPE/CmdModel.cs index 42b188d9c..d44e0ed06 100644 --- a/Commands/CPE/CmdModel.cs +++ b/Commands/CPE/CmdModel.cs @@ -70,7 +70,7 @@ namespace MCGalaxy.Commands.CPE { if (p != null && who != null && who.group.Permission > p.group.Permission) { MessageTooHighRank(p, "change the model of", true); return; } - if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedPerms(p, "can change the model of others."); return; } + if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedExtra(p, "can change the model of others."); return; } if (isBot) { bot.model = model; diff --git a/Commands/CPE/CmdSkin.cs b/Commands/CPE/CmdSkin.cs index 13d14a07f..b4714c9c0 100644 --- a/Commands/CPE/CmdSkin.cs +++ b/Commands/CPE/CmdSkin.cs @@ -61,7 +61,7 @@ namespace MCGalaxy.Commands.CPE { if (p != null && who != null && who.group.Permission > p.group.Permission) { MessageTooHighRank(p, "change the skin of", true); return; } - if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedPerms(p, "can change the skin of others."); return; } + if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedExtra(p, "can change the skin of others."); return; } if (skin[0] == '+') skin = "http://skins.minecraft.net/MinecraftSkins/" + skin.Substring(1) + ".png"; diff --git a/Commands/Chat/CmdChatRoom.cs b/Commands/Chat/CmdChatRoom.cs index 6d618cc13..f9fbbb5e2 100644 --- a/Commands/Chat/CmdChatRoom.cs +++ b/Commands/Chat/CmdChatRoom.cs @@ -105,7 +105,7 @@ namespace MCGalaxy.Commands { } void HandleCreate(Player p, string[] parts) { - if (!CheckExtraPerm(p, 1)) { MessageNeedPerms(p, "can create a chatroom.", 1); return; } + if (!CheckExtraPerm(p, 1)) { MessageNeedExtra(p, "can create a chatroom.", 1); return; } if (parts.Length <= 1) { Player.Message(p, "You need to provide a new chatroom name."); return; @@ -170,7 +170,7 @@ namespace MCGalaxy.Commands { } void HandleSpy(Player p, string[] parts) { - if (!CheckExtraPerm(p, 4)) { MessageNeedPerms(p, "can spy on a chatroom.", 4); return; } + if (!CheckExtraPerm(p, 4)) { MessageNeedExtra(p, "can spy on a chatroom.", 4); return; } if (parts.Length <= 1) { Player.Message(p, "You need to provide a chatroom name to spy on."); return; @@ -194,7 +194,7 @@ namespace MCGalaxy.Commands { } void HandleForceJoin(Player p, string[] parts) { - if (!CheckExtraPerm(p, 5)) { MessageNeedPerms(p, "can force players to join a chatroom.", 5); return; } + if (!CheckExtraPerm(p, 5)) { MessageNeedExtra(p, "can force players to join a chatroom.", 5); return; } if (parts.Length <= 2) { Player.Message(p, "You need to provide a player name, then a chatroom name."); return; @@ -223,7 +223,7 @@ namespace MCGalaxy.Commands { } void HandleKick(Player p, string[] parts) { - if (!CheckExtraPerm(p, 6)) { MessageNeedPerms(p, "can kick players from a chatroom.", 6); return; } + if (!CheckExtraPerm(p, 6)) { MessageNeedExtra(p, "can kick players from a chatroom.", 6); return; } if (parts.Length <= 1) { Player.Message(p, "You need to provide a player name."); return; diff --git a/Commands/Chat/CmdColor.cs b/Commands/Chat/CmdColor.cs index 21ce76ecd..e216428d7 100644 --- a/Commands/Chat/CmdColor.cs +++ b/Commands/Chat/CmdColor.cs @@ -50,7 +50,7 @@ namespace MCGalaxy.Commands { if (p != null && who != null && who.group.Permission > p.group.Permission) { MessageTooHighRank(p, "change the color of", true); return; } - if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedPerms(p, "can change the color of others."); return; } + if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedExtra(p, "can change the color of others."); return; } if (isBot) SetBotColor(p, pBot, args); else SetColor(p, who, args); } diff --git a/Commands/Chat/CmdNick.cs b/Commands/Chat/CmdNick.cs index e71257cb7..480dbb902 100644 --- a/Commands/Chat/CmdNick.cs +++ b/Commands/Chat/CmdNick.cs @@ -51,7 +51,7 @@ namespace MCGalaxy.Commands { if (p != null && who != null && who.group.Permission > p.group.Permission) { MessageTooHighRank(p, "change the nick of", true); return; } - if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedPerms(p, "can change the nick of others."); return; } + if ((isBot || who != p) && !CheckExtraPerm(p)) { MessageNeedExtra(p, "can change the nick of others."); return; } if (isBot) SetBotNick(p, pBot, args); else SetNick(p, who, args); } diff --git a/Commands/Chat/CmdTColor.cs b/Commands/Chat/CmdTColor.cs index 478819555..36d329eb6 100644 --- a/Commands/Chat/CmdTColor.cs +++ b/Commands/Chat/CmdTColor.cs @@ -44,7 +44,7 @@ namespace MCGalaxy.Commands { if (p != null && who.group.Permission > p.group.Permission) { MessageTooHighRank(p, "change the title color of", true); return; } - if (who != p && !CheckExtraPerm(p)) { MessageNeedPerms(p, "can change the title color of others."); return; } + if (who != p && !CheckExtraPerm(p)) { MessageNeedExtra(p, "can change the title color of others."); return; } SetTColor(p, who, args); } diff --git a/Commands/Chat/CmdTitle.cs b/Commands/Chat/CmdTitle.cs index 6db37aca6..acf4721b2 100644 --- a/Commands/Chat/CmdTitle.cs +++ b/Commands/Chat/CmdTitle.cs @@ -45,7 +45,7 @@ namespace MCGalaxy.Commands { if (p != null && who.group.Permission > p.group.Permission) { MessageTooHighRank(p, "change the title of", true); return; } - if (who != p && !CheckExtraPerm(p)) { MessageNeedPerms(p, "can change the title of others."); return; } + if (who != p && !CheckExtraPerm(p)) { MessageNeedExtra(p, "can change the title of others."); return; } SetTitle(p, who, args); } diff --git a/Commands/Command.Helpers.cs b/Commands/Command.Helpers.cs index c871ed006..721ffb30e 100644 --- a/Commands/Command.Helpers.cs +++ b/Commands/Command.Helpers.cs @@ -65,7 +65,7 @@ namespace MCGalaxy { return p == null || (int)p.group.Permission >= CommandOtherPerms.GetPerm(this, num); } - protected void MessageNeedPerms(Player p, string action, int num = 1) { + protected void MessageNeedExtra(Player p, string action, int num = 1) { int perm = CommandOtherPerms.GetPerm(this, num); MessageNeedMinPerm(p, action, perm); } diff --git a/Commands/Economy/CmdEconomy.cs b/Commands/Economy/CmdEconomy.cs index d620612ca..2ded301fb 100644 --- a/Commands/Economy/CmdEconomy.cs +++ b/Commands/Economy/CmdEconomy.cs @@ -42,7 +42,7 @@ namespace MCGalaxy.Commands { } void HandleSetup(Player p, string message, string[] args) { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can setup the economy."); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can setup the economy."); return; } switch (args[0].ToLower()) { case "apply": diff --git a/Commands/Fun/CmdTeam.cs b/Commands/Fun/CmdTeam.cs index 66ed467b2..574624394 100644 --- a/Commands/Fun/CmdTeam.cs +++ b/Commands/Fun/CmdTeam.cs @@ -117,7 +117,7 @@ namespace MCGalaxy.Commands { } void HandleCreate(Player p, string[] args) { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can create a team.", 1); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can create a team.", 1); return; } Team team = p.Game.Team; if (team != null) { Player.Message(p, "You need to leave your current team before you can create one."); return; } if (args.Length == 1) { diff --git a/Commands/Information/CmdRules.cs b/Commands/Information/CmdRules.cs index 5fa2e953d..3b73fb60f 100644 --- a/Commands/Information/CmdRules.cs +++ b/Commands/Information/CmdRules.cs @@ -39,7 +39,7 @@ namespace MCGalaxy.Commands Player who = p; if (message != "") { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can send the rules to a player."); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can send the rules to a player."); return; } who = PlayerInfo.FindMatches(p, message); if (who == null) return; } diff --git a/Commands/Moderation/CmdHide.cs b/Commands/Moderation/CmdHide.cs index 8e5086f45..a6990171d 100644 --- a/Commands/Moderation/CmdHide.cs +++ b/Commands/Moderation/CmdHide.cs @@ -44,7 +44,7 @@ namespace MCGalaxy.Commands } bool messageOps = true; if (message.CaselessEq("silent")) { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can hide silently"); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can hide silently"); return; } messageOps = false; } diff --git a/Commands/Moderation/CmdReview.cs b/Commands/Moderation/CmdReview.cs index 32ffe1bd9..a442a55a6 100644 --- a/Commands/Moderation/CmdReview.cs +++ b/Commands/Moderation/CmdReview.cs @@ -95,7 +95,7 @@ namespace MCGalaxy.Commands { } void HandleView(Player p) { - if (!CheckExtraPerm(p, 1)) { MessageNeedPerms(p, "can view the review queue.", 1); return; } + if (!CheckExtraPerm(p, 1)) { MessageNeedExtra(p, "can view the review queue.", 1); return; } if (Server.reviewlist.Count == 0) { Player.Message(p, "There are no players in the review queue."); return; @@ -126,7 +126,7 @@ namespace MCGalaxy.Commands { void HandleNext(Player p) { if (p == null) { Player.Message(p, "Console cannot answer the review queue."); return; } - if (!CheckExtraPerm(p, 2)) { MessageNeedPerms(p, "can teleport to next in the review queue.", 2); return; } + if (!CheckExtraPerm(p, 2)) { MessageNeedExtra(p, "can teleport to next in the review queue.", 2); return; } if (Server.reviewlist.Count == 0) { Player.Message(p, "There are no players in the review queue."); return; } @@ -150,7 +150,7 @@ namespace MCGalaxy.Commands { } void HandleClear(Player p) { - if (!CheckExtraPerm(p, 3)) { MessageNeedPerms(p, "can clear the review queue.", 3); return; } + if (!CheckExtraPerm(p, 3)) { MessageNeedExtra(p, "can clear the review queue.", 3); return; } Server.reviewlist.Clear(); Player.Message(p, "The review queue has been cleared"); } diff --git a/Commands/Moderation/CmdZone.cs b/Commands/Moderation/CmdZone.cs index d62c02e10..d3f75ebbc 100644 --- a/Commands/Moderation/CmdZone.cs +++ b/Commands/Moderation/CmdZone.cs @@ -38,7 +38,7 @@ namespace MCGalaxy.Commands { Player.Message(p, "Place a block where you would like to check for zones."); p.MakeSelection(1, null, CheckZone); } else if (args[0].CaselessEq("add")) { - if (!CheckExtraPerm(p, 3)) { MessageNeedPerms(p, "can create zones.", 3); return; } + if (!CheckExtraPerm(p, 3)) { MessageNeedExtra(p, "can create zones.", 3); return; } if (args.Length == 1) { Help(p); return; } if (Group.Find(args[1]) != null) @@ -49,7 +49,7 @@ namespace MCGalaxy.Commands { Player.Message(p, "Zone for: &b" + args[1] + "."); p.MakeSelection(2, args[1], AddZone); } else if (args[0].CaselessEq("del") && args.Length > 1 && args[1].CaselessEq("all")) { - if (!CheckExtraPerm(p, 2)) { MessageNeedPerms(p, "can delete all zones.", 2); return; } + if (!CheckExtraPerm(p, 2)) { MessageNeedExtra(p, "can delete all zones.", 2); return; } for (int i = 0; i < p.level.ZoneList.Count; i++) { Level.Zone Zn = p.level.ZoneList[i]; @@ -60,7 +60,7 @@ namespace MCGalaxy.Commands { i--; } } else if (args[0].CaselessEq("del")) { - if (!CheckExtraPerm(p, 1)) { MessageNeedPerms(p, "can delete zones.", 1); return; } + if (!CheckExtraPerm(p, 1)) { MessageNeedExtra(p, "can delete zones.", 1); return; } if (p.canBuild) { //Checks if player can build there Player.Message(p, "Place a block where you would like to delete a zone."); diff --git a/Commands/World/CmdMain.cs b/Commands/World/CmdMain.cs index aebdb285e..d0228ab32 100644 --- a/Commands/World/CmdMain.cs +++ b/Commands/World/CmdMain.cs @@ -35,7 +35,7 @@ namespace MCGalaxy.Commands.World { } PlayerActions.ChangeMap(p, Server.mainLevel.name); } else { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "change the main level"); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "change the main level"); return; } if (!ValidName(p, message, "level")) return; string map = LevelInfo.FindMapMatches(p, message); diff --git a/Commands/World/CmdMap.cs b/Commands/World/CmdMap.cs index ed25aba5b..62a9a1094 100644 --- a/Commands/World/CmdMap.cs +++ b/Commands/World/CmdMap.cs @@ -72,7 +72,7 @@ namespace MCGalaxy.Commands.World { if (lvl == null || message.Split(' ')[0].ToLower() == "ps" || message.Split(' ')[0].ToLower() == "rp") lvl = p.level; else message = message.Substring(message.IndexOf(' ') + 1); } - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can set map options."); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can set map options."); return; } string foundStart; if (message.IndexOf(' ') == -1) foundStart = message.ToLower(); diff --git a/Commands/World/CmdReload.cs b/Commands/World/CmdReload.cs index f8836ab0a..8b7a54797 100644 --- a/Commands/World/CmdReload.cs +++ b/Commands/World/CmdReload.cs @@ -60,7 +60,7 @@ namespace MCGalaxy.Commands { SuperRequiresArgs(name + " all", p, "level name"); return false; } - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can reload all players in a map."); return false; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can reload all players in a map."); return false; } Player[] players = PlayerInfo.Online.Items; foreach (Player who in players) { if (who.level == lvl) diff --git a/Commands/building/CmdUndo.cs b/Commands/building/CmdUndo.cs index e028f8bb2..ab3e4b236 100644 --- a/Commands/building/CmdUndo.cs +++ b/Commands/building/CmdUndo.cs @@ -146,13 +146,13 @@ namespace MCGalaxy.Commands.Building { } bool CheckUndoPerms(Player p, Group grp) { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can undo other players."); return false; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can undo other players."); return false; } if (grp.Permission > p.group.Permission) { MessageTooHighRank(p, "undo", true); return false; } return true; } void UndoLevelPhysics(Player p, long seconds) { - if (!CheckExtraPerm(p, 2)) { MessageNeedPerms(p, "can undo physics.", 2); return; } + if (!CheckExtraPerm(p, 2)) { MessageNeedExtra(p, "can undo physics.", 2); return; } if (p != null && !p.group.CanExecute("physics")) { Player.Message(p, "You can only undo physics if you can use /physics."); return; } diff --git a/Commands/other/CmdPass.cs b/Commands/other/CmdPass.cs index 929389910..694dfec3c 100644 --- a/Commands/other/CmdPass.cs +++ b/Commands/other/CmdPass.cs @@ -1,22 +1,22 @@ /* + Written by Jack1312 + Copyright 2011-2012 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. - Copyright 2012 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.IO; using MCGalaxy.Util; @@ -28,79 +28,91 @@ namespace MCGalaxy.Commands { public override string type { get { return CommandTypes.Other; } } public override bool museumUsable { get { return true; } } public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - - public CmdPass() { } - - public override void Use(Player p, string message) - { - - if (p.group.Permission < Server.verifyadminsrank) - { - Player.Message(p, "You do not have the &crequired rank to use this command!"); - return; - } - - if (!Server.verifyadmins) - { - Player.Message(p, "Verification of admins is &cdisabled!"); - return; - } - - if (!p.adminpen) - { - Player.Message(p, "You have &calready verified."); - return; - } - - if (p.passtries >= 3) - { - p.Kick("Did you really think you could keep on guessing?"); - return; - } - - if (String.IsNullOrEmpty(message.Trim())) - { - Help(p); - return; - } - - int number = message.Split(' ').Length; - - if (number > 1) - { - Player.Message(p, "Your password must be &cone %Sword!"); - return; - } - - if (!Directory.Exists("extra/passwords")) - { - Player.Message(p, "You have not &cset a password, %Suse &a/setpass [Password] &cto set one!"); - return; - } - - if (!File.Exists("extra/passwords/" + p.name + ".dat")) - { - Player.Message(p, "You have not &cset a password, %Suse &a/setpass [Password] &cto set one!"); - return; - } - - if (PasswordHasher.MatchesPass(p.name, message)) - { - Player.Message(p, "Thank you, " + p.color + p.name + "%S! You have now &averified %Sand have &aaccess to admin commands and features!"); - p.adminpen = false; - return; - } - - p.passtries++; - Player.Message(p, "&cWrong Password. %SRemember your password is &ccase sensitive!"); - Player.Message(p, "Forgot your password? %SContact the owner so they can reset it!"); + public override CommandAlias[] Aliases { + get { return new[] { new CommandAlias("setpass", "set"), new CommandAlias("resetpass", "reset") }; } } - public override void Help(Player p) - { - Player.Message(p, "/pass [Password] - If you are an admin, use this command to verify"); - Player.Message(p, "your login. You will need to use this to be given access to commands"); - Player.Message(p, "Note: If you do not have a password, use /setpass [Password]"); + public override void Use(Player p, string message) { + if (!Directory.Exists("extra/passwords")) + Directory.CreateDirectory("extra/passwords"); + if (p.group.Permission < Server.verifyadminsrank) { + MessageNeedMinPerm(p, "verify or set a password", (int)Server.verifyadminsrank); return; + } + if (!Server.verifyadmins) { Player.Message(p, "Admin verficiation is not currently enabled."); return; } + if (message == "") { Help(p); return; } + + string[] args = message.SplitSpaces(2); + if (args.Length == 2 && args[1].CaselessEq("set")) + SetPassword(p, args[1]); + else if (args.Length == 2 && args[1].CaselessEq("reset")) + ResetPassword(p, args[1]); + else + VerifyPassword(p, message); + } + + void VerifyPassword(Player p, string message) { + if (!p.adminpen) { Player.Message(p, "You are &calready verified."); return; } + if (p.passtries >= 3) { p.Kick("Did you really think you could keep on guessing?"); return; } + + if (message.IndexOf(' ') >= 0) { Player.Message(p, "Your password must be &cone %Sword!"); return; } + if (!File.Exists("extra/passwords/" + p.name + ".dat")) { + Player.Message(p, "You have not &cset a password, %Suse &a/setpass [Password] &cto set one!"); return; + } + + if (PasswordHasher.MatchesPass(p.name, message)) { + Player.Message(p, "You are now &averified %Sand have &aaccess to admin commands and features."); + p.adminpen = false; + } else { + p.passtries++; + Player.Message(p, "&cWrong Password. %SRemember your password is &ccase sensitive."); + Player.Message(p, "Forgot your password? %SContact the owner so they can reset it."); + } + } + + void SetPassword(Player p, string message) { + if (p.adminpen && File.Exists("extra/passwords/" + p.name + ".dat")) { + Player.Message(p, "&cYou already have a password set. %SYou &ccannot change %Sit unless &cyou verify it with &a/pass [Password]. " + + "%SIf you have &cforgotten %Syour password, contact &c" + Server.server_owner + " %Sand they can &creset it!"); + return; + } + if (message.IndexOf(' ') >= 0) { Player.Message(p, "Your password must be one word!"); return; } + + PasswordHasher.StoreHash(p.name, message); + Player.Message(p, "Your password has &asuccessfully &abeen set to:"); + Player.Message(p, "&c" + message); + } + + void ResetPassword(Player p, string message) { + if (message == "") { Help(p); return; } + Player who = PlayerInfo.FindMatches(p, message); + if (who == null) return; + if (p != null && p.adminpen) { + Player.Message(p, "&cYou must first verify with %T/pass [Password]"); return; + } + + if (p != null && (Server.server_owner == "Notch" || Server.server_owner == "")) { + Player.Message(p, "Please tell the server owner to set the 'Server Owner' property."); + return; + } + if (p != null && Server.server_owner != p.name) { + Player.Message(p, "Only console and the server owner may reset passwords."); return; + } + + if (!File.Exists("extra/passwords/" + who.name + ".dat")) { + Player.Message(p, "That player does not have a password."); return; + } + File.Delete("extra/passwords/" + who.name + ".dat"); + Player.Message(p, "Password sucessfully removed for " + who.ColoredName + "%S."); + } + + public override void Help(Player p) { + Player.Message(p, "%T/pass reset [Player] %H- Resets the password for that player"); + Player.Message(p, "%H Note: Can only be used by console and the server owner."); + Player.Message(p, "%T/pass set [Password] %H- Sets your password to [password]"); + Player.Message(p, "%H Note: &cDo NOT set this as your Minecraft password!"); + Player.Message(p, "%T/pass [Password]"); + Player.Message(p, "%HIf you are an admin, use this command to verify your login. " + + "You will need to be verified to be able to use commands."); } } } diff --git a/Commands/other/CmdReport.cs b/Commands/other/CmdReport.cs index 57138b0eb..303cff45c 100644 --- a/Commands/other/CmdReport.cs +++ b/Commands/other/CmdReport.cs @@ -59,7 +59,7 @@ namespace MCGalaxy.Commands { } void HandleList(Player p, string[] args) { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can see the list of reports."); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can see the list of reports."); return; } bool foundone = false; string[] files = Directory.GetFiles("extra/reported", "*.txt"); @@ -81,7 +81,7 @@ namespace MCGalaxy.Commands { if (args.Length != 2) { Player.Message(p, "You need to provide a player's name."); return; } - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can view the details of a report."); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can view the details of a report."); return; } if (!ValidName(p, args[1], "player")) return; if (!File.Exists("extra/reported/" + args[1] + ".txt")) { @@ -95,7 +95,7 @@ namespace MCGalaxy.Commands { if (args.Length != 2) { Player.Message(p, "You need to provide a player's name."); return; } - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can delete reports."); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can delete reports."); return; } if (!ValidName(p, args[1], "player")) return; if (!File.Exists("extra/reported/" + args[1] + ".txt")) { @@ -113,7 +113,7 @@ namespace MCGalaxy.Commands { } void HandleClear(Player p, string[] args) { - if (!CheckExtraPerm(p)) { MessageNeedPerms(p, "can clear the list of reports."); return; } + if (!CheckExtraPerm(p)) { MessageNeedExtra(p, "can clear the list of reports."); return; } if (!Directory.Exists("extra/reportedbackups")) Directory.CreateDirectory("extra/reportedbackups"); string[] files = Directory.GetFiles("extra/reported", "*.txt"); diff --git a/Commands/other/CmdResetPass.cs b/Commands/other/CmdResetPass.cs deleted file mode 100644 index 991276d0f..000000000 --- a/Commands/other/CmdResetPass.cs +++ /dev/null @@ -1,61 +0,0 @@ -/* - Written by Jack1312 - - 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 System.IO; - -namespace MCGalaxy.Commands { - - public class CmdResetPass : Command { - public override string name { get { return "resetpass"; } } - public override string shortcut { get { return ""; } } - public override string type { get { return CommandTypes.Other; } } - public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.Admin; } } - public CmdResetPass() { } - - public override void Use(Player p, string message) { - if (message == "") { Help(p); return; } - Player who = PlayerInfo.FindMatches(p, message); - if (who == null) return; - - if (p != null && (Server.server_owner == "Notch" || Server.server_owner == "")) { - Player.Message(p, "Please tell the server owner to change the 'Server Owner' property."); - return; - } - if (p != null && Server.server_owner != p.name) { - Player.Message(p, "You're not the server owner!"); return; - } - - if (!File.Exists("extra/passwords/" + who.name + ".dat")) { - Player.Message(p, "The player you specified does not have a password!"); return; - } - File.Delete("extra/passwords/" + who.name + ".dat"); - Player.Message(p, "The admin password has sucessfully been removed for " + who.ColoredName + "!"); - } - - public override void Help(Player p) { - Player.Message(p, "%T/resetpass [Player]"); - Player.Message(p, "%HResets the password for the specified player."); - Player.Message(p, "%HNote: Can only be used by console and the server owner."); - } - } -} diff --git a/Commands/other/CmdSetPass.cs b/Commands/other/CmdSetPass.cs deleted file mode 100644 index b68dfd785..000000000 --- a/Commands/other/CmdSetPass.cs +++ /dev/null @@ -1,78 +0,0 @@ -/* - - Copyright 2012 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.IO; -using MCGalaxy.Util; - -namespace MCGalaxy.Commands { - public sealed class CmdSetPass : Command { - public override string name { get { return "setpass"; } } - public override string shortcut { get { return ""; } } - public override string type { get { return CommandTypes.Other; } } - public override bool museumUsable { get { return true; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } - public CmdSetPass() { } - - public override void Use(Player p, string message) - { - if (!Directory.Exists("extra/passwords")) - Directory.CreateDirectory("extra/passwords"); - if (p.group.Permission < Server.verifyadminsrank) - { - Player.Message(p, "You do not have the &crequired rank %Sto use this command!"); - return; - } - if (!Server.verifyadmins) - { - Player.Message(p, "Verification of admins is &cdisabled!"); - return; - } - if (p.adminpen) - { - if (File.Exists("extra/passwords/" + p.name + ".dat")) - { - Player.Message(p, "&cYou already have a password set. %SYou &ccannot change %Sit unless &cyou verify it with &a/pass [Password]. " + - "%SIf you have &cforgotten %Syour password, contact &c" + Server.server_owner + " %Sand they can &creset it!"); - return; - } - } - if (String.IsNullOrEmpty(message.Trim())) - { - Help(p); - return; - - } - int number = message.Split(' ').Length; - if (number > 1) - { - Player.Message(p, "Your password must be one word!"); - return; - } - PasswordHasher.StoreHash(p.name, message); - Player.Message(p, "Your password has &asuccessfully &abeen set to:"); - Player.Message(p, "&c" + message); - } - - public override void Help(Player p) { - Player.Message(p, "%T/setpass [Password]"); - Player.Message(p, "%HSets your admin password to [password]."); - Player.Message(p, "%HNote: &cDo NOT set this as your Minecraft password!"); - } - } -} diff --git a/Commands/other/CmdTnt.cs b/Commands/other/CmdTnt.cs index c23a45d03..f328d627e 100644 --- a/Commands/other/CmdTnt.cs +++ b/Commands/other/CmdTnt.cs @@ -56,7 +56,7 @@ namespace MCGalaxy.Commands p.modeType = Block.bigtnt; Player.Message(p, "TNT (Big) mode is now &aON%S."); } else { - MessageNeedPerms(p, "can use big TNT mode.", 1); return; + MessageNeedExtra(p, "can use big TNT mode.", 1); return; } } else if (message.ToLower() == "nuke") { if (!p.allowTnt) { @@ -67,20 +67,20 @@ namespace MCGalaxy.Commands p.modeType = Block.nuketnt; Player.Message(p, "TNT (Nuke) mode is now &aON%S."); } else { - MessageNeedPerms(p, "can use nuke TNT mode.", 3); return; + MessageNeedExtra(p, "can use nuke TNT mode.", 3); return; } } else if (message.ToLower() == "allow") { if (CheckExtraPerm(p, 2)) { p.allowTnt = true; Player.Message(p, "&cTnt usage has now been enabled!"); } else { - MessageNeedPerms(p, "can allow TNT usage.", 2); return; + MessageNeedExtra(p, "can allow TNT usage.", 2); return; } return; } else if (message.ToLower() == "disallow") { if (CheckExtraPerm(p, 2)) { p.allowTnt = false; Player.Message(p, "&cTnt usage has now been disabled!"); } else { - MessageNeedPerms(p, "can disallow TNT usage.", 2); return; + MessageNeedExtra(p, "can disallow TNT usage.", 2); return; } return; } else { diff --git a/Commands/other/CmdWarp.cs b/Commands/other/CmdWarp.cs index 0c5918004..1e5adaee3 100644 --- a/Commands/other/CmdWarp.cs +++ b/Commands/other/CmdWarp.cs @@ -86,7 +86,7 @@ namespace MCGalaxy.Commands } } } - else { MessageNeedPerms(p, "can create warps.", 1); return; } + else { MessageNeedExtra(p, "can create warps.", 1); return; } } if (par0 == "delete" || par0 == "remove" || par0 == "d" || par0 == "r") @@ -111,7 +111,7 @@ namespace MCGalaxy.Commands } } } - else { MessageNeedPerms(p, "can delete warps.", 2); return; } + else { MessageNeedExtra(p, "can delete warps.", 2); return; } } if (par0 == "move" || par0 == "change" || par0 == "edit" || par0 == "m" || par0 == "e") @@ -137,7 +137,7 @@ namespace MCGalaxy.Commands } } } - else { MessageNeedPerms(p, "can move warps.", 3); return; } + else { MessageNeedExtra(p, "can move warps.", 3); return; } } else diff --git a/MCGalaxy_.csproj b/MCGalaxy_.csproj index 666998642..1636eb5d7 100644 --- a/MCGalaxy_.csproj +++ b/MCGalaxy_.csproj @@ -346,11 +346,9 @@ - - diff --git a/Player/Player.Handlers.cs b/Player/Player.Handlers.cs index 0e4eb94be..9fc95c725 100644 --- a/Player/Player.Handlers.cs +++ b/Player/Player.Handlers.cs @@ -62,8 +62,8 @@ namespace MCGalaxy { if ( !canBuild ) { RevertBlock(x, y, z); return; } - if ( Server.verifyadmins && adminpen ) { - SendMessage("&cYou must use &a/pass [Password]&c to verify!"); + if (Server.verifyadmins && adminpen) { + SendMessage("&cYou must first verify with %T/pass [Password]"); RevertBlock(x, y, z); return; } @@ -1235,8 +1235,8 @@ return; if (jailed) { SendMessage("You cannot use any commands while jailed."); return false; } - if (Server.verifyadmins && adminpen && !(cmd == "pass" || cmd == "setpass")) { - SendMessage("&cYou must use &a/pass [Password]&c to verify!"); return false; + if (Server.verifyadmins && adminpen && cmd != "pass") { + SendMessage("&cYou must verify first with %T/pass [Password]"); return false; } //DO NOT REMOVE THE TWO COMMANDS BELOW, /PONY AND /RAINBOWDASHLIKESCOOLTHINGS. -EricKilla @@ -1309,14 +1309,11 @@ return; bool UseCommand(Command command, string message) { string cmd = command.name; - if (!(cmd == "repeat" || cmd == "pass" || cmd == "setpass")) { + if (cmd != "repeat" && cmd != "pass") { lastCMD = cmd + " " + message; lastCmdTime = DateTime.Now; - } - - if (!(cmd == "pass" || cmd == "setpass")) { - Server.s.CommandUsed(name + " used /" + cmd + " " + message); - } + } + if (cmd != "pass") Server.s.CommandUsed(name + " used /" + cmd + " " + message); try { //opstats patch (since 5.5.11) if (Server.opstats.Contains(cmd) || (cmd == "review" && message.ToLower() == "next" && Server.reviewlist.Count > 0)) {