From 4d0b33fbeacb4840e60ca0ca4e5c97ecf77b6f90 Mon Sep 17 00:00:00 2001 From: AkjaHAsLk1IALk0MasH <46046453+AgaSpace@users.noreply.github.com> Date: Sun, 28 Nov 2021 21:31:58 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D1=8C=D1=82?= =?UTF-8?q?=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=BF=D1=80=D0=BE?= =?UTF-8?q?=D0=B5=D0=BA=D1=82=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AntiCustomDeath.sln | 25 +++++++++ AntiCustomDeath/AntiCustomDeath.csproj | 60 ++++++++++++++++++++++ AntiCustomDeath/Plugin.cs | 46 +++++++++++++++++ AntiCustomDeath/Properties/AssemblyInfo.cs | 36 +++++++++++++ 4 files changed, 167 insertions(+) create mode 100644 AntiCustomDeath.sln create mode 100644 AntiCustomDeath/AntiCustomDeath.csproj create mode 100644 AntiCustomDeath/Plugin.cs create mode 100644 AntiCustomDeath/Properties/AssemblyInfo.cs diff --git a/AntiCustomDeath.sln b/AntiCustomDeath.sln new file mode 100644 index 0000000..9a471b4 --- /dev/null +++ b/AntiCustomDeath.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30907.101 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AntiCustomDeath", "AntiCustomDeath\AntiCustomDeath.csproj", "{75D3F123-EED2-4CAE-827E-AAB1101EAEC8}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {75D3F123-EED2-4CAE-827E-AAB1101EAEC8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {75D3F123-EED2-4CAE-827E-AAB1101EAEC8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {75D3F123-EED2-4CAE-827E-AAB1101EAEC8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {75D3F123-EED2-4CAE-827E-AAB1101EAEC8}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {5A0D4605-00B6-4855-A099-A96E3A7D9B33} + EndGlobalSection +EndGlobal diff --git a/AntiCustomDeath/AntiCustomDeath.csproj b/AntiCustomDeath/AntiCustomDeath.csproj new file mode 100644 index 0000000..96c87ff --- /dev/null +++ b/AntiCustomDeath/AntiCustomDeath.csproj @@ -0,0 +1,60 @@ + + + + + Debug + AnyCPU + {75D3F123-EED2-4CAE-827E-AAB1101EAEC8} + Library + Properties + AntiCustomDeath + AntiCustomDeath + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\..\TShockRefs\Newtonsoft.Json.dll + + + ..\..\..\..\..\..\TShockRefs\OTAPI.dll + + + + + + + + + + + ..\..\..\..\..\..\TShockRefs\TerrariaServer.exe + + + ..\..\..\..\..\..\TShockRefs\TShockAPI.dll + + + + + + + + \ No newline at end of file diff --git a/AntiCustomDeath/Plugin.cs b/AntiCustomDeath/Plugin.cs new file mode 100644 index 0000000..adc373f --- /dev/null +++ b/AntiCustomDeath/Plugin.cs @@ -0,0 +1,46 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using TShockAPI; +using TShockAPI.Hooks; +using Terraria; +using TerrariaApi.Server; +using System.IO; +using Terraria.DataStructures; + +namespace AntiCustomDeath +{ + [ApiVersion(2, 1)] + public class Plugin : TerrariaPlugin + { + public override string Author => "Zoom L1"; + public override string Name => "AntiCustomDeath"; + public Plugin(Main game) : base(game) { } + + public override void Initialize() + { + ServerApi.Hooks.NetGetData.Register(this, OnGetData); + } + + public static void OnGetData(GetDataEventArgs args) + { + if (args.MsgID == PacketTypes.PlayerDeathV2) + { + using (var reader = new BinaryReader(new MemoryStream(args.Msg.readBuffer, args.Index, args.Length))) + { + int Index = reader.ReadByte(); + PlayerDeathReason pdr = PlayerDeathReason.FromReader(reader); + + if (pdr._sourceCustomReason != null) + { + args.Handled = true; + return; + } + } + + } + } + } +} diff --git a/AntiCustomDeath/Properties/AssemblyInfo.cs b/AntiCustomDeath/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..599dabf --- /dev/null +++ b/AntiCustomDeath/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Общие сведения об этой сборке предоставляются следующим набором +// набора атрибутов. Измените значения этих атрибутов для изменения сведений, +// связанные со сборкой. +[assembly: AssemblyTitle("AntiCustomDeath")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AntiCustomDeath")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми +// для компонентов COM. Если необходимо обратиться к типу в этой сборке через +// COM, задайте атрибуту ComVisible значение TRUE для этого типа. +[assembly: ComVisible(false)] + +// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM +[assembly: Guid("75d3f123-eed2-4cae-827e-aab1101eaec8")] + +// Сведения о версии сборки состоят из указанных ниже четырех значений: +// +// Основной номер версии +// Дополнительный номер версии +// Номер сборки +// Редакция +// +// Можно задать все значения или принять номера сборки и редакции по умолчанию +// используя "*", как показано ниже: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]