- Fixed new lines in configs

- Fixed sign protection
- Doesn't protect with LWC if the limit is reached
- Added a message when you paid for shop.
This commit is contained in:
Acrobot 2011-08-31 20:57:10 +02:00
parent 0418629062
commit fac79282df
7 changed files with 28 additions and 12 deletions

View File

@ -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);
}
}
}

View File

@ -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());
}

View File

@ -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;

View File

@ -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];

View File

@ -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;
}

View File

@ -11,6 +11,7 @@ import org.bukkit.plugin.Plugin;
* @copyright (c) 2011
* @license AOL license <http://aol.nexua.org>
*/
@SuppressWarnings({"deprecation"})
public class BOSE6 implements Method {
private BOSEconomy BOSEconomy;

View File

@ -2,7 +2,7 @@ name: ChestShop
main: com.Acrobot.ChestShop.ChestShop
version: 3.02
version: 3.03
author: Acrobot