2011-05-15 19:33:03 +02:00
|
|
|
package com.Acrobot.ChestShop.Listeners;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2012-01-09 22:39:38 +01:00
|
|
|
import com.Acrobot.ChestShop.Config.Config;
|
|
|
|
import com.Acrobot.ChestShop.Config.Language;
|
|
|
|
import com.Acrobot.ChestShop.Protection.Security;
|
|
|
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
2011-07-05 19:08:55 +02:00
|
|
|
import com.Acrobot.ChestShop.Utils.uSign;
|
2012-01-09 22:39:38 +01:00
|
|
|
import org.bukkit.Material;
|
2011-05-15 18:16:25 +02:00
|
|
|
import org.bukkit.block.Block;
|
2012-01-09 22:39:38 +01:00
|
|
|
import org.bukkit.block.Chest;
|
2011-05-15 18:16:25 +02:00
|
|
|
import org.bukkit.block.Sign;
|
2012-02-16 19:09:37 +01:00
|
|
|
import org.bukkit.event.EventHandler;
|
|
|
|
import org.bukkit.event.Listener;
|
2011-05-15 18:16:25 +02:00
|
|
|
import org.bukkit.event.block.BlockPlaceEvent;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
2012-02-16 19:09:37 +01:00
|
|
|
public class blockPlace implements Listener {
|
|
|
|
@EventHandler
|
|
|
|
public static void onBlockPlace(BlockPlaceEvent event) {
|
2011-05-15 18:16:25 +02:00
|
|
|
Block block = event.getBlockAgainst();
|
2011-07-05 19:08:55 +02:00
|
|
|
if (uSign.isSign(block) && uSign.isValid((Sign) block.getState())) {
|
2011-05-15 18:16:25 +02:00
|
|
|
event.setCancelled(true);
|
2012-01-09 22:39:38 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Block placed = event.getBlockPlaced();
|
2012-03-17 15:00:25 +01:00
|
|
|
if (placed.getType() == Material.CHEST) {
|
2012-01-09 22:39:38 +01:00
|
|
|
Chest neighbor = uBlock.findNeighbor(placed);
|
|
|
|
if (neighbor == null) return;
|
|
|
|
|
|
|
|
Block neighborBlock = neighbor.getBlock();
|
2012-03-17 15:00:25 +01:00
|
|
|
if (Security.isProtected(neighborBlock) && !Security.canAccess(event.getPlayer(), neighborBlock)) {
|
2012-01-09 22:39:38 +01:00
|
|
|
event.getPlayer().sendMessage(Config.getLocal(Language.ACCESS_DENIED));
|
|
|
|
event.setCancelled(true);
|
|
|
|
}
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|