Removed User.GetFaction()
This commit is contained in:
@@ -53,31 +53,21 @@ namespace ReallifeGamemode.Server.Entities
|
||||
public Faction Faction { get; set; }
|
||||
|
||||
public bool FactionLeader { get; set; }
|
||||
|
||||
|
||||
public int? FactionRankId { get; set; }
|
||||
public FactionRank FactionRank { get;set; }
|
||||
|
||||
public int? BusinessId { get; set; }
|
||||
|
||||
public Faction GetFaction()
|
||||
{
|
||||
using(var context = new DatabaseContext())
|
||||
{
|
||||
return context.Factions.FirstOrDefault(f => f.Id == FactionId);
|
||||
}
|
||||
}
|
||||
public FactionRank FactionRank { get; set; }
|
||||
|
||||
public FactionRank GetFactionRank()
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
FactionRank toReturn = context.FactionRanks.FirstOrDefault(fR => fR.Id == FactionRankId);
|
||||
if(toReturn == null)
|
||||
FactionRank toReturn = dbContext.FactionRanks.FirstOrDefault(fR => fR.Id == FactionRankId);
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = context.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == FactionId);
|
||||
toReturn = dbContext.FactionRanks.OrderBy(f => f.Order).FirstOrDefault(f => f.FactionId == FactionId);
|
||||
}
|
||||
|
||||
if(toReturn == null)
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = new FactionRank
|
||||
{
|
||||
@@ -89,6 +79,8 @@ namespace ReallifeGamemode.Server.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public int? BusinessId { get; set; }
|
||||
|
||||
public void BanPlayer(Client admin, string reason, int mins)
|
||||
{
|
||||
using (var banUserContext = new DatabaseContext())
|
||||
@@ -101,7 +93,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + this.Name + " wurde von " + admin.Name + " permanent gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = this.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp };
|
||||
|
||||
GetClient()?.Kick();
|
||||
this.Client?.Kick();
|
||||
|
||||
mins--;
|
||||
}
|
||||
@@ -109,7 +101,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
{
|
||||
NAPI.Chat.SendChatMessageToAll("!{#FF4040}[BAN] " + this.Name + " wurde von " + admin.Name + " für " + mins + " Minuten gebannt. [" + reason + "]");
|
||||
banUser = new Ban { UserId = this.Id, Reason = reason, BannedBy = admin.Name, Applied = unixTimestamp, UntilDateTime = unixTimestamp + mins * 60 };
|
||||
GetClient()?.Kick();
|
||||
this.Client?.Kick();
|
||||
}
|
||||
|
||||
banUserContext.Bans.Add(banUser);
|
||||
@@ -138,6 +130,7 @@ namespace ReallifeGamemode.Server.Entities
|
||||
return dbContext.UserItems.ToList().FindAll(u => u.UserId == this.Id);
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
|
||||
|
||||
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
|
||||
@@ -155,9 +148,10 @@ namespace ReallifeGamemode.Server.Entities
|
||||
}
|
||||
}
|
||||
|
||||
public Client GetClient()
|
||||
[NotMapped]
|
||||
public Client Client
|
||||
{
|
||||
return NAPI.Player.GetPlayerFromName(Name);
|
||||
get => NAPI.Player.GetPlayerFromName(this.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user