public ECommandRunError ExecuteCommand(string text, PointBlankPlayer executor) { string[] info = ParseCommand(text); List <string> args = new List <string>(); CommandWrapper wrapper = Commands.FirstOrDefault(a => a.Commands.FirstOrDefault(b => b.ToLower() == info[0].ToLower()) != null && a.Enabled); string permission = ""; if (wrapper == null) { PointBlankPlayer.SendMessage(executor, Environment.ServiceTranslations[typeof(ServiceTranslations)].Translations["CommandManager_Invalid"], ConsoleColor.Red); return(ECommandRunError.COMMAND_NOT_EXIST); } permission = wrapper.Permission; if (info.Length > 1) { for (int i = 1; i < info.Length; i++) { args.Add(info[i]); } } if (args.Count > 0) { permission += "." + string.Join(".", args.ToArray()); } if (!PointBlankPlayer.IsServer(executor) && !executor.HasPermission(permission)) { PointBlankPlayer.SendMessage(executor, Environment.ServiceTranslations[typeof(ServiceTranslations)].Translations["CommandManager_NotEnoughPermissions"], ConsoleColor.Red); return(ECommandRunError.NO_PERMISSION); } return(wrapper.Execute(executor, args.ToArray())); }
private void PointBlankCommandEvents_OnCommandExecuted(PointBlankCommand command, string[] args, PointBlankPlayer executor, ref bool allowExecute) { if (!typeof(FireworksCommand).IsAssignableFrom(command.GetType())) { return; } bool cancel = false; IRocketPlayer rocketPlayer = (PointBlankPlayer.IsServer(executor) ? new ConsolePlayer() : (IRocketPlayer) new UnturnedPlayer((PBPlayer)executor)); RocketCommandManager.Instance.RunExecuteCommand(rocketPlayer, ((FireworksCommand)command)._RocketCommand, ref cancel); allowExecute = !cancel; }
public override void Execute(PointBlankPlayer executor, string[] args) { if (!PlayerTool.tryGetSteamID(args[0], out CSteamID player)) { UnturnedChat.SendMessage(executor, Translations["Base_InvalidPlayer"], ConsoleColor.Red); return; } if (executor == null) { SteamAdminlist.admin(player, CSteamID.Nil); CommandWindow.Log(string.Format(Translations["Admin_Set"], player), ConsoleColor.Green); } else { SteamAdminlist.admin(player, (PointBlankPlayer.IsServer(executor) ? CSteamID.Nil : ((UnturnedPlayer)executor).SteamID)); executor.SendMessage(string.Format(Translations["Admin_Set"], player), Color.green); } }
public override void Execute(PointBlankPlayer executor, string[] args) => _RocketCommand.Execute((PointBlankPlayer.IsServer(executor) ? new ConsolePlayer() : (IRocketPlayer)(new UnturnedPlayer((PBPlayer)executor))), args);