From ecc53f1b32a71079fe17869ba90a9da6390b2967 Mon Sep 17 00:00:00 2001 From: Thomasjosif Date: Sat, 30 Jan 2021 22:57:57 -0500 Subject: [PATCH] Update to Exiled v2.1.29 - Add config value to ignore tutorials - Add config value for minimum players - Add config value (for development) to ignore permissions and localhost checks - Other minor changes --- UltimateAFK/AFKComponent.cs | 6 +----- UltimateAFK/Config.cs | 14 ++++++-------- UltimateAFK/MainClass.cs | 8 ++++---- UltimateAFK/PlayerEvents.cs | 6 +++--- UltimateAFK/UltimateAFK.csproj | 24 ++++++++++++------------ UltimateAFK/app.config | 4 ++++ UltimateAFK/packages.config | 2 +- 7 files changed, 31 insertions(+), 33 deletions(-) diff --git a/UltimateAFK/AFKComponent.cs b/UltimateAFK/AFKComponent.cs index 8403dd3..69e8ac6 100644 --- a/UltimateAFK/AFKComponent.cs +++ b/UltimateAFK/AFKComponent.cs @@ -1,6 +1,5 @@ using System; using System.Linq; -using System.Collections.Generic; using UnityEngine; using MEC; using Exiled.API.Features; @@ -67,10 +66,7 @@ void Update() private void AFKChecker() { //Log.Info($"AFK Time: {this.AFKTime} AFK Count: {this.AFKCount}"); - if (this.ply.Team == Team.RIP || Player.List.Count() < plugin.Config.MinPlayers) return; - - // Check if Ignoring Tutorials is enabled & player is tutorial - if (plugin.Config.IgnoreTut == true && this.ply.Team == Team.TUT) return; + if (this.ply.Team == Team.RIP || Player.List.Count() <= plugin.Config.MinPlayers || (plugin.Config.IgnoreTut && this.ply.Team == Team.TUT)) return; bool isScp079 = (this.ply.Role == RoleType.Scp079) ? true : false; bool scp096TryNotToCry = false; diff --git a/UltimateAFK/Config.cs b/UltimateAFK/Config.cs index 9437ac6..868f589 100644 --- a/UltimateAFK/Config.cs +++ b/UltimateAFK/Config.cs @@ -1,17 +1,13 @@ -using System; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace UltimateAFK +namespace UltimateAFK { - using System.Collections.Generic; using System.ComponentModel; using Exiled.API.Interfaces; public sealed class Config : IConfig { + [Description("Is the plugin enabled?")] public bool IsEnabled { get; set; } = true; + [Description("Minimum required players for uAFK to be active.")] public int MinPlayers { get; set; } = 2; [Description("Do AFK players get replaced by spectators?")] public bool TryReplace { get; private set; } = true; @@ -25,10 +21,12 @@ public sealed class Config : IConfig public int NumBeforeKick { get; private set; } = 2; [Description("Maximum replace time, if the round time is past this value it will not replace the player (Set to -1 to disable)")] public int MaxReplaceTime { get; private set; } = -1; + [Description("Don't touch this if you do not understand the repercussions! - Ignore Perm and IP Checks.")] + public bool IgnorePermissionsAndIP { get; private set; } = false; public string MsgPrefix { get; private set; } = "[uAFK]"; public string MsgGrace { get; private set; } = "You will be moved to spectator in %timeleft% seconds if you do not move!"; public string MsgFspec { get; private set; } = "You were detected as AFK and automatically moved to spectator!"; - public string MsgKick { get; private set; } = "You were AFK for too long!"; + public string MsgKick { get; private set; } = "[Kicked by uAFK] You were AFK for too long!"; public string MsgReplace { get; private set; } = "You have replaced a player that was AFK."; } } diff --git a/UltimateAFK/MainClass.cs b/UltimateAFK/MainClass.cs index 95bd79a..3d9f670 100644 --- a/UltimateAFK/MainClass.cs +++ b/UltimateAFK/MainClass.cs @@ -51,8 +51,8 @@ public class MainClass : Plugin public override string Author { get; } = "Thomasjosif"; public override string Name { get; } = "Ultimate AFK"; public override string Prefix { get; } = "uAFK"; - public override Version Version { get; } = new Version(3, 1, 1); - public override Version RequiredExiledVersion { get; } = new Version(2, 0, 0); + public override Version Version { get; } = new Version(3, 1, 4); + public override Version RequiredExiledVersion { get; } = new Version(2, 1, 29, 0); public PlayerEvents PlayerEvents; public override PluginPriority Priority { get; } = PluginPriority.Medium; @@ -64,7 +64,7 @@ public override void OnEnabled() { PlayerEvents = new PlayerEvents(this); - Handlers.Player.Joined += PlayerEvents.OnPlayerJoin; + Handlers.Player.Joined += PlayerEvents.OnPlayerJoined; Handlers.Player.ChangingRole += PlayerEvents.OnSetClass; Handlers.Player.Shooting += PlayerEvents.OnPlayerShoot; Handlers.Player.InteractingDoor += PlayerEvents.OnDoorInteract; @@ -85,7 +85,7 @@ public override void OnEnabled() public override void OnDisabled() { base.OnDisabled(); - Handlers.Player.Joined -= PlayerEvents.OnPlayerJoin; + Handlers.Player.Joined -= PlayerEvents.OnPlayerJoined; Handlers.Player.ChangingRole -= PlayerEvents.OnSetClass; Handlers.Player.Shooting -= PlayerEvents.OnPlayerShoot; Handlers.Player.InteractingDoor -= PlayerEvents.OnDoorInteract; diff --git a/UltimateAFK/PlayerEvents.cs b/UltimateAFK/PlayerEvents.cs index 41648d2..ab3b849 100644 --- a/UltimateAFK/PlayerEvents.cs +++ b/UltimateAFK/PlayerEvents.cs @@ -14,11 +14,11 @@ public PlayerEvents(MainClass plugin) this.plugin = plugin; } - public void OnPlayerJoin(JoinedEventArgs ev) + public void OnPlayerJoined(JoinedEventArgs ev) { // Add a component to the player to check AFK status. AFKComponent afkComponent = ev.Player.GameObject.gameObject.AddComponent(); - afkComponent.plugin = this.plugin; + afkComponent.plugin = plugin; } // This check was moved here, because player's rank's are set AFTER OnPlayerJoin() @@ -29,7 +29,7 @@ public void OnSetClass(ChangingRoleEventArgs ev) if (ev.Player == null) return; AFKComponent afkComponent = ev.Player.GameObject.gameObject.GetComponent(); - if (afkComponent != null) + if (afkComponent != null && !plugin.Config.IgnorePermissionsAndIP) if (ev.Player.CheckPermission("uafk.ignore") || ev.Player.IPAddress == "127.0.0.1") //127.0.0.1 is sometimes used for "Pets" which causes issues afkComponent.disabled = true; diff --git a/UltimateAFK/UltimateAFK.csproj b/UltimateAFK/UltimateAFK.csproj index d78305b..f77565f 100644 --- a/UltimateAFK/UltimateAFK.csproj +++ b/UltimateAFK/UltimateAFK.csproj @@ -61,23 +61,23 @@ False ..\..\..\EXILED_REFERENCES\CommandSystem.Core.dll - - ..\packages\EXILED.2.1.15\lib\net472\Exiled.API.dll + + ..\packages\EXILED.2.1.29\lib\net472\Exiled.API.dll - - ..\packages\EXILED.2.1.15\lib\net472\Exiled.Bootstrap.dll + + ..\packages\EXILED.2.1.29\lib\net472\Exiled.Bootstrap.dll - - ..\packages\EXILED.2.1.15\lib\net472\Exiled.Events.dll + + ..\packages\EXILED.2.1.29\lib\net472\Exiled.Events.dll - - ..\packages\EXILED.2.1.15\lib\net472\Exiled.Loader.dll + + ..\packages\EXILED.2.1.29\lib\net472\Exiled.Loader.dll - - ..\packages\EXILED.2.1.15\lib\net472\Exiled.Permissions.dll + + ..\packages\EXILED.2.1.29\lib\net472\Exiled.Permissions.dll - ..\packages\EXILED.2.1.15\lib\net472\Exiled.Updater.dll + ..\packages\EXILED.2.1.29\lib\net472\Exiled.Updater.dll False @@ -98,7 +98,7 @@ False - ..\..\..\EXILED_REFERENCES\YamlDotNet.dll + ..\..\..\EXILED\bin\Debug\YamlDotNet.dll False diff --git a/UltimateAFK/app.config b/UltimateAFK/app.config index 0cac7f9..97df915 100644 --- a/UltimateAFK/app.config +++ b/UltimateAFK/app.config @@ -6,6 +6,10 @@ + + + + \ No newline at end of file diff --git a/UltimateAFK/packages.config b/UltimateAFK/packages.config index c03d4f5..39947d1 100644 --- a/UltimateAFK/packages.config +++ b/UltimateAFK/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file