bank account refactor
This commit is contained in:
@@ -2,15 +2,19 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Core.Commands.User;
|
||||
using ReallifeGamemode.Server.Core.Extensions;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
|
||||
namespace ReallifeGamemode.Server.Core.Commands.Admin
|
||||
{
|
||||
abstract class AdminCommand : Command
|
||||
abstract class AdminCommand : UserCommand
|
||||
{
|
||||
protected abstract AdminLevel AdminLevel { get; }
|
||||
|
||||
public override bool CanExecute(IPlayer player)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
return base.CanExecute(player) && player.IsAdmin(AdminLevel, GetDbContext());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ReallifeGamemode.Database.Models;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
using ReallifeGamemode.Server.Log;
|
||||
|
||||
@@ -11,8 +12,9 @@ namespace ReallifeGamemode.Server.Core.Commands
|
||||
{
|
||||
public abstract bool CanExecute(IPlayer player);
|
||||
|
||||
protected abstract IAPI Api { get; }
|
||||
protected IAPI Api => Main.API;
|
||||
protected ILogger Log { get; set; }
|
||||
|
||||
public abstract string CommandName { get; }
|
||||
public virtual string HelpText { get; } = null;
|
||||
|
||||
@@ -20,5 +22,7 @@ namespace ReallifeGamemode.Server.Core.Commands
|
||||
{
|
||||
Log = LogManager.GetLogger(this.GetType());
|
||||
}
|
||||
|
||||
protected DatabaseContext GetDbContext() => Main.GetDbContext();
|
||||
}
|
||||
}
|
||||
|
||||
15
ReallifeGamemode.Server.Core/Commands/User/UserCommand.cs
Normal file
15
ReallifeGamemode.Server.Core/Commands/User/UserCommand.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ReallifeGamemode.Server.Core.API;
|
||||
|
||||
namespace ReallifeGamemode.Server.Core.Commands.User
|
||||
{
|
||||
public abstract class UserCommand : Command
|
||||
{
|
||||
public override bool CanExecute(IPlayer player)
|
||||
{
|
||||
return player.GetSharedData("loggedIn", false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -36,7 +36,7 @@ namespace ReallifeGamemode.Server.Core.Menus
|
||||
return;
|
||||
}
|
||||
|
||||
var account = user.GetBankAccount(dbContext);
|
||||
var account = user.BankAccount;
|
||||
|
||||
if (account.Balance < 5000)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user