diff --git a/pom.xml b/pom.xml
index ff1f8b6c0..0bc18e4a4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -4,7 +4,7 @@
4.0.0
org.maxgamer
QuickShop
- Reremake 1.3.1
+ Reremake 1.3.1.1_snapshot
diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java
index 8ef61d0a0..293b45ccb 100644
--- a/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java
+++ b/src/main/java/org/maxgamer/quickshop/Listeners/BlockListener.java
@@ -24,7 +24,6 @@ import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.inventory.InventoryMoveItemEvent;
import org.bukkit.event.world.StructureGrowEvent;
-import org.bukkit.inventory.InventoryHolder;
import org.maxgamer.quickshop.QuickShop;
import org.maxgamer.quickshop.Shop.Info;
import org.maxgamer.quickshop.Shop.Shop;
@@ -74,7 +73,7 @@ public class BlockListener implements Listener {
}
Player p = e.getPlayer();
// If the shop was a chest
- if (b.getState() instanceof InventoryHolder) {
+ if (Util.canBeShop(b)) {
Shop shop = plugin.getShopManager().getShop(b.getLocation());
if (shop == null)
return;
diff --git a/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java b/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java
index c3319cad8..f86e86410 100644
--- a/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java
+++ b/src/main/java/org/maxgamer/quickshop/Listeners/PlayerListener.java
@@ -110,6 +110,7 @@ public class PlayerListener implements Listener {
// As of the new checking system, most plugins will tell the
// player why they can't create a shop there.
// So telling them a message would cause spam etc.
+ Util.debugLog("Can't be shop");
return;
}
if (Util.getSecondHalf(b) != null && !p.hasPermission("quickshop.create.double")) {
@@ -121,6 +122,17 @@ public class PlayerListener implements Listener {
p.sendMessage(MsgUtil.getMessage("blacklisted-item"));
return;
}
+ if (b.getType()==Material.ENDER_CHEST) {
+ if(!plugin.getConfig().getBoolean("shop.enable-enderchest")) {
+ Util.debugLog("Not enabled");
+ return;
+ }
+ if(!p.hasPermission("quickshop.create.enderchest")) {
+ Util.debugLog("No permission");
+ Util.debugLog(""+p.hasPermission("quickshop.create.enderchest"));
+ return;
+ }
+ }
// Finds out where the sign should be placed for the shop
Block last = null;
Location from = p.getLocation().clone();
diff --git a/src/main/java/org/maxgamer/quickshop/QuickShop.java b/src/main/java/org/maxgamer/quickshop/QuickShop.java
index 399618a69..d9abf324e 100644
--- a/src/main/java/org/maxgamer/quickshop/QuickShop.java
+++ b/src/main/java/org/maxgamer/quickshop/QuickShop.java
@@ -11,7 +11,6 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import org.bukkit.*;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
@@ -358,7 +357,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 && (loc.getBlock().getState() instanceof InventoryHolder) == false) {
+ if (world != null && Util.canBeShop(loc.getBlock()) == 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.");
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
index 6312d1177..f4161e1f2 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/ContainerShop.java
@@ -221,6 +221,13 @@ public class ContainerShop implements Shop {
* @return The chest this shop is based on.
*/
public Inventory getInventory() throws IllegalStateException {
+ try {
+ if(loc.getBlock().getType()==Material.ENDER_CHEST) {
+ return Bukkit.getPlayer(owner).getEnderChest();
+ }
+ }catch(Exception e){
+ throw new IllegalStateException("Player enderchest inventory is null: "+this);
+ }
InventoryHolder container;
try {
container = (InventoryHolder) this.loc.getBlock().getState();
diff --git a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
index ba7911e4f..7cdbc27b6 100644
--- a/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
+++ b/src/main/java/org/maxgamer/quickshop/Shop/ShopManager.java
@@ -558,9 +558,10 @@ public class ShopManager {
}
private void actionCreate(Player p, HashMap actions2, Info info, String message) {
- // TODO Auto-generated method stub
+ Util.debugLog("actionCreate");
try {
// Checking the shop can be created
+ Util.debugLog("calling for protection check...");
BlockBreakEvent be = new BlockBreakEvent(info.getLocation().getBlock(), p);
Bukkit.getPluginManager().callEvent(be);
if (be.isCancelled()) {
@@ -580,6 +581,12 @@ public class ShopManager {
p.sendMessage(MsgUtil.getMessage("chest-was-removed"));
return;
}
+ if (info.getLocation().getWorld().getBlockAt(info.getLocation()).getType()==Material.ENDER_CHEST) {
+ if(!plugin.getConfig().getBoolean("shop.enable-enderchest"))
+ return;
+ if(!p.hasPermission("quickshop.create.enderchest"))
+ return;
+ }
// Price per item
double price;
if (plugin.getConfig().getBoolean("whole-number-prices-only")) {
diff --git a/src/main/java/org/maxgamer/quickshop/Util/Util.java b/src/main/java/org/maxgamer/quickshop/Util/Util.java
index 7e9f901ab..2101987a0 100644
--- a/src/main/java/org/maxgamer/quickshop/Util/Util.java
+++ b/src/main/java/org/maxgamer/quickshop/Util/Util.java
@@ -142,8 +142,11 @@ public class Util {
*/
public static boolean canBeShop(Block b) {
BlockState bs = b.getState();
- if (bs instanceof InventoryHolder == false)
+ if ((bs instanceof InventoryHolder == false)&&b.getType()!=Material.ENDER_CHEST)
return false;
+ if(!shoppables.contains(bs.getType()))
+ if(b.getType()==Material.ENDER_CHEST)
+ return true;
return shoppables.contains(bs.getType());
}
diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml
index 374021b82..c94097e26 100644
--- a/src/main/resources/config.yml
+++ b/src/main/resources/config.yml
@@ -123,6 +123,9 @@ shop:
#Ignore trade messages if shop is unlimited
ignore-unlimited-shop-messages: false
+
+ #Enable enderchest shop feature
+ enable-enderchest: true
#List of items to disallow selling of. Anyone with quickshop.bypass. can bypass it
blacklist:
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index b775d2a38..4eb2897b9 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -25,6 +25,9 @@ permissions:
quickshop.create.double:
description: Allows a player to create a double shop
default: op
+ quickshop.create.enderchest:
+ description: Allows a player to create a enderchest shop
+ default: op
quickshop.use:
description: Allows a player to buy/sell using other players shops
default: true