- Fixed protections

This commit is contained in:
Acrobot 2011-07-02 20:34:14 +02:00
parent e522b33d9d
commit 0bde74f3ad
18 changed files with 72 additions and 67 deletions

View File

@ -1,7 +1,7 @@
package com.Acrobot.ChestShop.Chests;
import com.Acrobot.ChestShop.Utils.InventoryUtil;
import com.Acrobot.ChestShop.Utils.BlockSearch;
import com.Acrobot.ChestShop.Utils.InventoryUtil;
import org.bukkit.block.Chest;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;

View File

@ -13,7 +13,7 @@ public enum Property {
GENERATE_STATISTICS_PAGE(false, "If true, plugin will generate shop statistics webpage."),
STATISTICS_PAGE_PATH("plugins/ChestShop/website.html", "Where should your generated website be saved?"),
RECORD_TIME_TO_LIVE(600, "How long should transaction information be stored?"),
USE_BUILT_IN_PROTECTION(true, "Do you want to use built-in protection?"),
USE_BUILT_IN_PROTECTION(true, "Do you want to use built-in protection against chest destruction?"),
PROTECT_CHEST_WITH_LWC(false, "Do you want to protect shop chests with LWC?"),
PROTECT_SIGN_WITH_LWC(false, "Do you want to protect shop signs with LWC?");

View File

@ -44,8 +44,8 @@ public class playerInteract extends PlayerListener {
Block block = event.getClickedBlock();
if (Config.getBoolean(Property.USE_BUILT_IN_PROTECTION) && block.getType() == Material.CHEST) {
Default defProtection = new Default();
if (!Permission.has(player, Permission.ADMIN) && !Permission.has(player, Permission.MOD) && (defProtection.isProtected(block) && !defProtection.canAccess(player, block))) {
Default protection = new Default();
if (!Permission.has(player, Permission.ADMIN) && !Permission.has(player, Permission.MOD) && (protection.isProtected(block) && !protection.canAccess(player, block))) {
player.sendMessage(Config.getLocal(Language.ACCESS_DENIED));
event.setCancelled(true);
return;

View File

@ -56,8 +56,7 @@ public class signChange extends BlockListener {
if (!(playerIsAdmin ||
Permission.has(player, Permission.SHOP_CREATION) ||
(Permission.has(player, Permission.SHOP_CREATION + "." + mat.getId()) &&
!Permission.has(player, Permission.EXCLUDE_ITEM + "." + mat.getId()))))
{
!Permission.has(player, Permission.EXCLUDE_ITEM + "." + mat.getId())))) {
player.sendMessage(Config.getLocal(Language.YOU_CANNOT_CREATE_SHOP));
dropSign(event);
@ -121,26 +120,33 @@ public class signChange extends BlockListener {
dropSign(event);
return;
} else if (!playerIsAdmin) {
boolean canPlaceSign = Security.canPlaceSign(player, signBlock);
if (!canPlaceSign) {
if (!Security.canPlaceSign(player, signBlock)) {
player.sendMessage(Config.getLocal(Language.ANOTHER_SHOP_DETECTED));
dropSign(event);
return;
}
Default protection = new Default();
boolean canAccess = true;
Block chestBlock = chest.getBlock();
if(Security.isProtected(chestBlock) || protection.isProtected(chestBlock)){
if(!Security.canAccess(player, chestBlock) || !protection.canAccess(player, chestBlock)){
if (Security.isProtected(chestBlock) && !Security.canAccess(player, chestBlock)) {
canAccess = false;
}
if (!(Security.protection instanceof Default)) {
Default protection = new Default();
if (protection.isProtected(chestBlock) && !protection.canAccess(player, chestBlock)) {
canAccess = false;
}
}
if (!canAccess) {
player.sendMessage(Config.getLocal(Language.CANNOT_ACCESS_THE_CHEST));
dropSign(event);
return;
}
}
}
}
if (Config.getBoolean(Property.PROTECT_CHEST_WITH_LWC) && chest != null && Security.protect(player.getName(), chest.getBlock())) {
if (Config.getBoolean(Property.PROTECT_SIGN_WITH_LWC)) {

View File

@ -87,7 +87,6 @@ public class InventoryUtil {
if (!inv.contains(item.getType())) {
return amount;
}
ItemStack[] contents = inv.getContents();
for (ItemStack i : contents) {
if (i != null) {

View File

@ -3,7 +3,7 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
database: true
version: 3.00 BETA 6
version: 3.00 BETA 7
author: Acrobot