diff options
| author | CoolLord22 <mastermodmaker@yahoo.com> | 2021-08-11 15:27:45 -0400 |
|---|---|---|
| committer | LMBishop <13875753+LMBishop@users.noreply.github.com> | 2021-08-11 23:04:24 +0100 |
| commit | 54eb5d7db0ff1ace6c0152e4b73aa896e8f6f869 (patch) | |
| tree | fdcb192c2f8c7244b3784c895067d9046e773bb1 /bukkit/src/main/java/com | |
| parent | c2830540c8b51a53a9c200b5d02df9d22e09e650 (diff) | |
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).
Diffstat (limited to 'bukkit/src/main/java/com')
| -rw-r--r-- | bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java | 6 |
1 files changed, 6 insertions, 0 deletions
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)) { |
