Merge branch 'develop' into feature/inventory-system

This commit is contained in:
VegaZ
2018-11-30 20:49:12 +01:00
55 changed files with 1114 additions and 9974 deletions

View File

@@ -3,11 +3,9 @@ using reallife_gamemode.Model;
using reallife_gamemode.Server.Extensions;
using reallife_gamemode.Server.Util;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
/**
* @overview Life of German Reallife - Entities User (User.cs)
@@ -59,6 +57,8 @@ namespace reallife_gamemode.Server.Entities
public int? FactionRankId { get; set; }
public FactionRank FactionRank { get;set; }
public int? BusinessId { get; set; }
public Faction GetFaction()
{
using(var context = new DatabaseContext())
@@ -100,14 +100,16 @@ namespace reallife_gamemode.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 };
//TODO user.Kick();
GetClient()?.Kick();
mins--;
}
else
{
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 };
//TODO user.Kick();
GetClient()?.Kick();
}
banUserContext.Bans.Add(banUser);
@@ -119,12 +121,11 @@ namespace reallife_gamemode.Server.Entities
}
}
public void UnbanPlayer(Client admin)
public void UnbanPlayer()
{
using (var unbanUser = new DatabaseContext())
{
User user = admin.GetUser();
var targetUser = unbanUser.Users.FirstOrDefault(u => u.Id == user.Id);
var targetUser = unbanUser.Users.FirstOrDefault(u => u.Id == this.Id);
targetUser.BanId = null;
unbanUser.SaveChanges();
}
@@ -153,5 +154,10 @@ namespace reallife_gamemode.Server.Entities
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
}
}
public Client GetClient()
{
return NAPI.Player.GetPlayerFromName(Name);
}
}
}