ChestShop-3/com/Acrobot/ChestShop/Listeners/blockPlace.java
Acrobot d6bdb0486a - Fixed chests in 1.2.3
- Formatting
- Warning about old Bukkit version
- Renamed "TOWNY_CANNOT_CREATE_SHOP_HERE" to "CANNOT_CREATE_SHOP_HERE" to avoid confusion
- Renamed "NOT_ENOUGH_LWC_PROTECTIONS" to "NOT_ENOUGH_PROTECTIONS" and changed its message

- Fixed armour enchantments
- Logging shop location
- Fixed Heroes for the newest version
- Removed redutant plugin object
- Added dev-url for CraftBukkitUpToDate
- Removed redutant plugins from softdepend
- Fixed a bug when the player interacts with a shop with a sign in hand
2012-03-17 15:00:25 +01:00

41 lines
1.3 KiB
Java

package com.Acrobot.ChestShop.Listeners;
import com.Acrobot.ChestShop.Config.Config;
import com.Acrobot.ChestShop.Config.Language;
import com.Acrobot.ChestShop.Protection.Security;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uSign;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.block.Sign;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent;
/**
* @author Acrobot
*/
public class blockPlace implements Listener {
@EventHandler
public static void onBlockPlace(BlockPlaceEvent event) {
Block block = event.getBlockAgainst();
if (uSign.isSign(block) && uSign.isValid((Sign) block.getState())) {
event.setCancelled(true);
return;
}
Block placed = event.getBlockPlaced();
if (placed.getType() == Material.CHEST) {
Chest neighbor = uBlock.findNeighbor(placed);
if (neighbor == null) return;
Block neighborBlock = neighbor.getBlock();
if (Security.isProtected(neighborBlock) && !Security.canAccess(event.getPlayer(), neighborBlock)) {
event.getPlayer().sendMessage(Config.getLocal(Language.ACCESS_DENIED));
event.setCancelled(true);
}
}
}
}