From f767edba93f4e81fc24684e72778a0fd3bfb6409 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 26 Feb 2013 09:53:01 -0500 Subject: [PATCH] Add SpoutHudAPI for other GUI-related plugins to tweak our XP Bar. --- .../com/gmail/nossr50/api/SpoutHudAPI.java | 28 +++++++++++++++++++ .../com/gmail/nossr50/spout/SpoutConfig.java | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java diff --git a/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java b/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java new file mode 100644 index 000000000..dfb3b3df9 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/api/SpoutHudAPI.java @@ -0,0 +1,28 @@ +package com.gmail.nossr50.api; + +import org.bukkit.entity.Player; + +import com.gmail.nossr50.spout.SpoutConfig; +import com.gmail.nossr50.spout.huds.HudType; +import com.gmail.nossr50.util.Users; + +public class SpoutHudAPI { + + /** + * Disable the mcMMO XP bar for a player. + *
+ * This function is designed for API usage. + */ + public static void disableXpBar(Player player) { + Users.getPlayer(player).getProfile().setHudType(HudType.DISABLED); + } + + /** + * Disable the mcMMO XP bar for the server. + *
+ * This function is designed for API usage. + */ + public static void disableXpBar() { + SpoutConfig.getInstance().setXPBarEnabled(false); + } +} diff --git a/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java b/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java index fc025cf0f..cc8a3c88c 100644 --- a/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java +++ b/src/main/java/com/gmail/nossr50/spout/SpoutConfig.java @@ -42,6 +42,8 @@ public class SpoutConfig extends ConfigLoader { /* XP Bar */ public boolean getXPBarEnabled() { return config.getBoolean("XP.Bar.Enabled", true); } + public void setXPBarEnabled(boolean enabled) { config.set("XP.Bar.Enabled", enabled); } + public boolean getXPBarIconEnabled() { return config.getBoolean("XP.Icon.Enabled", true); } public int getXPBarXPosition() { return config.getInt("XP.Bar.X_POS", 95); } public int getXPBarYPosition() { return config.getInt("XP.Bar.Y_POS", 6); }