mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-28 22:47:46 +02:00
- Fixed protections
This commit is contained in:
parent
e522b33d9d
commit
0bde74f3ad
@ -1,7 +1,7 @@
|
|||||||
package com.Acrobot.ChestShop.Chests;
|
package com.Acrobot.ChestShop.Chests;
|
||||||
|
|
||||||
import com.Acrobot.ChestShop.Utils.InventoryUtil;
|
|
||||||
import com.Acrobot.ChestShop.Utils.BlockSearch;
|
import com.Acrobot.ChestShop.Utils.BlockSearch;
|
||||||
|
import com.Acrobot.ChestShop.Utils.InventoryUtil;
|
||||||
import org.bukkit.block.Chest;
|
import org.bukkit.block.Chest;
|
||||||
import org.bukkit.inventory.Inventory;
|
import org.bukkit.inventory.Inventory;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -13,7 +13,7 @@ public enum Property {
|
|||||||
GENERATE_STATISTICS_PAGE(false, "If true, plugin will generate shop statistics webpage."),
|
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?"),
|
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?"),
|
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_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?");
|
PROTECT_SIGN_WITH_LWC(false, "Do you want to protect shop signs with LWC?");
|
||||||
|
|
||||||
|
@ -44,8 +44,8 @@ public class playerInteract extends PlayerListener {
|
|||||||
Block block = event.getClickedBlock();
|
Block block = event.getClickedBlock();
|
||||||
|
|
||||||
if (Config.getBoolean(Property.USE_BUILT_IN_PROTECTION) && block.getType() == Material.CHEST) {
|
if (Config.getBoolean(Property.USE_BUILT_IN_PROTECTION) && block.getType() == Material.CHEST) {
|
||||||
Default defProtection = new Default();
|
Default protection = new Default();
|
||||||
if (!Permission.has(player, Permission.ADMIN) && !Permission.has(player, Permission.MOD) && (defProtection.isProtected(block) && !defProtection.canAccess(player, block))) {
|
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));
|
player.sendMessage(Config.getLocal(Language.ACCESS_DENIED));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
|
@ -56,8 +56,7 @@ public class signChange extends BlockListener {
|
|||||||
if (!(playerIsAdmin ||
|
if (!(playerIsAdmin ||
|
||||||
Permission.has(player, Permission.SHOP_CREATION) ||
|
Permission.has(player, Permission.SHOP_CREATION) ||
|
||||||
(Permission.has(player, Permission.SHOP_CREATION + "." + mat.getId()) &&
|
(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));
|
player.sendMessage(Config.getLocal(Language.YOU_CANNOT_CREATE_SHOP));
|
||||||
dropSign(event);
|
dropSign(event);
|
||||||
@ -121,26 +120,33 @@ public class signChange extends BlockListener {
|
|||||||
dropSign(event);
|
dropSign(event);
|
||||||
return;
|
return;
|
||||||
} else if (!playerIsAdmin) {
|
} else if (!playerIsAdmin) {
|
||||||
boolean canPlaceSign = Security.canPlaceSign(player, signBlock);
|
if (!Security.canPlaceSign(player, signBlock)) {
|
||||||
|
|
||||||
if (!canPlaceSign) {
|
|
||||||
player.sendMessage(Config.getLocal(Language.ANOTHER_SHOP_DETECTED));
|
player.sendMessage(Config.getLocal(Language.ANOTHER_SHOP_DETECTED));
|
||||||
dropSign(event);
|
dropSign(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Default protection = new Default();
|
boolean canAccess = true;
|
||||||
Block chestBlock = chest.getBlock();
|
Block chestBlock = chest.getBlock();
|
||||||
|
|
||||||
if(Security.isProtected(chestBlock) || protection.isProtected(chestBlock)){
|
if (Security.isProtected(chestBlock) && !Security.canAccess(player, chestBlock)) {
|
||||||
if(!Security.canAccess(player, chestBlock) || !protection.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));
|
player.sendMessage(Config.getLocal(Language.CANNOT_ACCESS_THE_CHEST));
|
||||||
dropSign(event);
|
dropSign(event);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Config.getBoolean(Property.PROTECT_CHEST_WITH_LWC) && chest != null && Security.protect(player.getName(), chest.getBlock())) {
|
if (Config.getBoolean(Property.PROTECT_CHEST_WITH_LWC) && chest != null && Security.protect(player.getName(), chest.getBlock())) {
|
||||||
if (Config.getBoolean(Property.PROTECT_SIGN_WITH_LWC)) {
|
if (Config.getBoolean(Property.PROTECT_SIGN_WITH_LWC)) {
|
||||||
|
@ -87,7 +87,6 @@ public class InventoryUtil {
|
|||||||
if (!inv.contains(item.getType())) {
|
if (!inv.contains(item.getType())) {
|
||||||
return amount;
|
return amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
ItemStack[] contents = inv.getContents();
|
ItemStack[] contents = inv.getContents();
|
||||||
for (ItemStack i : contents) {
|
for (ItemStack i : contents) {
|
||||||
if (i != null) {
|
if (i != null) {
|
||||||
|
@ -3,7 +3,7 @@ name: ChestShop
|
|||||||
main: com.Acrobot.ChestShop.ChestShop
|
main: com.Acrobot.ChestShop.ChestShop
|
||||||
|
|
||||||
database: true
|
database: true
|
||||||
version: 3.00 BETA 6
|
version: 3.00 BETA 7
|
||||||
|
|
||||||
|
|
||||||
author: Acrobot
|
author: Acrobot
|
||||||
|
Loading…
Reference in New Issue
Block a user