diff --git a/pom.xml b/pom.xml
index 4380ea5..9b03eb0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -126,6 +126,10 @@
tastybento-repo
http://dl.bintray.com/tastybento/maven-repo
+
+ jitpack-repo
+ https://jitpack.io
+
@@ -188,6 +192,12 @@
7.0
provided
+
+ com.github.TechFortress
+ GriefPrevention
+ 16.6
+ provided
+
diff --git a/src/main/java/de/epiceric/shopchest/ShopChest.java b/src/main/java/de/epiceric/shopchest/ShopChest.java
index b741589..7a7b6c3 100644
--- a/src/main/java/de/epiceric/shopchest/ShopChest.java
+++ b/src/main/java/de/epiceric/shopchest/ShopChest.java
@@ -20,6 +20,7 @@ import de.epiceric.shopchest.utils.*;
import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
import de.epiceric.shopchest.external.WorldGuardShopFlag;
import fr.xephi.authme.AuthMe;
+import me.ryanhamshire.GriefPrevention.GriefPrevention;
import net.milkbowl.vault.economy.Economy;
import org.bstats.Metrics;
import org.bukkit.Bukkit;
@@ -55,6 +56,7 @@ public class ShopChest extends JavaPlugin {
private uSkyBlockAPI uSkyBlock;
private ASkyBlock aSkyBlock;
private IslandWorld islandWorld;
+ private GriefPrevention griefPrevention;
private ShopUpdater updater;
/**
@@ -183,6 +185,11 @@ public class ShopChest extends JavaPlugin {
islandWorld = (IslandWorld) islandWorldPlugin;
}
+ Plugin griefPreventionPlugin = Bukkit.getServer().getPluginManager().getPlugin("GriefPrevention");
+ if (griefPreventionPlugin instanceof GriefPrevention) {
+ griefPrevention = (GriefPrevention) griefPreventionPlugin;
+ }
+
if (hasPlotSquared()) {
new PlotSquaredShopFlag().register(this);
}
@@ -408,6 +415,20 @@ public class ShopChest extends JavaPlugin {
this.updater = updater;
}
+ /**
+ * @return Whether the plugin 'GriefPrevention' is enabled
+ */
+ public boolean hasGriefPrevention() {
+ return griefPrevention != null && griefPrevention.isEnabled();
+ }
+
+ /**
+ * @return An instance of {@link GriefPrevention} or {@code null} if GriefPrevention is not enabled
+ */
+ public GriefPrevention getGriefPrevention() {
+ return griefPrevention;
+ }
+
/**
* @return Whether the plugin 'IslandWorld' is enabled
*/
diff --git a/src/main/java/de/epiceric/shopchest/config/Config.java b/src/main/java/de/epiceric/shopchest/config/Config.java
index f2bef7b..10becf4 100644
--- a/src/main/java/de/epiceric/shopchest/config/Config.java
+++ b/src/main/java/de/epiceric/shopchest/config/Config.java
@@ -125,6 +125,9 @@ public class Config {
/** Whether IslandWorld integration should be enabled **/
public boolean enable_islandworld_integration;
+ /** Whether GriefPrevention integration should be enabled **/
+ public boolean enable_griefprevention_integration;
+
/** Whether the vendor of the shop should get messages about buys and sells **/
public boolean enable_vendor_messages;
@@ -373,6 +376,7 @@ public class Config {
enable_uskyblock_integration = plugin.getConfig().getBoolean("enable-uskyblock-integration");
enable_askyblock_integration = plugin.getConfig().getBoolean("enable-askyblock-integration");
enable_islandworld_integration = plugin.getConfig().getBoolean("enable-islandworld-integration");
+ enable_griefprevention_integration = plugin.getConfig().getBoolean("enable-griefprevention-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 8ad4192..a46ae70 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/ChestProtectListener.java
@@ -162,7 +162,7 @@ public class ChestProtectListener implements Listener {
externalPluginsAllowed = query.testState(b.getLocation(), p, WorldGuardShopFlag.CREATE_SHOP);
}
- if (plugin.hasTowny() && config.enable_towny_integration) {
+ if (externalPluginsAllowed && plugin.hasTowny() && config.enable_towny_integration) {
TownBlock townBlock = TownyUniverse.getTownBlock(b.getLocation());
if (townBlock != null) {
try {
@@ -184,33 +184,37 @@ public class ChestProtectListener implements Listener {
}
}
- if (plugin.hasPlotSquared() && config.enable_plotsquared_integration) {
+ if (externalPluginsAllowed && plugin.hasPlotSquared() && config.enable_plotsquared_integration) {
com.intellectualcrafters.plot.object.Location loc =
new com.intellectualcrafters.plot.object.Location(b.getWorld().getName(), b.getX(), b.getY(), b.getZ());
externalPluginsAllowed &= Utils.isFlagAllowedOnPlot(loc.getOwnedPlot(), PlotSquaredShopFlag.CREATE_SHOP, p);
}
- if (plugin.hasUSkyBlock() && config.enable_uskyblock_integration) {
+ if (externalPluginsAllowed && plugin.hasUSkyBlock() && config.enable_uskyblock_integration) {
IslandInfo islandInfo = plugin.getUSkyBlock().getIslandInfo(b.getLocation());
if (islandInfo != null) {
externalPluginsAllowed &= islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName());
}
}
- if (plugin.hasASkyBlock() && config.enable_askyblock_integration) {
+ if (externalPluginsAllowed && plugin.hasASkyBlock() && config.enable_askyblock_integration) {
Island island = ASkyBlockAPI.getInstance().getIslandAt(b.getLocation());
if (island != null) {
externalPluginsAllowed &= island.getMembers().contains(p.getUniqueId()) || island.getOwner().equals(p.getUniqueId());
}
}
- if (plugin.hasIslandWorld() && config.enable_islandworld_integration && IslandWorldApi.isInitialized()) {
+ if (externalPluginsAllowed && plugin.hasIslandWorld() && config.enable_islandworld_integration && IslandWorldApi.isInitialized()) {
if (b.getWorld().getName().equals(IslandWorldApi.getIslandWorld().getName())) {
externalPluginsAllowed &= IslandWorldApi.canBuildOnLocation(p, b.getLocation(), true);
}
}
+ if (externalPluginsAllowed && plugin.hasGriefPrevention() && config.enable_griefprevention_integration) {
+ externalPluginsAllowed &= plugin.getGriefPrevention().allowBuild(p, b.getLocation()) == null;
+ }
+
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 c781b97..84b6ee0 100644
--- a/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
+++ b/src/main/java/de/epiceric/shopchest/listeners/ShopInteractListener.java
@@ -229,6 +229,19 @@ public class ShopInteractListener implements Listener {
if (!externalPluginsAllowed) denyReason = "IslandWorld";
}
+ if (externalPluginsAllowed && plugin.hasGriefPrevention() && config.enable_griefprevention_integration) {
+ plugin.debug("Checking if GriefPrevention allows shop creation...");
+ String gpDenyReason = "";
+ for (Location loc : chestLocations) {
+ if (loc != null) {
+ gpDenyReason = plugin.getGriefPrevention().allowBuild(p, loc);
+ externalPluginsAllowed &= gpDenyReason == null;
+ }
+ }
+
+ if (!externalPluginsAllowed) denyReason = "GriefPrevention (" + gpDenyReason + ")";
+ }
+
if ((e.isCancelled() || !externalPluginsAllowed) && !p.hasPermission(Permissions.CREATE_PROTECTED)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE_PROTECTED));
ClickType.removePlayerClickType(p);
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 62e5e98..02f92ae 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -61,6 +61,10 @@ enable-askyblock-integration: true
# Of course, this only works if IslandWorld is installed
enable-islandworld-integration: true
+# Set whether GriefPrevention integration should be enabled
+# Of course, this only works if GriefPrevention is installed
+enable-griefprevention-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