Moved Alias Database into interface...
This commit is contained in:
parent
bc452cfd93
commit
d86836ae8d
@ -19,6 +19,7 @@ namespace IW4MAdmin
|
||||
public List<Server> Servers { get; private set; }
|
||||
List<AsyncStatus> TaskStatuses;
|
||||
Database ClientDatabase;
|
||||
Database AliasesDatabase;
|
||||
SharedLibrary.Interfaces.IPenaltyList ClientPenalties;
|
||||
List<Command> Commands;
|
||||
Kayak.IScheduler webServiceTask;
|
||||
@ -33,15 +34,13 @@ namespace IW4MAdmin
|
||||
|
||||
private Manager()
|
||||
{
|
||||
//IFile logFile = new IFile("Logs/IW4MAdminManager.log", true);
|
||||
Logger = new Logger("Logs/IW4MAdmin.log");
|
||||
//Logger = new Log(logFile, Log.Level.Production, 0);
|
||||
Servers = new List<Server>();
|
||||
Commands = new List<Command>();
|
||||
TaskStatuses = new List<AsyncStatus>();
|
||||
|
||||
|
||||
ClientDatabase = new ClientsDB("Database/clients.rm");
|
||||
AliasesDatabase = new AliasesDB("Database/aliases.rm");
|
||||
ClientPenalties = new PenaltyList();
|
||||
}
|
||||
|
||||
@ -149,6 +148,11 @@ namespace IW4MAdmin
|
||||
return ClientDatabase as ClientsDB;
|
||||
}
|
||||
|
||||
public AliasesDB GetAliasesDatabase()
|
||||
{
|
||||
return AliasesDatabase as AliasesDB;
|
||||
}
|
||||
|
||||
public SharedLibrary.Interfaces.IPenaltyList GetClientPenalties()
|
||||
{
|
||||
return ClientPenalties;
|
||||
|
@ -17,17 +17,17 @@ namespace IW4MAdmin
|
||||
initCommands();
|
||||
}
|
||||
|
||||
private void getAliases(List<Aliases> returnAliases, Aliases currentAlias)
|
||||
private void GetAliases(List<Aliases> returnAliases, Aliases currentAlias)
|
||||
{
|
||||
foreach(String IP in currentAlias.IPS)
|
||||
{
|
||||
List<Aliases> Matching = aliasDB.getPlayer(IP);
|
||||
List<Aliases> Matching = Manager.GetAliasesDatabase().getPlayer(IP);
|
||||
foreach(Aliases I in Matching)
|
||||
{
|
||||
if (!returnAliases.Contains(I) && returnAliases.Find(x => x.Number == I.Number) == null)
|
||||
{
|
||||
returnAliases.Add(I);
|
||||
getAliases(returnAliases, I);
|
||||
GetAliases(returnAliases, I);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -40,12 +40,12 @@ namespace IW4MAdmin
|
||||
if (Origin == null)
|
||||
return allAliases;
|
||||
|
||||
Aliases currentIdentityAliases = aliasDB.getPlayer(Origin.databaseID);
|
||||
Aliases currentIdentityAliases = Manager.GetAliasesDatabase().getPlayer(Origin.databaseID);
|
||||
|
||||
if (currentIdentityAliases == null)
|
||||
return allAliases;
|
||||
|
||||
getAliases(allAliases, currentIdentityAliases);
|
||||
GetAliases(allAliases, currentIdentityAliases);
|
||||
return allAliases;
|
||||
}
|
||||
|
||||
@ -62,11 +62,8 @@ namespace IW4MAdmin
|
||||
}
|
||||
|
||||
Logger.WriteDebug($"Client slot #{P.clientID} now reserved");
|
||||
|
||||
|
||||
#if DEBUG == false
|
||||
|
||||
try
|
||||
#endif
|
||||
{
|
||||
Player NewPlayer = Manager.GetClientDatabase().getPlayer(P.npID, P.clientID);
|
||||
|
||||
@ -75,7 +72,7 @@ namespace IW4MAdmin
|
||||
Logger.WriteDebug($"Client slot #{P.clientID} first time connecting");
|
||||
Manager.GetClientDatabase().addPlayer(P);
|
||||
NewPlayer = Manager.GetClientDatabase().getPlayer(P.npID, P.clientID);
|
||||
aliasDB.addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
|
||||
Manager.GetAliasesDatabase().addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
|
||||
}
|
||||
|
||||
|
||||
@ -88,12 +85,12 @@ namespace IW4MAdmin
|
||||
|
||||
// below this needs to be optimized ~ 425ms runtime
|
||||
NewPlayer.updateName(P.Name.Trim());
|
||||
NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.databaseID);
|
||||
NewPlayer.Alias = Manager.GetAliasesDatabase().getPlayer(NewPlayer.databaseID);
|
||||
|
||||
if (NewPlayer.Alias == null)
|
||||
{
|
||||
aliasDB.addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
|
||||
NewPlayer.Alias = aliasDB.getPlayer(NewPlayer.databaseID);
|
||||
Manager.GetAliasesDatabase().addPlayer(new Aliases(NewPlayer.databaseID, NewPlayer.Name, NewPlayer.IP));
|
||||
NewPlayer.Alias = Manager.GetAliasesDatabase().getPlayer(NewPlayer.databaseID);
|
||||
}
|
||||
|
||||
if (P.lastEvent == null || P.lastEvent.Owner == null)
|
||||
@ -116,7 +113,7 @@ namespace IW4MAdmin
|
||||
|
||||
NewPlayer.updateIP(P.IP);
|
||||
|
||||
aliasDB.updatePlayer(NewPlayer.Alias);
|
||||
Manager.GetAliasesDatabase().updatePlayer(NewPlayer.Alias);
|
||||
Manager.GetClientDatabase().updatePlayer(NewPlayer);
|
||||
|
||||
await ExecuteEvent(new Event(Event.GType.Connect, "", NewPlayer, null, this));
|
||||
@ -171,13 +168,13 @@ namespace IW4MAdmin
|
||||
ClientNum++;
|
||||
return true;
|
||||
}
|
||||
#if DEBUG == false
|
||||
|
||||
catch (Exception E)
|
||||
{
|
||||
Manager.GetLogger().WriteError("Unable to add player " + P.Name + " - " + E.Message);
|
||||
Manager.GetLogger().WriteError($"Unable to add player {P.Name}::{P.npID}");
|
||||
Manager.GetLogger().WriteDebug(E.StackTrace);
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//Remove player by CLIENT NUMBER
|
||||
|
Binary file not shown.
@ -406,8 +406,7 @@ namespace SharedLibrary.Commands
|
||||
return;
|
||||
}
|
||||
|
||||
//var db_players = E.Owner.Manager.GetClientDatabase().findPlayers(E.Data.Trim());
|
||||
var db_aliases = E.Owner.aliasDB.findPlayers(E.Data);
|
||||
var db_aliases = E.Owner.Manager.GetAliasesDatabase().findPlayers(E.Data);
|
||||
|
||||
if (db_aliases == null)
|
||||
{
|
||||
@ -625,7 +624,7 @@ namespace SharedLibrary.Commands
|
||||
|
||||
public override async Task ExecuteAsync(Event E)
|
||||
{
|
||||
E.Target.Alias = E.Owner.aliasDB.getPlayer(E.Target.databaseID);
|
||||
E.Target.Alias = E.Owner.Manager.GetAliasesDatabase().getPlayer(E.Target.databaseID);
|
||||
|
||||
if (E.Target.Alias == null)
|
||||
{
|
||||
|
@ -16,5 +16,6 @@ namespace SharedLibrary.Interfaces
|
||||
List<Command> GetCommands();
|
||||
IPenaltyList GetClientPenalties();
|
||||
ClientsDB GetClientDatabase();
|
||||
AliasesDB GetAliasesDatabase();
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,7 @@ namespace SharedLibrary
|
||||
Port = port;
|
||||
Manager = mgr;
|
||||
Logger = Manager.GetLogger();
|
||||
ClientNum = 0;
|
||||
aliasDB = new AliasesDB("Database/aliases.rm");
|
||||
ClientNum = 0;
|
||||
|
||||
Players = new List<Player>(new Player[18]);
|
||||
events = new Queue<Event>();
|
||||
@ -221,6 +220,7 @@ namespace SharedLibrary
|
||||
/// <param name="Message">Message to be sent to all players</param>
|
||||
public async Task Broadcast(String Message)
|
||||
{
|
||||
return;
|
||||
await this.ExecuteCommandAsync($"sayraw {Message}");
|
||||
}
|
||||
|
||||
@ -231,6 +231,7 @@ namespace SharedLibrary
|
||||
/// <param name="Target">Player to send message to</param>
|
||||
public async Task Tell(String Message, Player Target)
|
||||
{
|
||||
return;
|
||||
if (Target.clientID > -1 && Message.Length > 0 && Target.Level != Player.Permission.Console && !Target.lastEvent.Remote)
|
||||
await this.ExecuteCommandAsync($"tellraw {Target.clientID} {Message}^7");
|
||||
|
||||
@ -467,7 +468,7 @@ namespace SharedLibrary
|
||||
|
||||
// Databases
|
||||
//public ClientsDB clientDB;
|
||||
public AliasesDB aliasDB;
|
||||
//public AliasesDB aliasDB;
|
||||
|
||||
//Remote
|
||||
public Queue<String> commandResult = new Queue<string>();
|
||||
|
Loading…
Reference in New Issue
Block a user