Added support for uSkyBlock

Only the leader pr members of an island can create or expand a shop,
but everyone can use them.
This commit is contained in:
Eric 2017-04-10 17:25:48 +02:00
parent 35028f2cab
commit d7985c615d
7 changed files with 61 additions and 9 deletions

View File

@ -118,6 +118,10 @@
<id>athion-reop</id>
<url>http://ci.athion.net/job/PlotSquared/ws/mvn/</url>
</repository>
<repository>
<id>uskyblock-repo</id>
<url>https://raw.github.com/rlf/uSkyBlock/mvn-repo/</url>
</repository>
</repositories>
<dependencies>
@ -162,6 +166,11 @@
<version>latest</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.rlf</groupId>
<artifactId>uSkyBlock-API</artifactId>
<version>2.6.4</version>
</dependency>
</dependencies>
<distributionManagement>

View File

@ -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();
}
/**

View File

@ -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");

View File

@ -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)) {

View File

@ -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)) {

View File

@ -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

View File

@ -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: