Skip to content

Commit

Permalink
added hashes and built dll
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkbound committed Jul 5, 2020
1 parent abcf111 commit 058bdcd
Show file tree
Hide file tree
Showing 23 changed files with 84 additions and 53 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ $RECYCLE.BIN/
Network Trash Folder
Temporary Items
.apdisk

# build folders
bin/
obj/
6 changes: 5 additions & 1 deletion AdminWarnings.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,11 @@
<Compile Include="WarningsPlugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include=".gitignore" />
<Content Include="BUILT_DLL\AdminWarnings.dll" />
<Content Include="BUILT_DLL\hashes.txt" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>REM copy "$(TargetPath)" "C:\Users\owner\Desktop\Unturned\unturned\Servers\testserver\Rocket\Plugins\"</PostBuildEvent>
Expand Down
Binary file not shown.
8 changes: 8 additions & 0 deletions BUILT_DLL/hashes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
------------------------------------------------------------
HASHES ARE FROM BUILDING THIS AS A DLL AND AS A RELEASE MODE
DATE BUILT: JULY/4/2020 @ 10:38PM (CST)
------------------------------------------------------------
MD5 - E46264997271E62FE0AB39526438DBDE
SHA-1 - 27B67D9D93C1B0C2ECBC0EB1D8DFEFED04144F04
SHA-256 - 39BF85744B1188CA16A367BB5076288F6FAB22230A5BAEEE4C54B6FA22224766
SHA-512 - D2709CD5D02C3E25616E880FE87B1CE5810839AC67B831C03A4ABFBF45CACE8036558AA3BD22A6BE4A3207EDA8FD357C1523DEB5CC9A780C8E8A0441BDA137C7
104 changes: 67 additions & 37 deletions WarningsPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
using Steamworks;
using System.Threading;
using AdminWarnings.Helpers;

using logger = Rocket.Core.Logging.Logger;

namespace AdminWarnings
Expand All @@ -19,6 +18,7 @@ public class WarningsPlugin : RocketPlugin<WarningsConfig>
{
public static WarningsPlugin Instance;
public static WarningUtilities util = new WarningUtilities();

public override Rocket.API.Collections.TranslationList DefaultTranslations
{
get
Expand All @@ -29,8 +29,14 @@ public override Rocket.API.Collections.TranslationList DefaultTranslations
{"warning_reason", "You have been given a warning! Reason: '{0}'"},
{"warning_count_self", "You currently have {0} warnings!"},
{"warning_count_admin", "'{0}' currently has {1} warnings!"},
{"warning_ban", "You have been banned because you reached {0} warnings! Ban duration (seconds): {1}"},
{"warning_ban_reason", "You have been banned because you reached {0} warnings! Reason: '{1}' Ban duration (seconds): {2}"},
{
"warning_ban",
"You have been banned because you reached {0} warnings! Ban duration (seconds): {1}"
},
{
"warning_ban_reason",
"You have been banned because you reached {0} warnings! Reason: '{1}' Ban duration (seconds): {2}"
},
{"warning_kick", "You have been kicked because you reached {0} warnings!"},
{"warning_kick_reason", "You have been kicked because you reached {0} warnings! Reason: '{1}'"},
{"warned_caller", "You have warned player: {0}"},
Expand All @@ -40,17 +46,23 @@ public override Rocket.API.Collections.TranslationList DefaultTranslations
{"wrong_usage_removewarn", "Correct command usage: /removewarn <player> [amount]"},
{"console_player_warning", "'{0}' has warned '{1}', '{1}' is at {2} warnings"},
{"console_player_banned", "'{0}' has warned '{1}', '{1}' was banned for {2} seconds"},
{"console_player_banned_reason", "'{0}' has warned '{1}', '{1}' was banned for {2} seconds with the reason '{3}'"},
{
"console_player_banned_reason",
"'{0}' has warned '{1}', '{1}' was banned for {2} seconds with the reason '{3}'"
},
{"console_player_kicked", "'{0}' has warned '{1}', '{1}' was kicked"},
{"console_player_kicked_reason", "'{0}' has warned '{1}', '{1}' was kicked with the reason '{2}'"},
{"public_player_banned", "'{0}' has received {1} warnings and was banned for {2} seconds!"},
{"public_player_kicked", "'{0}' has received {1} warnings and was kicked!"},
{"public_player_warned", "'{0}' has been giving a warning, they are currently at {1} warnings!"},
{"console_warnings_noparameter", "You must enter a player when calling this command from the console!"},
{
"console_warnings_noparameter",
"You must enter a player when calling this command from the console!"
},
{"public_player_warned_reason", "'{0}' has been giving a warning! Reason: {1}"},
{"remove_warn", "Removed {0} warnings from '{1}'!"},
{"no_data", "'{0}' does not have any warnings!"},
{ "cleared_logs", "Cleared warning logs!" },
{"cleared_logs", "Cleared warning logs!"},
{"console_command", "Ran command '{0}' because player:{1} hit {2} warnings"}
};
}
Expand Down Expand Up @@ -80,7 +92,8 @@ public void RemoveExpiredWarnings(int delay)
Thread.Sleep(delay);
foreach (var playerWarning in GetAllPlayerWarnings())
{
if (GetDaysSinceWarning(playerWarning.DateAdded) >= WarningsPlugin.Instance.Configuration.Instance.DaysWarningsExpire)
if (GetDaysSinceWarning(playerWarning.DateAdded) >=
WarningsPlugin.Instance.Configuration.Instance.DaysWarningsExpire)
{
RemovePlayerData(playerWarning);
}
Expand All @@ -90,17 +103,19 @@ public void RemoveExpiredWarnings(int delay)

public int GetDaysSinceWarning(DateTime warningDate)
{
return (int)(DateTime.Now - warningDate).TotalDays;
return (int) (DateTime.Now - warningDate).TotalDays;
}

public int GetPlayerWarnings(UnturnedPlayer P)
{
return GetAllPlayerWarnings().FirstOrDefault(pWarning => pWarning.CSteamID.ToString() == P.CSteamID.ToString()).Warnings;
return GetAllPlayerWarnings()
.FirstOrDefault(pWarning => pWarning.CSteamID.ToString() == P.CSteamID.ToString()).Warnings;
}

public PlayerWarning GetPlayerData(UnturnedPlayer P)
{
return GetAllPlayerWarnings().FirstOrDefault(pWarning => pWarning.CSteamID.ToString() == P.CSteamID.ToString());
return GetAllPlayerWarnings()
.FirstOrDefault(pWarning => pWarning.CSteamID.ToString() == P.CSteamID.ToString());
}

public void DecreasePlayerWarnings(UnturnedPlayer player, int amount)
Expand All @@ -120,7 +135,8 @@ public void DecreasePlayerWarnings(UnturnedPlayer player, int amount)

public bool CheckIfHasData(UnturnedPlayer P)
{
var pWarning = GetAllPlayerWarnings().FirstOrDefault(warning => warning.CSteamID.ToString() == P.CSteamID.ToString());
var pWarning = GetAllPlayerWarnings()
.FirstOrDefault(warning => warning.CSteamID.ToString() == P.CSteamID.ToString());
if (pWarning == null) return false;
return true;
}
Expand All @@ -138,44 +154,54 @@ public void WarnPlayer(IRocketPlayer caller, UnturnedPlayer Player, string reaso

if (!string.IsNullOrEmpty(point.ConsoleCommand))
{
string cmd = ConsoleCommandHelper.FormatConsoleCommandString(point.ConsoleCommand.ToLower(), Player);
var cmd = ConsoleCommandHelper.FormatConsoleCommandString(point.ConsoleCommand.ToLower(), Player);
CommandWindow.input.onInputText(cmd);
logger.Log(WarningsPlugin.Instance.Translate("console_command", cmd, Player.DisplayName, point.WarningsToTrigger));
logger.Log(WarningsPlugin.Instance.Translate("console_command", cmd, Player.DisplayName,
point.WarningsToTrigger));
}
else if (point.KickPlayer)
{
if (reasonIncluded)
{
KickPlayer(Player, reason, pData.Warnings);
LogWarning(WarningsPlugin.Instance.Translate("console_player_kicked_reason", GetPlayerName(caller), Player.DisplayName, reason));
LogWarning(WarningsPlugin.Instance.Translate("console_player_kicked_reason",
GetPlayerName(caller), Player.DisplayName, reason));
}
else
{
KickPlayer(Player, pData.Warnings);
LogWarning(WarningsPlugin.Instance.Translate("console_player_kicked", GetPlayerName(caller), Player.DisplayName));
LogWarning(WarningsPlugin.Instance.Translate("console_player_kicked", GetPlayerName(caller),
Player.DisplayName));
}

actionTaken = true;

if (GetConfigAnnouceMessageServerWide())
UnturnedChat.Say(WarningsPlugin.Instance.Translate("public_player_kicked", Player.DisplayName, pData.Warnings), GetMessageColor());

UnturnedChat.Say(
WarningsPlugin.Instance.Translate("public_player_kicked", Player.DisplayName,
pData.Warnings), GetMessageColor());
}
else if (point.BanPlayer)
{
if (reasonIncluded)
{
BanPlayer(Player, reason, pData.Warnings, point.BanLengthSeconds, caller);
LogWarning(WarningsPlugin.Instance.Translate("console_player_banned_reason", GetPlayerName(caller), Player.DisplayName, point.BanLengthSeconds, reason));
LogWarning(WarningsPlugin.Instance.Translate("console_player_banned_reason",
GetPlayerName(caller), Player.DisplayName, point.BanLengthSeconds, reason));
}
else
{
BanPlayer(Player, pData.Warnings, point.BanLengthSeconds, caller);
LogWarning(WarningsPlugin.Instance.Translate("console_player_banned", GetPlayerName(caller), Player.DisplayName, point.BanLengthSeconds));
LogWarning(WarningsPlugin.Instance.Translate("console_player_banned", GetPlayerName(caller),
Player.DisplayName, point.BanLengthSeconds));
}

actionTaken = true;

if (GetConfigAnnouceMessageServerWide())
UnturnedChat.Say(WarningsPlugin.Instance.Translate("public_player_banned", Player.DisplayName, pData.Warnings, point.BanLengthSeconds), GetMessageColor());
UnturnedChat.Say(
WarningsPlugin.Instance.Translate("public_player_banned", Player.DisplayName,
pData.Warnings, point.BanLengthSeconds), GetMessageColor());
}
}

Expand All @@ -190,7 +216,8 @@ public void WarnPlayer(IRocketPlayer caller, UnturnedPlayer Player, string reaso
PrivateWarnPlayer(Player, pData, reason, reasonIncluded);
}

LogWarning(WarningsPlugin.Instance.Translate("console_player_warning", GetPlayerName(caller), Player.DisplayName, pData.Warnings));
LogWarning(WarningsPlugin.Instance.Translate("console_player_warning", GetPlayerName(caller),
Player.DisplayName, pData.Warnings));
}

var allWarningPoints = GetAllWarningPoints();
Expand All @@ -203,22 +230,21 @@ public void WarnPlayer(IRocketPlayer caller, UnturnedPlayer Player, string reaso
if (caller is ConsolePlayer)
WarningLogger.LogWarning(0.ToString(), "*Console*", Player, reason);
else
WarningLogger.LogWarning((UnturnedPlayer)caller, Player, reason);

WarningLogger.LogWarning((UnturnedPlayer) caller, Player, reason);
}

public void PublicWarnPlayer(UnturnedPlayer Player, PlayerWarning pData, string reason, bool reasonIncluded)
{

if (reasonIncluded)
TellPlayerWarning(Player, WarningsPlugin.Instance.Translate("public_player_warned_reason", Player.DisplayName, reason));
TellPlayerWarning(Player,
WarningsPlugin.Instance.Translate("public_player_warned_reason", Player.DisplayName, reason));
else
TellPlayerWarning(Player, WarningsPlugin.Instance.Translate("public_player_warned", Player.DisplayName, pData.Warnings));
TellPlayerWarning(Player,
WarningsPlugin.Instance.Translate("public_player_warned", Player.DisplayName, pData.Warnings));
}

public void PrivateWarnPlayer(UnturnedPlayer Player, PlayerWarning pData, string reason, bool reasonIncluded)
{

if (reasonIncluded)
SendMessage(Player, WarningsPlugin.Instance.Translate("warning_reason", reason));
else
Expand All @@ -233,7 +259,7 @@ public string GetPlayerName(IRocketPlayer caller)
}
else
{
return ((UnturnedPlayer)caller).DisplayName;
return ((UnturnedPlayer) caller).DisplayName;
}
}

Expand Down Expand Up @@ -280,25 +306,28 @@ public void KickPlayer(UnturnedPlayer player, string reason, int warnings)

public void BanPlayer(UnturnedPlayer player, int warnings, uint banDuration, IRocketPlayer caller)
{
CSteamID judge = (CSteamID)0;
CSteamID judge = (CSteamID) 0;
if (!(caller is ConsolePlayer))
{
judge = ((UnturnedPlayer)caller).CSteamID;
judge = ((UnturnedPlayer) caller).CSteamID;
}

SteamBlacklist.ban(player.CSteamID, GetIP(player.CSteamID), judge, WarningsPlugin.Instance.Translate("warning_ban", warnings, banDuration),
SteamBlacklist.ban(player.CSteamID, GetIP(player.CSteamID), judge,
WarningsPlugin.Instance.Translate("warning_ban", warnings, banDuration),
banDuration);
}

public void BanPlayer(UnturnedPlayer player, string reason, int warnings, uint banDuration, IRocketPlayer caller)
public void BanPlayer(UnturnedPlayer player, string reason, int warnings, uint banDuration,
IRocketPlayer caller)
{
CSteamID judge = (CSteamID)0;
CSteamID judge = (CSteamID) 0;
if (!(caller is ConsolePlayer))
{
judge = ((UnturnedPlayer)caller).CSteamID;
judge = ((UnturnedPlayer) caller).CSteamID;
}

SteamBlacklist.ban(player.CSteamID, GetIP(player.CSteamID), judge, WarningsPlugin.Instance.Translate("warning_ban_reason", warnings, reason, banDuration),
SteamBlacklist.ban(player.CSteamID, GetIP(player.CSteamID), judge,
WarningsPlugin.Instance.Translate("warning_ban_reason", warnings, reason, banDuration),
banDuration);
}

Expand Down Expand Up @@ -328,7 +357,8 @@ public UnityEngine.Color GetMessageColor()
{
UnityEngine.Color MsgColor;

MsgColor = UnturnedChat.GetColorFromName(WarningsPlugin.Instance.Configuration.Instance.MessageColor, UnityEngine.Color.green);
MsgColor = UnturnedChat.GetColorFromName(WarningsPlugin.Instance.Configuration.Instance.MessageColor,
UnityEngine.Color.green);
return MsgColor;
}

Expand Down Expand Up @@ -384,4 +414,4 @@ public static void SendMessage(IRocketPlayer caller, string message)
UnturnedChat.Say(caller, message, WarningsPlugin.util.GetMessageColor());
}
}
}
}
Binary file removed bin/Debug/AdminWarnings.dll
Binary file not shown.
Binary file removed bin/Debug/AdminWarnings.pdb
Binary file not shown.
Binary file removed bin/Debug/AdminWarnings.zip
Binary file not shown.
Binary file removed bin/Release/AdminWarnings.dll
Binary file not shown.
Binary file removed bin/Release/AdminWarnings.pdb
Binary file not shown.
Binary file modified lib/Assembly-CSharp-firstpass.dll
Binary file not shown.
Binary file modified lib/Assembly-CSharp.dll
Binary file not shown.
Binary file modified lib/Rocket.Unturned.dll
Binary file not shown.
Binary file modified lib/UnityEngine.CoreModule.dll
Binary file not shown.
Binary file modified lib/UnityEngine.dll
Binary file not shown.
4 changes: 0 additions & 4 deletions obj/Debug/AdminWarnings.csproj.FileListAbsolute.txt

This file was deleted.

Binary file removed obj/Debug/AdminWarnings.dll
Binary file not shown.
Binary file removed obj/Debug/AdminWarnings.pdb
Binary file not shown.
Binary file not shown.
10 changes: 0 additions & 10 deletions obj/Release/AdminWarnings.csproj.FileListAbsolute.txt

This file was deleted.

Binary file removed obj/Release/AdminWarnings.pdb
Binary file not shown.
1 change: 0 additions & 1 deletion obj/Release/CoreCompileInputs.cache

This file was deleted.

Binary file not shown.

0 comments on commit 058bdcd

Please sign in to comment.