mirror of
https://github.com/Sanae6/SmoOnlineServer.git
synced 2024-11-22 19:25:16 +00:00
The user management update
This commit is contained in:
parent
d898f4754b
commit
74c00aa0f8
2 changed files with 59 additions and 2 deletions
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Concurrent;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Net;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
using Server;
|
using Server;
|
||||||
using Shared;
|
using Shared;
|
||||||
|
@ -139,6 +140,52 @@ server.PacketHandler = (c, p) => {
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
CommandHandler.RegisterCommand("rejoin", args => {
|
||||||
|
if (server.Clients.SingleOrDefault(c => c.Connected && args[0] == c.Name) is { } user) {
|
||||||
|
user.Dispose();
|
||||||
|
return $"Kicked {user.Name}, use \"crash\" if you want to crash the user";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Usage: kick <username>";
|
||||||
|
});
|
||||||
|
|
||||||
|
CommandHandler.RegisterCommand("crash", args => {
|
||||||
|
if (server.Clients.SingleOrDefault(c => c.Connected && args[0] == c.Name) is { } user) {
|
||||||
|
Task.Run(async () => {
|
||||||
|
await user.Send(new ChangeStagePacket {
|
||||||
|
Id = "$among$us/SubArea",
|
||||||
|
Stage = "$agogusStage",
|
||||||
|
Scenario = 21,
|
||||||
|
SubScenarioType = 69 // invalid id
|
||||||
|
});
|
||||||
|
user.Dispose();
|
||||||
|
});
|
||||||
|
return $"Crashed {user.Name}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Usage: crash <username>";
|
||||||
|
});
|
||||||
|
|
||||||
|
CommandHandler.RegisterCommand("ban", args => {
|
||||||
|
if (server.Clients.SingleOrDefault(c => c.Connected && args[0] == c.Name) is { } user) {
|
||||||
|
Task.Run(async () => {
|
||||||
|
await user.Send(new ChangeStagePacket {
|
||||||
|
Id = "$agogus/banned4lyfe",
|
||||||
|
Stage = "$ejected",
|
||||||
|
Scenario = 69,
|
||||||
|
SubScenarioType = 21 // invalid id
|
||||||
|
});
|
||||||
|
IPEndPoint? endpoint = (IPEndPoint?) user.Socket?.RemoteEndPoint;
|
||||||
|
Settings.Instance.BanList.Players.Add(user.Id);
|
||||||
|
if (endpoint != null) Settings.Instance.BanList.IpAddresses.Add(endpoint.ToString());
|
||||||
|
user.Dispose();
|
||||||
|
});
|
||||||
|
return $"Crashed {user.Name}";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "Usage: crash <username>";
|
||||||
|
});
|
||||||
|
|
||||||
CommandHandler.RegisterCommand("send", args => {
|
CommandHandler.RegisterCommand("send", args => {
|
||||||
const string optionUsage = "Usage: send <stage> <id> <scenario[0..255]> <player/*>";
|
const string optionUsage = "Usage: send <stage> <id> <scenario[0..255]> <player/*>";
|
||||||
if (args.Length < 4)
|
if (args.Length < 4)
|
||||||
|
@ -291,6 +338,9 @@ CommandHandler.RegisterCommand("maxplayers", args => {
|
||||||
if (!ushort.TryParse(args[0], out ushort maxPlayers)) return optionUsage;
|
if (!ushort.TryParse(args[0], out ushort maxPlayers)) return optionUsage;
|
||||||
Settings.Instance.Server.MaxPlayers = maxPlayers;
|
Settings.Instance.Server.MaxPlayers = maxPlayers;
|
||||||
Settings.SaveSettings();
|
Settings.SaveSettings();
|
||||||
|
foreach (Client client in server.Clients)
|
||||||
|
client.Dispose(); // reconnect all players
|
||||||
|
return $"Saved and set max players to {maxPlayers}";
|
||||||
});
|
});
|
||||||
|
|
||||||
CommandHandler.RegisterCommand("list", _ => $"List: {string.Join("\n\t", server.Clients.Where(x => x.Connected).Select(x => $"{x.Name} ({x.Id})"))}");
|
CommandHandler.RegisterCommand("list", _ => $"List: {string.Join("\n\t", server.Clients.Where(x => x.Connected).Select(x => $"{x.Name} ({x.Id})"))}");
|
||||||
|
|
|
@ -42,6 +42,7 @@ public class Settings {
|
||||||
public ServerTable Server { get; set; } = new ServerTable();
|
public ServerTable Server { get; set; } = new ServerTable();
|
||||||
public FlipTable Flip { get; set; } = new FlipTable();
|
public FlipTable Flip { get; set; } = new FlipTable();
|
||||||
public ScenarioTable Scenario { get; set; } = new ScenarioTable();
|
public ScenarioTable Scenario { get; set; } = new ScenarioTable();
|
||||||
|
public BannedPlayers BanList { get; set; } = new BannedPlayers();
|
||||||
|
|
||||||
public class ServerTable {
|
public class ServerTable {
|
||||||
public string Address { get; set; } = IPAddress.Any.ToString();
|
public string Address { get; set; } = IPAddress.Any.ToString();
|
||||||
|
@ -54,13 +55,19 @@ public class Settings {
|
||||||
}
|
}
|
||||||
|
|
||||||
public class HiddenPlayers {
|
public class HiddenPlayers {
|
||||||
public List<Guid> Players { get; set; } = new List<Guid>();
|
|
||||||
public bool Enabled { get; set; } = false;
|
public bool Enabled { get; set; } = false;
|
||||||
|
public List<Guid> Players { get; set; } = new List<Guid>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class BannedPlayers {
|
||||||
|
public bool Enabled { get; set; } = false;
|
||||||
|
public List<Guid> Players { get; set; } = new List<Guid>();
|
||||||
|
public List<string> IpAddresses { get; set; } = new List<string>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public class FlipTable {
|
public class FlipTable {
|
||||||
public List<Guid> Players { get; set; } = new List<Guid>();
|
|
||||||
public bool Enabled { get; set; } = true;
|
public bool Enabled { get; set; } = true;
|
||||||
|
public List<Guid> Players { get; set; } = new List<Guid>();
|
||||||
public FlipOptions Pov { get; set; } = FlipOptions.Both;
|
public FlipOptions Pov { get; set; } = FlipOptions.Both;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue