diff --git a/Main.cs b/Main.cs index e957eb1..8bdfdf3 100644 --- a/Main.cs +++ b/Main.cs @@ -1,86 +1,83 @@ -using System.Collections.Generic; -using System.Drawing; -using Rocket.API.DependencyInjection; -using Rocket.API.Eventing; -using Rocket.API.User; -using Rocket.Core.I18N; -using Rocket.Core.Logging; using Rocket.Unturned.Player; using SDG.Unturned; using Rocket.Core.Plugins; -using Rocket.Unturned.Player.Events; +using Rocket.API.Collections; +using Rocket.Unturned.Events; +using Rocket.Unturned.Chat; +using Rocket.Core.Logging; +using Color = UnityEngine.Color; +using Steamworks; namespace coolpuppy24.simpledeathmessages { - public class Main : Plugin, IEventListener + public class Main : RocketPlugin { - private readonly IUserManager _userManager; - - protected override void OnLoad(bool isFromReload) + protected override void Load() { - Logger.LogInformation("Successfully Loaded!"); + UnturnedPlayerEvents.OnPlayerDeath += OnPlayerDeath; + Logger.Log("Successfully Loaded!"); } - protected override void OnUnload() + protected override void Unload() { - Logger.LogInformation("Unloaded!"); + UnturnedPlayerEvents.OnPlayerDeath -= OnPlayerDeath; + Logger.Log("Unloaded!"); } - public override Dictionary DefaultTranslations => new Dictionary - { - {"gun_headshot","{1} [GUN - {3}] {2} {0}"}, - {"gun","{1} [GUN - {2}] {0}"}, - {"food","[FOOD] {0}"}, - {"arena","[ARENA] {0}"}, - {"shred","[SHRED] {0}"}, - {"punch_headshot","{1} [PUNCH] {2} {0}"}, - {"punch","{0} [PUNCH] {1}"}, - {"bones","[BONES] {0}"}, - {"melee_headshot","{1} [MELEE - {3}] {2} {0}"}, - {"melee","{0} [MELEE- {2}] {1}"}, - {"water","[WATER] {0}"}, - {"breath","[BREATH] {0}"}, - {"zombie","[ZOMBIE] {0}"}, - {"animal","[ANIMAL] {0}"}, - {"grenade","[GRENADE] {0}"}, - {"vehicle","[VEHICLE] {0}"}, - {"suicide","[SUICIDE] {0}"}, - {"burning","[BURNING] {0}"}, - {"headshot","+ [HEADSHOT]" }, - {"landmine","[LANDMINE] {0}"}, - {"roadkill","{1} [ROADKILL] {0}"}, - {"bleeding","[BLEEDING] {0}"}, - {"freezing","[FREEZING] {0}"}, - {"sentry","[SENTRY] {0}"}, - {"charge","[CHARGE] {0}"}, - {"missile","[MISSILE] {0}"}, - {"splash","[SPLASH] {0}"}, - {"acid","[ACID] {0}"}, - {"spark", "[SPARK] {0}"}, - {"infection", "[INFECTION] {0}"}, - {"spit","[SPIT] {0}"}, - {"kill","[ADMIN KILL] {0}"}, - {"boulder","[BOULDER] {0}"}, - }; - - public Main(IDependencyContainer container, IEventManager eventManager, IUserManager userManager) : base("SimpleDeathMessages", container) - { - _userManager = userManager; - eventManager.AddEventListener(this, this); - } + public override TranslationList DefaultTranslations => + new TranslationList + { + {"gun","{0} was shot in the {1} by {2} using a {3}"}, + {"food","{0} starved to death!"}, + {"arena","{0} was eliminated by the arena!"}, + {"shred","{0} was shreaded to bits!"}, + {"punch","{0} was punched in the {1} by {2}"}, + {"bones","{0} shattered his bones and died!"}, + {"melee","{0} was chopped to death in the {1} by {2} using a {3}"}, + {"water","{0} dehydrated to death!"}, + {"breath","{0} suffocated to death!"}, + {"zombie","{0} was mauled by a zombie!"}, + {"animal","{0} was mauled by an animal!"}, + {"grenade","{0} was blown up by {1} with a grenade!"}, + {"vehicle","{0} was blown up by a vehicle!"}, + {"suicide","{0} died at their own hand. Everyone is disappointed."}, + {"burning","{0} burned to death!"}, + {"landmine","{0} was blown up by a landmine!"}, + {"roadkill","{0} was roadkilled by {1}"}, + {"bleeding","{0} bled to death!"}, + {"freezing","{0} froze to death!"}, + {"sentry","{0} was shot by a sentry gun!"}, + {"charge","{0} was obliterated by {1} with a remote detonator!"}, + {"missile","{0} was annihilated by {1} with a missile!"}, + {"splash","{0} was blown up by {1} with an explosive bullet!"}, + {"acid","{0} was blown up by a zombie!"}, + {"spark", "{0} was electrocuted by a zombie!"}, + {"infection", "{0} died of infection"}, + {"spit","{0} was dissolved by a zombie!"}, + {"kill","{0} was killed by an admin!"}, + {"boulder","{0} was crushed by a zombie using a big boulder!"}, + {"left_foot", "left foot"}, + {"left_leg", "left leg"}, + {"right_foot", "right foot"}, + {"right_leg", "right leg"}, + {"left_hand", "left hand"}, + {"left_arm", "left arm"}, + {"right_hand", "right hand"}, + {"right_arm", "right arm"}, + {"left_back", "back"}, + {"right_back", "back"}, + {"left_front", "torso"}, + {"right_front", "torso"}, + {"spine", "spine"}, + {"skull", "head"}, + }; - public void HandleEvent(IEventEmitter emitter, UnturnedPlayerDeathEvent @event) + private void OnPlayerDeath(UnturnedPlayer player, EDeathCause cause, ELimb limb, CSteamID murderer) { - var player = (UnturnedPlayer)@event.Player; - - UnturnedPlayer killer = ((UnturnedPlayerEntity)@event.Killer).Player; - var cause = @event.DeathCause; - var limb = @event.Limb; + var deathMessageColor = Color.red; - var deathmessageColor = Color.Red; //ConfigurationInstance.DeathMessagesColor; + var killer = UnturnedPlayer.FromCSteamID(murderer); - - string headshot = Translations.Get("headshot"); if (cause.ToString() == "SHRED" || cause.ToString() == "ZOMBIE" || cause.ToString() == "ANIMAL" || cause.ToString() == "SPARK" || cause.ToString() == "VEHICLE" || cause.ToString() == "FOOD" || cause.ToString() == "WATER" || cause.ToString() == "INFECTION" || cause.ToString() == "BLEEDING" || @@ -90,45 +87,43 @@ public void HandleEvent(IEventEmitter emitter, UnturnedPlayerDeathEvent @event) cause.ToString() == "ACID" || cause.ToString() == "SPIT" || cause.ToString() == "BURNING" || cause.ToString() == "BURNER" || cause.ToString() == "BOULDER" || cause.ToString() == "ARENA" || cause.ToString() == "GRENADE" || - (ConfigurationInstance.ShowSuicideMSG && cause.ToString() == "SUICIDE") || + (Configuration.Instance.ShowSuicideMSG && cause.ToString() == "SUICIDE") || cause.ToString() == "ROADKILL" || cause.ToString() == "MELEE" || cause.ToString() == "GUN" || cause.ToString() == "PUNCH") { if (cause.ToString() != "ROADKILL" && cause.ToString() != "MELEE" && cause.ToString() != "GUN" && - cause.ToString() != "PUNCH") - { - _userManager.BroadcastLocalized(Translations, cause.ToString().ToLower(), deathmessageColor, player.DisplayName); - } - else if (cause.ToString() == "ROADKILL") - { - _userManager.BroadcastLocalized(Translations, "roadkill", deathmessageColor, player.DisplayName, killer.DisplayName); - } - else if (cause.ToString() == "MELEE" || cause.ToString() == "GUN") + cause.ToString() != "PUNCH" && cause.ToString() != "GRENADE" && cause.ToString() != "MISSILE" && + cause.ToString() != "CHARGE" && cause.ToString() != "SPLASH") { - if (limb == ELimb.SKULL) - _userManager.BroadcastLocalized(Translations, cause.ToString().ToLower() + "_headshot", deathmessageColor, player.DisplayName, killer.DisplayName, headshot, killer.NativePlayer.equipment.asset.itemName); - else - _userManager.BroadcastLocalized(Translations, cause.ToString().ToLower(), deathmessageColor, player.DisplayName, killer.DisplayName, headshot, killer.NativePlayer.equipment.asset.itemName); + UnturnedChat.Say(Translate(cause.ToString().ToLower(), player.DisplayName), deathMessageColor); } - else if (cause.ToString() == "PUNCH") + else switch (cause.ToString()) { - _userManager.BroadcastLocalized(Translations, - limb == ELimb.SKULL ? "punch_headshot" : "punch", deathmessageColor, player.DisplayName, killer.DisplayName, headshot); + case "ROADKILL": + case "MISSILE": + case "CHARGE": + case "SPLASH": + UnturnedChat.Say(Translate(cause.ToString().ToLower(), player.DisplayName, killer.DisplayName), deathMessageColor); + break; + case "PUNCH": + UnturnedChat.Say(Translate(cause.ToString().ToLower(), player.DisplayName, Translate(limb.ToString().ToLower()), killer.DisplayName), deathMessageColor); + break; + case "MELEE": + case "GUN": + var limbString = Translate(limb.ToString().ToLower()); + UnturnedChat.Say(Translate(cause.ToString().ToLower(), player.DisplayName, limbString, killer.DisplayName, killer.Player.equipment.asset.itemName), deathMessageColor); + break; } return; } - if (Translations.Get(cause.ToString().ToLower()) != null) + if (Translate(cause.ToString().ToLower()) != null) { - if (Translations.Get(cause.ToString().ToLower()).Contains("{1}")) - { - _userManager.BroadcastLocalized(Translations, cause.ToString().ToLower(), deathmessageColor, player.DisplayName, killer.DisplayName, headshot); - } - else - { - _userManager.BroadcastLocalized(Translations, cause.ToString().ToLower(), deathmessageColor, player.DisplayName, headshot); - } + UnturnedChat.Say( + Translate(cause.ToString().ToLower()).Contains("{1}") + ? Translate(cause.ToString().ToLower(), player.DisplayName, killer.DisplayName) + : Translate(cause.ToString().ToLower(), player.DisplayName), deathMessageColor); return; } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..f63a090 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("SimpleDeathMessages")] +[assembly: AssemblyDescription("Adds death messages.")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("SimpleDeathMessages")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("602882B6-F16C-4247-9F5D-21846BC4C09A")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.3.1.2")] +[assembly: AssemblyFileVersion("1.3.1.2")] diff --git a/SimpleDeathMessages.csproj b/SimpleDeathMessages.csproj index 077f790..b0298d3 100644 --- a/SimpleDeathMessages.csproj +++ b/SimpleDeathMessages.csproj @@ -1,33 +1,92 @@ - + + + - net35 + Debug + AnyCPU + {602882B6-F16C-4247-9F5D-21846BC4C09A} + Library + Properties SimpleDeathMessages coolpuppy24.SimpleDeathMessages - Library - - - SimpleDeathMessages - RocketMod Unturned - Coopyy, Enes Sadık Özbek <esozbek.me> - Coopyy - 1.0.0 - 1.0.0 - Coopyy, Enes Sadık Özbek <esozbek.me> - Show death messages in the server's chat! - Coopyy - 1.0.0 - 1.0.0 - true + netcoreapp3.1 + 512 + + 0.2.1 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 - - false - - - - + + lib\Assembly-CSharp.dll + False + + + lib\Rocket.API.dll + False + + + lib\Rocket.Core.dll + False + + + lib\Rocket.Unturned.dll + False + + + + + + + lib\UnityEngine.dll + False + + + False + lib\UnityEngine.CoreModule.dll + False + + + lib\com.rlabrecque.steamworks.net.dll - \ No newline at end of file + + + + + + + + + + + + + + + + + diff --git a/SimpleDeathMessages.sln b/SimpleDeathMessages.sln index cf151f7..64b0403 100644 --- a/SimpleDeathMessages.sln +++ b/SimpleDeathMessages.sln @@ -1,28 +1,38 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26228.9 +# Visual Studio 14 +VisualStudioVersion = 14.0.25123.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleDeathMessages", "SimpleDeathMessages.csproj", "{602882B6-F16C-4247-9F5D-21846BC4C09A}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Play|Any CPU = Play|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {602882B6-F16C-4247-9F5D-21846BC4C09A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {602882B6-F16C-4247-9F5D-21846BC4C09A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {602882B6-F16C-4247-9F5D-21846BC4C09A}.Play|Any CPU.ActiveCfg = Release|Any CPU - {602882B6-F16C-4247-9F5D-21846BC4C09A}.Play|Any CPU.Build.0 = Release|Any CPU {602882B6-F16C-4247-9F5D-21846BC4C09A}.Release|Any CPU.ActiveCfg = Release|Any CPU {602882B6-F16C-4247-9F5D-21846BC4C09A}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {68150744-9943-4542-A8D3-057D770555ED} + GlobalSection(MonoDevelopProperties) = preSolution + version = 0.2.1 + Policies = $0 + $0.DotNetNamingPolicy = $1 + $1.DirectoryNamespaceAssociation = PrefixedHierarchical + $0.TextStylePolicy = $2 + $2.inheritsSet = null + $2.scope = text/x-csharp + $0.CSharpFormattingPolicy = $3 + $3.scope = text/x-csharp + $0.TextStylePolicy = $4 + $4.FileWidth = 80 + $4.TabsToSpaces = True + $4.scope = text/plain + $0.StandardHeader = $5 EndGlobalSection EndGlobal diff --git a/SimpleDeathMessagesConfiguration.cs b/SimpleDeathMessagesConfiguration.cs index 802f622..1808854 100644 --- a/SimpleDeathMessagesConfiguration.cs +++ b/SimpleDeathMessagesConfiguration.cs @@ -1,15 +1,13 @@ using Rocket.API; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace coolpuppy24.simpledeathmessages { - public class SimpleDeathMessagesConfiguration + public class SimpleDeathMessagesConfiguration : IRocketPluginConfiguration { //public string DeathMessagesColor = "Red"; - public bool ShowSuicideMSG = true; + public bool ShowSuicideMSG = false; + + public void LoadDefaults() { } } } diff --git a/lib/Assembly-CSharp.dll b/lib/Assembly-CSharp.dll new file mode 100755 index 0000000..56465f9 Binary files /dev/null and b/lib/Assembly-CSharp.dll differ diff --git a/lib/Rocket.API.dll b/lib/Rocket.API.dll new file mode 100755 index 0000000..cd40e84 Binary files /dev/null and b/lib/Rocket.API.dll differ diff --git a/lib/Rocket.Core.dll b/lib/Rocket.Core.dll new file mode 100755 index 0000000..1e52f31 Binary files /dev/null and b/lib/Rocket.Core.dll differ diff --git a/lib/Rocket.Unturned.dll b/lib/Rocket.Unturned.dll new file mode 100755 index 0000000..23f21ab Binary files /dev/null and b/lib/Rocket.Unturned.dll differ diff --git a/lib/UnityEngine.CoreModule.dll b/lib/UnityEngine.CoreModule.dll new file mode 100755 index 0000000..e5f72d2 Binary files /dev/null and b/lib/UnityEngine.CoreModule.dll differ diff --git a/lib/UnityEngine.dll b/lib/UnityEngine.dll old mode 100644 new mode 100755 index f953314..be2cbeb Binary files a/lib/UnityEngine.dll and b/lib/UnityEngine.dll differ diff --git a/lib/com.rlabrecque.steamworks.net.dll b/lib/com.rlabrecque.steamworks.net.dll new file mode 100755 index 0000000..c4bb552 Binary files /dev/null and b/lib/com.rlabrecque.steamworks.net.dll differ