mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-07-20 10:04:56 +02:00
- 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
41 lines
1.3 KiB
Java
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);
|
|
}
|
|
}
|
|
}
|
|
}
|