Skip to content

Commit 314045b

Browse files
Add rich text support and remove "x player homes data has been saved!" log
1 parent 7b00124 commit 314045b

21 files changed

Lines changed: 119 additions & 116 deletions

MoreHomes/Commands/DestroyHomeCommand.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,38 +2,37 @@
22
using Rocket.Unturned.Player;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using Rocket.Unturned.Chat;
65
using RestoreMonarchy.MoreHomes.Models;
76
using RestoreMonarchy.MoreHomes.Helpers;
87

98
namespace RestoreMonarchy.MoreHomes.Commands
109
{
1110
public class DestroyHomeCommand : IRocketCommand
1211
{
13-
private MoreHomesPlugin pluginInstance => MoreHomesPlugin.Instance;
12+
private MoreHomesPlugin pluginInstance => MoreHomesPlugin.Instance;
1413

1514
public void Execute(IRocketPlayer caller, string[] command)
1615
{
1716
UnturnedPlayer player = (UnturnedPlayer)caller;
1817
string homeName = command.ElementAtOrDefault(0);
19-
18+
2019
if (string.IsNullOrEmpty(homeName))
2120
{
22-
UnturnedChat.Say(caller, pluginInstance.Translate("DestroyHomeFormat"), pluginInstance.MessageColor);
21+
pluginInstance.SendMessageToPlayer(caller, "DestroyHomeFormat");
2322
return;
2423
}
2524

2625
PlayerHome home = HomesHelper.GetPlayerHome(player.CSteamID, homeName);
2726
if (home == null)
2827
{
29-
UnturnedChat.Say(caller, pluginInstance.Translate("HomeNotFound", home.Name), pluginInstance.MessageColor);
28+
pluginInstance.SendMessageToPlayer(caller, "HomeNotFound", homeName);
3029
return;
3130
}
3231

3332
HomesHelper.RemoveHome(player.CSteamID, home);
3433
home.Destroy();
3534

36-
UnturnedChat.Say(caller, pluginInstance.Translate("DestroyHomeSuccess", home.Name), pluginInstance.MessageColor);
35+
pluginInstance.SendMessageToPlayer(caller, "DestroyHomeSuccess", home.Name);
3736
}
3837

3938
public AllowedCaller AllowedCaller => AllowedCaller.Player;
@@ -48,4 +47,4 @@ public void Execute(IRocketPlayer caller, string[] command)
4847

4948
public List<string> Permissions => new List<string>();
5049
}
51-
}
50+
}

MoreHomes/Commands/HomeCommand.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using Rocket.API;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using Rocket.Unturned.Chat;
65
using Rocket.Core.Utils;
76
using Rocket.Unturned.Player;
87
using SDG.Unturned;
@@ -11,7 +10,6 @@
1110
using System;
1211
using RestoreMonarchy.MoreHomes.Helpers;
1312
using UnityEngine;
14-
using System.Threading;
1513

1614
namespace RestoreMonarchy.MoreHomes.Commands
1715
{
@@ -26,17 +24,18 @@ public void Execute(IRocketPlayer caller, string[] command)
2624

2725
if (home == null)
2826
{
29-
UnturnedChat.Say(caller, pluginInstance.Translate("NoHome"), pluginInstance.MessageColor);
27+
pluginInstance.SendMessageToPlayer(caller, "NoHome");
3028
return;
3129
}
3230

3331
if (!ValidateTeleportation(player, home))
32+
{
3433
return;
34+
}
3535

3636
if (pluginInstance.PlayerCooldowns.TryGetValue(caller.Id, out DateTime cooldownExpire) && cooldownExpire > DateTime.Now)
3737
{
38-
UnturnedChat.Say(caller, pluginInstance.Translate("HomeCooldown", System.Math.Round((cooldownExpire - DateTime.Now).TotalSeconds)),
39-
pluginInstance.MessageColor);
38+
pluginInstance.SendMessageToPlayer(caller, "HomeCooldown", Math.Round((cooldownExpire - DateTime.Now).TotalSeconds));
4039
return;
4140
}
4241

@@ -46,7 +45,7 @@ public void Execute(IRocketPlayer caller, string[] command)
4645

4746
if (delay > 0)
4847
{
49-
UnturnedChat.Say(caller, pluginInstance.Translate("HomeDelayWarn", delay), pluginInstance.MessageColor);
48+
pluginInstance.SendMessageToPlayer(caller, "HomeDelayWarn", delay);
5049
}
5150

5251
bool shouldCancel = false;
@@ -56,9 +55,9 @@ public void Execute(IRocketPlayer caller, string[] command)
5655
pluginInstance.MovementDetector.AddPlayer(player.Player, () =>
5756
{
5857
shouldCancel = true;
59-
UnturnedChat.Say(player, pluginInstance.Translate("HomeCanceledYouMoved"), pluginInstance.MessageColor);
58+
pluginInstance.SendMessageToPlayer(player, "HomeCanceledYouMoved");
6059
});
61-
}
60+
}
6261

6362
TaskDispatcher.QueueOnMainThread(() =>
6463
{
@@ -80,11 +79,11 @@ public void Execute(IRocketPlayer caller, string[] command)
8079

8180
if (!player.Player.teleportToLocation(home.LivePosition + new Vector3(0f, pluginInstance.Configuration.Instance.TeleportHeight, 0f), player.Rotation))
8281
{
83-
UnturnedChat.Say(caller, pluginInstance.Translate("HomeTeleportationFailed", home.Name), pluginInstance.MessageColor);
82+
pluginInstance.SendMessageToPlayer(caller, "HomeTeleportationFailed", home.Name);
8483
pluginInstance.PlayerCooldowns.Remove(caller.Id);
8584
return;
8685
}
87-
UnturnedChat.Say(caller, pluginInstance.Translate("HomeSuccess", home.Name), pluginInstance.MessageColor);
86+
pluginInstance.SendMessageToPlayer(caller, "HomeSuccess", home.Name);
8887
}, delay);
8988
}
9089

@@ -93,13 +92,13 @@ private bool ValidateTeleportation(UnturnedPlayer player, PlayerHome home)
9392
if (home.InteractableBed == null || !home.InteractableBed.isActiveAndEnabled || home.InteractableBed.owner != player.CSteamID)
9493
{
9594
HomesHelper.RemoveHome(player.CSteamID, home);
96-
UnturnedChat.Say(player, pluginInstance.Translate("BedDestroyed"), pluginInstance.MessageColor);
95+
pluginInstance.SendMessageToPlayer(player, "BedDestroyed");
9796
return false;
9897
}
9998

10099
if (player.Stance == EPlayerStance.DRIVING)
101100
{
102-
UnturnedChat.Say(player, pluginInstance.Translate("WhileDriving"), pluginInstance.MessageColor);
101+
pluginInstance.SendMessageToPlayer(player, "WhileDriving");
103102
return false;
104103
}
105104

@@ -116,18 +115,18 @@ private bool ValitedateRaidAndCombat(UnturnedPlayer player)
116115
TeleportationPlugin teleportation = pluginInstance.TeleportationPlugin as TeleportationPlugin;
117116
if (teleportation.IsPlayerInCombat(player.CSteamID))
118117
{
119-
UnturnedChat.Say(player, pluginInstance.Translate("WhileCombat"), pluginInstance.MessageColor);
118+
pluginInstance.SendMessageToPlayer(player, "WhileCombat");
120119
return false;
121120
}
122121

123122
if (teleportation.IsPlayerInRaid(player.CSteamID))
124123
{
125-
UnturnedChat.Say(player, pluginInstance.Translate("WhileRaid"), pluginInstance.MessageColor);
124+
pluginInstance.SendMessageToPlayer(player, "WhileRaid");
126125
return false;
127126
}
128127
return true;
129128
}
130-
129+
131130
public AllowedCaller AllowedCaller => AllowedCaller.Player;
132131

133132
public string Name => "home";
@@ -140,4 +139,4 @@ private bool ValitedateRaidAndCombat(UnturnedPlayer player)
140139

141140
public List<string> Permissions => new List<string>();
142141
}
143-
}
142+
}

MoreHomes/Commands/HomesCommand.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
using RestoreMonarchy.MoreHomes.Helpers;
22
using RestoreMonarchy.MoreHomes.Models;
33
using Rocket.API;
4-
using Rocket.Unturned.Chat;
54
using Rocket.Unturned.Player;
65
using System.Collections.Generic;
76
using System.Text;
@@ -14,24 +13,24 @@ public class HomesCommand : IRocketCommand
1413
public void Execute(IRocketPlayer caller, string[] command)
1514
{
1615
UnturnedPlayer player = (UnturnedPlayer)caller;
17-
16+
1817
PlayerData playerData = HomesHelper.GetOrCreatePlayer(player.CSteamID);
1918

2019
if (playerData.Homes.Count == 0)
2120
{
22-
UnturnedChat.Say(caller, pluginInstance.Translate("NoHomes"), pluginInstance.MessageColor);
21+
pluginInstance.SendMessageToPlayer(caller, "NoHomes");
2322
return;
2423
}
2524

2625
StringBuilder sb = new StringBuilder(pluginInstance.Translate("HomeList", playerData.Homes.Count, VipHelper.GetPlayerMaxHomes(player.Id)));
27-
26+
2827
foreach (PlayerHome home in playerData.Homes)
2928
{
3029
sb.Append($"{home.Name}, ");
3130
}
3231
string msg = sb.ToString().TrimEnd(',', ' ');
3332

34-
UnturnedChat.Say(caller, msg, pluginInstance.MessageColor);
33+
pluginInstance.SendMessageToPlayer(caller, msg);
3534
}
3635

3736
public AllowedCaller AllowedCaller => AllowedCaller.Player;
@@ -44,6 +43,6 @@ public void Execute(IRocketPlayer caller, string[] command)
4443

4544
public List<string> Aliases => new List<string>();
4645

47-
public List<string> Permissions => new List<string>();
46+
public List<string> Permissions => new List<string>();
4847
}
49-
}
48+
}

MoreHomes/Commands/RenameHomeCommand.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Rocket.API;
2-
using Rocket.Unturned.Chat;
32
using Rocket.Unturned.Player;
43
using System.Collections.Generic;
54
using RestoreMonarchy.MoreHomes.Helpers;
@@ -15,25 +14,25 @@ public void Execute(IRocketPlayer caller, string[] command)
1514
UnturnedPlayer player = (UnturnedPlayer)caller;
1615
if (command.Length < 2)
1716
{
18-
UnturnedChat.Say(caller, pluginInstance.Translate("RenameHomeFormat"));
17+
pluginInstance.SendMessageToPlayer(caller, "RenameHomeFormat");
1918
return;
2019
}
2120

2221
var home = HomesHelper.GetPlayerHome(player.CSteamID, command[0]);
2322
if (home == null)
2423
{
25-
UnturnedChat.Say(player, pluginInstance.Translate("HomeNotFound", command[0]), pluginInstance.MessageColor);
24+
pluginInstance.SendMessageToPlayer(player, "HomeNotFound", command[0]);
2625
return;
2726
}
2827

2928
if (HomesHelper.GetPlayerHome(player.CSteamID, command[1]) != null)
3029
{
31-
UnturnedChat.Say(player, pluginInstance.Translate("RenameHomeFail", command[1]), pluginInstance.MessageColor);
30+
pluginInstance.SendMessageToPlayer(player, "RenameHomeFail", command[1]);
3231
return;
3332
}
3433

3534
home.Name = command[1];
36-
UnturnedChat.Say(player, pluginInstance.Translate("RenameHomeSuccess", command[0], command[1]), pluginInstance.MessageColor);
35+
pluginInstance.SendMessageToPlayer(player, "RenameHomeSuccess", command[0], command[1]);
3736
}
3837

3938
public AllowedCaller AllowedCaller => AllowedCaller.Player;
@@ -48,4 +47,4 @@ public void Execute(IRocketPlayer caller, string[] command)
4847

4948
public List<string> Permissions => new List<string>();
5049
}
51-
}
50+
}

MoreHomes/Commands/RestoreHomesCommand.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ public void Execute(IRocketPlayer caller, string[] command)
2121
InteractableBed interactableBed = drop.interactable as InteractableBed;
2222
if (interactableBed != null && interactableBed.isClaimed)
2323
{
24-
var player = HomesHelper.GetOrCreatePlayer(interactableBed.owner);
25-
var playerHome = new PlayerHome(player.GetUniqueHomeName(), interactableBed);
24+
PlayerData player = HomesHelper.GetOrCreatePlayer(interactableBed.owner);
25+
PlayerHome playerHome = new PlayerHome(player.GetUniqueHomeName(), interactableBed);
2626
player.Homes.Add(playerHome);
2727
num++;
2828
}
2929
}
3030
}
3131
pluginInstance.DataService.SaveData();
32-
UnturnedChat.Say(caller, pluginInstance.Translate("RestoreHomesSuccess", num), pluginInstance.MessageColor);
32+
pluginInstance.SendMessageToPlayer(caller, "RestoreHomesSuccess", num.ToString("N0"));
3333
}
3434

3535
public AllowedCaller AllowedCaller => AllowedCaller.Console;

MoreHomes/MoreHomes.csproj

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -4,54 +4,19 @@
44
<TargetFramework>net48</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<RootNamespace>RestoreMonarchy.MoreHomes</RootNamespace>
7-
<Version>1.9.0</Version>
7+
<Version>1.10.0</Version>
88
</PropertyGroup>
99

1010
<ItemGroup>
1111
<PackageReference Include="Lib.Harmony" Version="2.2.2" />
12+
<PackageReference Include="RestoreMonarchy.RocketRedist" Version="3.24.6" ExcludeAssets="runtime" />
1213
</ItemGroup>
1314

1415
<ItemGroup>
15-
<Reference Include="Assembly-CSharp">
16-
<HintPath>..\lib\Assembly-CSharp.dll</HintPath>
17-
<Private>False</Private>
18-
</Reference>
19-
<Reference Include="com.rlabrecque.steamworks.net">
20-
<HintPath>..\lib\com.rlabrecque.steamworks.net.dll</HintPath>
21-
<Private>False</Private>
22-
</Reference>
23-
<Reference Include="Newtonsoft.Json">
24-
<HintPath>..\lib\Newtonsoft.Json.dll</HintPath>
25-
<Private>False</Private>
26-
</Reference>
27-
<Reference Include="Rocket.API">
28-
<HintPath>..\lib\Rocket.API.dll</HintPath>
29-
<Private>False</Private>
30-
</Reference>
31-
<Reference Include="Rocket.Core">
32-
<HintPath>..\lib\Rocket.Core.dll</HintPath>
33-
<Private>False</Private>
34-
</Reference>
35-
<Reference Include="Rocket.Unturned">
36-
<HintPath>..\lib\Rocket.Unturned.dll</HintPath>
37-
<Private>False</Private>
38-
</Reference>
39-
<Reference Include="SDG.NetTransport">
40-
<HintPath>..\lib\SDG.NetTransport.dll</HintPath>
41-
<Private>False</Private>
42-
</Reference>
4316
<Reference Include="Teleportation">
4417
<HintPath>..\lib\Teleportation.dll</HintPath>
4518
<Private>False</Private>
4619
</Reference>
47-
<Reference Include="UnityEngine">
48-
<HintPath>..\lib\UnityEngine.dll</HintPath>
49-
<Private>False</Private>
50-
</Reference>
51-
<Reference Include="UnityEngine.CoreModule">
52-
<HintPath>..\lib\UnityEngine.CoreModule.dll</HintPath>
53-
<Private>False</Private>
54-
</Reference>
5520
</ItemGroup>
5621

5722
</Project>

MoreHomes/MoreHomesConfiguration.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ namespace RestoreMonarchy.MoreHomes
66
{
77
public class MoreHomesConfiguration : IRocketPluginConfiguration
88
{
9-
public string MessageColor { get; set; }
9+
public string MessageColor { get; set; }
10+
public string MessageIconUrl { get; set; } = "https://i.imgur.com/9TF5aB1.png";
1011
public int DefaultHomeCooldown { get; set; }
1112
public int DefaultHomeDelay { get; set; }
1213
public int DefaultMaxHomes { get; set; }
@@ -20,6 +21,7 @@ public class MoreHomesConfiguration : IRocketPluginConfiguration
2021
public void LoadDefaults()
2122
{
2223
MessageColor = "yellow";
24+
MessageIconUrl = "https://i.imgur.com/9TF5aB1.png";
2325
DefaultHomeCooldown = 20;
2426
DefaultHomeDelay = 10;
2527
DefaultMaxHomes = 2;

0 commit comments

Comments
 (0)