Add Header Comments, Add 'null'-Checks on Commands
This commit is contained in:
@@ -19,7 +19,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("o", "~m~Benutzung: ~s~/o [Nachricht]", GreedyArg = true)]
|
||||
public void CmdAdminO(Client player, string message)
|
||||
{
|
||||
if (!player.GetUser().IsAdmin(AdminLevel.SUPPORTER))
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
@@ -32,9 +32,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("veh", "~m~Benutzung:~s~ /veh [Fahrzeug] (Farbe 1) (Farbe 2)")]
|
||||
public void CmdAdminVeh(Client player, VehicleHash hash, int color1 = 111, int color2 = 111)
|
||||
{
|
||||
// Alternative: siehe O Chat
|
||||
int playerAdminLevel = 1;
|
||||
if (playerAdminLevel < /* Benötigtes Level */ 1)
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
@@ -54,7 +52,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("fixveh")]
|
||||
public void CmdAdminFixveh(Client player)
|
||||
{
|
||||
if (!player.GetUser().IsAdmin(AdminLevel.SUPPORTER))
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
@@ -72,8 +70,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("delveh")]
|
||||
public void CmdAdminDelveh(Client player)
|
||||
{
|
||||
int playerAdminLevel = 1;
|
||||
if (playerAdminLevel < /* Benötigtes Level */ 1)
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.ADMIN) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
@@ -94,7 +91,7 @@ namespace reallife_gamemode.Server.Commands
|
||||
[Command("goto", "~m~Benutzung:~s~ /goto [Name]")]
|
||||
public void CmdAdminGoto(Client player, string name)
|
||||
{
|
||||
if (!player.GetUser().IsAdmin(AdminLevel.SUPPORTER))
|
||||
if (!player.GetUser()?.IsAdmin(AdminLevel.SUPPORTER) ?? true)
|
||||
{
|
||||
ChatService.NotAuthorized(player);
|
||||
return;
|
||||
|
||||
@@ -3,17 +3,24 @@ using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace reallife_gamemode.Server.Extensions
|
||||
{
|
||||
public static class ClientExtension
|
||||
{
|
||||
/**
|
||||
* @overview Life of German Reallife - Client Extension (ClientExtension.cs)
|
||||
* @author VegaZ, hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
public static User GetUser(this Client client)
|
||||
{
|
||||
using(DatabaseContext dbContext = new DatabaseContext())
|
||||
{
|
||||
return dbContext.Users.Find(client.Name);
|
||||
return dbContext.Users.FirstOrDefault(u => u.Name == client.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,12 @@ namespace reallife_gamemode.Server.Services
|
||||
{
|
||||
class ChatService
|
||||
{
|
||||
/**
|
||||
* @overview Life of German Reallife - Chat Service (ChatService.cs)
|
||||
* @author hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
public static void NotAuthorized(Client player)
|
||||
{
|
||||
player.SendChatMessage("~r~[FEHLER]~s~ Du kannst diesen Befehl nicht ausführen.");
|
||||
|
||||
@@ -6,6 +6,12 @@ namespace reallife_gamemode.Server.Util
|
||||
{
|
||||
public enum AdminLevel : int
|
||||
{
|
||||
/**
|
||||
* @overview Life of German Reallife - Admin Levels (AdminLevel.cs)
|
||||
* @author VegaZ, hydrant
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
PLAYER,
|
||||
SUPPORTER,
|
||||
ADMIN
|
||||
|
||||
Reference in New Issue
Block a user