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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user