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 | |
| 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')
| -rw-r--r-- | bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/PlaytimeTaskType.java | 6 | ||||
| -rw-r--r-- | bukkit/src/main/resources/resources/bukkit/config.yml | 2 |
2 files changed, 8 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)) { diff --git a/bukkit/src/main/resources/resources/bukkit/config.yml b/bukkit/src/main/resources/resources/bukkit/config.yml index 34205102..4f7b36c9 100644 --- a/bukkit/src/main/resources/resources/bukkit/config.yml +++ b/bukkit/src/main/resources/resources/bukkit/config.yml @@ -150,6 +150,8 @@ options: trim-gui-size: true # Enable/disable titles titles-enabled: true + # Should the playtime task type ignore users who are marked AFK by Essentials + playtime-ignores-afk: false # Allow players to have multiple active quests. # You can set the default number of quests using the 'default' rank below. # To grant different quest limits to different people, you can define a 'quest-rank' |
