Skip to content

Commit 27cfc41

Browse files
authored
Merge pull request #68 from BPEssentials/colorize
2 parents d0ff470 + 9eed3ab commit 27cfc41

File tree

11 files changed

+96
-15
lines changed

11 files changed

+96
-15
lines changed

dist/localization.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@
113113
"pay_error_negative": "You cannot pay 0 or less.",
114114
"unbanned": "{0} was unbanned.",
115115
"user_not_found": "Could not find user by the username of {0}.",
116-
"user_not_ban": "{0} is not banned."
116+
"user_not_ban": "{0} is not banned.",
117+
"pm>": "[PM] {0} > {1}",
118+
"pm<": "[PM] {0} < {1}"
117119
},
118120
"BR": {
119121
"arrested": "Preso {0}.",

dist/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
},
1111
"Announcements": [],
1212
"Messages": {
13-
"DiscordLink": "http://discord.gg/WpdNCDw"
13+
"DiscordLink": "http://discord.gg/WpdNCDw",
14+
"InfoColor": "#179b43",
15+
"ArgColor": "#178d9b"
1416
},
1517
"Levenshtein": {
1618
"GiveMode": "Automatic",

src/BPEssentials/BPEssentials.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@
368368
<Compile Include="Paths.cs" />
369369
<Compile Include="Properties\AssemblyInfo.cs" />
370370
<Compile Include="FileChecker.cs" />
371-
<Compile Include="Utils\CustomFormatter.cs" />
371+
<Compile Include="Utils\Formatters\FormatterChat.cs" />
372+
<Compile Include="Utils\Formatters\FormatterResponse.cs" />
372373
<Compile Include="Utils\LevenshteinDistance.cs" />
373374
<Compile Include="Utils\IO.cs" />
374375
<Compile Include="Utils\ChatUtils.cs" />

src/BPEssentials/Commands/Kits/Kit.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ public void Invoke(ShPlayer player, string kit)
6060
player.AddCooldown(Core.Instance.KitHandler.Name, obj.Name, obj.Delay);
6161
}
6262
player.SendChatMessage(
63-
player.T(Core.Instance.KitHandler.Name + "_received", obj.Name) +
64-
(obj.Price > 0 ? player.T(Core.Instance.KitHandler.Name + "_received_Price", obj.Price.ToString()) : "") +
65-
(obj.Delay > 0 ? player.T(Core.Instance.KitHandler.Name + "_received_Delay", obj.Delay.ToString()) : ""));
63+
player.TC(Core.Instance.KitHandler.Name + "_received", obj.Name) +
64+
(obj.Price > 0 ? player.TC(Core.Instance.KitHandler.Name + "_received_Price", obj.Price.ToString()) : "") +
65+
(obj.Delay > 0 ? player.TC(Core.Instance.KitHandler.Name + "_received_Delay", obj.Delay.ToString()) : ""));
6666
}
6767
}
6868
}

src/BPEssentials/Commands/Warps/Warp.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ public void Invoke(ShPlayer player, string warp)
6060
player.AddCooldown(Core.Instance.WarpHandler.Name, obj.Name, obj.Delay);
6161
}
6262
player.SendChatMessage(
63-
player.T(Core.Instance.WarpHandler.Name + "_teleported", obj.Name) +
64-
(obj.Price > 0 ? player.T(Core.Instance.WarpHandler.Name + "_telported_Price", obj.Price.ToString()) : "") +
65-
(obj.Delay > 0 ? player.T(Core.Instance.WarpHandler.Name + "_telported_Delay", obj.Delay.ToString()) : ""));
63+
player.TC(Core.Instance.WarpHandler.Name + "_teleported", obj.Name) +
64+
(obj.Price > 0 ? player.TC(Core.Instance.WarpHandler.Name + "_telported_Price", obj.Price.ToString()) : "") +
65+
(obj.Delay > 0 ? player.TC(Core.Instance.WarpHandler.Name + "_telported_Delay", obj.Delay.ToString()) : ""));
6666
}
6767
}
6868
}

src/BPEssentials/Configuration/Models/SettingsModel.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ public class FunctionUI
6363
public class Messages
6464
{
6565
public string DiscordLink { get; set; }
66+
67+
public string InfoColor { get; set; } = "#179b43";
68+
69+
public string ArgColor { get; set; } = "#178d9b";
70+
6671
}
6772

6873
public class General

src/BPEssentials/ExtendedPlayer/ExtendedPlayer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public PlayerItem(ShPlayer player) : base(player)
3030

3131
public void SendPmMessage(ShPlayer target, string message)
3232
{
33-
Client.SendChatMessage($"[PM] {target.username.CleanerMessage()} > {message.CleanerMessage()}");
34-
target.SendChatMessage($"[PM] {Client.username.CleanerMessage()} < {message.CleanerMessage()}");
33+
Client.TS("pm>", target.username.CleanerMessage(), message.CleanerMessage());
34+
target.TS("pm<", Client.username.CleanerMessage(), message.CleanerMessage());
3535
}
3636

3737
public void SendSpyChatMessage(ShPlayer target, string command)

src/BPEssentials/ExtensionMethods/Player.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using BPEssentials.ExtendedPlayer;
2+
using BPEssentials.Utils.Formatter.Response;
23
using BrokeProtocol.Entities;
34
using BrokeProtocol.Utility;
45
using BrokeProtocol.Utility.Networking;
@@ -12,24 +13,42 @@ public static PlayerItem GetExtendedPlayer(this ShPlayer player)
1213
return Core.Instance.PlayerHandler.GetSafe(player.ID);
1314
}
1415

15-
public static string T(this SvPlayer player, string node, params object[] formatting) {
16+
public static string TC(this SvPlayer player, string node, params object[] formatting)
17+
{
18+
var formatter = new CustomFormatter(Core.Instance.Settings.Messages.ArgColor, Core.Instance.Settings.Messages.InfoColor);
19+
return $"<color={Core.Instance.Settings.Messages.InfoColor}>" +
20+
(Core.Instance.I18n.Localize(formatter, player.language.code, node, formatting) ?? Core.Instance.I18n.Localize(formatter, "EN", node, formatting) ?? $"{node} [{string.Join(", ", formatting)}]")
21+
+ "</color>";
22+
}
23+
24+
public static string TC(this ShPlayer player, string node, params object[] formatting)
25+
{
26+
return player.svPlayer.TC(node, formatting);
27+
}
28+
29+
public static string T(this SvPlayer player, string node, params object[] formatting)
30+
{
31+
1632
return Core.Instance.I18n.Localize(player.language.code, node, formatting) ?? Core.Instance.I18n.Localize("EN", node, formatting) ?? $"{node} [{string.Join(", ", formatting)}]";
33+
1734
}
1835

1936
public static string T(this ShPlayer player, string node, params object[] formatting)
2037
{
2138
return player.svPlayer.T(node, formatting);
2239
}
2340

41+
2442
public static void TS(this ShPlayer player, string node, params object[] formatting)
2543
{
26-
player.SendChatMessage(player.T(node, formatting));
44+
player.SendChatMessage(player.TC(node, formatting));
2745
}
2846

2947
public static void SendChatMessage(this ShPlayer player, string message, bool useColors = false)
3048
{
3149
message = useColors ? message.ParseColorCodes() : message;
3250
player.svPlayer.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, message);
3351
}
52+
3453
}
3554
}

src/BPEssentials/Utils/ChatUtils.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Linq;
44
using BPEssentials.Enums;
55
using BPEssentials.ExtensionMethods;
6+
using BPEssentials.Utils.Formatter.Chat;
67
using BrokeProtocol.Collections;
78
using BrokeProtocol.Entities;
89

@@ -18,7 +19,7 @@ public static void SendStaffChatMessage(ShPlayer player, string message)
1819
{
1920
continue;
2021
}
21-
currPlayer.SendChatMessage($"[STAFFCHAT] {player.username.CleanerMessage()}: {message}");
22+
currPlayer.SendChatMessage(ChatUtils.FormatMessage(player, message, "staffformat"), false);
2223
}
2324
}
2425

src/BPEssentials/Utils/CustomFormatter.cs renamed to src/BPEssentials/Utils/Formatters/FormatterChat.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using BPEssentials.ExtensionMethods;
55

66

7-
namespace BPEssentials.Utils
7+
namespace BPEssentials.Utils.Formatter.Chat
88
{
99
public class CustomFormatter : IFormatProvider, ICustomFormatter
1010
{

0 commit comments

Comments
 (0)