Added comments to some functions, renamed GetClientByName to GetClientByNameOrId

This commit is contained in:
hydrant
2018-11-01 12:13:20 +01:00
parent e5be3783f6
commit 15498b1baf
14 changed files with 133 additions and 41 deletions

View File

@@ -8,6 +8,11 @@ namespace reallife_gamemode.Server.Extensions
{
public static class AdminLevelExtension
{
/// <summary>
/// Gibt den richtigen Namen eines Admin Levels zurück
/// </summary>
/// <param name="level">Das Admin Level, dessen Namen man bekommen möchte</param>
/// <returns></returns>
public static string GetName(this AdminLevel level)
{
switch(level)

View File

@@ -19,6 +19,13 @@ namespace reallife_gamemode.Server.Extensions
{
public static class ClientExtension
{
/// <summary>
/// Gibt das User-Objekt eines Client's zurück
/// Gibt nichts zurück, wenn der Client nicht eingeloggt ist
/// </summary>
/// <param name="client">Der Client, dessen User man bekommen möchte</param>
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
/// <returns></returns>
public static User GetUser(this Client client, DatabaseContext context = null)
{
if (!client.IsLoggedIn()) return null;
@@ -35,6 +42,11 @@ namespace reallife_gamemode.Server.Extensions
}
}
/// <summary>
/// Gibt zurück, ob ein Client eingeloggt ist
/// </summary>
/// <param name="player">Der Client, dessen Login-Status man bekommen möchte</param>
/// <returns></returns>
public static bool IsLoggedIn(this Client player)
{
return player.HasData("isLoggedIn") ? player.GetData("isLoggedIn") : false;

View File

@@ -17,6 +17,12 @@ namespace reallife_gamemode.Server.Extensions
{
public static class FactionExtension
{
/// <summary>
/// Gibt das Bankkonto einer Fraktion zurück
/// </summary>
/// <param name="faction">Die Fraktion, dessen Bankkonto man bekommen möchte</param>
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
/// <returns></returns>
public static FactionBankAccount GetFactionBankAccount(this Faction faction, DatabaseContext context = null)
{
if (context == null)

View File

@@ -17,6 +17,12 @@ namespace reallife_gamemode.Server.Extensions
{
public static class UserExtension
{
/// <summary>
/// Gibt das Bankkonto eines Users zurück
/// </summary>
/// <param name="user">Der User, dessen Bankkonto man bekommen möchte</param>
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
/// <returns></returns>
public static UserBankAccount GetUserBankAccount(this User user, DatabaseContext context = null)
{
if (context == null)
@@ -31,6 +37,13 @@ namespace reallife_gamemode.Server.Extensions
return context.UserBankAccounts.FirstOrDefault(u => u.UserId == user.Id);
}
}
/// <summary>
/// Gibt den Character eines Users zurück
/// </summary>
/// <param name="user">Der Client, dessen Character man bekommen möchte</param>
/// <param name="context">Ein eventuell vorhandener Datenbank-Context, falls man Änderungen in der Datenbank vornehmen will</param>
/// <returns></returns>
public static Character GetUserCharacter(this User user, DatabaseContext context = null)
{
if (context == null)

View File

@@ -18,6 +18,11 @@ namespace reallife_gamemode.Server.Extensions
{
public static class VehicleExtension
{
/// <summary>
/// Gibt zurück, ob das Vehicle ein Fraktions-Fahrzeug ist
/// </summary>
/// <param name="vehicle">Das Vehicle, von dem man wissen möchte, ob es ein Fraktionsfahrzeug ist</param>
/// <returns></returns>
public static bool IsFactionVehicle(this Vehicle vehicle)
{
return LoadManager.FactionVehicleList.Contains(vehicle);