Java Code Examples for org.bukkit.Material#STONE_HOE

The following examples show how to use org.bukkit.Material#STONE_HOE . 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: IslandGuard1_9.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handle blocks that need special treatment
 * Tilling of coarse dirt into dirt using off-hand (regular hand is in 1.8)
 * Usually prevented because it could lead to an endless supply of dirt with gravel
 * 
 * @param e - event
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!IslandGuard.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getInventory().getItemInOffHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}
 
Example 2
Source File: IslandGuard1_8.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Handle V1.8 blocks that need special treatment
 * Tilling of coarse dirt into dirt
 * Usually prevented because it could lead to an endless supply of dirt with gravel
 *
 * @param e - event
 */
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onPlayerInteract(final PlayerInteractEvent e) {
    if (DEBUG) {
        plugin.getLogger().info("1.8 " + e.getEventName());
    }
    if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
        return;
    }
    if (!IslandGuard.inWorld(e.getPlayer())) {
        return;
    }
    if (e.getPlayer().isOp()) {
        return;
    }
    // This permission bypasses protection
    if (VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")
            || VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "craft.dirt")) {
        return;
    }
    // Prevents tilling of coarse dirt into dirt
    ItemStack inHand = e.getPlayer().getItemInHand();
    if (inHand.getType() == Material.WOOD_HOE || inHand.getType() == Material.IRON_HOE || inHand.getType() == Material.GOLD_HOE
            || inHand.getType() == Material.DIAMOND_HOE || inHand.getType() == Material.STONE_HOE) {
        // plugin.getLogger().info("1.8 " + "DEBUG: hoe in hand");
        Block block = e.getClickedBlock();
        // plugin.getLogger().info("1.8 " + "DEBUG: block is " + block.getType() +
        // ":" + block.getData());
        // Check if coarse dirt
        if (block.getType() == Material.DIRT && block.getData() == (byte) 1) {
            // plugin.getLogger().info("1.8 " + "DEBUG: hitting coarse dirt!");
            e.setCancelled(true);
        }
    }
}