Added support for ASkyBlock

Only members and the owner of an island are allowed to create a shop,
but everyone is allowed to use it (if not restricted by other plugins
like WorldGuard)

Closes #50
This commit is contained in:
Eric 2017-04-17 17:07:47 +02:00
parent dcea39ab9e
commit 7c1cb7f665
7 changed files with 59 additions and 1 deletions

11
pom.xml
View File

@ -122,6 +122,10 @@
<id>uskyblock-repo</id>
<url>https://raw.github.com/rlf/uSkyBlock/mvn-repo/</url>
</repository>
<repository>
<id>tastybento-repo</id>
<url>http://dl.bintray.com/tastybento/maven-repo</url>
</repository>
</repositories>
<dependencies>
@ -170,6 +174,13 @@
<groupId>com.github.rlf</groupId>
<artifactId>uSkyBlock-API</artifactId>
<version>2.6.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.wasteofplastic</groupId>
<artifactId>askyblock</artifactId>
<version>3.0.6.2</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -2,6 +2,7 @@ package de.epiceric.shopchest;
import com.palmergames.bukkit.towny.Towny;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.wasteofplastic.askyblock.ASkyBlock;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.config.Regex;
import de.epiceric.shopchest.event.ShopReloadEvent;
@ -51,6 +52,7 @@ public class ShopChest extends JavaPlugin {
private Towny towny;
private AuthMe authMe;
private uSkyBlockAPI uSkyBlock;
private ASkyBlock aSkyBlock;
private ShopUpdater updater;
/**
@ -169,6 +171,11 @@ public class ShopChest extends JavaPlugin {
uSkyBlock = (uSkyBlockAPI) uSkyBlockPlugin;
}
Plugin aSkyBlockPlugin = Bukkit.getServer().getPluginManager().getPlugin("ASkyBlock");
if (aSkyBlockPlugin instanceof ASkyBlock) {
aSkyBlock = (ASkyBlock) aSkyBlockPlugin;
}
if (hasPlotSquared()) {
new PlotSquaredShopFlag().register(this);
}
@ -394,6 +401,20 @@ public class ShopChest extends JavaPlugin {
this.updater = updater;
}
/**
* @return Whether the plugin 'ASkyBlock' is enabled
*/
public boolean hasASkyBlock() {
return aSkyBlock != null && aSkyBlock.isEnabled();
}
/**
* @return An instance of {@link ASkyBlock} or {@code null} if ASkyBlock is not enabled
*/
public ASkyBlock getASkyBlock() {
return aSkyBlock;
}
/**
* @return Whether the plugin 'uSkyBlock' is enabled
*/

View File

@ -119,6 +119,9 @@ public class Config {
/** Whether uSkyBlock integration should be enabled **/
public boolean enable_uskyblock_integration;
/** Whether ASkyBlock integration should be enabled **/
public boolean enable_askyblock_integration;
/** Whether the vendor of the shop should get messages about buys and sells **/
public boolean enable_vendor_messages;
@ -362,6 +365,7 @@ public class Config {
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_askyblock_integration = plugin.getConfig().getBoolean("enable-askyblock-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");

View File

@ -7,6 +7,8 @@ import com.palmergames.bukkit.towny.object.TownyUniverse;
import com.sk89q.worldguard.bukkit.RegionContainer;
import com.sk89q.worldguard.bukkit.RegionQuery;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import com.wasteofplastic.askyblock.Island;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
@ -192,6 +194,11 @@ public class ChestProtectListener implements Listener {
externalPluginsAllowed &= islandInfo.getMembers().contains(p.getName()) || islandInfo.getLeader().equals(p.getName());
}
if (plugin.hasASkyBlock() && config.enable_askyblock_integration) {
Island island = ASkyBlockAPI.getInstance().getIslandAt(b.getLocation());
externalPluginsAllowed &= island.getMembers().contains(p.getUniqueId()) || island.getOwner().equals(p.getUniqueId());
}
if (externalPluginsAllowed || p.hasPermission(Permissions.EXTEND_PROTECTED)) {
if (shop.getVendor().getUniqueId().equals(p.getUniqueId()) || p.hasPermission(Permissions.EXTEND_OTHER)) {

View File

@ -10,6 +10,8 @@ import com.sk89q.worldguard.bukkit.RegionContainer;
import com.sk89q.worldguard.bukkit.RegionQuery;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.protection.flags.StateFlag;
import com.wasteofplastic.askyblock.ASkyBlockAPI;
import com.wasteofplastic.askyblock.Island;
import de.epiceric.shopchest.ShopChest;
import de.epiceric.shopchest.config.Config;
import de.epiceric.shopchest.config.Regex;
@ -170,6 +172,15 @@ public class ShopInteractListener implements Listener {
}
}
if (plugin.hasASkyBlock() && config.enable_askyblock_integration) {
for (Location loc : chestLocations) {
if (loc != null) {
Island island = ASkyBlockAPI.getInstance().getIslandAt(loc);
externalPluginsAllowed &= island.getMembers().contains(p.getUniqueId()) || island.getOwner().equals(p.getUniqueId());
}
}
}
if ((e.isCancelled() || !externalPluginsAllowed) && !p.hasPermission(Permissions.CREATE_PROTECTED)) {
p.sendMessage(LanguageUtils.getMessage(LocalizedMessage.Message.NO_PERMISSION_CREATE_PROTECTED));
ClickType.removePlayerClickType(p);

View File

@ -53,6 +53,10 @@ enable-plotsquared-integration: true
# Of course, this only works if uSkyBlock is installed
enable-uskyblock-integration: true
# Set whether ASkyBlock integration should be enabled
# Of course, this only works if ASkyBlock is installed
enable-askyblock-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

View File

@ -5,7 +5,7 @@ main: de.epiceric.shopchest.ShopChest
version: ${project.version}
author: EpicEric
website: ${project.url}
softdepend: [WorldGuard, Towny, AuthMe, PlotSquared, uSkyBlock]
softdepend: [WorldGuard, Towny, AuthMe, PlotSquared, uSkyBlock, ASkyBlock]
depend: [Vault]
permissions: