Java Code Examples for org.bukkit.Material#SOIL

The following examples show how to use org.bukkit.Material#SOIL . 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: EntityListener.java    From BedwarsRel with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler
public void onEntityInteract(EntityInteractEvent event) {
  if (!(event.getEntity() instanceof Player)) {
    return;
  }

  if (event.getBlock().getType() != Material.SOIL
      && event.getBlock().getType() != Material.WHEAT) {
    return;
  }

  Player player = (Player) event.getEntity();
  Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player);

  if (game == null) {
    return;
  }

  if (game.getState() == GameState.WAITING) {
    event.setCancelled(true);
  }
}
 
Example 2
Source File: ServerListener.java    From ZombieEscape with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This is specific to my test server to prevent Crop trample.
 */
@EventHandler
public void onTrample(PlayerInteractEvent e) {
    if (e.getClickedBlock() == null) {
        return;
    }

    if (e.getAction() == Action.PHYSICAL) {
        Block block = e.getClickedBlock();

        Material material = block.getType();

        if (material == Material.CROPS || material == Material.SOIL) {
            e.setUseInteractedBlock(PlayerInteractEvent.Result.DENY);
            e.setCancelled(true);

            block.setType(material);
            block.setData(block.getData());
        }
    }
}
 
Example 3
Source File: WrappedBlock8.java    From Hawk with GNU General Public License v3.0 5 votes vote down vote up
private boolean isReallySolid(Block b) {
    boolean reallySolid = block.getMaterial().isSolid();
    MaterialData matData = b.getState().getData();
    if (matData instanceof Sign || matData instanceof Banner)
        reallySolid = false;
    else if (matData instanceof FlowerPot || matData instanceof Diode || matData instanceof Skull ||
            b.getType() == Material.CARPET || matData instanceof Ladder ||
            b.getType() == Material.REDSTONE_COMPARATOR || b.getType() == Material.REDSTONE_COMPARATOR_ON ||
            b.getType() == Material.REDSTONE_COMPARATOR_OFF || b.getType() == Material.SOIL ||
            b.getType() == Material.WATER_LILY || b.getType() == Material.SNOW || b.getType() == Material.COCOA) {
        reallySolid = true;
    }
    return reallySolid;
}