mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 10:22:29 +00:00
Added support for GriefPrevention
Only players who are allowed to build can create a shop
This commit is contained in:
parent
53a9bb0274
commit
4ecbbb417b
10
pom.xml
10
pom.xml
@ -126,6 +126,10 @@
|
||||
<id>tastybento-repo</id>
|
||||
<url>http://dl.bintray.com/tastybento/maven-repo</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack-repo</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@ -188,6 +192,12 @@
|
||||
<version>7.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.TechFortress</groupId>
|
||||
<artifactId>GriefPrevention</artifactId>
|
||||
<version>16.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -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");
|
||||
|
@ -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)) {
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user