Skip to content

Commit

Permalink
Update to Exiled v2.1.29
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
thomasjosif committed Jan 31, 2021
1 parent 0d19c19 commit ecc53f1
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 33 deletions.
6 changes: 1 addition & 5 deletions UltimateAFK/AFKComponent.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Linq;
using System.Collections.Generic;
using UnityEngine;
using MEC;
using Exiled.API.Features;
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 6 additions & 8 deletions UltimateAFK/Config.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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; } = "<color=white>[</color><color=green>uAFK</color><color=white>]</color>";
public string MsgGrace { get; private set; } = "<color=red>You will be moved to spectator in</color> <color=white>%timeleft% seconds</color><color=red> if you do not move!</color>";
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.";
}
}
8 changes: 4 additions & 4 deletions UltimateAFK/MainClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public class MainClass : Plugin<Config>
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;
Expand All @@ -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;
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions UltimateAFK/PlayerEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>();
afkComponent.plugin = this.plugin;
afkComponent.plugin = plugin;
}

// This check was moved here, because player's rank's are set AFTER OnPlayerJoin()
Expand All @@ -29,7 +29,7 @@ public void OnSetClass(ChangingRoleEventArgs ev)
if (ev.Player == null) return;
AFKComponent afkComponent = ev.Player.GameObject.gameObject.GetComponent<AFKComponent>();

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;

Expand Down
24 changes: 12 additions & 12 deletions UltimateAFK/UltimateAFK.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,23 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\EXILED_REFERENCES\CommandSystem.Core.dll</HintPath>
</Reference>
<Reference Include="Exiled.API, Version=2.1.15.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.15\lib\net472\Exiled.API.dll</HintPath>
<Reference Include="Exiled.API, Version=2.1.29.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.29\lib\net472\Exiled.API.dll</HintPath>
</Reference>
<Reference Include="Exiled.Bootstrap, Version=2.1.15.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.15\lib\net472\Exiled.Bootstrap.dll</HintPath>
<Reference Include="Exiled.Bootstrap, Version=2.1.29.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.29\lib\net472\Exiled.Bootstrap.dll</HintPath>
</Reference>
<Reference Include="Exiled.Events, Version=2.1.15.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.15\lib\net472\Exiled.Events.dll</HintPath>
<Reference Include="Exiled.Events, Version=2.1.29.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.29\lib\net472\Exiled.Events.dll</HintPath>
</Reference>
<Reference Include="Exiled.Loader, Version=2.1.15.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.15\lib\net472\Exiled.Loader.dll</HintPath>
<Reference Include="Exiled.Loader, Version=2.1.29.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.29\lib\net472\Exiled.Loader.dll</HintPath>
</Reference>
<Reference Include="Exiled.Permissions, Version=2.1.15.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.15\lib\net472\Exiled.Permissions.dll</HintPath>
<Reference Include="Exiled.Permissions, Version=2.1.29.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.29\lib\net472\Exiled.Permissions.dll</HintPath>
</Reference>
<Reference Include="Exiled.Updater, Version=3.0.3.0, Culture=neutral, processorArchitecture=AMD64">
<HintPath>..\packages\EXILED.2.1.15\lib\net472\Exiled.Updater.dll</HintPath>
<HintPath>..\packages\EXILED.2.1.29\lib\net472\Exiled.Updater.dll</HintPath>
</Reference>
<Reference Include="Mirror, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand All @@ -98,7 +98,7 @@
</Reference>
<Reference Include="YamlDotNet, Version=8.0.0.0, Culture=neutral, PublicKeyToken=ec19458f3c15af5e, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\EXILED_REFERENCES\YamlDotNet.dll</HintPath>
<HintPath>..\..\..\EXILED\bin\Debug\YamlDotNet.dll</HintPath>
</Reference>
<Reference Include="zxing.unity, Version=0.16.4.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
Expand Down
4 changes: 4 additions & 0 deletions UltimateAFK/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
<assemblyIdentity name="BouncyCastle.Crypto" publicKeyToken="0e99375e54769942" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.8.5.0" newVersion="1.8.5.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="YamlDotNet" publicKeyToken="ec19458f3c15af5e" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
2 changes: 1 addition & 1 deletion UltimateAFK/packages.config
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EXILED" version="2.1.15" targetFramework="net472" />
<package id="EXILED" version="2.1.29" targetFramework="net472" />
</packages>

0 comments on commit ecc53f1

Please sign in to comment.