add localized level names
intellisense suggestion junk
This commit is contained in:
@ -273,7 +273,7 @@ namespace SharedLibraryCore.Commands
|
||||
|
||||
public override async Task ExecuteAsync(GameEvent E)
|
||||
{
|
||||
String You = String.Format("{0} [^3#{1}^7] {2} [^3@{3}^7] [{4}^7] IP: {5}", E.Origin.Name, E.Origin.ClientNumber, E.Origin.NetworkId, E.Origin.ClientId, Utilities.ConvertLevelToColor(E.Origin.Level), E.Origin.IPAddressString);
|
||||
String You = String.Format("{0} [^3#{1}^7] {2} [^3@{3}^7] [{4}^7] IP: {5}", E.Origin.Name, E.Origin.ClientNumber, E.Origin.NetworkId, E.Origin.ClientId, Utilities.ConvertLevelToColor(E.Origin.Level, E.Origin.ClientPermission.Name), E.Origin.IPAddressString);
|
||||
await E.Origin.Tell(You);
|
||||
}
|
||||
}
|
||||
@ -294,11 +294,11 @@ namespace SharedLibraryCore.Commands
|
||||
|
||||
if (P == null)
|
||||
continue;
|
||||
|
||||
// todo: fix spacing
|
||||
if (P.Masked)
|
||||
playerList.AppendFormat("[^3{0}^7]{3}[^3{1}^7] {2}", Utilities.ConvertLevelToColor(Player.Permission.User), P.ClientNumber, P.Name, Utilities.GetSpaces(Player.Permission.SeniorAdmin.ToString().Length - Player.Permission.User.ToString().Length));
|
||||
playerList.AppendFormat("[^3{0}^7]{3}[^3{1}^7] {2}", Utilities.ConvertLevelToColor(Player.Permission.User, P.ClientPermission.Name), P.ClientNumber, P.Name, Utilities.GetSpaces(Player.Permission.SeniorAdmin.ToString().Length - Player.Permission.User.ToString().Length));
|
||||
else
|
||||
playerList.AppendFormat("[^3{0}^7]{3}[^3{1}^7] {2}", Utilities.ConvertLevelToColor(P.Level), P.ClientNumber, P.Name, Utilities.GetSpaces(Player.Permission.SeniorAdmin.ToString().Length - P.Level.ToString().Length));
|
||||
playerList.AppendFormat("[^3{0}^7]{3}[^3{1}^7] {2}", Utilities.ConvertLevelToColor(P.Level, P.ClientPermission.Name), P.ClientNumber, P.Name, Utilities.GetSpaces(Player.Permission.SeniorAdmin.ToString().Length - P.Level.ToString().Length));
|
||||
|
||||
if (count == 2 || E.Owner.GetPlayersAsList().Count == 1)
|
||||
{
|
||||
@ -536,7 +536,7 @@ namespace SharedLibraryCore.Commands
|
||||
var onlineAdmins = S.GetPlayersAsList()
|
||||
.Where(p => p.Level > Player.Permission.Flagged)
|
||||
.Where(p => !p.Masked)
|
||||
.Select(p => $"[^3{Utilities.ConvertLevelToColor(p.Level)}^7] {p.Name}");
|
||||
.Select(p => $"[^3{Utilities.ConvertLevelToColor(p.Level, p.ClientPermission.Name)}^7] {p.Name}");
|
||||
|
||||
return onlineAdmins.Count() > 0 ?
|
||||
string.Join(Environment.NewLine, onlineAdmins) :
|
||||
@ -622,10 +622,11 @@ namespace SharedLibraryCore.Commands
|
||||
|
||||
foreach (var P in db_players)
|
||||
{
|
||||
string localizedLevel = Utilities.CurrentLocalization.LocalizationIndex[$"GLOBAL_PERMISSION_{P.Level.ToString().ToUpper()}"];
|
||||
// they're not going by another alias
|
||||
string msg = P.Name.ToLower().Contains(E.Data.ToLower()) ?
|
||||
$"[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor(P.Level)}^7] - {P.IPAddressString} | last seen {Utilities.GetTimePassed(P.LastConnection)}" :
|
||||
$"({P.AliasLink.Children.First(a => a.Name.ToLower().Contains(E.Data.ToLower())).Name})->[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor(P.Level)}^7] - {P.IPAddressString} | last seen {Utilities.GetTimePassed(P.LastConnection)}";
|
||||
$"[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor(P.Level, localizedLevel)}^7] - {P.IPAddressString} | last seen {Utilities.GetTimePassed(P.LastConnection)}" :
|
||||
$"({P.AliasLink.Children.First(a => a.Name.ToLower().Contains(E.Data.ToLower())).Name})->[^3{P.Name}^7] [^3@{P.ClientId}^7] - [{ Utilities.ConvertLevelToColor(P.Level, localizedLevel)}^7] - {P.IPAddressString} | last seen {Utilities.GetTimePassed(P.LastConnection)}";
|
||||
await E.Origin.Tell(msg);
|
||||
}
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ namespace SharedLibraryCore
|
||||
{
|
||||
public class RemoteFile : IFile
|
||||
{
|
||||
string Location;
|
||||
readonly string Location;
|
||||
string[] FileCache = new string[0];
|
||||
|
||||
public RemoteFile(string location) : base(string.Empty)
|
||||
@ -101,7 +101,7 @@ namespace SharedLibraryCore
|
||||
//END
|
||||
|
||||
private long sze;
|
||||
private String Name;
|
||||
private readonly String Name;
|
||||
private StreamReader Handle;
|
||||
}
|
||||
}
|
||||
|
13
SharedLibraryCore/Objects/Permission.cs
Normal file
13
SharedLibraryCore/Objects/Permission.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using static SharedLibraryCore.Objects.Player;
|
||||
|
||||
namespace SharedLibraryCore.Objects
|
||||
{
|
||||
public sealed class ClientPermission
|
||||
{
|
||||
public Permission Level { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
@ -26,7 +27,7 @@ namespace SharedLibraryCore.Objects
|
||||
SeniorAdmin = 5,
|
||||
Owner = 6,
|
||||
Creator = 7,
|
||||
Console = 8,
|
||||
Console = 8
|
||||
}
|
||||
|
||||
public Player()
|
||||
@ -102,8 +103,6 @@ namespace SharedLibraryCore.Objects
|
||||
[NotMapped]
|
||||
public int Score { get; set; }
|
||||
[NotMapped]
|
||||
public IList<Dtos.ProfileMeta> Meta { get; set; }
|
||||
[NotMapped]
|
||||
public bool IsBot { get; set; }
|
||||
private int _ipaddress;
|
||||
public override int IPAddress
|
||||
@ -115,7 +114,7 @@ namespace SharedLibraryCore.Objects
|
||||
public override string Name
|
||||
{
|
||||
get { return _name; }
|
||||
set { _name = value; }
|
||||
set { _name = value; }
|
||||
}
|
||||
[NotMapped]
|
||||
public bool IsAuthenticated { get; set; }
|
||||
@ -123,6 +122,14 @@ namespace SharedLibraryCore.Objects
|
||||
public ClientState State { get; set; }
|
||||
[NotMapped]
|
||||
public Queue<GameEvent> DelayedEvents { get; set; }
|
||||
[NotMapped]
|
||||
// this is kinda dirty, but I need localizable level names
|
||||
public ClientPermission ClientPermission => new ClientPermission()
|
||||
{
|
||||
Level = Level,
|
||||
Name = Utilities.CurrentLocalization
|
||||
.LocalizationIndex[$"GLOBAL_PERMISSION_{Level.ToString().ToUpper()}"]
|
||||
};
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
|
@ -330,8 +330,8 @@ namespace SharedLibraryCore
|
||||
protected ManualResetEventSlim OnRemoteCommandResponse;
|
||||
|
||||
// only here for performance
|
||||
private bool CustomSayEnabled;
|
||||
private string CustomSayName;
|
||||
private readonly bool CustomSayEnabled;
|
||||
private readonly string CustomSayName;
|
||||
|
||||
//Remote
|
||||
public IList<CommandResponseInfo> CommandResult = new List<CommandResponseInfo>();
|
||||
|
@ -56,7 +56,8 @@ namespace SharedLibraryCore
|
||||
String lookingFor = str.ToLower();
|
||||
|
||||
for (Player.Permission Perm = Player.Permission.User; Perm < Player.Permission.Console; Perm++)
|
||||
if (lookingFor.Contains(Perm.ToString().ToLower()))
|
||||
if (lookingFor.Contains(Perm.ToString().ToLower())
|
||||
|| lookingFor.Contains(CurrentLocalization.LocalizationIndex[$"GLOBAL_PERMISSION_{Perm.ToString().ToUpper()}"].ToLower()))
|
||||
return Perm;
|
||||
|
||||
return Player.Permission.Banned;
|
||||
@ -83,25 +84,36 @@ namespace SharedLibraryCore
|
||||
/// </summary>
|
||||
/// <param name="level">Specified player level</param>
|
||||
/// <returns></returns>
|
||||
public static String ConvertLevelToColor(Player.Permission level)
|
||||
public static String ConvertLevelToColor(Player.Permission level, string localizedLevel)
|
||||
{
|
||||
char colorCode = '6';
|
||||
// todo: maybe make this game independant?
|
||||
switch (level)
|
||||
{
|
||||
case Player.Permission.Banned:
|
||||
return "^1" + Player.Permission.Banned;
|
||||
colorCode = '1';
|
||||
break;
|
||||
case Player.Permission.Flagged:
|
||||
return "^9" + Player.Permission.Flagged;
|
||||
colorCode = '9';
|
||||
break;
|
||||
case Player.Permission.Owner:
|
||||
return "^5" + Player.Permission.Owner;
|
||||
colorCode = '5';
|
||||
break;
|
||||
case Player.Permission.User:
|
||||
return "^2" + Player.Permission.User;
|
||||
colorCode = '2';
|
||||
break;
|
||||
case Player.Permission.Trusted:
|
||||
return "^3" + Player.Permission.Trusted;
|
||||
colorCode = '3';
|
||||
break;
|
||||
default:
|
||||
return "^6" + level;
|
||||
break;
|
||||
}
|
||||
|
||||
return $"^{colorCode}{localizedLevel ?? level.ToString()}";
|
||||
}
|
||||
|
||||
public static string ToLocalizedLevelName(this Player.Permission perm) => CurrentLocalization.LocalizationIndex[$"GLOBAL_PERMISSION_{perm.ToString().ToUpper()}"];
|
||||
|
||||
public static String ProcessMessageToken(this Server server, IList<Helpers.MessageToken> tokens, String str)
|
||||
{
|
||||
MatchCollection RegexMatches = Regex.Matches(str, @"\{\{[A-Z]+\}\}", RegexOptions.IgnoreCase);
|
||||
|
Reference in New Issue
Block a user