Java Code Examples for org.bukkit.Material#WATER

The following examples show how to use org.bukkit.Material#WATER . 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: ChunkEventHelper.java    From ClaimChunk with MIT License 6 votes vote down vote up
public static void handleToFromEvent(@Nonnull BlockFromToEvent e) {
    if (e.isCancelled()) return;

    // Only continue if we should stop the spread from the config.
    if (!config.getBool("protection", "blockFluidSpreadIntoClaims")) return;

    // If the block isn't water or lava, we don't protect it.
    Material blockType = e.getBlock().getType();
    if (blockType != Material.WATER && blockType != Material.LAVA) return;

    Chunk from = e.getBlock().getChunk();
    Chunk to = e.getToBlock().getChunk();

    // If the from and to chunks have the same owner or if the to chunk is
    // unclaimed, the flow is allowed.
    final ChunkHandler CHUNK = ClaimChunk.getInstance().getChunkHandler();
    if (getChunksSameOwner(CHUNK, from, to) || !CHUNK.isClaimed(to)) return;

    // Cancel the flow
    e.setCancelled(true);
}
 
Example 2
Source File: MenuUtil.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
public static void sanitizeItem(ItemStack item) {
    Material mat = item.getType();
    if (mat == Material.RED_BED || mat == Material.BLACK_BED || mat == Material.BLUE_BED
            || mat == Material.BROWN_BED || mat == Material.CYAN_BED
            || mat == Material.GRAY_BED || mat == Material.GREEN_BED || mat == Material.LIGHT_BLUE_BED
            || mat == Material.LIGHT_GRAY_BED || mat == Material.LIME_BED || mat == Material.MAGENTA_BED
            || mat == Material.ORANGE_BED || mat == Material.PINK_BED || mat == Material.PURPLE_BED
            || mat == Material.WHITE_BED || mat == Material.YELLOW_BED) {
        divideByTwo(item);
    } else if (mat == Material.OAK_DOOR || mat == Material.IRON_DOOR || mat == Material.DARK_OAK_DOOR
            || mat == Material.BIRCH_DOOR || mat == Material.ACACIA_DOOR || mat == Material.SPRUCE_DOOR
            || mat == Material.JUNGLE_DOOR) {
        divideByTwo(item);
    } else if (mat == Material.REDSTONE_WIRE) {
        item.setType(Material.REDSTONE);
    } else if (mat == Material.WATER) {
        item.setType(Material.WATER_BUCKET);
    } else if (mat == Material.LAVA) {
        item.setType(Material.LAVA_BUCKET);
    } else if (mat == Material.POTATOES) {
        item.setType(Material.POTATO);
    } else if (mat == Material.CARROTS) {
        item.setType(Material.CARROT);
    }
}
 
Example 3
Source File: LWCBlockListener.java    From Modern-LWC with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR)
public void onBlockFromTo(BlockFromToEvent event) {
    Block block = event.getBlock();
    LWC lwc = this.plugin.getLWC();
    if (block.getType() == Material.WATER && lwc.isProtectable(event.getToBlock())) {
        if (lwc.findProtection(event.getToBlock().getLocation()) != null) {
            event.setCancelled(true);
            return;
        }
    }
}
 
Example 4
Source File: PlantsListener.java    From ExoticGarden with GNU General Public License v3.0 5 votes vote down vote up
private void pasteTree(ChunkPopulateEvent e, int x, int z, Tree tree) {
    for (int y = e.getWorld().getMaxHeight(); y > 30; y--) {
        Block current = e.getWorld().getBlockAt(x, y, z);
        if (!current.getType().isSolid() && current.getType() != Material.WATER && current.getType() != Material.SEAGRASS && current.getType() != Material.TALL_SEAGRASS && !(current.getBlockData() instanceof Waterlogged && ((Waterlogged) current.getBlockData()).isWaterlogged()) && tree.isSoil(current.getRelative(0, -1, 0).getType()) && isFlat(current)) {
            Schematic.pasteSchematic(new Location(e.getWorld(), x, y, z), tree);
            break;
        }
    }
}
 
Example 5
Source File: Crucible.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private void generateLiquid(Block block, boolean water) {
    if (block.getType() == (water ? Material.WATER : Material.LAVA)) {
        addLiquidLevel(block, water);
    }
    else if (block.getType() == (water ? Material.LAVA : Material.WATER)) {
        int level = ((Levelled) block.getBlockData()).getLevel();
        block.setType(level == 0 || level == 8 ? Material.OBSIDIAN : Material.STONE);
        block.getWorld().playSound(block.getLocation(), Sound.BLOCK_LAVA_EXTINGUISH, 1F, 1F);
    }
    else {
        Slimefun.runSync(() -> placeLiquid(block, water), 50L);
    }
}
 
Example 6
Source File: Materials.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
public static Material materialInBucket(Material bucket) {
    switch(bucket) {
        case BUCKET:
        case MILK_BUCKET:
            return Material.AIR;

        case LAVA_BUCKET: return Material.LAVA;
        case WATER_BUCKET: return Material.WATER;

        default: throw new IllegalArgumentException(bucket + " is not a bucket");
    }
}
 
Example 7
Source File: BlockEventRegion.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
    Material material = (event.getBucket().equals(Material.WATER_BUCKET) ? Material.WATER : (event.getBucket().equals(Material.LAVA_BUCKET) ? Material.LAVA : Material.AIR));
    if (!event.isCancelled() && filter.evaluate(event.getPlayer(), material, event).equals(FilterState.DENY)
            && region.contains(new BlockRegion(null, event.getBlockClicked().getRelative(event.getBlockFace()).getLocation().toVector()))) {
        event.setCancelled(true);
        ChatUtil.sendWarningMessage(event.getPlayer(), message);
    }
}
 
Example 8
Source File: FluidPump.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private void consumeFluid(Block fluid) {
    if (fluid.getType() == Material.WATER) {
        fluid.setType(Material.AIR);
        return;
    }

    List<Block> list = Vein.find(fluid, RANGE, block -> block.isLiquid() && block.getType() == fluid.getType());
    list.get(list.size() - 1).setType(Material.AIR);
}
 
Example 9
Source File: Strafe.java    From Hawk with GNU General Public License v3.0 5 votes vote down vote up
private boolean testLiquid(Set<Material> mats) {
    for(Material mat : mats) {
        if(mat == Material.WATER || mat == Material.STATIONARY_WATER || mat == Material.LAVA || mat == Material.STATIONARY_LAVA)
            return true;
    }
    return false;
}
 
Example 10
Source File: ChunkGenerator.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Tests if the specified location is valid for a natural spawn position
 *
 * @param world The world we're testing on
 * @param x     X-coordinate of the block to test
 * @param z     Z-coordinate of the block to test
 * @return true if the location is valid, otherwise false
 */
public boolean canSpawn(World world, int x, int z) {
    Block highest = world.getBlockAt(x, world.getHighestBlockYAt(x, z), z);

    switch (world.getEnvironment()) {
        case NETHER:
            return true;
        case THE_END:
            return highest.getType() != Material.AIR && highest.getType() != Material.WATER && highest.getType() != Material.LAVA;
        case NORMAL:
        default:
            return highest.getType() == Material.SAND || highest.getType() == Material.GRAVEL;
    }
}
 
Example 11
Source File: FluidPump.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
private Optional<ItemStack> getFilledBucket(Block fluid) {
    if (fluid.getType() == Material.LAVA) {
        return Optional.of(new ItemStack(Material.LAVA_BUCKET));
    }
    else if (fluid.getType() == Material.WATER) {
        return Optional.of(new ItemStack(Material.WATER_BUCKET));
    }

    return Optional.empty();
}
 
Example 12
Source File: Materials.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
static Material materialInBucket(Material bucket) {
  switch (bucket) {
    case BUCKET:
    case MILK_BUCKET:
      return Material.AIR;

    case LAVA_BUCKET:
      return Material.LAVA;
    case WATER_BUCKET:
      return Material.WATER;

    default:
      throw new IllegalArgumentException(bucket + " is not a bucket");
  }
}
 
Example 13
Source File: AcidEffect.java    From askyblock with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Check if player can be burned by acid
 * @param player
 * @return true if player is not safe
 */
private boolean isSafeFromAcid(Player player) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: safe from acid");
    if (!player.getWorld().equals(ASkyBlock.getIslandWorld())) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: wrong world");
        return true;
    }
    // In liquid
    Material bodyMat = player.getLocation().getBlock().getType();
    Material headMat = player.getLocation().getBlock().getRelative(BlockFace.UP).getType();
    if (bodyMat.equals(Material.STATIONARY_WATER))
        bodyMat = Material.WATER;
    if (headMat.equals(Material.STATIONARY_WATER))
        headMat = Material.WATER;
    if (bodyMat != Material.WATER && headMat != Material.WATER) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: not in water " + player.getLocation().getBlock().isLiquid() + " " + player.getLocation().getBlock().getRelative(BlockFace.UP).isLiquid());
        return true;
    }
    // Check if player is in a boat
    Entity playersVehicle = player.getVehicle();
    if (playersVehicle != null) {
        // They are in a Vehicle
        if (playersVehicle.getType().equals(EntityType.BOAT)) {
            // I'M ON A BOAT! I'M ON A BOAT! A %^&&* BOAT!
            if (DEBUG)
                plugin.getLogger().info("DEBUG: boat");
            return true;
        }
    }
    // Check if full armor protects
    if (Settings.fullArmorProtection) {
        boolean fullArmor = true;
        for (ItemStack item : player.getInventory().getArmorContents()) {
            if (item == null || (item != null && item.getType().equals(Material.AIR))) {
                fullArmor = false;
                break;
            }
        }
        if (fullArmor) {
            if (DEBUG)
                plugin.getLogger().info("DEBUG: full armor");
            return true;
        }
    }
    // Check if player has an active water potion or not
    Collection<PotionEffect> activePotions = player.getActivePotionEffects();
    for (PotionEffect s : activePotions) {
        // plugin.getLogger().info("Potion is : " +
        // s.getType().toString());
        if (s.getType().equals(PotionEffectType.WATER_BREATHING)) {
            // Safe!
            if (DEBUG)
                plugin.getLogger().info("DEBUG: Water breathing potion protection!");
            return true;
        }
    }
    // Check if water above sea-level is not acid
    Island island = plugin.getGrid().getIslandAt(player.getLocation());
    if (island != null && !island.getIgsFlag(SettingsFlag.ACID_DAMAGE) && player.getLocation().getBlockY() > Settings.seaHeight) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG:no acid damage above sea level 1");
        return true;
    }
    if (island == null && !Settings.defaultWorldSettings.get(SettingsFlag.ACID_DAMAGE) && player.getLocation().getBlockY() > Settings.seaHeight) {
        if (DEBUG)
            plugin.getLogger().info("DEBUG: no acid damage above sea level");
        return true;
    }
    if (DEBUG)
        plugin.getLogger().info("DEBUG: burn in acid");
    return false;
}
 
Example 14
Source File: FlatteningRegion.java    From BedWars with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean isLiquid(Material material) {
    return material == Material.WATER || material == Material.LAVA;
}
 
Example 15
Source File: CraftBlock.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public boolean isLiquid() {
    return (getType() == Material.WATER) || (getType() == Material.STATIONARY_WATER) || (getType() == Material.LAVA) || (getType() == Material.STATIONARY_LAVA);
}
 
Example 16
Source File: Materials.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static boolean isWater(Material material) {
    return material == Material.WATER || material == Material.STATIONARY_WATER;
}
 
Example 17
Source File: FlatteningRegion.java    From BedWars with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public boolean isLiquid(Material material) {
    return material == Material.WATER || material == Material.LAVA;
}
 
Example 18
Source File: MagicBlockCompat.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isLiquid(Material type) {
	// TODO moving water and lava
	return type == Material.WATER || type == Material.LAVA;
}
 
Example 19
Source File: NewBlockCompat.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@Override
public boolean isLiquid(Material type) {
	return type == Material.WATER || type == Material.LAVA;
}
 
Example 20
Source File: Materials.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
static boolean isWater(Material material) {
  return material == Material.WATER || material == Material.STATIONARY_WATER;
}