Skip to content

Commit

Permalink
BPE 2.6.3
Browse files Browse the repository at this point in the history
Might actually remove all code from this branch and only leave the development branch for code.. what do you guys think?
  • Loading branch information
UserR00T committed Feb 5, 2019
1 parent 9644978 commit c2ed63a
Show file tree
Hide file tree
Showing 122 changed files with 3,326 additions and 1,634 deletions.
37 changes: 25 additions & 12 deletions source/BP-Essentials/BP-Essentials.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand All @@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>BP_Essentials</RootNamespace>
<AssemblyName>BP_Essentials</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
Expand Down Expand Up @@ -40,8 +40,12 @@
<CodeAnalysisRuleSet>BP-Essentials.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<ItemGroup>
<Compile Include="Chat\Commands\Admin\Arrest.cs" />
<Compile Include="Chat\Commands\Admin\Back.cs" />
<Compile Include="Chat\Commands\Admin\CheckAlts.cs" />
<Compile Include="Chat\Commands\Admin\Clear.cs" />
<Compile Include="Chat\Commands\Admin\ClearWanted.cs" />
Expand All @@ -65,15 +69,19 @@
<Compile Include="Chat\Commands\Admin\Launch.cs" />
<Compile Include="Chat\Commands\Admin\Money.cs" />
<Compile Include="Chat\Commands\Admin\Promote.cs" />
<Compile Include="Chat\Commands\Admin\RepairVehicle.cs" />
<Compile Include="Chat\Commands\Admin\Restrain.cs" />
<Compile Include="Chat\Commands\Admin\Say.cs" />
<Compile Include="Chat\Commands\Admin\Search.cs" />
<Compile Include="Chat\Commands\Admin\Snap.cs" />
<Compile Include="Chat\Commands\Admin\SpawnVehicle.cs" />
<Compile Include="Chat\Commands\Admin\Spy.cs" />
<Compile Include="Chat\Commands\Admin\Sudo.cs" />
<Compile Include="Chat\Commands\Admin\ToggleReceiveStaffChat.cs" />
<Compile Include="Chat\Commands\Admin\ToggleStaffChat.cs" />
<Compile Include="Chat\Commands\Admin\TpAll.cs" />
<Compile Include="Chat\Commands\Admin\TpHere.cs" />
<Compile Include="Chat\Commands\Admin\TpJob.cs" />
<Compile Include="Chat\Commands\Admin\TpLocation.cs" />
<Compile Include="Chat\Commands\Admin\TpToApartment.cs" />
<Compile Include="Chat\Commands\Admin\Wipe.cs" />
Expand All @@ -94,6 +102,7 @@
<Compile Include="Chat\Commands\Everyone\Home.cs" />
<Compile Include="Chat\Commands\Everyone\ListKits.cs" />
<Compile Include="Chat\Commands\Everyone\ListWarps.cs" />
<Compile Include="Chat\Commands\Everyone\Me.cs" />
<Compile Include="Chat\Commands\Everyone\OnlinePlayers.cs" />
<Compile Include="Chat\Commands\Everyone\Pay.cs" />
<Compile Include="Chat\Commands\Admin\Reload.cs" />
Expand All @@ -107,29 +116,35 @@
<Compile Include="Chat\Commands\Everyone\TpaAccept.cs" />
<Compile Include="Chat\Commands\Everyone\TpaUser.cs" />
<Compile Include="Chat\LangAndChatBlock.cs" />
<Compile Include="EssentialsChat.cs" />
<Compile Include="EssentialsCore.cs" />
<Compile Include="EssentialsMethods.cs" />
<Compile Include="EssentialsVariables.cs" />
<Compile Include="HookChat.cs" />
<Compile Include="Core.cs" />
<Compile Include="HookMethods.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Variables.cs" />
<Compile Include="ExtensionMethods.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="Chat\Announce.cs" />
<Compile Include="Methods\FileHandler\Warps.cs" />
<Compile Include="Methods\Utils\FillPlaceholders.cs" />
<Compile Include="Methods\FileHandler\ExpandableFileHandler.cs" />
<Compile Include="Methods\FileHandler\WarpsHandler.cs" />
<Compile Include="Methods\Utils\FilterComments.cs" />
<Compile Include="Methods\Utils\FunctionMenu.cs" />
<Compile Include="Methods\Utils\GetShByStr.cs" />
<Compile Include="Methods\Utils\GetWebsiteContent.cs" />
<Compile Include="Methods\Utils\HandleSpam.cs" />
<Compile Include="Methods\Utils\HasPermission.cs" />
<Compile Include="Methods\Utils\IsJailed.cs" />
<Compile Include="Methods\Utils\IsCuffed.cs" />
<Compile Include="Methods\Utils\HasWantedLevel.cs" />
<Compile Include="Methods\Utils\MultiDictionary.cs" />
<Compile Include="Methods\Utils\PlaceholderParser.cs" />
<Compile Include="Methods\Utils\SendDiscordMessage.cs" />
<Compile Include="Methods\Check\CheckAltAcc.cs" />
<Compile Include="Methods\Check\CheckBanned.cs" />
<Compile Include="Methods\FileHandler\CheckAutoReloadFile.cs" />
<Compile Include="Methods\FileHandler\CheckFiles.cs" />
<Compile Include="Methods\Check\CheckGodMode.cs" />
<Compile Include="Methods\FileHandler\CreateFile.cs" />
<Compile Include="Methods\FileHandler\ReadGroups.cs" />
<Compile Include="Methods\FileHandler\Kits.cs" />
<Compile Include="Methods\FileHandler\KitsHandler.cs" />
<Compile Include="Methods\FileHandler\RegisterCommands.cs" />
<Compile Include="Methods\GameMethods\CleanupApartment.cs" />
<Compile Include="Methods\GameMethods\GetExtraCount.cs" />
Expand All @@ -138,7 +153,6 @@
<Compile Include="Methods\Utils\ErrorLogging.cs" />
<Compile Include="Methods\Utils\GetArgument.cs" />
<Compile Include="Chat\Commands\Admin\GetLogs.cs" />
<Compile Include="Methods\Utils\GetPlaceHolders.cs" />
<Compile Include="Methods\misc\GetIdList.cs" />
<Compile Include="Methods\misc\IsOnline.cs" />
<Compile Include="Methods\Utils\LogMessage.cs" />
Expand All @@ -152,7 +166,6 @@
<Compile Include="Methods\GameMethods\SendToJail.cs" />
<Compile Include="Methods\misc\SendChatMessage.cs" />
<Compile Include="Methods\misc\SendChatMessageToAdmins.cs" />
<Compile Include="Methods\Utils\SetTimeStamp.cs" />
<Compile Include="Methods\FileHandler\WriteIpToFile.cs" />
</ItemGroup>
<ItemGroup>
Expand Down
69 changes: 48 additions & 21 deletions source/BP-Essentials/Chat/Announce.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,66 @@
using System.Linq;
using System.Text;
using UnityEngine;
using static BP_Essentials.EssentialsVariablesPlugin;
using static BP_Essentials.EssentialsMethodsPlugin;
using static BP_Essentials.Variables;
using static BP_Essentials.HookMethods;
using System.Threading;

namespace BP_Essentials.Chat
namespace BP_Essentials
{
class Announce : EssentialsCorePlugin
{
public static void Run()
public class Announcer
{
public System.Timers.Timer Timer { get; private set; }
public List<string> Announcements { get; set; } = new List<string>();
public double Interval
{
get => Timer.Interval;
set
{
Timer.Enabled = false;
Timer.Interval = value * 1000;
Timer.Enabled = true;
}
}
public Announcer(List<string> announcements) : this()
{
Announcements = announcements;
}
public Announcer()
{
try
{
_Timer.Elapsed += (sender, e) => OnTime();
_Timer.Interval = TimeBetweenAnnounce * 1000;
_Timer.Enabled = true;
Timer = new System.Timers.Timer();

Timer.Elapsed += (sender, e) => OnTime();
if (TimeBetweenAnnounce == 0)
{
Timer.Enabled = false;
return;
}
Timer.Interval = TimeBetweenAnnounce * 1000;
Timer.Enabled = true;
}
catch (Exception ex)
{
ErrorLogging.Run(ex);
}
}

private static void OnTime()
{
if (!string.IsNullOrWhiteSpace(Announcements[AnnounceIndex]))
{
foreach (var player in SvMan.players)
foreach (var line in Announcements[AnnounceIndex].Split(new[] { "\\r\\n", "\\r", "\\n" }, StringSplitOptions.None))
player.Value.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, line);
Debug.Log($"{SetTimeStamp.Run()}[INFO] Announcement made...");
}
if (++AnnounceIndex > Announcements.Length - 1)
AnnounceIndex = 0;
}
void OnTime()
{
if (Announcements == null || Announcements.Count == 0)
return;
if (++AnnounceIndex > Announcements.Count - 1)
AnnounceIndex = 0;
if (string.IsNullOrWhiteSpace(Announcements[AnnounceIndex]))
return;
var lines = Announcements[AnnounceIndex].Split(new[] { "\r\n", "\r", "\n", "\\r\\n", "\\r", "\\n" }, StringSplitOptions.None);
foreach (var player in SvMan.players)
{
foreach (var line in lines)
player.Value.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.GameMessage, line);
}
Debug.Log($"{PlaceholderParser.ParseTimeStamp()} [INFO] Announcement made...");
}
}
}
39 changes: 18 additions & 21 deletions source/BP-Essentials/Chat/Commands/Admin/Arrest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,28 @@
using System.Linq;
using System.Text;
using UnityEngine;
using static BP_Essentials.EssentialsVariablesPlugin;
using static BP_Essentials.EssentialsMethodsPlugin;
using static BP_Essentials.Variables;

namespace BP_Essentials.Commands
{
class Arrest
{
public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (!string.IsNullOrEmpty(arg1))
{
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnline);
return;
}
shPlayer.svPlayer.Restrain(shPlayer.manager.handcuffed);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Arrested</color> <color={argColor}>" + shPlayer.username + $"</color><color={infoColor}>.</color>");

}
else
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
public static void Run(SvPlayer player, string message)
{
string arg1 = GetArgument.Run(1, false, true, message);
if (string.IsNullOrEmpty(arg1))
{
player.SendChatMessage(ArgRequired);
return;
}
var shPlayer = GetShByStr.Run(arg1);
if (shPlayer == null)
{
player.SendChatMessage(NotFoundOnline);
return;
}
shPlayer.svPlayer.Restrain(shPlayer.manager.handcuffed);
player.SendChatMessage($"<color={infoColor}>Arrested</color> <color={argColor}>{shPlayer.username}</color><color={infoColor}>.</color>");
}
}
}
25 changes: 25 additions & 0 deletions source/BP-Essentials/Chat/Commands/Admin/Back.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UnityEngine;
using static BP_Essentials.Variables;
using static BP_Essentials.HookMethods;

namespace BP_Essentials.Commands
{
class Back
{
public static void Run(SvPlayer player, string message)
{
var lastLocation = PlayerList[player.player.ID].LastLocation;
if (!lastLocation.HasPositionSet())
{
player.SendChatMessage($"<color={errorColor}>There is no location to teleport to.</color>");
return;
}
player.ResetAndSavePosition(lastLocation.Position, lastLocation.Rotation, lastLocation.PlaceIndex);
player.SendChatMessage($"<color={infoColor}>You've been teleported to your last known location.</color>");
}
}
}
46 changes: 23 additions & 23 deletions source/BP-Essentials/Chat/Commands/Admin/Ban.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
using System;
using static BP_Essentials.EssentialsVariablesPlugin;
using static BP_Essentials.Variables;
namespace BP_Essentials.Commands {
public class Ban
{
public static void Run(SvPlayer player, string message)
{
var arg1 = GetArgument.Run(1, false, false, message);
var arg2 = GetArgument.Run(2, false, true, message);
if (!string.IsNullOrEmpty(arg1) && !string.IsNullOrEmpty(arg2))
{
var shPlayer = GetShByStr.Run(arg1, true);
if (shPlayer == null)
{
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, NotFoundOnlineIdOnly);
return;
}
LogMessage.LogOther($"{SetTimeStamp.Run()}[INFO] {shPlayer.username} Got banned by {player.playerData.username} (Reason: {arg2}");
player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"<color={argColor}>{shPlayer.username}</color> <color={warningColor}>Just got banned by</color> <color={argColor}>{player.playerData.username}</color> <color={warningColor}>(Reason: </color><color={argColor}>{arg2}</color><color={warningColor}>)</color>");
SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username, arg2);
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, $"<color={infoColor}>Banned</color> <color={argColor}>{shPlayer.username}</color><color={infoColor}>. (Reason: {arg2})</color>");
player.svManager.AddBanned(shPlayer);
player.svManager.Disconnect(shPlayer.svPlayer.connection);
}
else
player.Send(SvSendType.Self, Channel.Unsequenced, ClPacket.GameMessage, ArgRequired);
}
public static void Run(SvPlayer player, string message)
{
var arg1 = GetArgument.Run(1, false, false, message);
var arg2 = GetArgument.Run(2, false, true, message);
if (string.IsNullOrEmpty(arg1) || string.IsNullOrEmpty(arg2))
{
player.SendChatMessage(ArgRequired);
return;
}
var shPlayer = GetShByStr.Run(arg1, true);
if (shPlayer == null)
{
player.SendChatMessage(NotFoundOnlineIdOnly);
return;
}
LogMessage.LogOther($"{PlaceholderParser.ParseTimeStamp()} [INFO] {shPlayer.username} Got banned by {player.playerData.username} (Reason: {arg2}");
player.Send(SvSendType.All, Channel.Unsequenced, ClPacket.GameMessage, $"<color={argColor}>{shPlayer.username}</color> <color={warningColor}>Just got banned by</color> <color={argColor}>{player.playerData.username}</color> <color={warningColor}>(Reason: </color><color={argColor}>{arg2}</color><color={warningColor}>)</color>");
SendDiscordMessage.BanMessage(shPlayer.username, player.playerData.username, arg2);
player.SendChatMessage($"<color={infoColor}>Banned</color> <color={argColor}>{shPlayer.username}</color><color={infoColor}>. (Reason: {arg2})</color>");
player.svManager.AddBanned(shPlayer);
player.svManager.Disconnect(shPlayer.svPlayer.connection, DisconnectTypes.Banned);
}
}
}
Loading

0 comments on commit c2ed63a

Please sign in to comment.