added editorconfig and formatted code
This commit is contained in:
@@ -14,94 +14,94 @@ using System.Linq;
|
||||
|
||||
namespace ReallifeGamemode.Server.Services
|
||||
{
|
||||
class ChatService
|
||||
class ChatService
|
||||
{
|
||||
public static void NotAuthorized(Client player)
|
||||
{
|
||||
public static void NotAuthorized(Client player)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Du kannst diesen Befehl nicht ausführen");
|
||||
}
|
||||
|
||||
public static void PlayerNotFound(Client player)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Der Spieler wurde nicht gefunden");
|
||||
}
|
||||
|
||||
public static void ErrorMessage(Client player, string message)
|
||||
{
|
||||
ChatService.SendMessage(player, $"~r~[FEHLER]~s~ {message}~s~.");
|
||||
}
|
||||
|
||||
public static void SendMessage(Client player, string message)
|
||||
{
|
||||
if (player == null) return;
|
||||
player.SendChatMessage(message);
|
||||
}
|
||||
|
||||
public static void Broadcast(string message) => NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).ToList().ForEach(c => SendMessage(c, message));
|
||||
|
||||
/// <summary>
|
||||
/// Sendet eine Nachricht an eine Liste von Fraktionen
|
||||
/// </summary>
|
||||
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
||||
/// <param name="factions">Die Liste an Fraktionen, die diese Nachricht bekommen sollen</param>
|
||||
public static void BroadcastFaction(string message, List<Faction> factions)
|
||||
{
|
||||
foreach (Client c in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
Faction f = c.GetUser()?.Faction;
|
||||
if (f != null)
|
||||
{
|
||||
if (factions.Find(fT => fT.Id == f.Id) != null)
|
||||
{
|
||||
ChatService.SendMessage(c, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet eine Nachricht an eine Fraktion
|
||||
/// </summary>
|
||||
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
||||
/// <param name="f">Die Fraktion, die diese Nachricht bekommen soll</param>
|
||||
public static void BroadcastFaction(string message, Faction f)
|
||||
{
|
||||
BroadcastFaction(message, new List<Faction>() { f });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet eine Nachricht an alle Spieler mit einem bestimmten Admin Level
|
||||
/// </summary>
|
||||
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
||||
/// <param name="minLevel">Das mindest Admin Level, das für das Erhalten dieser Nachricht benötigt wird</param>
|
||||
public static void BroadcastAdmin(string message, AdminLevel minLevel)
|
||||
{
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
if (p.GetUser()?.IsAdmin(minLevel) ?? false)
|
||||
{
|
||||
ChatService.SendMessage(p, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void BroadcastGroup(string message, Group group)
|
||||
{
|
||||
message = $"!{{FF8080}}** Gruppe: {message}";
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
Group pGroup = p.GetUser()?.Group;
|
||||
if (pGroup?.Id == group.Id)
|
||||
{
|
||||
ChatService.SendMessage(p, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void BroadcastJob(string message, JobBase job)
|
||||
{
|
||||
job.GetUsersInJob().ForEach(c => ChatService.SendMessage(c, message));
|
||||
}
|
||||
ChatService.ErrorMessage(player, "Du kannst diesen Befehl nicht ausführen");
|
||||
}
|
||||
|
||||
public static void PlayerNotFound(Client player)
|
||||
{
|
||||
ChatService.ErrorMessage(player, "Der Spieler wurde nicht gefunden");
|
||||
}
|
||||
|
||||
public static void ErrorMessage(Client player, string message)
|
||||
{
|
||||
ChatService.SendMessage(player, $"~r~[FEHLER]~s~ {message}~s~.");
|
||||
}
|
||||
|
||||
public static void SendMessage(Client player, string message)
|
||||
{
|
||||
if (player == null) return;
|
||||
player.SendChatMessage(message);
|
||||
}
|
||||
|
||||
public static void Broadcast(string message) => NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).ToList().ForEach(c => SendMessage(c, message));
|
||||
|
||||
/// <summary>
|
||||
/// Sendet eine Nachricht an eine Liste von Fraktionen
|
||||
/// </summary>
|
||||
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
||||
/// <param name="factions">Die Liste an Fraktionen, die diese Nachricht bekommen sollen</param>
|
||||
public static void BroadcastFaction(string message, List<Faction> factions)
|
||||
{
|
||||
foreach (Client c in NAPI.Pools.GetAllPlayers())
|
||||
{
|
||||
Faction f = c.GetUser()?.Faction;
|
||||
if (f != null)
|
||||
{
|
||||
if (factions.Find(fT => fT.Id == f.Id) != null)
|
||||
{
|
||||
ChatService.SendMessage(c, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet eine Nachricht an eine Fraktion
|
||||
/// </summary>
|
||||
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
||||
/// <param name="f">Die Fraktion, die diese Nachricht bekommen soll</param>
|
||||
public static void BroadcastFaction(string message, Faction f)
|
||||
{
|
||||
BroadcastFaction(message, new List<Faction>() { f });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sendet eine Nachricht an alle Spieler mit einem bestimmten Admin Level
|
||||
/// </summary>
|
||||
/// <param name="message">Die Nachricht, die gesendet werden soll</param>
|
||||
/// <param name="minLevel">Das mindest Admin Level, das für das Erhalten dieser Nachricht benötigt wird</param>
|
||||
public static void BroadcastAdmin(string message, AdminLevel minLevel)
|
||||
{
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
if (p.GetUser()?.IsAdmin(minLevel) ?? false)
|
||||
{
|
||||
ChatService.SendMessage(p, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void BroadcastGroup(string message, Group group)
|
||||
{
|
||||
message = $"!{{FF8080}}** Gruppe: {message}";
|
||||
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p =>
|
||||
{
|
||||
Group pGroup = p.GetUser()?.Group;
|
||||
if (pGroup?.Id == group.Id)
|
||||
{
|
||||
ChatService.SendMessage(p, message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void BroadcastJob(string message, JobBase job)
|
||||
{
|
||||
job.GetUsersInJob().ForEach(c => ChatService.SendMessage(c, message));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,34 +11,34 @@ using System.Text;
|
||||
|
||||
namespace ReallifeGamemode.Server.Services
|
||||
{
|
||||
class ClientService
|
||||
class ClientService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt einen Client anhand seines Namens oder der ID zurück
|
||||
/// </summary>
|
||||
/// <param name="nameOrId">Die ID oder der Name, nach dem gesucht werden soll</param>
|
||||
/// <returns></returns>
|
||||
public static Client GetClientByNameOrId(string nameOrId)
|
||||
{
|
||||
/// <summary>
|
||||
/// Gibt einen Client anhand seines Namens oder der ID zurück
|
||||
/// </summary>
|
||||
/// <param name="nameOrId">Die ID oder der Name, nach dem gesucht werden soll</param>
|
||||
/// <returns></returns>
|
||||
public static Client GetClientByNameOrId(string nameOrId)
|
||||
{
|
||||
Client toReturn = null;
|
||||
nameOrId = nameOrId.ToLower();
|
||||
Client toReturn = null;
|
||||
nameOrId = nameOrId.ToLower();
|
||||
|
||||
List<Client> playerList = NAPI.Pools.GetAllPlayers();
|
||||
List<Client> playerList = NAPI.Pools.GetAllPlayers();
|
||||
|
||||
if (int.TryParse(nameOrId, out int id))
|
||||
{
|
||||
toReturn = playerList.Find(p => p.Handle.Value == id);
|
||||
return toReturn;
|
||||
}
|
||||
if (int.TryParse(nameOrId, out int id))
|
||||
{
|
||||
toReturn = playerList.Find(p => p.Handle.Value == id);
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
toReturn = playerList.Find(p => p.Name.ToLower() == nameOrId);
|
||||
toReturn = playerList.Find(p => p.Name.ToLower() == nameOrId);
|
||||
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = playerList.Find(p => p.Name.ToLower().StartsWith(nameOrId));
|
||||
}
|
||||
if (toReturn == null)
|
||||
{
|
||||
toReturn = playerList.Find(p => p.Name.ToLower().StartsWith(nameOrId));
|
||||
}
|
||||
|
||||
return toReturn;
|
||||
}
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user