Java Code Examples for org.bukkit.Material#WATER_BUCKET

The following examples show how to use org.bukkit.Material#WATER_BUCKET . 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: Materials.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
static boolean isBucket(Material bucket) {
  return bucket == Material.BUCKET
      || bucket == Material.LAVA_BUCKET
      || bucket == Material.WATER_BUCKET
      || bucket == Material.MILK_BUCKET;
}
 
Example 2
Source File: Materials.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
public static boolean isBucket(Material bucket) {
    return bucket == Material.BUCKET || bucket == Material.LAVA_BUCKET || bucket == Material.WATER_BUCKET || bucket == Material.MILK_BUCKET;
}
 
Example 3
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Prevents emptying of buckets outside of island space
 * @param e - event
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBucketEmpty(final PlayerBucketEmptyEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (inWorld(e.getPlayer())) {
        Player p = e.getPlayer();
        if (e.getBlockClicked() != null) {
            // This is where the water or lava actually will be dumped
            Block dumpBlock = e.getBlockClicked().getRelative(e.getBlockFace());
            if (actionAllowed(p, dumpBlock.getLocation(), SettingsFlag.BUCKET)) {
                // Check if biome is Nether and then allow water placement but fizz the water
                if (e.getBlockClicked().getBiome().equals(Biome.HELL)) {
                    if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
                        if (e.getPlayer().getItemInHand().getType().equals(Material.WATER_BUCKET)) {
                            e.setCancelled(true);
                            e.getPlayer().getItemInHand().setType(Material.BUCKET);
                            e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
                            Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).biomeSet.replace("[biome]", "Nether"));
                        }
                    } else {
                        if (Util.playerIsHolding(e.getPlayer(), Material.WATER_BUCKET)) {
                            e.setCancelled(true);
                            if (e.getPlayer().getInventory().getItemInMainHand().getType() == Material.WATER_BUCKET) {
                                e.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.BUCKET));
                            } else if (e.getPlayer().getInventory().getItemInOffHand().getType() == Material.WATER_BUCKET) {
                                e.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.BUCKET));
                            }
                            e.getPlayer().getWorld().playSound(e.getPlayer().getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
                            Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).biomeSet.replace("[biome]", "Nether"));
                        }
                    }
                }
                return;
            }
            // Not allowed
            Util.sendMessage(p, ChatColor.RED + plugin.myLocale(p.getUniqueId()).islandProtected);
            e.setCancelled(true);
        }
    }
}