private void OnPlayerCommand(PlayerCommandEventArgs e) { if (e.Handled || e.Player == null) { return; } }
public void OnCommandExecute(CommandData data) { data.SplitText(); if (data.Sender.IsPlayer) { PlayerCommandEventArgs ev = new PlayerCommandEventArgs(data); Server.Instance.Event.Player.OnPlayerCommand(this, ev); if (ev.IsCancel) { return; } } else { ServerCommandEventArgs ev = new ServerCommandEventArgs(data); Server.Instance.Event.Server.OnServerCommand(this, ev); if (ev.IsCancel) { return; } } Command command = this.Manager.GetCommand(data.Command); if (command != null) { command.OnExecute(data.Sender, data.Command, data.Args); } else { data.Sender.SendMessage(new TranslationContainer(TextFormat.RED, "commands.generic.unknown", data.Command)); } }
private void OnPlayerCommand(PlayerCommandEventArgs e) { if (e.Handled || e.Player == null) { return; } Command command = e.CommandList.FirstOrDefault(); if (command == null || (command.Permissions.Any() && !command.Permissions.Any(s => e.Player.Group.HasPermission(s)))) { return; } if (e.Player.TPlayer.hostile && command.Names.Select(s => s.ToLowerInvariant()) .Intersect(Config.DisabledCommandsInPvp.Select(s => s.ToLowerInvariant())) .Any()) { e.Player.SendErrorMessage("This command is blocked while in PvP!"); e.Handled = true; return; } if (e.Player.Group.HasPermission(Permissions.LastCommand) && command.CommandDelegate != Commands.RepeatLast) { e.Player.GetPlayerInfo().LastCommand = e.CommandText; } if (teleportCommands.Contains(e.CommandName) && e.Player.Group.HasPermission(Permissions.TpBack)) { e.Player.GetPlayerInfo().PushBackHistory(e.Player.TPlayer.position); } }
private void ContextNearPlayer(PlayerCommandEventArgs args, int paramID) { if (TShock.Utils.GetActivePlayerCount() == 1) { args.Player.SendErrorMessage("Context: You are alone on server!"); args.Handled = true; return; } float x = args.Player.X; float y = args.Player.Y; var player = TShock.Players.FirstOrDefault(plr => plr != null && plr.Active && plr != args.Player && plr.Account != null); if (player == null) { args.Player.SendErrorMessage("Context: Failed found nearest player!"); args.Handled = true; return; } float minDistance = Utils.CountDistance(x, y, player.X, player.Y); for (int i = 0; i < TShock.Players.Length; i++) { if (TShock.Players[i] != null && TShock.Players[i].Active && TShock.Players[i] != args.Player && TShock.Players[i].Account != null) { float distance = Utils.CountDistance(x, y, TShock.Players[i].X, TShock.Players[i].Y); if (minDistance > distance) { player = TShock.Players[i]; minDistance = distance; } } } args.Parameters[paramID] = player.Account.Name; }
private void OnPlayerCommand(PlayerCommandEventArgs args) { if (!args.Player.HasPermission(Permissions.manageregion) && !args.Player.HasPermission("regionext.own")) { return; } switch (args.CommandName) { case "/re": case "/regionext": case "/ro": case "/regionown": case "region": for (int i = 1; i < args.Parameters.Count; i++) { if (args.Parameters[i].StartsWith(Config.ContextSpecifier)) { Contexts.InitializeContext(i, args); } } if (Config.AutoCompleteSameName && args.Parameters.Count > 1 && "define" == args.Parameters[0]) { args.Parameters[1] = Utils.AutoCompleteSameName(args.Parameters[1], Config.AutoCompleteSameNameFormat); } break; } }
void OnCommand(PlayerCommandEventArgs args) { if (args.CommandName == "register") { if (args.Parameters[0].ToUpper() == args.Player.Name.ToUpper()) { args.Player.SendErrorMessage("ERROR: Your password cannot be the same as your name."); args.Handled = true; return; } if (args.Parameters[0].Length < 6) { args.Player.SendErrorMessage("ERROR: Your password is too short."); args.Handled = true; return; } if (args.Parameters[0].Contains("password")) { args.Player.SendErrorMessage("ERROR: Your password cannot contain 'password'."); args.Handled = true; return; } Match match = Regex.Match(args.Parameters[0], @"^(?=.*\d)(?=.*[a-zA-Z]).*$"); if (!match.Success) { args.Player.SendErrorMessage("ERROR: Your password requires both letters and numbers."); args.Handled = true; return; } } if (args.CommandName == "password") { if (args.Parameters[1].ToUpper() == args.Player.Name.ToUpper()) { args.Player.SendErrorMessage("ERROR: Your password cannot be the same as your name."); args.Handled = true; return; } if (args.Parameters[1].Length < 6) { args.Player.SendErrorMessage("ERROR: Your password is too short."); args.Handled = true; return; } if (args.Parameters[1].Contains("password")) { args.Player.SendErrorMessage("ERROR: Your password cannot contain 'password'."); args.Handled = true; return; } Match match = Regex.Match(args.Parameters[1], @"^(?=.*\d)(?=.*[a-zA-Z]).*$"); if (!match.Success) { args.Player.SendErrorMessage("ERROR: Your password requires both letters and numbers."); args.Handled = true; return; } } }
private void OnPlayerCommand(PlayerCommandEventArgs e) { var handler = PlayerCommand; if (handler != null) { handler(this, e); } }
private void CommandEntered(Player player, PlayerCommandEventArgs e) { foreach (var commandHandler in this.registeredCommandHandlers) { if (commandHandler.CommandName == e.Command) { commandHandler.Delegate.CallbackDelegate.Invoke(player, e.Command, e.Arguments); } } }
private void onPlayerCommand(PlayerCommandEventArgs e) { if (e.Parameters.Count >= 2 && e.CommandName.ToLower() == "region" && new string[] { "delete", "resize", "expand" }.Contains(e.Parameters[0].ToLower())) { if (Commands.ChatCommands.Any(c => c.HasAlias("region") && c.CanRun(e.Player))) { refreshTimer.Interval = 1500; } } }
private void OnCommand(PlayerCommandEventArgs args) { if (args.CommandName.Equals("w") || args.CommandName.Equals("whisper") || args.CommandName.Equals("reply") || args.CommandName.Equals("r") || args.CommandName.Equals("tell")) { foreach (var player in TShock.Players.Where(e => e != null && Spying[e.Index])) { player.SendMessage($"{args.Player.Name}: {args.CommandText}", staffchatcolor); } } }
private void ContextThis(PlayerCommandEventArgs args, int paramID) { if (args.Player.CurrentRegion == null) { args.Player.SendErrorMessage("Context: You are not in a region!"); args.Handled = true; return; } args.Parameters[paramID] = args.Player.CurrentRegion.Name; }
private void HandlePlayerCommand(Player sender, PlayerCommandEventArgs args) { if (this.commandHandlers.ContainsKey(args.Command)) { foreach (var handler in this.commandHandlers[args.Command]) { handler.Trigger(args.Source, args.Arguments); } } }
void OnPlayerCommand(PlayerCommandEventArgs e) { if (!e.Handled && e.Player.RealPlayer && !e.Player.HasPermission("antispam.ignore")) { var plr = e.Player; if ((DateTime.Now - Times[plr.Index]).TotalSeconds > _config.Time) { Spams[plr.Index] = 0.0; Times[plr.Index] = DateTime.Now; } switch (e.CommandName) { case "me": case "r": case "reply": case "tell": case "w": case "whisper": string text = e.CommandText.Substring(e.CommandName.Length); if (text == LastMsg[plr.Index]) { Spams[plr.Index] += _config.RepeatMsgWeight; } else { LastMsg[plr.Index] = text; } if ((double)text.Count(Char.IsUpper) / text.Length >= _config.CapsRatio) { Spams[plr.Index] += _config.CapsWeight; text = text.ToLower(); } else if (text.Trim().Length <= _config.ShortLength) { Spams[plr.Index] += _config.ShortWeight; } else { Spams[plr.Index] += _config.NormalWeight; } break; default: Spams[plr.Index] += _config.CommandWeight; break; } if (SpamCheck(plr.Index)) { e.Handled = true; } } }
public void InitializeContext(int param, PlayerCommandEventArgs args) { for (int i = 0; i < Contexts.Count; i++) { if (Contexts[i].Names.Contains(args.Parameters[i].Remove(0, 1))) { Contexts[i].Action(args, i); return; } } args.Player.SendErrorMessage("Context: Invalid context command!"); }
private void OnPlayerCommand(PlayerCommandEventArgs args) { if (!args.CommandName.Equals("password") && !args.CommandName.Equals("login") && !args.CommandName.Equals("logout") && !args.CommandName.Equals("me") && !args.CommandName.Equals("register")) { Discord.SendLog($"{args.Player.Name} executed: {args.CommandPrefix}{args.CommandText}"); } if (args.CommandName.Equals("me")) { Discord.Send($"* {args.Player.Name} {args.CommandText.Substring(3)}"); } }
void OnPlayerCommand(PlayerCommandEventArgs e) { if (!e.Handled && e.Player.RealPlayer) { switch (e.CommandName) { case "me": case "r": case "reply": case "tell": case "w": case "whisper": if ((DateTime.Now - Times[e.Player.Index]).TotalSeconds > Config.Time) { Spams[e.Player.Index] = 0.0; Times[e.Player.Index] = DateTime.Now; } string text = e.CommandText.Substring(e.CommandName.Length); if ((double)text.Where(c => Char.IsUpper(c)).Count() / text.Length >= Config.CapsRatio) { Spams[e.Player.Index] += Config.CapsWeight; } else if (text.Trim().Length <= Config.ShortLength) { Spams[e.Player.Index] += Config.ShortWeight; } else { Spams[e.Player.Index] += Config.NormalWeight; } if (Spams[e.Player.Index] > Config.Threshold && !TShock.Players[e.Player.Index].Group.HasPermission("antispam.ignore")) { switch (Config.Action.ToLower()) { case "ignore": default: Times[e.Player.Index] = DateTime.Now; TShock.Players[e.Player.Index].SendErrorMessage("[SpamBot] You've been ignored for spamming. Wait 5 seconds to chat."); e.Handled = true; return; case "kick": TShock.Utils.ForceKick(TShock.Players[e.Player.Index], "[SpamBot] You've been kicked for spamming. Do not spam again.", false, true); e.Handled = true; return; } } return; } } }
private void OnPlayerCommand(PlayerCommandEventArgs e) { if (e.Handled || e.Player == null) { return; } TSPlayer player = e.Player; if (everyTeleportCommands.Contains(e.CommandName)) { player.GetPlayerInfo().pushLastLocation(player.TPlayer.position); } }
public void OnCommand(PlayerCommandEventArgs args) { if (args.Handled) { return; } TSPlayer player = args.Player; if (args.CommandName.Equals("who") || args.CommandName.Equals("online") || args.CommandName.Equals("playing")) { player.SendMessage(getStaff(), Color.Cyan); return; } }
private void OnPlayerCommand(PlayerCommandEventArgs args) { if (!args.CommandName.Equals("password") && !args.CommandName.Equals("login") && !args.CommandName.Equals("logout") && !args.CommandName.Equals("me") && !args.CommandName.Equals("register")) { Discord.SendLog($"```{args.Player.Name} executed: {args.CommandPrefix}{args.CommandText}```"); } if (args.CommandName.Equals("me")) { Discord.Send($"* {args.Player.Name} {args.CommandText.Substring(3)}"); } if (args.CommandName.Equals("broadcast") || args.CommandName.Equals("bc") || args.CommandName.Equals("say")) { Discord.Send($"(Server Broadcast) {string.Join(" ", args.Parameters)}"); } }
public static async void OnPlayerCommand(PlayerCommandEventArgs args) { if ((args.Player == null) || (args.Player == TSPlayer.Server) || args.CommandText.Contains("login") || args.CommandText.Contains("register") || args.CommandText.Contains("user password")) { return; } try { var logs = await Discord.DiscordBot.GetChannelAsync(Discord.Config.LogID); await Discord.DiscordBot.SendMessageAsync(logs, "**" + args.Player.Name + ":** " + args.CommandText); } catch (Exception ex) { TShock.Log.Error(ex.ToString()); } }
private void OnPlayerCommand(PlayerCommandEventArgs args) { if (!args.Player.HasPermission(Permissions.manageregion) && !args.Player.HasPermission("regionext.own")) { return; } switch (args.CommandName) { case "/re": case "/regionext": case "/ro": case "/regionown": case "region": for (int i = 1; i < args.Parameters.Count; i++) { if (args.Parameters[i].StartsWith(Config.ContextSpecifier)) { bool success = false; for (int j = 0; j < Contexts.Count; j++) { if (Contexts[j].Context == args.Parameters[i].Remove(0, 1)) { Contexts[j].Initialize(args, i); success = true; break; } } if (!success) { args.Player.SendErrorMessage("Context: Invalid context command!"); args.Handled = true; return; } } } if (Config.AutoCompleteSameName && args.Parameters.Count > 1 && "define" == args.Parameters[0]) { args.Parameters[1] = AutoCompleteSameName(args.Parameters[1]); } break; } }
public void OnCommand(PlayerCommandEventArgs args) { if (args.CommandPrefix == "/") { ToWarps w = manager.GetWarp(args.CommandName); if (w == null) { return; } Warp warp = TShock.Warps.Find(w.WarpName); if (warp == null) { args.Player.SendErrorMessage("Oops. The administration did not create such a warp."); args.Handled = true; return; } args.Player.Teleport((float)(warp.Position.X * 16), (float)(warp.Position.Y * 16), 1); args.Handled = true; return; } }
void OnPlayerCommand(PlayerCommandEventArgs e) { if (!IrcClient.IsConnected) { Connect(); } else if (e.Player.RealPlayer) { if (String.Equals(e.CommandName, "me", StringComparison.CurrentCultureIgnoreCase) && e.CommandText.Length > 2) { if (!e.Player.mute && e.Player.Group.HasPermission(Permissions.cantalkinthird) && !String.IsNullOrEmpty(Config.ServerActionMessageFormat)) { SendMessage(Config.Channel, String.Format(Config.ServerActionMessageFormat, e.Player.Name, e.CommandText.Substring(3))); } } else if (e.CommandList.Count() == 0 || e.CommandList.First().DoLog) { if (!String.IsNullOrEmpty(Config.ServerCommandMessageFormat)) { SendMessage(Config.AdminChannel, String.Format(Config.ServerCommandMessageFormat, e.Player.Group.Prefix, e.Player.Name, e.CommandText)); } } } }
private void ContextMyName(PlayerCommandEventArgs args, int paramID) => args.Parameters[paramID] = args.Player.Account.Name;
public void Initialize(PlayerCommandEventArgs args, int paramID) { action(args, paramID); }