From 1c3b3a2c5629da58a3c0604cbe525bb6ba079723 Mon Sep 17 00:00:00 2001 From: Florian CUNY Date: Fri, 22 Dec 2017 13:37:28 +0100 Subject: [PATCH] AddonsAPI - Added #getFolder() in BSModule --- src/main/java/us/tastybento/bskyblock/BSkyBlock.java | 7 +++++++ .../java/us/tastybento/bskyblock/api/BSModule.java | 3 +++ .../us/tastybento/bskyblock/api/addons/BSAddon.java | 11 +++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/main/java/us/tastybento/bskyblock/BSkyBlock.java b/src/main/java/us/tastybento/bskyblock/BSkyBlock.java index 1f69a5c89..0b00f8767 100755 --- a/src/main/java/us/tastybento/bskyblock/BSkyBlock.java +++ b/src/main/java/us/tastybento/bskyblock/BSkyBlock.java @@ -20,6 +20,8 @@ import us.tastybento.bskyblock.managers.LocalesManager; import us.tastybento.bskyblock.util.Util; import us.tastybento.bskyblock.util.nms.NMSAbstraction; +import java.io.File; + /** * Main BSkyBlock class - provides an island minigame in the sky * @author Tastybento @@ -222,4 +224,9 @@ public class BSkyBlock extends JavaPlugin implements BSModule { public boolean isAddon() { return false; } + + @Override + public File getFolder() { + return getDataFolder(); + } } diff --git a/src/main/java/us/tastybento/bskyblock/api/BSModule.java b/src/main/java/us/tastybento/bskyblock/api/BSModule.java index c59873267..8d08efc85 100644 --- a/src/main/java/us/tastybento/bskyblock/api/BSModule.java +++ b/src/main/java/us/tastybento/bskyblock/api/BSModule.java @@ -1,7 +1,10 @@ package us.tastybento.bskyblock.api; +import java.io.File; + public interface BSModule { String getIdentifier(); boolean isAddon(); + File getFolder(); } diff --git a/src/main/java/us/tastybento/bskyblock/api/addons/BSAddon.java b/src/main/java/us/tastybento/bskyblock/api/addons/BSAddon.java index ec29be4f7..31d03d521 100644 --- a/src/main/java/us/tastybento/bskyblock/api/addons/BSAddon.java +++ b/src/main/java/us/tastybento/bskyblock/api/addons/BSAddon.java @@ -5,8 +5,11 @@ import us.tastybento.bskyblock.api.BSModule; import us.tastybento.bskyblock.managers.CommandsManager; import us.tastybento.bskyblock.managers.LocalesManager; +import java.io.File; + public abstract class BSAddon implements BSModule { + private File folder; private AddonDescription description; private AddonState state; @@ -41,4 +44,12 @@ public abstract class BSAddon implements BSModule { public boolean isAddon() { return true; } + + @Override + public File getFolder() { + if (folder == null) { + folder = new File(BSkyBlock.getPlugin().getFolder() + "/addons/" + getIdentifier()); + } + return folder; + } }