org.bukkit.Material#WOOD_HOE源码实例Demo

下面列出了org.bukkit.Material#WOOD_HOE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: askyblock   文件: IslandGuard1_9.java
/**
 * 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);
        }
    }
}
 
源代码2 项目: askyblock   文件: IslandGuard1_8.java
/**
 * 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);
        }
    }
}
 
 方法所在类
 同类方法