From a15b3aeccd0ed6858ea87683beacc51acc3d1d7c Mon Sep 17 00:00:00 2001 From: UnknownShadow200 Date: Mon, 11 Dec 2017 21:46:00 +1100 Subject: [PATCH] make games commands have 1 extra permission to maange them --- MCGalaxy/Commands/Fun/CTF/CmdCtf.cs | 28 ++++++---- MCGalaxy/Commands/Fun/CmdCountdown.cs | 55 ++++++------------- MCGalaxy/Commands/Fun/CmdLavaSurvival.cs | 18 ++---- MCGalaxy/Commands/Fun/RateMapCmds.cs | 1 + .../Fun/ZombieSurvival/CmdZombieGame.cs | 26 +++++---- MCGalaxy/Commands/Moderation/CmdReport.cs | 3 +- 6 files changed, 57 insertions(+), 74 deletions(-) diff --git a/MCGalaxy/Commands/Fun/CTF/CmdCtf.cs b/MCGalaxy/Commands/Fun/CTF/CmdCtf.cs index 8668fd840..fa73db7b2 100644 --- a/MCGalaxy/Commands/Fun/CTF/CmdCtf.cs +++ b/MCGalaxy/Commands/Fun/CTF/CmdCtf.cs @@ -27,9 +27,11 @@ namespace MCGalaxy.Commands.Fun { public override string shortcut { get { return "CTFSetup"; } } public override string type { get { return CommandTypes.Games; } } public override bool museumUsable { get { return false; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override bool SuperUseable { get { return false; } } - + public override CommandPerm[] ExtraPerms { + get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can manage CTF") }; } + } + public override void Use(Player p, string message) { if (message.CaselessEq("go")) { HandleGo(p); @@ -56,17 +58,19 @@ namespace MCGalaxy.Commands.Fun { PlayerActions.ChangeMap(p, Server.ctf.Map.name); } - static void HandleStart(Player p) { + void HandleStart(Player p) { + if (!CheckExtraPerm(p, 1)) return; if (Server.ctf == null) { Player.Message(p, "Initialising CTF.."); Server.ctf = new CTFGame(); } if (!Server.ctf.Start(p)) return; - Chat.MessageGlobal("A CTF GAME IS STARTING AT CTF! TYPE %T/Goto " + Server.ctf.Map.name + " %Sto join!"); + Chat.MessageGlobal("A CTF GAME IS STARTING! TYPE %T/CTF goto %Sto join!"); } - static void HandleStop(Player p) { + void HandleStop(Player p) { + if (!CheckExtraPerm(p, 1)) return; if (Server.ctf == null || !Server.ctf.started) { Player.Message(p, "No CTF game is active."); return; } @@ -74,7 +78,8 @@ namespace MCGalaxy.Commands.Fun { } - static void HandleAdd(Player p) { + void HandleAdd(Player p) { + if (!CheckExtraPerm(p, 1)) return; if (!Directory.Exists("CTF")) Directory.CreateDirectory("CTF"); List maps = GetCtfMaps(); @@ -87,7 +92,8 @@ namespace MCGalaxy.Commands.Fun { } } - static void HandleRemove(Player p) { + void HandleRemove(Player p) { + if (!CheckExtraPerm(p, 1)) return; if (!Directory.Exists("CTF")) Directory.CreateDirectory("CTF"); List maps = GetCtfMaps(); @@ -107,6 +113,7 @@ namespace MCGalaxy.Commands.Fun { void HandleSet(Player p, string property) { + if (!CheckExtraPerm(p, 1)) return; CTFConfig cfg = RetrieveConfig(p); if (property.CaselessEq("bluespawn")) { @@ -176,12 +183,11 @@ namespace MCGalaxy.Commands.Fun { } public override void Help(Player p) { - Player.Message(p, "%T/CTF go %H- Moves you to the current CTF map."); - Player.Message(p, "%T/CTF start/stop %H- Starts/stops the CTF game."); - Player.Message(p, "%T/CTF add/remove"); - Player.Message(p, "%HAdds or removes current map from list of CTF maps."); + Player.Message(p, "%T/CTF start/stop %H- Starts/stops the CTF game"); + Player.Message(p, "%T/CTF add/remove %H- Adds/removes current map from CTF map list"); Player.Message(p, "%T/CTF set [property]"); Player.Message(p, "%HSets a CTF game property, see %T/Help CTF set"); + Player.Message(p, "%T/CTF go %H- Moves you to the current CTF map"); } public override void Help(Player p, string message) { diff --git a/MCGalaxy/Commands/Fun/CmdCountdown.cs b/MCGalaxy/Commands/Fun/CmdCountdown.cs index 11e9a4653..ddffe1cdb 100644 --- a/MCGalaxy/Commands/Fun/CmdCountdown.cs +++ b/MCGalaxy/Commands/Fun/CmdCountdown.cs @@ -26,19 +26,16 @@ using MCGalaxy.Generator; namespace MCGalaxy.Commands.Fun { - public sealed class CmdCountdown : Command { + public sealed class CmdCountdown : Command { public override string name { get { return "CountDown"; } } public override string shortcut { get { return "CD"; } } public override string type { get { return CommandTypes.Games; } } public override bool museumUsable { get { return false; } } public override bool SuperUseable { get { return false; } } public override CommandPerm[] ExtraPerms { - get { return new[] { - new CommandPerm(LevelPermission.Operator, "+ can send the countdown rules to everybody"), - new CommandPerm(LevelPermission.Operator, "+ can setup and manage countdown"), - }; } + get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can manage countdown") }; } } - + public override void Use(Player p, string message) { if (message.Length == 0) { Help(p); return; } @@ -152,30 +149,15 @@ namespace MCGalaxy.Commands.Fun { } void HandleRules(Player p, string target) { - Player who = p; - if (target.Length > 0 && HasExtraPerm(p, 1)) { - who = PlayerInfo.FindMatches(p, target); - if (who == null) return; - - if (p.Rank < who.Rank) { - MessageTooHighRank(p, "send countdown rules", true); return; - } - } - - Player.Message(who, "The aim of the game is to stay alive the longest."); - Player.Message(who, "Don't fall in the lava!"); - Player.Message(who, "Blocks on the ground will disapear randomly, first going yellow, then orange, then red and finally disappearing."); - Player.Message(who, "The last person alive wins!"); - - if (p != who) { - Player.Message(who, "Countdown rules sent to you by " + p.ColoredName); - Player.Message(p, "Countdown rules sent to: " + who.ColoredName); - } + Player.Message(p, "The aim of the game is to stay alive the longest."); + Player.Message(p, "Don't fall in the lava!"); + Player.Message(p, "Blocks on the ground will disapear randomly, first going yellow, then orange, then red and finally disappearing."); + Player.Message(p, "The last person alive wins!"); } void HandleGenerate(Player p, CountdownGame game, string x, string y, string z) { - if (!CheckExtraPerm(p, 2)) return; + if (!CheckExtraPerm(p, 1)) return; int width, height, length; if(!int.TryParse(x, out width) || !int.TryParse(y, out height) || !int.TryParse(z, out length)) { @@ -190,7 +172,7 @@ namespace MCGalaxy.Commands.Fun { } void HandleEnable(Player p, CountdownGame game) { - if (!CheckExtraPerm(p, 2)) return; + if (!CheckExtraPerm(p, 1)) return; if (game.Status == CountdownGameStatus.Disabled) { game.Enable(p); @@ -200,7 +182,7 @@ namespace MCGalaxy.Commands.Fun { } void HandleDisable(Player p, CountdownGame game) { - if (!CheckExtraPerm(p, 2)) return; + if (!CheckExtraPerm(p, 1)) return; if (game.Status == CountdownGameStatus.Disabled) { Player.Message(p, "Countdown is not running."); return; @@ -210,7 +192,7 @@ namespace MCGalaxy.Commands.Fun { void HandleStart(Player p, CountdownGame game, string speed, string mode) { - if (!CheckExtraPerm(p, 2)) return; + if (!CheckExtraPerm(p, 1)) return; switch (game.Status) { case CountdownGameStatus.Disabled: @@ -243,7 +225,7 @@ namespace MCGalaxy.Commands.Fun { } void HandleEnd(Player p, CountdownGame game) { - if (!CheckExtraPerm(p, 2)) return; + if (!CheckExtraPerm(p, 1)) return; switch (game.Status) { case CountdownGameStatus.Disabled: @@ -256,7 +238,7 @@ namespace MCGalaxy.Commands.Fun { } void HandleReset(Player p, CountdownGame game, string type) { - if (!CheckExtraPerm(p, 2)) return; + if (!CheckExtraPerm(p, 1)) return; switch (game.Status) { case CountdownGameStatus.Disabled: @@ -273,14 +255,6 @@ namespace MCGalaxy.Commands.Fun { public override void Help(Player p) { - Player.Message(p, "%T/CD join/leave %H- joins/leaves the game"); - Player.Message(p, "%T/CD players %H- lists players currently playing"); - Player.Message(p, "%T/CD rules %H- view the rules of countdown"); - if (HasExtraPerm(p, 1)) { - Player.Message(p, "%T/CD rules [player] %H- sends rules to that player."); - } - - if (!HasExtraPerm(p, 2)) return; Player.Message(p, "%T/CD generate [width] [height] [length] %H- generates the countdown map (default is 32x32x32)"); Player.Message(p, "%T/CD enable/disable %H- enables/disables countdown"); Player.Message(p, "%T/CD start %H- starts a round of countdown"); @@ -288,6 +262,9 @@ namespace MCGalaxy.Commands.Fun { Player.Message(p, "%H mode can be: normal or freeze"); Player.Message(p, "%T/CD end %H- force ends current round of countdown"); Player.Message(p, "%T/CD reset %H- resets the map. %T/CD start %Halso resets map."); + Player.Message(p, "%T/CD join/leave %H- joins/leaves the game"); + Player.Message(p, "%T/CD players %H- lists players currently playing"); + Player.Message(p, "%T/CD rules %H- view the rules of countdown"); } } } diff --git a/MCGalaxy/Commands/Fun/CmdLavaSurvival.cs b/MCGalaxy/Commands/Fun/CmdLavaSurvival.cs index 45d41bdaf..5dcd1c4a3 100644 --- a/MCGalaxy/Commands/Fun/CmdLavaSurvival.cs +++ b/MCGalaxy/Commands/Fun/CmdLavaSurvival.cs @@ -27,8 +27,7 @@ namespace MCGalaxy.Commands.Fun { public override string type { get { return CommandTypes.Games; } } public override bool museumUsable { get { return false; } } public override CommandPerm[] ExtraPerms { - get { return new[] { new CommandPerm(LevelPermission.Admin, "+ can setup lava survival"), - new CommandPerm(LevelPermission.Operator, "+ can start/stop lava survival") }; } + get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can manage lava survival") }; } } public override void Use(Player p, string message) { @@ -262,17 +261,12 @@ namespace MCGalaxy.Commands.Fun { } public override void Help(Player p) { - Player.Message(p, "%T/LS go %H- Join the fun!"); + Player.Message(p, "%T/LS start %H- Starts Lava Survival, optionally on the given map."); + Player.Message(p, "%T/LS stop %H- Stops the current Lava Survival game."); + Player.Message(p, "%T/LS end %H- End the current round or vote."); + Player.Message(p, "%T/LS setup %H- Setup lava survival, use it for more info."); Player.Message(p, "%T/LS info %H- View current round info and time."); - - if (HasExtraPerm(p, 1)) { - Player.Message(p, "%T/LS start %H- Starts Lava Survival, optionally on the given map."); - Player.Message(p, "%T/LS stop %H- Stops the current Lava Survival game."); - Player.Message(p, "%T/LS end %H- End the current round or vote."); - } - if (HasExtraPerm(p, 2)) { - Player.Message(p, "%T/LS setup %H- Setup lava survival, use it for more info."); - } + Player.Message(p, "%T/LS go %H- Join the fun!"); } void SetupHelp(Player p, string mode = "") { diff --git a/MCGalaxy/Commands/Fun/RateMapCmds.cs b/MCGalaxy/Commands/Fun/RateMapCmds.cs index 61c7106fc..3ae5fb1c6 100644 --- a/MCGalaxy/Commands/Fun/RateMapCmds.cs +++ b/MCGalaxy/Commands/Fun/RateMapCmds.cs @@ -18,6 +18,7 @@ using System; namespace MCGalaxy.Commands.Fun { + public class CmdMapLike : Command { public override string name { get { return "MapLike"; } } public override string shortcut { get { return "Like"; } } diff --git a/MCGalaxy/Commands/Fun/ZombieSurvival/CmdZombieGame.cs b/MCGalaxy/Commands/Fun/ZombieSurvival/CmdZombieGame.cs index 054c477fb..5f4556bc0 100644 --- a/MCGalaxy/Commands/Fun/ZombieSurvival/CmdZombieGame.cs +++ b/MCGalaxy/Commands/Fun/ZombieSurvival/CmdZombieGame.cs @@ -25,10 +25,12 @@ namespace MCGalaxy.Commands.Fun { public override string shortcut { get { return "ZG"; } } public override string type { get { return CommandTypes.Games; } } public override bool museumUsable { get { return false; } } - public override LevelPermission defaultRank { get { return LevelPermission.Operator; } } public override CommandAlias[] Aliases { get { return new[] { new CommandAlias("ZS"), new CommandAlias("ZombieSurvival") }; } } + public override CommandPerm[] ExtraPerms { + get { return new[] { new CommandPerm(LevelPermission.Operator, "+ can manage zombie survival") }; } + } public override void Use(Player p, string message) { ZSGame game = Server.zombie; @@ -76,7 +78,8 @@ namespace MCGalaxy.Commands.Fun { Player.Message(p, "Running on map: " + game.MapName); } - static void HandleStart(Player p, ZSGame game, string[] args) { + void HandleStart(Player p, ZSGame game, string[] args) { + if (!CheckExtraPerm(p, 1)) return; if (game.Running) { Player.Message(p, "There is already a Zombie Survival game currently in progress."); return; } @@ -94,7 +97,8 @@ namespace MCGalaxy.Commands.Fun { } } - static void HandleEnd(Player p, ZSGame game) { + void HandleEnd(Player p, ZSGame game) { + if (!CheckExtraPerm(p, 1)) return; if (game.RoundInProgress) { game.EndRound(); } else { @@ -102,7 +106,8 @@ namespace MCGalaxy.Commands.Fun { } } - static void HandleStop(Player p, ZSGame game) { + void HandleStop(Player p, ZSGame game) { + if (!CheckExtraPerm(p, 1)) return; if (!game.Running) { Player.Message(p, "There is no Zombie Survival game currently in progress."); return; } @@ -119,14 +124,15 @@ namespace MCGalaxy.Commands.Fun { } void HandleSet(Player p, ZSGame game, string[] args) { + if (!CheckExtraPerm(p, 1)) return; if (args.Length == 1) { Help(p, "set"); return; } - if (args[1].CaselessEq("hitbox")) { HandleHitbox(p, game, args); return; } - if (args[1].CaselessEq("maxmove")) { HandleMaxMove(p, game, args); return; } + if (args[1].CaselessEq("hitbox")) { SetHitbox(p, game, args); return; } + if (args[1].CaselessEq("maxmove")) { SetMaxMove(p, game, args); return; } Help(p, "set"); } - static void HandleHitbox(Player p, ZSGame game, string[] args) { + static void SetHitbox(Player p, ZSGame game, string[] args) { if (args.Length == 2) { Player.Message(p, "Hitbox detection is currently &a" + ZSConfig.HitboxPrecision + " %Sunits apart."); return; @@ -140,7 +146,7 @@ namespace MCGalaxy.Commands.Fun { ZSConfig.SaveSettings(); } - static void HandleMaxMove(Player p, ZSGame game, string[] args) { + static void SetMaxMove(Player p, ZSGame game, string[] args) { if (args.Length == 2) { Player.Message(p, "Maxmium move distance is currently &a" + ZSConfig.MaxMoveDistance + " %Sunits apart."); return; @@ -155,14 +161,14 @@ namespace MCGalaxy.Commands.Fun { } public override void Help(Player p) { - Player.Message(p, "%T/ZG status %H- Outputs current status of Zombie Survival."); - Player.Message(p, "%T/ZG go %H- Moves you to the current Zombie Survival map."); Player.Message(p, "%T/ZG start 0 %H- Runs Zombie Survival for infinite rounds."); Player.Message(p, "%T/ZG start [x] %H- Runs Zombie Survival for [x] rounds."); Player.Message(p, "%T/ZG end %H- Ends current round of Zombie Survival."); Player.Message(p, "%T/ZG stop %H- Immediately stops Zombie Survival."); Player.Message(p, "%T/ZG set [property] [value]"); Player.Message(p, "%HSets a Zombie Survival game property, see %T/Help ZG set"); + Player.Message(p, "%T/ZG status %H- Outputs current status of Zombie Survival."); + Player.Message(p, "%T/ZG go %H- Moves you to the current Zombie Survival map."); } public override void Help(Player p, string message) { diff --git a/MCGalaxy/Commands/Moderation/CmdReport.cs b/MCGalaxy/Commands/Moderation/CmdReport.cs index be61657b2..c03b9137b 100644 --- a/MCGalaxy/Commands/Moderation/CmdReport.cs +++ b/MCGalaxy/Commands/Moderation/CmdReport.cs @@ -162,12 +162,11 @@ namespace MCGalaxy.Commands.Moderation { } public override void Help(Player p) { - Player.Message(p, "%T/Report [Player] [Reason] %H- Reports that player for the given reason."); - if (!HasExtraPerm(p, 1)) return; Player.Message(p, "%T/Report list %H- Lists all reported players."); Player.Message(p, "%T/Report check [Player] %H- Views reports for that player."); Player.Message(p, "%T/Report delete [Player] %H- Deletes reports for that player."); Player.Message(p, "%T/Report clear %H- Clears &call%H reports."); + Player.Message(p, "%T/Report [Player] [Reason] %H- Reports that player for the given reason."); } } }