From cf6d95b5752b7191fd64b7e6bbbd549aa61936f5 Mon Sep 17 00:00:00 2001 From: nossr50 Date: Fri, 18 Jan 2019 12:41:38 -0800 Subject: [PATCH] More config options for XP bars --- .../skills/ExperienceBarHideTask.java | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java b/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java index c6169edf7..23e78909c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/skills/ExperienceBarHideTask.java @@ -1,4 +1,39 @@ package com.gmail.nossr50.runnables.skills; -public class ExperienceBarHideTask { +import com.gmail.nossr50.datatypes.player.McMMOPlayer; +import com.gmail.nossr50.datatypes.skills.PrimarySkillType; +import com.gmail.nossr50.util.experience.ExperienceBarManager; +import org.bukkit.scheduler.BukkitRunnable; + +public class ExperienceBarHideTask extends BukkitRunnable { + public final McMMOPlayer mcMMOPlayer; + public final PrimarySkillType primarySkillType; + public final ExperienceBarManager experienceBarManagerRef; + + public ExperienceBarHideTask(ExperienceBarManager experienceBarManagerRef, McMMOPlayer mcMMOPlayer, PrimarySkillType primarySkillType) + { + this.experienceBarManagerRef = experienceBarManagerRef; + this.mcMMOPlayer = mcMMOPlayer; + this.primarySkillType = primarySkillType; + } + + /** + * When an object implementing interface Runnable is used + * to create a thread, starting the thread causes the object's + * run method to be called in that separately executing + * thread. + *

+ * The general contract of the method run is that it may + * take any action whatsoever. + * + * @see Thread#run() + */ + @Override + public void run() { + if(experienceBarManagerRef == null || mcMMOPlayer == null) + return; + + experienceBarManagerRef.hideExperienceBar(primarySkillType); + experienceBarManagerRef.clearTask(primarySkillType); + } }