mirror of
https://github.com/EarthMC/QuickShop-Reremake.git
synced 2026-11-25 01:49:49 -05:00
EnderChest Feature
Former-commit-id: 2bed13a81ca9764060be38251a4d9a2f56d4d4e1 [formerly f5376a93fde063ddb0eb13607bd927537479e989] Former-commit-id: 389b4965899fb1025b2966e7c05e092b7c23cd5e
This commit is contained in:
1 parent
600faf7aaf
commit
751151c787
9 files changed
+40
-7
No files matched your search
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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.");
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -558,9 +558,10 @@ public class ShopManager {
|
||||
}
|
||||
|
||||
private void actionCreate(Player p, HashMap<UUID, Info> 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")) {
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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.<itemID> can bypass it
|
||||
blacklist:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user