From 54eb5d7db0ff1ace6c0152e4b73aa896e8f6f869 Mon Sep 17 00:00:00 2001 From: CoolLord22 Date: Wed, 11 Aug 2021 15:27:45 -0400 Subject: Add option to ignore AFK players for PlaytimeTaskType Hooks into Essentials and exempts users who are AFK at the time of the PlaytimeTask increment from getting time added to their quest progress. Adds config option to enable this (defaults to false, that way this feature isn't automatically on in old configs). --- .../quests/bukkit/tasktype/type/PlaytimeTaskType.java | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bukkit/src/main/java') diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java index 7ab9d279..ab0fb9e3 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java @@ -1,5 +1,6 @@ package com.leonardobishop.quests.bukkit.tasktype.type; +import com.earth2me.essentials.Essentials; import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin; import com.leonardobishop.quests.bukkit.tasktype.BukkitTaskType; import com.leonardobishop.quests.bukkit.util.TaskUtils; @@ -40,6 +41,8 @@ public final class PlaytimeTaskType extends BukkitTaskType { @Override public void onReady() { + boolean ignoreAFK = plugin.getQuestsConfig().getBoolean("options.playtime-ignores-afk", false); + Essentials ess = (Essentials) Bukkit.getPluginManager().getPlugin("Essentials"); if (this.poll == null) { this.poll = new BukkitRunnable() { @Override @@ -49,6 +52,9 @@ public final class PlaytimeTaskType extends BukkitTaskType { if (qPlayer == null) { continue; } + if (ignoreAFK && ess != null && ess.getUser(player).isAfk()) { + continue; // user is AFK so we will not track progress + } for (Quest quest : PlaytimeTaskType.super.getRegisteredQuests()) { if (qPlayer.hasStartedQuest(quest)) { -- cgit v1.2.3-70-g09d2