Java Code Examples for org.bukkit.event.player.PlayerBucketEmptyEvent#setCancelled()

The following examples show how to use org.bukkit.event.player.PlayerBucketEmptyEvent#setCancelled() . 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: DisplayProtectionListener.java    From QuickShop-Reremake with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void player(PlayerBucketEmptyEvent event) {
    if (!useEnhanceProtection) {
        return;
    }
    if (DisplayItem.getNowUsing() != DisplayType.REALITEM) {
        return;
    }
    final Block waterBlock = event.getBlockClicked().getRelative(event.getBlockFace());
    final Shop shop =
            getShopPlayer(waterBlock.getRelative(BlockFace.DOWN).getLocation(),true);
    if (shop == null) {
        return;
    }
    event.setCancelled(true);
    sendAlert(
            "[DisplayGuard] Player  "
                    + event.getPlayer().getName()
                    + " trying use water to move somethings on the shop top, QuickShop already remove it.");
}
 
Example 2
Source File: PlayerListener.java    From civcraft with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST)
public void OnPlayerBucketEmptyEvent(PlayerBucketEmptyEvent event) {
	Resident resident = CivGlobal.getResident(event.getPlayer());

	if (resident == null) {
		event.setCancelled(true);
		return;
	}

	ChunkCoord coord = new ChunkCoord(event.getBlockClicked().getLocation());
	CultureChunk cc = CivGlobal.getCultureChunk(coord);
	if (cc != null) {
		if (event.getBucket().equals(Material.LAVA_BUCKET) || 
				event.getBucket().equals(Material.LAVA)) {
			
			if (!resident.hasTown() || (resident.getTown().getCiv() != cc.getCiv())) {
				CivMessage.sendError(event.getPlayer(), "You cannot place lava inside another civ's culture.");
				event.setCancelled(true);
				return;
			}
			
		}
	}
}
 
Example 3
Source File: NetherPortals.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onBucketEmpty(final PlayerBucketEmptyEvent e) {
    if (DEBUG)
        plugin.getLogger().info("DEBUG: " + e.getEventName());
    if (!Settings.newNether) {
        if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_nether")
                || e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName + "_the_end")) {
            if (VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
                return;
            }
            if (!awayFromSpawn(e.getPlayer()) && !e.getPlayer().isOp()) {
                e.setCancelled(true);
            }
        }
    }
}
 
Example 4
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 5
Source File: ProtectionHandler.java    From Civs with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
    boolean cancel = shouldBlockAction(event.getBlockClicked().getLocation(), event.getPlayer(), "block_build");
    if (cancel) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(Civs.getPrefix() +
                LocaleManager.getInstance().getTranslationWithPlaceholders(event.getPlayer(), LocaleConstants.REGION_PROTECTED));
    }
}
 
Example 6
Source File: Areas.java    From AnnihilationPro with MIT License 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST,ignoreCancelled = true)
public void checkBreaks(PlayerBucketEmptyEvent event)
{
	if(event.getPlayer().getGameMode() != GameMode.CREATIVE)
	{
		Area a = this.getArea(new Loc(event.getBlockClicked().getRelative(event.getBlockFace()).getLocation(),false));
		if(a != null)
		{
			event.setCancelled(true);
		}
	}
}
 
Example 7
Source File: RegionInteractListener.java    From NovaGuilds with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event) {
	Block block = event.getBlockClicked().getRelative(event.getBlockFace());
	Player player = event.getPlayer();
	NovaPlayer nPlayer = PlayerManager.getPlayer(player);

	if(nPlayer.getPreferences().getBypass()) {
		return;
	}

	//Fluid protection
	NovaRegion fluidProtectRegion = null;
	for(NovaRegion region : plugin.getRegionManager().getRegions()) {
		if(!region.getWorld().equals(block.getWorld())) {
			continue;
		}

		Location centerLocation = region.getCenter().clone();
		Location blockLocation = block.getLocation().clone();
		centerLocation.setY(0);
		blockLocation.setY(0);

		if(blockLocation.distance(centerLocation) <= region.getDiagonal() / 2 + Config.REGION_FLUIDPROTECT.getInt()) {
			fluidProtectRegion = region;
			break;
		}
	}

	if((fluidProtectRegion != null
			&& (!nPlayer.hasGuild()
				|| (!fluidProtectRegion.getGuild().isMember(nPlayer)
					&& !fluidProtectRegion.getGuild().isAlly(nPlayer.getGuild()))))
			|| (RegionManager.get(block) != null
				&& (!plugin.getRegionManager().canInteract(player, block)
					|| !nPlayer.hasPermission(GuildPermission.BLOCK_PLACE)))) {
		event.setCancelled(true);
		Message.CHAT_REGION_DENY_INTERACT.send(player);
	}
}
 
Example 8
Source File: BlockPhysicsListener.java    From Slimefun4 with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler
public void onBucketUse(PlayerBucketEmptyEvent e) {
    // Fix for placing water on player heads
    Location l = e.getBlockClicked().getRelative(e.getBlockFace()).getLocation();
    if (BlockStorage.hasBlockInfo(l)) {
        e.setCancelled(true);
    }
}
 
Example 9
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 10
Source File: BukkitPlotListener.java    From PlotMe-Core with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBucketEmptyEvent(PlayerBucketEmptyEvent event) {
    IPlayer player = plugin.wrapPlayer(event.getPlayer());
    Location location = BukkitUtil.adapt(event.getBlockClicked().getLocation());

    if (player.hasPermission(PermissionNames.ADMIN_BUILDANYWHERE)) {
        return;
    }
    if (manager.isPlotWorld(location)) {
        Plot plot = manager.getPlot(location.add(event.getBlockFace().getModX(), event.getBlockFace().getModY(), event.getBlockFace().getModZ()));
        if (plot == null) {
            player.sendMessage(api.C("CannotBuild"));
            event.setCancelled(true);
        } else {
            if (plot.getOwnerId().equals(event.getPlayer().getUniqueId())) {
                return;
            }
            Optional<Plot.AccessLevel> member = plot.isMember(player.getUniqueId());
            if (member.isPresent()) {
                if (member.get().equals(Plot.AccessLevel.TRUSTED) && !api.getServerBridge().getOfflinePlayer(plot.getOwnerId()).isOnline()) {
                    player.sendMessage(api.C("CannotBuild"));
                    event.setCancelled(true);
                } else if (api.isPlotLocked(plot.getId())) {
                    player.sendMessage(api.C("PlotLocked"));
                    event.setCancelled(true);
                }
            } else {
                player.sendMessage(api.C("CannotBuild"));
                event.setCancelled(true);
            }
        }
    }
}
 
Example 11
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 12
Source File: TitleRespawn.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
    boolean material = event.getBucket().equals(Material.WATER_BUCKET) || event.getBucket().equals(Material.LAVA_BUCKET) || event.getBucket().equals(Material.LAVA) || event.getBucket().equals(Material.WATER) || event.getBucket().equals(Material.AIR);
    if (material && isDeadUUID(event.getPlayer().getUniqueId())) {
        event.setCancelled(true);
    }
}
 
Example 13
Source File: BuildHeight.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onEmptyBucket(PlayerBucketEmptyEvent event) {
    Block toFill = event.getBlockClicked().getRelative(event.getBlockFace());
    if (toFill.getY() >= height && !event.isCancelled()) {
        event.setCancelled(true);
        ChatUtil.sendWarningMessage(event.getPlayer(), "You have reached the maximum build height (" + ChatColor.AQUA + height + ChatColor.RED + " blocks)");
    }
}
 
Example 14
Source File: CoreObjective.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
    if (lava.contains(event.getBlockClicked().getRelative(event.getBlockFace())))
        event.setCancelled(true);
}
 
Example 15
Source File: FreezeMatchModule.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBucketEmpty(final PlayerBucketEmptyEvent event) {
  if (freeze.isFrozen(event.getPlayer())) {
    event.setCancelled(true);
  }
}
 
Example 16
Source File: BucketAction.java    From FunnyGuilds with Apache License 2.0 4 votes vote down vote up
@EventHandler
public void onEmpty(PlayerBucketEmptyEvent e) {
    if (ProtectionSystem.build(e.getPlayer(), e.getBlockClicked().getLocation())) {
        e.setCancelled(true);
    }
}
 
Example 17
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);
        }
    }
}
 
Example 18
Source File: EnvironmentControlListener.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void noBucket(final PlayerBucketEmptyEvent event) {
    event.setCancelled(true);
}
 
Example 19
Source File: FreezeListener.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBucketEmpty(final PlayerBucketEmptyEvent event) {
    if(freeze.isFrozen(event.getPlayer())) {
        event.setCancelled(true);
    }
}