diff --git a/pom.xml b/pom.xml
index 4f6a4b7a0..7a0059281 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,10 @@
bukkit-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
+
+ sk89q-repo
+ http://maven.sk89q.com/repo/
+
mv-core
http://repo.onarandombox.com/content/repositories/multiverse/
@@ -63,10 +67,6 @@
fanciful-repo
https://github.com/mkremins/fanciful/tree/mvn-repo
-
- sk89q-repo
- http://maven.sk89q.com/repo/
-
vault-repo
http://nexus.hc.to/content/repositories/pub_releases
diff --git a/src/main/java/org/maxgamer/quickshop/Command/QS.java b/src/main/java/org/maxgamer/quickshop/Command/QS.java
index 4d8906ae0..42700aac8 100644
--- a/src/main/java/org/maxgamer/quickshop/Command/QS.java
+++ b/src/main/java/org/maxgamer/quickshop/Command/QS.java
@@ -359,7 +359,7 @@ public class QS implements CommandExecutor {
while (bIt.hasNext()) {
Block b = bIt.next();
- if (Util.canBeShop(b)) {
+ if (Util.canBeShop(b,null,true)) {
if (p != null && b != null && p.isOnline()) {
BlockBreakEvent be = new BlockBreakEvent(b, p);
Bukkit.getPluginManager().callEvent(be);
diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/AreaShopListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/AreaShopListener.java
new file mode 100644
index 000000000..38a16fdd9
--- /dev/null
+++ b/src/main/java/org/maxgamer/quickshop/Listeners/AreaShopListener.java
@@ -0,0 +1,47 @@
+package org.maxgamer.quickshop.Listeners;
+
+import java.util.Iterator;
+import org.maxgamer.quickshop.Util.*;
+
+import org.bukkit.event.EventHandler;
+import org.bukkit.event.Listener;
+import org.bukkit.util.Vector;
+import org.maxgamer.quickshop.QuickShop;
+import org.maxgamer.quickshop.Shop.Shop;
+import me.wiefferink.areashop.events.notify.UnrentedRegionEvent;
+
+public class AreaShopListener implements Listener {
+ QuickShop plugin = QuickShop.instance;
+
+ @EventHandler
+ public void unRentedArea(UnrentedRegionEvent e) {
+ Vector areaMaxVector = e.getRegion().getMaximumPoint();
+ Vector areaMinVector = e.getRegion().getMinimumPoint();
+ int minX = areaMinVector.getBlockX();
+ int maxX = areaMaxVector.getBlockX();
+ int minY = areaMinVector.getBlockY();
+ int maxY = areaMaxVector.getBlockY();
+ int minZ = areaMinVector.getBlockZ();
+ int maxZ = areaMaxVector.getBlockZ();
+ Iterator shops = plugin.getShopManager().getShopIterator();
+ while (shops.hasNext()) {
+ Shop shop = shops.next();
+ if(shop.getLocation().getWorld().getName()==e.getRegion().getWorld().getName()) {
+ int bX = shop.getLocation().getBlockX();
+ int bY = shop.getLocation().getBlockY();
+ int bZ = shop.getLocation().getBlockZ();
+ if(bX>=minX && bX<=maxX) {
+ if(bY>=minY && bY<=maxY) {
+ if(bZ>=minZ && bZ<=maxZ) {
+ //In region, we need remove that shop.
+ Util.debugLog("Removed shop at:["+shop.getLocation().toString()+"] cause AreaShop region unrented!");
+ shop.delete();
+ }
+ }
+ }
+ }
+
+
+ }
+ }
+}
diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java
index 293b45ccb..5e29ef99b 100644
--- a/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java
+++ b/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java
@@ -73,7 +73,7 @@ public class BlockListener implements Listener {
}
Player p = e.getPlayer();
// If the shop was a chest
- if (Util.canBeShop(b)) {
+ if (Util.canBeShop(b,null,true)) {
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return;
@@ -261,7 +261,7 @@ public class BlockListener implements Listener {
for (Block oBlock : event.getBlocks()) {
Block otherBlock = oBlock.getRelative(event.getDirection()).getRelative(BlockFace.DOWN);
- if (Util.canBeShop(otherBlock)) {
+ if (Util.canBeShop(otherBlock,null,true)) {
shop = plugin.getShopManager().getShop(otherBlock.getLocation());
if (shop!=null) {
event.setCancelled(true);
diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/LockListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/LockListener.java
index c974a8ed8..339fab7a7 100644
--- a/src/main/java/org/maxgamer/quickshop/Listeners/LockListener.java
+++ b/src/main/java/org/maxgamer/quickshop/Listeners/LockListener.java
@@ -30,7 +30,7 @@ public class LockListener implements Listener {
Player p = e.getPlayer();
if (e.getAction() != Action.RIGHT_CLICK_BLOCK)
return; // Didn't right click it, we dont care.
- if (!Util.canBeShop(b))
+ if (!Util.canBeShop(b,null,true))
return; // Interacted with air
Shop shop = plugin.getShopManager().getShop(b.getLocation());
// Make sure they're not using the non-shop half of a double chest.
@@ -93,7 +93,7 @@ public class LockListener implements Listener {
}
Player p = e.getPlayer();
// If the chest was a chest
- if (Util.canBeShop(b)) {
+ if (Util.canBeShop(b,null,true)) {
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return; // Wasn't a shop
diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java
index 8b4160643..264fa5c3e 100644
--- a/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java
+++ b/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java
@@ -50,7 +50,7 @@ public class PlayerListener implements Listener {
public void onClick(PlayerInteractEvent e) {
if (e.getAction().equals(Action.LEFT_CLICK_BLOCK)) {
Block b = e.getClickedBlock();
- if (!Util.canBeShop(b) && b.getType() != Material.WALL_SIGN) {
+ if (!Util.canBeShop(b,null,true) && b.getType() != Material.WALL_SIGN) {
Util.debugLog("No shop block");
return;
}
@@ -105,7 +105,7 @@ public class PlayerListener implements Listener {
}
// Handles creating shops
else if (!e.isCancelled() && shop == null && item != null && item.getType() != Material.AIR
- && p.hasPermission("quickshop.create.sell") && Util.canBeShop(b)
+ && p.hasPermission("quickshop.create.sell") && Util.canBeShop(b,null,true)
&& p.getGameMode() != GameMode.CREATIVE) {
if(e.isCancelled())
return;
diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java
index 56e8204b1..23f28ee3d 100644
--- a/src/main/java/org/maxgamer/quickshop/QuickShop.java
+++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java
@@ -1,6 +1,8 @@
package org.maxgamer.quickshop;
import com.onarandombox.MultiverseCore.MultiverseCore;
+import me.wiefferink.areashop.AreaShop;
+
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
@@ -75,6 +77,8 @@ public class QuickShop extends JavaPlugin {
public boolean priceChangeRequiresFee = false;
/** Whether or not to limit players shop amounts */
public boolean limit = false;
+ /** Only allow create shop in special region */
+ public boolean special_region_only=false;
/** The plugin OpenInv (null if not present) */
public Plugin openInvPlugin;
@@ -83,7 +87,8 @@ public class QuickShop extends JavaPlugin {
public boolean useSpout = false;
// private Metrics metrics;
QS commandExecutor =null;
- MultiverseCore mPlugin = null;
+ public MultiverseCore mPlugin = null;
+ public AreaShop areaShopPlugin = null;
private int displayItemCheckTicks;
private boolean noopDisable;
private boolean setupDBonEnableding = false;
@@ -96,7 +101,6 @@ public class QuickShop extends JavaPlugin {
}
return max;
}
-
@SuppressWarnings("resource")
public void onEnable() {
instance = this;
@@ -113,8 +117,8 @@ public class QuickShop extends JavaPlugin {
getServer().getPluginManager().disablePlugin(this);
return;
}
- if(getServer().getName().toLowerCase().contains("catserver")) {
- //Send FATAL ERROR TO CatServer's users.
+ if (getServer().getName().toLowerCase().contains("catserver")) {
+ // Send FATAL ERROR TO CatServer's users.
getLogger().info("NOTICE: QSRR nolonger support CatServer ALERT!");
getLogger().info("NOTICE: From 1.3.1.9, QSRR already nolonger support CatServer");
getLogger().info("NOTICE: Cause this server have important license issues,");
@@ -159,12 +163,19 @@ public class QuickShop extends JavaPlugin {
return;
}
if (getConfig().getBoolean("plugin.Multiverse-Core")) {
-
if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) {
mPlugin = (MultiverseCore) Bukkit.getPluginManager().getPlugin("Multiverse-Core");
getLogger().info("Successfully loaded MultiverseCore support!");
}
}
+ if (getConfig().getBoolean("plugin.AreaShop")) {
+ if (Bukkit.getPluginManager().getPlugin("AreaShop") != null) {
+ areaShopPlugin = (AreaShop) Bukkit.getPluginManager().getPlugin("AreaShop");
+ AreaShopListener areaShopListener = new AreaShopListener();
+ Bukkit.getPluginManager().registerEvents(areaShopListener, this);
+ getLogger().info("Successfully loaded AreaShop support!");
+ }
+ }
// added for compatibility reasons with OpenInv - see
// https://github.com/KaiKikuchi/QuickShop/issues/139
if (getConfig().getBoolean("plugin.OpenInv")) {
@@ -194,6 +205,22 @@ public class QuickShop extends JavaPlugin {
LockListener ll = new LockListener(this);
getServer().getPluginManager().registerEvents(ll, this);
}
+ // Impossible create shop check.
+ this.special_region_only = getConfig().getBoolean("shop.special-region-only");
+ if (special_region_only) {
+ if (areaShopPlugin == null) {
+ special_region_only=false;
+ getLogger().warning(
+ "WARNING: You enabled Special Region Only but not install AreaShop, we already auto disabled it this time.");
+ getLogger().warning("WARNING: Server will continue load in 15 secs.");
+ try {
+ Thread.sleep(15000);
+ } catch (InterruptedException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
getServer().getPluginManager().registerEvents(new UpdateWatcher(), this);
ConfigurationSection limitCfg = this.getConfig().getConfigurationSection("limits");
if (limitCfg != null) {
@@ -269,7 +296,7 @@ public class QuickShop extends JavaPlugin {
Location loc = new Location(world, x, y, z);
/* Skip invalid shops, if we know of any */
step = "Checking InventoryHolder";
- if (world != null && Util.canBeShop(loc.getBlock()) == false) {
+ if (world != null && Util.canBeShop(loc.getBlock(),null,true) == false) {
step = "Removeing shop in world: Because it not a correct InventoryHolder";
getLogger().info("Shop is not an InventoryHolder in " + rs.getString("world") + " at: " + x
+ ", " + y + ", " + z + ". Deleting.");
@@ -693,6 +720,14 @@ public class QuickShop extends JavaPlugin {
saveConfig();
reloadConfig();
}
+ if (selectedVersion == 13) {
+ getConfig().set("plugin.AreaShop",false);
+ getConfig().set("shop.special-region-only", false);
+ getConfig().set("config-version", 14);
+ selectedVersion = 14;
+ saveConfig();
+ reloadConfig();
+ }
}
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
index 174880c54..07e1a4b62 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
@@ -605,7 +605,6 @@ public class ContainerShop implements Shop {
try {
DatabaseHelper.removeShop(plugin.getDB(), x, y, z, world);
} catch (SQLException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
// Refund if necessary
@@ -620,7 +619,7 @@ public class ContainerShop implements Shop {
public boolean isValid() {
checkDisplay();
- return Util.canBeShop(this.getLocation().getBlock());
+ return Util.canBeShop(this.getLocation().getBlock(),null,true);
}
private void checkDisplay() {
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
index 37a742a3e..640a0539a 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
@@ -349,7 +349,7 @@ public class ShopManager {
// Get the shop they interacted with
Shop shop = plugin.getShopManager().getShop(info.getLocation());
// It's not valid anymore
- if (shop == null || Util.canBeShop(info.getLocation().getBlock()) == false) {
+ if (shop == null || Util.canBeShop(info.getLocation().getBlock(),null,true) == false) {
p.sendMessage(MsgUtil.getMessage("chest-was-removed"));
return;
}
@@ -439,7 +439,7 @@ public class ShopManager {
private void actionSell(Player p, HashMap actions2, Info info, String message, Shop shop2, int amount) {
Shop shop = plugin.getShopManager().getShop(info.getLocation());
// It's not valid anymore
- if (shop == null || Util.canBeShop(info.getLocation().getBlock()) == false) {
+ if (shop == null || Util.canBeShop(info.getLocation().getBlock(),null,true) == false) {
p.sendMessage(MsgUtil.getMessage("chest-was-removed"));
return;
}
@@ -539,7 +539,7 @@ public class ShopManager {
p.sendMessage(MsgUtil.getMessage("no-double-chests"));
return;
}
- if (Util.canBeShop(info.getLocation().getBlock()) == false) {
+ if (Util.canBeShop(info.getLocation().getBlock(),null,true) == false) {
p.sendMessage(MsgUtil.getMessage("chest-was-removed"));
return;
}
diff --git a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java
index f4ee46b82..95bc99173 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/MsgUtil.java
@@ -467,7 +467,7 @@ public class MsgUtil {
* on space.
*/
public static void clean() {
- plugin.getLogger().log(Level.WARNING, "Cleaning purchase messages from database that are over a week old...");
+ plugin.getLogger().info("Cleaning purchase messages from database that are over a week old...");
// 604800,000 msec = 1 week.
long weekAgo = System.currentTimeMillis() - 604800000;
DatabaseHelper.cleanMessage(weekAgo);
diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java
index 893582c8c..a2a430069 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/Util.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java
@@ -27,6 +27,9 @@ import org.bukkit.potion.PotionEffect;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Shop.DisplayItem;
import org.maxgamer.quickshop.Shop.Shop;
+
+import me.wiefferink.areashop.regions.RentRegion;
+
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -132,11 +135,23 @@ public class Util {
/**
* Returns true if the given block could be used to make a shop out of.
*
- * @param b
- * The block to check. Possibly a chest, dispenser, etc.
+ * @param b The block to check, Possibly a chest, dispenser, etc. player The player, can be null if onlyCheck=true, onlyCheck The option to disable check AreaShop use player.
* @return True if it can be made into a shop, otherwise false.
*/
- public static boolean canBeShop(Block b) {
+ public static boolean canBeShop(Block b,Player player, boolean onlyCheck) {
+ if (plugin.special_region_only&&onlyCheck==false) {
+ List regions = me.wiefferink.areashop.tools.Utils.getImportantRentRegions(b.getLocation());
+ boolean passTheRegionCheck = false;
+ for (RentRegion rentRegion : regions) {
+ if(rentRegion.getOwner()!=player.getUniqueId()) {
+ passTheRegionCheck=true;
+ break; //If there passed, will continue to check BlockState
+ }
+ }
+ if(passTheRegionCheck==false) {
+ return false;
+ }
+ }
BlockState bs = b.getState();
if ((bs instanceof InventoryHolder == false) && b.getState().getType() != Material.ENDER_CHEST) {
return false;
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index f95d7028c..34b3a4b0e 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -1,7 +1,7 @@
#Default config: https://github.com/KaiKikuchi/QuickShop/blob/master/src/main/resources/config.yml
#Do not touch if you not clear know about this
-config-version: 13
+config-version: 14
#Do not touch if you not know what is this
dev-mode: false
@@ -116,36 +116,15 @@ shop:
#Ignore trade messages if shop is unlimited
ignore-unlimited-shop-messages: false
+ #Enable this if you only want player create the shop in special region
+ #When you enable this, you only can create shop in AreaShop's area or have "allow-qs-shop" flags WorldGuard region.
+ special-region-only: false
+
#List of items to disallow selling of. Anyone with quickshop.bypass. can bypass it
blacklist:
- Bedrock
-# custom-potions-name:
- # sign:
- # format: "%variety%type"
- # variety:
- # normal: ""
- # splash: "Splash"
- # lingering: "Ling"
- # shopinfo:
- # format: "%variety %type"
- # variety:
- # normal: ""
- # splash: "Splash"
- # lingering: "Lingering"
-
- # #Custom names for potions types. Format: ;;
- # # PotionType: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionType.html
- # types:
- # - INVISIBILITY;Invis;Invisibility
-
- # #Custom names for potion effect type. Format: ;
- # # PotionEffect: https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html
- # effects:
- # - FIRE_RESISTANCE;Fire resistance
- # - INVISIBILITY;Invisibility
-
protect:
#Protect shop item can or cannot pull out by HopperMincart (Will remove HopprtMincart
minecart: true
@@ -200,4 +179,7 @@ plugin:
#If you have Multiverse-Core, QSRR will try load world when shop's world not exist and throw out exception auto repair the shop.
Multiverse-Core: true
#If you have OpenInv, QSRR will enable EnderChest feature.
- OpenInv: true
\ No newline at end of file
+ OpenInv: true
+ #Enable AreaShop support
+ #Allow QuickShop detect AS unrented event and remove shop from region.
+ AreaShop: false
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 52a00534e..e075bb54c 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -5,7 +5,7 @@ authors: [Netherfoam, Timtower, KaiNoMood, Ghost_chu, Mgazul]
description: Economy Shops plugin
#softdepend: [Herochat, Vault, Essentials, OpenInv] OLD Remove Herochat support.
-softdepend: [Vault, WorldGuard, Essentials, OpenInv, Multiverse-Core]
+softdepend: [Vault, WorldGuard, Essentials, OpenInv, Multiverse-Core, AreaShop]
api-version: 1.13