Java Code Examples for org.bukkit.Material#DETECTOR_RAIL

The following examples show how to use org.bukkit.Material#DETECTOR_RAIL . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChestProtectListener.java    From Shopkeepers with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
void onBlockPlace(BlockPlaceEvent event) {
	Block block = event.getBlock();
	Material type = block.getType();
	Player player = event.getPlayer();
	if (Utils.isChest(type)) {
		if (plugin.getProtectedChests().isChestProtected(block, player)) {
			Log.debug("Cancelled placing of chest block by '" + player.getName() + "' at '"
					+ Utils.getLocationString(block) + "': Protected chest nearby");
			event.setCancelled(true);
		}
	} else if (type == Material.HOPPER) {
		if (plugin.getProtectedChests().isProtectedChestAroundHopper(block, player)) {
			Log.debug("Cancelled placing of hopper block by '" + player.getName() + "' at '"
					+ Utils.getLocationString(block) + "': Protected chest nearby");
			event.setCancelled(true);
		}
	} else if (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL || type == Material.ACTIVATOR_RAIL) {
		Block upperBlock = block.getRelative(BlockFace.UP);
		if (Utils.isChest(upperBlock.getType()) && plugin.getProtectedChests().isChestProtected(upperBlock, player)) {
			Log.debug("Cancelled placing of rail block by '" + player.getName() + "' at '"
					+ Utils.getLocationString(block) + "': Protected chest nearby");
			event.setCancelled(true);
			return;
		}
	}
}
 
Example 2
Source File: DetectorRail.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public DetectorRail() {
    super(Material.DETECTOR_RAIL);
}
 
Example 3
Source File: MenuItemFactory.java    From uSkyBlock with GNU General Public License v3.0 4 votes vote down vote up
public ItemStack createIntegerIcon(int value, boolean readonly) {
    return Math.abs(value) <= MAX_INT_VALUE
            ? (readonly ? new ItemStack(Material.DETECTOR_RAIL, value) : new ItemStack(Material.RAIL, value))
            : (readonly ? new ItemStack(Material.IRON_BARS, 1, (short)1) : new ItemStack(Material.ACTIVATOR_RAIL, 1));
}