mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-12-22 17:11:46 +00:00
Added support for AreaShop
This commit is contained in:
parent
02275103c0
commit
56dc0c9c65
BIN
lib/AreaShop-2.4.0.jar
Normal file
BIN
lib/AreaShop-2.4.0.jar
Normal file
Binary file not shown.
7
pom.xml
7
pom.xml
@ -197,6 +197,13 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/worldguard-6.1.3-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.wiefferink</groupId>
|
||||
<artifactId>areashop</artifactId>
|
||||
<version>2.4.0</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/AreaShop-2.4.0.jar</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<distributionManagement>
|
||||
|
@ -21,6 +21,7 @@ import de.epiceric.shopchest.utils.UpdateChecker.UpdateCheckerResult;
|
||||
import de.epiceric.shopchest.external.WorldGuardShopFlag;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
||||
import me.wiefferink.areashop.AreaShop;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bstats.Metrics;
|
||||
import org.bukkit.Bukkit;
|
||||
@ -57,6 +58,7 @@ public class ShopChest extends JavaPlugin {
|
||||
private ASkyBlock aSkyBlock;
|
||||
private IslandWorld islandWorld;
|
||||
private GriefPrevention griefPrevention;
|
||||
private AreaShop areaShop;
|
||||
private ShopUpdater updater;
|
||||
|
||||
/**
|
||||
@ -190,6 +192,11 @@ public class ShopChest extends JavaPlugin {
|
||||
griefPrevention = (GriefPrevention) griefPreventionPlugin;
|
||||
}
|
||||
|
||||
Plugin areaShopPlugin = Bukkit.getServer().getPluginManager().getPlugin("AreaShop");
|
||||
if (areaShopPlugin instanceof AreaShop) {
|
||||
areaShop = (AreaShop) areaShopPlugin;
|
||||
}
|
||||
|
||||
if (hasPlotSquared()) {
|
||||
new PlotSquaredShopFlag().register(this);
|
||||
}
|
||||
@ -292,12 +299,18 @@ public class ShopChest extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new NotifyPlayerOnJoinListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new ChestProtectListener(this, worldGuard), this);
|
||||
|
||||
if (!Utils.getServerVersion().equals("v1_8_R1"))
|
||||
if (!Utils.getServerVersion().equals("v1_8_R1")) {
|
||||
getServer().getPluginManager().registerEvents(new BlockExplodeListener(this), this);
|
||||
}
|
||||
|
||||
if (hasWorldGuard())
|
||||
if (hasWorldGuard()) {
|
||||
getServer().getPluginManager().registerEvents(new WorldGuardListener(this), this);
|
||||
|
||||
if (hasAreaShop()) {
|
||||
getServer().getPluginManager().registerEvents(new AreaShopListener(this), this);
|
||||
}
|
||||
}
|
||||
|
||||
initializeShops();
|
||||
|
||||
updater = new ShopUpdater(this);
|
||||
@ -401,6 +414,20 @@ public class ShopChest extends JavaPlugin {
|
||||
this.updater = updater;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the plugin 'AreaShop' is enabled
|
||||
*/
|
||||
public boolean hasAreaShop() {
|
||||
return areaShop != null && areaShop.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An instance of {@link AreaShop} or {@code null} if AreaShop is not enabled
|
||||
*/
|
||||
public AreaShop getAreaShop() {
|
||||
return areaShop;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Whether the plugin 'GriefPrevention' is enabled
|
||||
*/
|
||||
|
@ -42,6 +42,9 @@ public class Config {
|
||||
/** The types of town plots the king is allowed to create shops in **/
|
||||
public List<String> towny_shop_plots_king;
|
||||
|
||||
/** The events of AreaShop when shops in that region should be removed **/
|
||||
public List<String> areashop_remove_shop_events;
|
||||
|
||||
/** The hostname used in ShopChest's MySQL database **/
|
||||
public String database_mysql_host;
|
||||
|
||||
@ -128,6 +131,9 @@ public class Config {
|
||||
/** Whether GriefPrevention integration should be enabled **/
|
||||
public boolean enable_griefprevention_integration;
|
||||
|
||||
/** Whether AreaShop integration should be enabled **/
|
||||
public boolean enable_areashop_integration;
|
||||
|
||||
/** Whether the vendor of the shop should get messages about buys and sells **/
|
||||
public boolean enable_vendor_messages;
|
||||
|
||||
@ -339,6 +345,7 @@ public class Config {
|
||||
towny_shop_plots_residents = plugin.getConfig().getStringList("towny-shop-plots.residents");
|
||||
towny_shop_plots_mayor = plugin.getConfig().getStringList("towny-shop-plots.mayor");
|
||||
towny_shop_plots_king = plugin.getConfig().getStringList("towny-shop-plots.king");
|
||||
areashop_remove_shop_events = plugin.getConfig().getStringList("areashop-remove-shops");
|
||||
database_mysql_ping_interval = plugin.getConfig().getInt("database.mysql.ping-interval");
|
||||
database_mysql_host = plugin.getConfig().getString("database.mysql.hostname");
|
||||
database_mysql_port = plugin.getConfig().getInt("database.mysql.port");
|
||||
@ -366,6 +373,7 @@ public class Config {
|
||||
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_areashop_integration = plugin.getConfig().getBoolean("enable-areashop-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");
|
||||
|
@ -0,0 +1,72 @@
|
||||
package de.epiceric.shopchest.listeners;
|
||||
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.shop.Shop;
|
||||
import me.wiefferink.areashop.events.notify.DeletedRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.ResoldRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.SoldRegionEvent;
|
||||
import me.wiefferink.areashop.events.notify.UnrentedRegionEvent;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
public class AreaShopListener implements Listener {
|
||||
|
||||
private ShopChest plugin;
|
||||
private Config config;
|
||||
|
||||
public AreaShopListener(ShopChest plugin) {
|
||||
this.plugin = plugin;
|
||||
this.config = plugin.getShopChestConfig();
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRegionDeleted(DeletedRegionEvent e) {
|
||||
if (config.enable_areashop_integration && config.areashop_remove_shop_events.contains("DELETE")) {
|
||||
removeShopsInRegion(e.getRegion());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRegionUnrented(UnrentedRegionEvent e) {
|
||||
if (config.enable_areashop_integration && config.areashop_remove_shop_events.contains("UNRENT")) {
|
||||
removeShopsInRegion(e.getRegion());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRegionResold(ResoldRegionEvent e) {
|
||||
if (config.enable_areashop_integration && config.areashop_remove_shop_events.contains("RESELL")) {
|
||||
removeShopsInRegion(e.getRegion());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onRegionSold(SoldRegionEvent e) {
|
||||
if (config.enable_areashop_integration && config.areashop_remove_shop_events.contains("SELL")) {
|
||||
removeShopsInRegion(e.getRegion());
|
||||
}
|
||||
}
|
||||
|
||||
private void removeShopsInRegion(GeneralRegion generalRegion) {
|
||||
if (!plugin.hasWorldGuard()) return;
|
||||
|
||||
RegionManager regionManager = plugin.getWorldGuard().getRegionManager(generalRegion.getWorld());
|
||||
|
||||
for (Shop shop : plugin.getShopUtils().getShops()) {
|
||||
if (!shop.getLocation().getWorld().getName().equals(generalRegion.getWorldName())) continue;
|
||||
|
||||
for (ProtectedRegion r : regionManager.getApplicableRegions(shop.getLocation())) {
|
||||
if (generalRegion.getName().equals(r.getId())) {
|
||||
plugin.getShopUtils().removeShop(shop, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -65,6 +65,10 @@ enable-islandworld-integration: true
|
||||
# Of course, this only works if GriefPrevention is installed
|
||||
enable-griefprevention-integration: true
|
||||
|
||||
# Set whether AreaShop integration should be enabled
|
||||
# Of course, this only works if AreaShop and WorldGuard is installed
|
||||
enable-areashop-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
|
||||
@ -197,6 +201,15 @@ blacklist:
|
||||
# - "STONE:1"
|
||||
# - "DIAMOND_BLOCK"
|
||||
|
||||
# Set the events of AreaShop when shops on that region should be removed.
|
||||
# Important: You must have exactly 2 leading spaces in each line
|
||||
# Valid values are: DELETE, UNRENT, RESELL, SELL
|
||||
areashop-remove-shops:
|
||||
- "DELETE"
|
||||
- "UNRENT"
|
||||
- "RESELL"
|
||||
- "SELL"
|
||||
|
||||
# Set whether the custom WorldGuard flags should be allowed by default
|
||||
# (true = Allowed by default, false = Denied by default)
|
||||
# This can, of course, be overridden in specific regions and is only
|
||||
|
@ -5,7 +5,7 @@ main: de.epiceric.shopchest.ShopChest
|
||||
version: ${project.version}
|
||||
author: EpicEric
|
||||
website: ${project.url}
|
||||
softdepend: [WorldGuard, Towny, AuthMe, PlotSquared, uSkyBlock, ASkyBlock, IslandWorld]
|
||||
softdepend: [WorldGuard, Towny, AuthMe, PlotSquared, uSkyBlock, ASkyBlock, IslandWorld, AreaShop]
|
||||
depend: [Vault]
|
||||
|
||||
permissions:
|
||||
|
Loading…
Reference in New Issue
Block a user