diff --git a/pom.xml b/pom.xml
index b3d1ace..ea95358 100644
--- a/pom.xml
+++ b/pom.xml
@@ -118,6 +118,10 @@
athion-reop
http://ci.athion.net/job/PlotSquared/ws/mvn/
+
+ uskyblock-repo
+ https://raw.github.com/rlf/uSkyBlock/mvn-repo/
+
@@ -162,6 +166,11 @@
latest
provided
+
+ com.github.rlf
+ uSkyBlock-API
+ 2.6.4
+
diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java
index 6468b36..4cca688 100644
--- a/src/main/java/de/epiceric/shopchest/ShopChest.java
+++ b/src/main/java/de/epiceric/shopchest/ShopChest.java
@@ -1,6 +1,5 @@
package de.epiceric.shopchest;
-import com.intellectualcrafters.plot.PS;
import com.palmergames.bukkit.towny.Towny;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import de.epiceric.shopchest.config.Config;
@@ -28,7 +27,7 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
-import org.bukkit.scheduler.BukkitRunnable;
+import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
import java.io.*;
import java.text.SimpleDateFormat;
@@ -51,6 +50,7 @@ public class ShopChest extends JavaPlugin {
private WorldGuardPlugin worldGuard;
private Towny towny;
private AuthMe authMe;
+ private uSkyBlockAPI uSkyBlock;
private ShopUpdater updater;
/**
@@ -164,6 +164,11 @@ public class ShopChest extends JavaPlugin {
authMe = (AuthMe) authMePlugin;
}
+ Plugin uSkyBlockPlugin = Bukkit.getServer().getPluginManager().getPlugin("uSkyBlock");
+ if (uSkyBlockPlugin instanceof uSkyBlockAPI) {
+ uSkyBlock = (uSkyBlockAPI) uSkyBlockPlugin;
+ }
+
if (hasPlotSquared()) {
new PlotSquaredShopFlag().register(this);
}
@@ -390,18 +395,33 @@ public class ShopChest extends JavaPlugin {
this.updater = updater;
}
+ /**
+ * @return Whether the plugin 'uSkyBlock' is enabled
+ */
+ public boolean hasUSkyBlock() {
+ return uSkyBlock != null && uSkyBlock.isEnabled();
+ }
+
+ /**
+ * @return An instance of {@link uSkyBlockAPI} or {@code null} if uSkyBlock is not enabled
+ */
+ public uSkyBlockAPI getUSkyBlock() {
+ return uSkyBlock;
+ }
+
/**
* @return Whether the plugin 'PlotSquared' is enabled
*/
public boolean hasPlotSquared() {
- return getServer().getPluginManager().getPlugin("PlotSquared") != null;
+ Plugin p = getServer().getPluginManager().getPlugin("PlotSquared");
+ return p != null && p.isEnabled();
}
/**
* @return Whether the plugin 'AuthMe' is enabled
*/
public boolean hasAuthMe() {
- return authMe != null;
+ return authMe != null && authMe.isEnabled();
}
/**
@@ -415,7 +435,7 @@ public class ShopChest extends JavaPlugin {
* @return Whether the plugin 'Towny' is enabled
*/
public boolean hasTowny() {
- return towny != null;
+ return towny != null && towny.isEnabled();
}
/**
@@ -429,7 +449,7 @@ public class ShopChest extends JavaPlugin {
* @return Whether the plugin 'WorldGuard' is enabled
*/
public boolean hasWorldGuard() {
- return worldGuard != null;
+ return worldGuard != null && worldGuard.isEnabled();
}
/**
diff --git a/src/main/java/de/epiceric/shopchest/config/Config.java b/src/main/java/de/epiceric/shopchest/config/Config.java
index 9f61a10..ae2870c 100644
--- a/src/main/java/de/epiceric/shopchest/config/Config.java
+++ b/src/main/java/de/epiceric/shopchest/config/Config.java
@@ -107,6 +107,9 @@ public class Config {
/** Whether PlotSquared integration should be enabled **/
public boolean enable_plotsquared_integration;
+ /** Whether uSkyBlock integration should be enabled **/
+ public boolean enable_uskyblock_integration;
+
/** Whether the vendor of the shop should get messages about buys and sells **/
public boolean enable_vendor_messages;
@@ -346,6 +349,7 @@ public class Config {
enable_towny_integration = plugin.getConfig().getBoolean("enable-towny-integration");
enable_authme_integration = plugin.getConfig().getBoolean("enable-authme-integration");
enable_plotsquared_integration = plugin.getConfig().getBoolean("enable-plotsquared-integration");
+ enable_uskyblock_integration = plugin.getConfig().getBoolean("enable-uskyblock-integration");
enable_vendor_messages = plugin.getConfig().getBoolean("enable-vendor-messages");
explosion_protection = plugin.getConfig().getBoolean("explosion-protection");
only_show_shops_in_sight = plugin.getConfig().getBoolean("only-show-shops-in-sight");
diff --git a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java
index e0ef056..c848db4 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java
@@ -8,6 +8,7 @@ import com.sk89q.worldguard.bukkit.RegionQuery;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
+import de.epiceric.shopchest.external.WorldGuardShopFlag;
import de.epiceric.shopchest.language.LanguageUtils;
import de.epiceric.shopchest.language.LocalizedMessage;
import de.epiceric.shopchest.nms.Hologram;
@@ -15,7 +16,6 @@ import de.epiceric.shopchest.shop.Shop;
import de.epiceric.shopchest.utils.Permissions;
import de.epiceric.shopchest.utils.ShopUtils;
import de.epiceric.shopchest.utils.Utils;
-import de.epiceric.shopchest.external.WorldGuardShopFlag;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
@@ -35,6 +35,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.InventoryHolder;
+import us.talabrek.ultimateskyblock.api.IslandInfo;
import java.util.ArrayList;
@@ -166,6 +167,11 @@ public class ChestProtectListener implements Listener {
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(loc.getOwnedPlot(), PlotSquaredShopFlag.CREATE_SHOP, p);
}
+ if (plugin.hasUSkyBlock() && plugin.getShopChestConfig().enable_uskyblock_integration) {
+ IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(b.getLocation());
+ externalPluginsAllowed &= islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName());
+ }
+
if (externalPluginsAllowed || p.hasPermission(Permissions.EXTEND_PROTECTED)) {
if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.EXTEND_OTHER)) {
diff --git a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
index 59e88b8..0717ac6 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
@@ -51,6 +51,7 @@ import org.bukkit.inventory.*;
import org.bukkit.inventory.meta.EnchantmentStorageMeta;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.Potion;
+import us.talabrek.ultimateskyblock.api.IslandInfo;
import java.util.HashMap;
import java.util.Map;
@@ -138,7 +139,15 @@ public class ShopInteractListener implements Listener {
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(plot, PlotSquaredShopFlag.CREATE_SHOP, p);
}
}
+ }
+ if (plugin.hasUSkyBlock() && config.enable_uskyblock_integration) {
+ for (Location loc : chestLocations) {
+ if (loc != null) {
+ IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(loc);
+ externalPluginsAllowed &= islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName());
+ }
+ }
}
if ((e.isCancelled() || !externalPluginsAllowed) && !p.hasPermission(Permissions.CREATE_PROTECTED)) {
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 09272dc..73f7972 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -46,9 +46,13 @@ enable-towny-integration: true
enable-authme-integration: true
# Set whether PlotSquared integration should be enabled
-# Of course, this only works if AuthMe is installed
+# Of course, this only works if PlotSquared is installed
enable-plotsquared-integration: true
+# Set whether uSkyBlock integration should be enabled
+# Of course, this only works if uSkyBlock is installed
+enable-uskyblock-integration: true
+
# Set whether the vendor of a shop should get messages when players
# buy or sell something from/to his shop or if his shop is out of stock
enable-vendor-messages: true
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index e719ba4..a9acfaf 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -5,7 +5,7 @@ main: de.epiceric.shopchest.ShopChest
version: ${project.version}
author: EpicEric
website: ${project.url}
-softdepend: [WorldGuard, Towny, AuthMe, PlotSquared]
+softdepend: [WorldGuard, Towny, AuthMe, PlotSquared, uSkyBlock]
depend: [Vault]
permissions: