Skip to content

Commit 4e84fdc

Browse files
committed
Merged branch develop and master together
1 parent cc1cdf3 commit 4e84fdc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+1435
-1795
lines changed

source/BP-Essentials/BP-Essentials.csproj

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
<ItemGroup>
4444
<Compile Include="Chat\Commands\Admin\Arrest.cs" />
4545
<Compile Include="Chat\Commands\Admin\CheckAlts.cs" />
46+
<Compile Include="Chat\Commands\Admin\Clear.cs" />
4647
<Compile Include="Chat\Commands\Admin\ClearWanted.cs" />
4748
<Compile Include="Chat\Commands\Admin\FakeJoin.cs" />
4849
<Compile Include="Chat\Commands\Admin\FakeLeave.cs" />
@@ -58,11 +59,15 @@
5859
<Compile Include="Chat\Commands\Admin\LatestVoteResults.cs" />
5960
<Compile Include="Chat\Commands\Admin\Launch.cs" />
6061
<Compile Include="Chat\Commands\Admin\Money.cs" />
62+
<Compile Include="Chat\Commands\Admin\Promote.cs" />
6163
<Compile Include="Chat\Commands\Admin\Restrain.cs" />
6264
<Compile Include="Chat\Commands\Admin\Say.cs" />
6365
<Compile Include="Chat\Commands\Admin\Search.cs" />
66+
<Compile Include="Chat\Commands\Admin\Spy.cs" />
6467
<Compile Include="Chat\Commands\Admin\ToggleReceiveStaffChat.cs" />
6568
<Compile Include="Chat\Commands\Admin\ToggleStaffChat.cs" />
69+
<Compile Include="Chat\Commands\Admin\TpHere.cs" />
70+
<Compile Include="Chat\Commands\Admin\TpToApartment.cs" />
6671
<Compile Include="Chat\Commands\Admin\_SetJob.cs" />
6772
<Compile Include="Chat\Commands\Admin\Slap.cs" />
6873
<Compile Include="Chat\Commands\Admin\Strip.cs" />
@@ -73,7 +78,6 @@
7378
<Compile Include="Chat\Commands\Admin\DebugCommands.cs" />
7479
<Compile Include="Chat\Commands\Everyone\Confirm.cs" />
7580
<Compile Include="Chat\Commands\Everyone\Essentials.cs" />
76-
<Compile Include="Chat\Commands\Admin\ExecuteOnPlayer.cs" />
7781
<Compile Include="Chat\Commands\Admin\GodMode.cs" />
7882
<Compile Include="Chat\Commands\Admin\Mute.cs" />
7983
<Compile Include="Chat\Commands\Everyone\OnlinePlayers.cs" />
@@ -92,15 +96,18 @@
9296
<Compile Include="Chat\Announce.cs" />
9397
<Compile Include="Methods\API\DownloadFile.cs" />
9498
<Compile Include="Methods\API\FilterComments.cs" />
99+
<Compile Include="Methods\API\GetShByStr.cs" />
95100
<Compile Include="Methods\API\GetShBySv.cs" />
96101
<Compile Include="Methods\API\HasPermission.cs" />
102+
<Compile Include="Methods\API\SendDiscordMessage.cs" />
97103
<Compile Include="Methods\API\StringToVar.cs" />
98104
<Compile Include="Methods\Check\CheckAltAcc.cs" />
99105
<Compile Include="Methods\Check\CheckBanned.cs" />
100106
<Compile Include="Methods\FileHandler\CheckFiles.cs" />
101107
<Compile Include="Methods\Check\CheckGodMode.cs" />
102108
<Compile Include="Methods\FileHandler\CreateFile.cs" />
103109
<Compile Include="Methods\FileHandler\ReadGroups.cs" />
110+
<Compile Include="Methods\FileHandler\RegisterCommands.cs" />
104111
<Compile Include="Methods\GameMethods\CleanupApartment.cs" />
105112
<Compile Include="Methods\GameMethods\SetJob.cs" />
106113
<Compile Include="Methods\GameMethods\UnRetain.cs" />
@@ -138,11 +145,7 @@
138145
<Private>False</Private>
139146
</Reference>
140147
<Reference Include="System" />
141-
<Reference Include="System.Runtime.Serialization, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
142-
<SpecificVersion>False</SpecificVersion>
143-
<HintPath>..\..\..\..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Unity Full v3.5\System.Runtime.Serialization.dll</HintPath>
144-
<Private>False</Private>
145-
</Reference>
148+
<Reference Include="System.Runtime.Serialization" />
146149
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
147150
<HintPath>..\..\BrokeProtocol_Data\Managed\UnityEngine.dll</HintPath>
148151
</Reference>
@@ -291,10 +294,6 @@
291294
<ItemGroup>
292295
<None Include="BP-Essentials.ruleset" />
293296
</ItemGroup>
294-
<ItemGroup>
295-
<Content Include="Newtonsoft.Json.dll" />
296-
<Content Include="System.Runtime.Serialization.dll" />
297-
</ItemGroup>
298297
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
299298
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
300299
Other similar extension points exist, see Microsoft.Common.targets.

source/BP-Essentials/Chat/Announce.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using static BP_Essentials.EssentialsVariablesPlugin;
77
using static BP_Essentials.EssentialsMethodsPlugin;
88
using System.Threading;
9-
using System.Timers;
109

1110
namespace BP_Essentials.Chat
1211
{
@@ -17,10 +16,9 @@ public static void Run(object man)
1716
try
1817
{
1918
var svManager = (SvManager)man;
20-
var Tmer = new System.Timers.Timer();
21-
Tmer.Elapsed += (sender, e) => OnTime(svManager);
22-
Tmer.Interval = TimeBetweenAnnounce * 1000;
23-
Tmer.Enabled = true;
19+
_Timer.Elapsed += (sender, e) => OnTime(svManager);
20+
_Timer.Interval = TimeBetweenAnnounce * 1000;
21+
_Timer.Enabled = true;
2422
}
2523
catch (Exception ex)
2624
{
@@ -32,7 +30,8 @@ private static void OnTime(object onetMan)
3230
{
3331
var svManager = (SvManager)onetMan;
3432
foreach (var player in svManager.players)
35-
player.svPlayer.SendToSelf(Channel.Reliable, ClPacket.GameMessage, Announcements[AnnounceIndex]);
33+
foreach (var line in Announcements[AnnounceIndex].Split(new[] { "\\r\\n", "\\r", "\\n" }, StringSplitOptions.None))
34+
player.Value.svPlayer.SendToSelf(Channel.Reliable, ClPacket.GameMessage, line);
3635
Debug.Log($"{SetTimeStamp.Run()}[INFO] Announcement made...");
3736
AnnounceIndex += 1;
3837
if (AnnounceIndex > Announcements.Length - 1)

source/BP-Essentials/Chat/Commands/Admin/Arrest.cs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,27 +10,23 @@ namespace BP_Essentials.Commands
1010
{
1111
class Arrest : EssentialsChatPlugin
1212
{
13-
public static bool Run(object oPlayer, string message)
13+
public static void Run(SvPlayer player, string message)
1414
{
15-
try
15+
string arg1 = GetArgument.Run(1, false, true, message);
16+
if (!string.IsNullOrEmpty(arg1))
1617
{
17-
var player = (SvPlayer)oPlayer;
18-
if (HasPermission.Run(player, CmdArrestExecutableBy))
18+
var shPlayer = GetShByStr.Run(arg1);
19+
if (shPlayer == null)
1920
{
20-
string arg1 = GetArgument.Run(1, false, true, message);
21-
if (!string.IsNullOrEmpty(arg1))
22-
ExecuteOnPlayer.Run(player, message, arg1);
23-
else
24-
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
21+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
22+
return;
2523
}
26-
else
27-
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
28-
}
29-
catch (Exception ex)
30-
{
31-
ErrorLogging.Run(ex);
24+
shPlayer.svPlayer.Restrain(shPlayer.manager.handcuffed);
25+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Arrested</color> <color={argColor}>" + shPlayer.username + $"</color><color={infoColor}>.</color>");
26+
3227
}
33-
return true;
28+
else
29+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
3430
}
3531
}
3632
}
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
using System;
22
using static BP_Essentials.EssentialsVariablesPlugin;
33
namespace BP_Essentials.Commands {
4-
public class Ban : EssentialsChatPlugin {
5-
public static bool Run(object oPlayer, string message) {
6-
try
4+
public class Ban : EssentialsChatPlugin
5+
{
6+
public static void Run(SvPlayer player, string message)
7+
{
8+
var arg1 = GetArgument.Run(1, false, false, message);
9+
var arg2 = GetArgument.Run(2, false, true, message);
10+
if (!string.IsNullOrEmpty(arg1) || !string.IsNullOrEmpty(arg2))
711
{
8-
var player = (SvPlayer)oPlayer;
9-
if (HasPermission.Run(player, CmdBanExecutableBy))
12+
var shPlayer = GetShByStr.Run(arg1, true);
13+
if (shPlayer == null)
1014
{
11-
string arg1 = GetArgument.Run(1, false, true, message);
12-
if (!string.IsNullOrEmpty(arg1))
13-
ExecuteOnPlayer.Run(player, message, arg1);
14-
else
15-
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
15+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnlineIdOnly);
16+
return;
1617
}
17-
else
18-
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
18+
LogMessage.LogOther($"{SetTimeStamp.Run()}[INFO] {shPlayer.username} Got banned by {player.playerData.username}");
19+
player.SendToAll(Channel.Unsequenced, ClPacket.GameMessage, $"<color={argColor}>{shPlayer.username}</color> <color={warningColor}>Just got banned by</color> <color={argColor}>{player.playerData.username}</color>");
20+
SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username, arg2);
21+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Banned</color> <color={argColor}>{shPlayer.username}</color><color={infoColor}>. (Reason: {arg2})</color>");
22+
player.svManager.AddBanned(shPlayer);
23+
player.svManager.Disconnect(shPlayer.svPlayer.connection);
1924
}
20-
catch (Exception ex)
21-
{
22-
ErrorLogging.Run(ex);
23-
}
24-
return true;
25+
else
26+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
2527
}
2628
}
2729
}

source/BP-Essentials/Chat/Commands/Admin/CheckAlts.cs

Lines changed: 33 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -11,65 +11,50 @@ namespace BP_Essentials.Commands
1111
{
1212
class CheckAlts : EssentialsChatPlugin
1313
{
14-
public static bool Run(object oPlayer, string message)
14+
public static void Run(SvPlayer player, string message)
1515
{
16-
try
16+
var arg1 = GetArgument.Run(1, false, false, message);
17+
var found = 0;
18+
if (!String.IsNullOrEmpty(arg1))
1719
{
18-
var player = (SvPlayer)oPlayer;
19-
if (HasPermission.Run(player, CmdCheckAltsExecutableBy))
20+
var arg2 = GetArgument.Run(2, false, true, message);
21+
if (arg1.Equals("ip", StringComparison.InvariantCultureIgnoreCase))
2022
{
21-
var arg1 = GetArgument.Run(1, false, false, message);
22-
var found = 0;
23-
if (!String.IsNullOrEmpty(arg1))
23+
var content = "Possible accounts using the IP " + arg2 + ":\r\n\r\n";
24+
var builder = new StringBuilder();
25+
builder.Append(content);
26+
foreach (var line in File.ReadAllLines(IpListFile))
2427
{
25-
var arg2 = GetArgument.Run(2, false, true, message);
26-
if (arg1.Equals("ip", StringComparison.InvariantCultureIgnoreCase))
28+
if (line.EndsWith(arg2))
2729
{
28-
var content = "Possible accounts using the IP " + arg2 + ":\r\n\r\n";
29-
var builder = new StringBuilder();
30-
builder.Append(content);
31-
foreach (var line in File.ReadAllLines(IpListFile))
32-
{
33-
if (line.EndsWith(arg2))
34-
{
35-
++found;
36-
builder.Append(line.Replace(": " + arg2, String.Empty) + "\r\n");
37-
}
38-
}
39-
content = builder.ToString();
40-
content += "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n";
41-
player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content);
30+
++found;
31+
builder.Append(line.Replace(": " + arg2, String.Empty) + "\r\n");
4232
}
43-
else if (arg1.Equals("ign", StringComparison.InvariantCultureIgnoreCase) || (arg1.Equals("player", StringComparison.InvariantCultureIgnoreCase)))
33+
}
34+
content = builder.ToString();
35+
content += "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n";
36+
player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content);
37+
}
38+
else if (arg1.Equals("ign", StringComparison.InvariantCultureIgnoreCase) || (arg1.Equals(nameof(player), StringComparison.InvariantCultureIgnoreCase)))
39+
{
40+
var content = "Possible logins on the account " + arg2 + " using the following IP's:\r\n\r\n";
41+
var builder = new StringBuilder();
42+
builder.Append(content);
43+
foreach (var line in File.ReadAllLines(IpListFile))
44+
{
45+
if (line.StartsWith(arg2 + ": "))
4446
{
45-
var content = "Possible logins on the account " + arg2 + " using the following IP's:\r\n\r\n";
46-
var builder = new StringBuilder();
47-
builder.Append(content);
48-
foreach (var line in File.ReadAllLines(IpListFile))
49-
{
50-
if (line.StartsWith(arg2 + ": "))
51-
{
52-
++found;
53-
builder.Append(line.Replace(arg2 + ": ", String.Empty) + "\r\n");
54-
}
55-
}
56-
content = builder.ToString();
57-
content = content + "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n";
58-
player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content);
47+
++found;
48+
builder.Append(line.Replace(arg2 + ": ", String.Empty) + "\r\n");
5949
}
6050
}
61-
else
62-
player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, CmdCheckAlts + "[IP/IGN] [Arg2] Eg " + CmdCheckAlts + " ip 127.0.0.1");
63-
51+
content = builder.ToString();
52+
content = content + "\r\n\r\n" + arg2 + " occurred " + found + " times in the iplog file." + "\r\n";
53+
player.SendToSelf(Channel.Reliable, ClPacket.ServerInfo, content);
6454
}
65-
else
66-
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
67-
}
68-
catch (Exception ex)
69-
{
70-
ErrorLogging.Run(ex);
7155
}
72-
return true;
56+
else
57+
player.SendToSelf(Channel.Reliable, ClPacket.GameMessage, GetArgument.Run(0, false,false,message) + "[IP/IGN] [Arg2] Eg " + GetArgument.Run(0,false,false,message) + " ip 127.0.0.1");
7358
}
7459
}
7560
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using static BP_Essentials.EssentialsVariablesPlugin;
4+
namespace BP_Essentials.Commands
5+
{
6+
public class Clear : EssentialsChatPlugin
7+
{
8+
public static void Run(SvPlayer player, string message)
9+
{
10+
string arg1 = GetArgument.Run(1, false, true, message);
11+
if (!string.IsNullOrEmpty(arg1))
12+
{
13+
var shPlayer = GetShByStr.Run(arg1);
14+
if (shPlayer == null)
15+
{
16+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
17+
return;
18+
}
19+
var tempList = new List<InventoryItem>();
20+
foreach (var item in shPlayer.myItems.Values)
21+
tempList.Add(item);
22+
for (int i = 0; i < tempList.Count; i++)
23+
shPlayer.TransferItem(2, tempList[i].item.index, shPlayer.MyItemCount(tempList[i].item.index), true);
24+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>You cleared the inventory of</color> <color={argColor}>{shPlayer.username}</color><color={infoColor}>.</color>");
25+
shPlayer.svPlayer.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"<color={warningColor}>Your inventory has been cleared by</color> <color={argColor}>{player.playerData.username}</color><color={warningColor}>.</color>");
26+
}
27+
else
28+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
29+
}
30+
}
31+
}

source/BP-Essentials/Chat/Commands/Admin/ClearWanted.cs

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,42 +10,27 @@ namespace BP_Essentials.Commands
1010
{
1111
class ClearWanted : EssentialsChatPlugin
1212
{
13-
public static bool Run(object oPlayer, string message)
13+
public static void Run(SvPlayer player, string message)
1414
{
15-
try
15+
bool found = false;
16+
string arg1 = GetArgument.Run(1, false, true, message);
17+
string msg;
18+
if (String.IsNullOrEmpty(arg1))
1619
{
17-
var player = (SvPlayer)oPlayer;
18-
19-
if (HasPermission.Run(player, CmdClearWantedExecutableBy))
20+
arg1 = player.playerData.username;
21+
msg = "yourself";
22+
}
23+
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
24+
if (shPlayer.username == arg1 && !shPlayer.svPlayer.IsServerside() || shPlayer.ID.ToString() == arg1.ToString() && !shPlayer.svPlayer.IsServerside())
2025
{
21-
bool found = false;
22-
string arg1 = GetArgument.Run(1, false, true, message);
23-
string msg;
24-
if (String.IsNullOrEmpty(arg1))
25-
{
26-
arg1 = player.playerData.username;
27-
msg = "yourself";
28-
}
29-
foreach (var shPlayer in UnityEngine.Object.FindObjectsOfType<ShPlayer>())
30-
if (shPlayer.username == arg1 && shPlayer.IsRealPlayer() || shPlayer.ID.ToString() == arg1.ToString() && shPlayer.IsRealPlayer())
31-
{
32-
msg = shPlayer.username;
33-
shPlayer.ClearCrimes();
34-
shPlayer.svPlayer.SendToSelf(Channel.Reliable, 33, shPlayer.ID);
35-
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Cleared crimes of '" + msg + "'.</color>");
36-
found = true;
37-
}
38-
if (!found)
39-
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
26+
msg = shPlayer.username;
27+
shPlayer.ClearCrimes();
28+
shPlayer.svPlayer.SendToSelf(Channel.Reliable, 33, shPlayer.ID);
29+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Cleared crimes of '" + msg + "'.</color>");
30+
found = true;
4031
}
41-
else
42-
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, MsgNoPerm);
43-
}
44-
catch (Exception ex)
45-
{
46-
ErrorLogging.Run(ex);
47-
}
48-
return true;
32+
if (!found)
33+
player.SendToSelf(Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
4934
}
5035
}
5136
}

0 commit comments

Comments
 (0)