Java Code Examples for org.bukkit.Material#LAVA

The following examples show how to use org.bukkit.Material#LAVA . 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: HuntEffect.java    From Civs with GNU General Public License v3.0 6 votes vote down vote up
public static Location findNearbyLocationForTeleport(Location location, int radius, Player player) {
    int times = 0;
    Block targetBlock;
    do {
        times++;
        int xRadius = (int) (Math.random()*radius);
        if (Math.random() > .5) {
            xRadius = xRadius *-1;
        }
        int x = location.getBlockX() + xRadius;
        int zRadius = (int) ((Math.sqrt(radius*radius - xRadius*xRadius)));
        if (Math.random() > .5) {
            zRadius = zRadius *-1;
        }
        int z = location.getBlockZ() + zRadius;
        targetBlock = location.getWorld().getHighestBlockAt(x, z);
    } while (times < 5 && (targetBlock.getType() == Material.LAVA));

    if (times == 5) {
        return null;
    }


    return targetBlock.getLocation();
}
 
Example 4
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 5
Source File: BlockPlaceRegion.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() && region.contains(new BlockRegion(null, event.getBlockClicked().getRelative(event.getBlockFace()).getLocation().toVector())) && filter.evaluate(event.getPlayer(), material, event).equals(FilterState.DENY)) {
        event.setCancelled(true);
        ChatUtil.sendWarningMessage(event.getPlayer(), message);
    }
}
 
Example 6
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 7
Source File: PlayerEvents.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onLavaAbsorption(EntityChangeBlockEvent event) {
    if (!plugin.getWorldManager().isSkyWorld(event.getBlock().getWorld())) {
        return;
    }
    if (isLavaSource(event.getBlock().getBlockData())) {
        if (event.getTo() != Material.LAVA) {
            event.setCancelled(true);
            // TODO: R4zorax - 21-07-2018: missing datavalue (might convert stuff - exploit)
            ItemStack item = new ItemStack(event.getTo(), 1);
            Location above = event.getBlock().getLocation().add(0, 1, 0);
            event.getBlock().getWorld().dropItemNaturally(above, item);
        }
    }
}
 
Example 8
Source File: PlayerEvents.java    From uSkyBlock with GNU General Public License v3.0 5 votes vote down vote up
private boolean isLavaSource(BlockData blockData) {
    if (blockData.getMaterial() == Material.LAVA) {
        Levelled level = (Levelled) blockData;
        return level.getLevel() == 0;
    }
    return false;
}
 
Example 9
Source File: RegionInteractListener.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onBlockFromTo(BlockFromToEvent event) {
	if(!Config.REGION_WATERFLOW.getBoolean()) {
		Material type = event.getBlock().getType();

		if((type == Material.WATER || type == CompatibilityUtils.Mat.WATER.get() || type == Material.LAVA || type == CompatibilityUtils.Mat.LAVA.get())
				&& RegionManager.get(event.getBlock()) == null
				&& RegionManager.get(event.getToBlock()) != null) {
			event.setCancelled(true);
		}
	}
}
 
Example 10
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 11
Source File: BlockPlaceAgainstRegion.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() && region.contains(new BlockRegion(null, event.getBlockClicked().getRelative(event.getBlockFace()).getLocation().toVector()))
            && filter.evaluate(event.getPlayer(), material, event).equals(FilterState.DENY)) {
        event.setCancelled(true);
        ChatUtil.sendWarningMessage(event.getPlayer(), message);
    }
}
 
Example 12
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 13
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 14
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 15
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 16
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 17
Source File: CraftBlock.java    From Thermos 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 18
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 19
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 20
Source File: Materials.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
static boolean isLava(Material material) {
  return material == Material.LAVA || material == Material.STATIONARY_LAVA;
}