diff --git a/com/Acrobot/ChestShop/Config/Config.java b/com/Acrobot/ChestShop/Config/Config.java index 0292953..fb23109 100644 --- a/com/Acrobot/ChestShop/Config/Config.java +++ b/com/Acrobot/ChestShop/Config/Config.java @@ -32,7 +32,7 @@ public class Config { config.load(); for (Property def : Property.values()) { if (config.getProperty(def.name()) == null) { - writeToFile(def.name() + ": " + def.getValue() + "\n#" + def.getComment(), configFile); + writeToFile('\n' + def.name() + ": " + def.getValue() + "\n#" + def.getComment(), configFile); } } } @@ -41,7 +41,7 @@ public class Config { language.load(); for (Language def : Language.values()) { if (language.getProperty(def.name()) == null) { - writeToFile(def.name() + ": \"" + def.toString() + '\"', langFile); + writeToFile('\n' + def.name() + ": \"" + def.toString() + '\"', langFile); } } } diff --git a/com/Acrobot/ChestShop/Listeners/blockBreak.java b/com/Acrobot/ChestShop/Listeners/blockBreak.java index a48ca05..a78eaa1 100644 --- a/com/Acrobot/ChestShop/Listeners/blockBreak.java +++ b/com/Acrobot/ChestShop/Listeners/blockBreak.java @@ -17,21 +17,25 @@ import org.bukkit.event.block.BlockPistonRetractEvent; */ public class blockBreak extends BlockListener { public static boolean cancellingBlockBreak(Block block, Player player) { - if (player != null && Permission.has(player, Permission.ADMIN)) return false; + if (player != null && (Permission.has(player, Permission.ADMIN) || Permission.has(player, Permission.MOD))) return false; if (uSign.isSign(block)) block.getState().update(); Sign sign = uBlock.findRestrictedSign(block); - if (sign != null && getAttachedFace(sign) == block) return true; + if (sign != null && isCorrectSign(sign, block)) return true; sign = uBlock.findSign(block); - return sign != null && getAttachedFace(sign) == block && playerIsNotOwner(player, sign); + return sign != null && (isCorrectSign(sign, block) && playerIsNotOwner(player, sign)); } public void onBlockBreak(BlockBreakEvent event) { if (cancellingBlockBreak(event.getBlock(), event.getPlayer())) event.setCancelled(true); } + private static boolean isCorrectSign(Sign sign, Block block){ + return sign.getBlock() == block || getAttachedFace(sign) == block; + } + private static Block getAttachedFace(Sign sign){ return sign.getBlock().getRelative(((org.bukkit.material.Sign) sign.getData()).getAttachedFace()); } diff --git a/com/Acrobot/ChestShop/Listeners/pluginEnable.java b/com/Acrobot/ChestShop/Listeners/pluginEnable.java index 1a6675c..c077c44 100644 --- a/com/Acrobot/ChestShop/Listeners/pluginEnable.java +++ b/com/Acrobot/ChestShop/Listeners/pluginEnable.java @@ -65,7 +65,7 @@ public class pluginEnable extends ServerListener { Permission.permissions = ((Permissions) plugin).getHandler(); } else if (name.equals("LWC")) { if (LWCplugin.lwc != null) return; - LWCplugin.lwc = ((LWCPlugin) plugin).getLWC(); + LWCplugin.setLWC(((LWCPlugin) plugin).getLWC()); Security.protection = new LWCplugin(); } else if (name.equals("Lockette")) { if (LockettePlugin.lockette != null) return; diff --git a/com/Acrobot/ChestShop/Listeners/signChange.java b/com/Acrobot/ChestShop/Listeners/signChange.java index 79c53f9..32726ad 100644 --- a/com/Acrobot/ChestShop/Listeners/signChange.java +++ b/com/Acrobot/ChestShop/Listeners/signChange.java @@ -109,8 +109,9 @@ public class signChange extends BlockListener { } float shopCreationPrice = Config.getFloat(Property.SHOP_CREATION_PRICE); - if(shopCreationPrice != 0 && !isAdminShop){ - if(!Economy.hasEnough(player.getName(), shopCreationPrice)){ + boolean paid = shopCreationPrice != 0 && !isAdminShop; + if (paid) { + if (!Economy.hasEnough(player.getName(), shopCreationPrice)) { player.sendMessage(Config.getLocal(Language.NOT_ENOUGH_MONEY)); dropSign(event); return; @@ -127,7 +128,7 @@ public class signChange extends BlockListener { } uLongName.saveName(player.getName()); - player.sendMessage(Config.getLocal(Language.SHOP_CREATED)); + player.sendMessage(Config.getLocal(Language.SHOP_CREATED) + (paid ? " - " + Economy.formatBalance(shopCreationPrice) : "")); } private static boolean canCreateShop(Player player, boolean isAdmin, int ID) { @@ -149,11 +150,11 @@ public class signChange extends BlockListener { return (thirdLine.length() > 15 ? null : thirdLine); } - private static String formatFourthLine(String fourthLine, Material material){ + private static String formatFourthLine(String fourthLine, Material material) { String[] split = fourthLine.split(":"); if (uNumber.isInteger(split[0])) { String materialLine = material.name(); - if (split.length == 2) { + if (split.length == 2) { int maxLength = (14 - split[1].length()); //15 - length - 1 if (materialLine.length() > maxLength) materialLine = materialLine.substring(0, maxLength); materialLine = materialLine + ':' + split[1]; diff --git a/com/Acrobot/ChestShop/Protection/LWCplugin.java b/com/Acrobot/ChestShop/Protection/LWCplugin.java index bc9299b..52d31f5 100644 --- a/com/Acrobot/ChestShop/Protection/LWCplugin.java +++ b/com/Acrobot/ChestShop/Protection/LWCplugin.java @@ -1,7 +1,10 @@ package com.Acrobot.ChestShop.Protection; +import com.Acrobot.ChestShop.ChestShop; import com.griefcraft.lwc.LWC; import com.griefcraft.model.ProtectionTypes; +import com.griefcraft.modules.limits.LimitsModule; +import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -10,8 +13,13 @@ import org.bukkit.entity.Player; */ public class LWCplugin implements Protection { public static LWC lwc; + private static LimitsModule limitsModule; + public static void setLWC(LWC LWC){ + lwc = LWC; + limitsModule = new LimitsModule(); + } public boolean isProtected(Block block) { return lwc.findProtection(block) != null; } @@ -22,6 +30,8 @@ public class LWCplugin implements Protection { public boolean protect(String name, Block block) { if (lwc.findProtection(block) != null) return false; + Player player = ChestShop.getBukkitServer().getPlayer(name); + if (player != null && lwc.getPhysicalDatabase().getProtectionCount(name) >= limitsModule.mapProtectionLimit(player, block.getTypeId())) return false; lwc.getPhysicalDatabase().registerProtection(block.getTypeId(), ProtectionTypes.PRIVATE, block.getWorld().getName(), name, "", block.getX(), block.getY(), block.getZ()); return true; } diff --git a/com/nijikokun/register/payment/forChestShop/methods/BOSE6.java b/com/nijikokun/register/payment/forChestShop/methods/BOSE6.java index 2667ddf..3be44e4 100644 --- a/com/nijikokun/register/payment/forChestShop/methods/BOSE6.java +++ b/com/nijikokun/register/payment/forChestShop/methods/BOSE6.java @@ -11,6 +11,7 @@ import org.bukkit.plugin.Plugin; * @copyright (c) 2011 * @license AOL license */ +@SuppressWarnings({"deprecation"}) public class BOSE6 implements Method { private BOSEconomy BOSEconomy; diff --git a/plugin.yml b/plugin.yml index 9d34da5..20c9109 100644 --- a/plugin.yml +++ b/plugin.yml @@ -2,7 +2,7 @@ name: ChestShop main: com.Acrobot.ChestShop.ChestShop -version: 3.02 +version: 3.03 author: Acrobot