2011-09-01 18:59:15 +02:00
|
|
|
package com.Acrobot.ChestShop.Protection.Plugins;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2011-08-31 20:57:10 +02:00
|
|
|
import com.Acrobot.ChestShop.ChestShop;
|
2011-09-01 18:59:15 +02:00
|
|
|
import com.Acrobot.ChestShop.Protection.Protection;
|
2011-05-15 18:16:25 +02:00
|
|
|
import com.griefcraft.lwc.LWC;
|
2011-08-31 20:57:10 +02:00
|
|
|
import com.griefcraft.modules.limits.LimitsModule;
|
2011-05-15 18:16:25 +02:00
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
2011-05-29 13:25:25 +02:00
|
|
|
public class LWCplugin implements Protection {
|
2011-05-15 18:16:25 +02:00
|
|
|
public static LWC lwc;
|
2011-08-31 20:57:10 +02:00
|
|
|
private static LimitsModule limitsModule;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
|
|
|
|
2011-09-01 18:59:15 +02:00
|
|
|
public static void setLWC(LWC LWC) {
|
2011-08-31 20:57:10 +02:00
|
|
|
lwc = LWC;
|
|
|
|
limitsModule = new LimitsModule();
|
|
|
|
}
|
2011-09-01 18:59:15 +02:00
|
|
|
|
2011-05-15 18:16:25 +02:00
|
|
|
public boolean isProtected(Block block) {
|
|
|
|
return lwc.findProtection(block) != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canAccess(Player player, Block block) {
|
2012-01-09 22:39:38 +01:00
|
|
|
return lwc.findProtection(block) == null || lwc.canAccessProtection(player, block);
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean protect(String name, Block block) {
|
2011-08-13 12:08:34 +02:00
|
|
|
if (lwc.findProtection(block) != null) return false;
|
2011-08-31 20:57:10 +02:00
|
|
|
Player player = ChestShop.getBukkitServer().getPlayer(name);
|
2012-03-06 19:41:14 +01:00
|
|
|
if (player != null && limitsModule.hasReachedLimit(player, block)) return false;
|
2011-09-01 18:59:15 +02:00
|
|
|
|
2012-03-06 19:41:14 +01:00
|
|
|
lwc.getPhysicalDatabase().registerProtection(block.getTypeId(), com.griefcraft.model.Protection.Type.PUBLIC, block.getWorld().getName(), name, "", block.getX(), block.getY(), block.getZ());
|
2011-05-15 18:16:25 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|