public bool OnRegisterCommand(IStarProxy proxy, StarCommand command) { var resp = new ChatReceivedMessage { Context = new MessageContext { Mode = Mode.CommandResult } }; if (command.Arguments.Length != 3) { resp.Text = "Syntax: /register <username> <password> <confirm>"; proxy.SendChatMessage(resp); return false; } if (!RegisterUser(command.Arguments[0], command.Arguments[1])) { resp.Text = $"The username {command.Arguments[0]} has already been taken!"; proxy.SendChatMessage(resp); return false; } resp.Text = $"The account {command.Arguments[0]} has been created!"; proxy.SendChatMessage(resp); return true; }
public bool OnBanUserCommand(IStarProxy proxy, StarCommand command) { if (!proxy.AuthenticatedUser.Admin) return false; ChatReceivedMessage message = new ChatReceivedMessage { Context = new MessageContext { Mode = Mode.CommandResult } }; if (command.Arguments.Length != 2) { message.Text = "Syntax: /banuser <uuid> \"<reason>\" <all characters? (optional)>"; proxy.SendChatMessage(message); } string uuid = command.Arguments[0]; string reason = command.Arguments[1]; string allCharsStr = command.Arguments[1]?.ToLower(); bool allChars = allCharsStr == "yes" || allCharsStr == "true" || allCharsStr == "1"; if (ActivateBanHammer(proxy.Server, uuid, reason, allChars)) message.Text = $"Player with uuid {uuid} has been banned!"; else message.Text = $"Error while trying to ban {uuid}!"; proxy.SendChatMessage(message); return true; }
public bool OnConsoleRegisterCommand(StarCommand command) { if (command.Arguments.Length != 3) { _logger.LogInformation("Syntax: register <username> <password> <confirm>"); return false; } if (!RegisterUser(command.Arguments[0], command.Arguments[1])) { _logger.LogError($"The user {command.Arguments[0]} already exists!"); } _logger.LogInformation($"The user {command.Arguments[0]} has been created!"); return true; }
public bool OnConsoleBanCommand(StarCommand command) { if (command.Arguments.Length != 2) { _logger.LogInformation("Syntax: banuser <uuid> \"<reason>\" <all characters? (optional)>"); return true; } string uuid = command.Arguments[0]; string reason = command.Arguments[1]; string allCharsStr = command.Arguments[1]?.ToLower(); bool allChars = allCharsStr == "yes" || allCharsStr == "true" || allCharsStr == "1"; if (ActivateBanHammer(_server, uuid, reason, allChars)) _logger.LogInformation($"Player with uuid {uuid} has been banned!"); else _logger.LogError($"Error banning player with uuid {uuid}"); return true; }