Skip to content

Commit

Permalink
Fixed backwards ternaries in ban, crash, rejoin, 0 arguments no longe…
Browse files Browse the repository at this point in the history
…r valid.
  • Loading branch information
TheUbMunster authored and Sanae6 committed Jul 27, 2022
1 parent f305c30 commit 5ca5b10
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions Server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,15 @@ async void SyncShineBag() {
};

CommandHandler.RegisterCommand("rejoin", args => {
if (args.Length == 0) {
return "Usage: rejoin <* | usernames...>";
}
bool moreThanOne = false;
StringBuilder builder = new StringBuilder();
Client[] clients = (args.Length == 1 && args[0] == "*"
? server.Clients.Where(c =>
c.Connected && args.Any(x => c.Name.StartsWith(x) || (Guid.TryParse(x, out Guid result) && result == c.Id)))
: server.Clients.Where(c => c.Connected)).ToArray();
Client[] clients = (args[0] == "*"
? server.Clients.Where(c => c.Connected)
: server.Clients.Where(c =>
c.Connected && args.Any(x => c.Name.StartsWith(x) || (Guid.TryParse(x, out Guid result) && result == c.Id)))).ToArray();
foreach (Client user in clients) {
if (moreThanOne) builder.Append(", ");
builder.Append(user.Name);
Expand All @@ -214,12 +217,15 @@ async void SyncShineBag() {
});

CommandHandler.RegisterCommand("crash", args => {
if (args.Length == 0) {
return "Usage: crash <* | usernames...>";
}
bool moreThanOne = false;
StringBuilder builder = new StringBuilder();
Client[] clients = (args.Length == 1 && args[0] == "*"
? server.Clients.Where(c =>
c.Connected && args.Any(x => c.Name.StartsWith(x) || (Guid.TryParse(x, out Guid result) && result == c.Id)))
: server.Clients.Where(c => c.Connected)).ToArray();
Client[] clients = (args[0] == "*"
? server.Clients.Where(c => c.Connected)
: server.Clients.Where(c =>
c.Connected && args.Any(x => c.Name.StartsWith(x) || (Guid.TryParse(x, out Guid result) && result == c.Id)))).ToArray();
foreach (Client user in clients) {
if (moreThanOne) builder.Append(", ");
moreThanOne = true;
Expand All @@ -239,13 +245,16 @@ await user.Send(new ChangeStagePacket {
});

CommandHandler.RegisterCommand("ban", args => {
if (args.Length == 0) {
return "Usage: ban <* | usernames...>";
}
bool moreThanOne = false;
StringBuilder builder = new StringBuilder();

Client[] clients = (args.Length == 1 && args[0] == "*"
? server.Clients.Where(c =>
c.Connected && args.Any(x => c.Name.StartsWith(x) || (Guid.TryParse(x, out Guid result) && result == c.Id)))
: server.Clients.Where(c => c.Connected)).ToArray();
Client[] clients = (args[0] == "*"
? server.Clients.Where(c => c.Connected)
: server.Clients.Where(c =>
c.Connected && args.Any(x => c.Name.StartsWith(x) || (Guid.TryParse(x, out Guid result) && result == c.Id)))).ToArray();
foreach (Client user in clients) {
if (moreThanOne) builder.Append(", ");
moreThanOne = true;
Expand Down

0 comments on commit 5ca5b10

Please sign in to comment.