org.bukkit.event.player.PlayerBucketFillEvent Java Examples

The following examples show how to use org.bukkit.event.player.PlayerBucketFillEvent. 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: BlockTransformEvent.java    From PGM with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Get whether the {@link Block} was probably transformed by a player.
 *
 * @return Whether the event is considered "manual."
 */
public final boolean isManual() {
  final Event event = getCause();

  if (event instanceof BlockPlaceEvent
      || event instanceof BlockBreakEvent
      || event instanceof PlayerBucketEmptyEvent
      || event instanceof PlayerBucketFillEvent) return true;

  if (event instanceof BlockIgniteEvent) {
    BlockIgniteEvent igniteEvent = (BlockIgniteEvent) event;
    if (igniteEvent.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL
        && igniteEvent.getIgnitingEntity() != null) {
      return true;
    }
  }

  if (event instanceof ExplosionPrimeByEntityEvent
      && ((ExplosionPrimeByEntityEvent) event).getPrimer() instanceof Player) {
    return true;
  }

  return false;
}
 
Example #2
Source File: BlockTransformEvent.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * Return true if the block transformation was performed "by hand".
 *
 * Handled:
 *  - place
 *  - mine
 *  - bucket fill/empty
 *  - flint & steel fire/tnt
 *
 * Not handled:
 *  - bonemeal
 *  - probably lots of other things
 */
public boolean isManual() {
    final Event event = getCause();

    if(Types.instanceOfAny(
        event,
        BlockPlaceEvent.class,
        BlockBreakEvent.class,
        PlayerBucketEmptyEvent.class,
        PlayerBucketFillEvent.class
    )) return true;

    if(event instanceof BlockIgniteEvent) {
        BlockIgniteEvent igniteEvent = (BlockIgniteEvent) event;
        if(igniteEvent.getCause() == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && igniteEvent.getIgnitingEntity() != null) {
            return true;
        }
    }

    if(event instanceof ExplosionPrimeByEntityEvent && ((ExplosionPrimeByEntityEvent) event).getPrimer() instanceof Player) {
        return true;
    }

    return false;
}
 
Example #3
Source File: AcidInventory.java    From askyblock with GNU General Public License v2.0 6 votes vote down vote up
/**
 * If the player filled up the bucket themselves
 * 
 * @param e - event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onBucketFill(PlayerBucketFillEvent e) {
    if (DEBUG)
        plugin.getLogger().info("Player filled the bucket");
    if (e.getPlayer().getWorld().getName().equalsIgnoreCase(Settings.worldName)) {
        if (DEBUG)
            plugin.getLogger().info("Correct world");
        if (Settings.acidDamage > 0D && Settings.acidBottle) {
            ItemStack item = e.getItemStack();
            if (item.getType().equals(Material.WATER_BUCKET) || item.getType().equals(Material.POTION)) {
                ItemMeta meta = item.getItemMeta();
                meta.setDisplayName(plugin.myLocale(e.getPlayer().getUniqueId()).acidBucket);
                lore = Arrays.asList(plugin.myLocale(e.getPlayer().getUniqueId()).acidLore.split("\n"));
                meta.setLore(lore);
                item.setItemMeta(meta);
            }
        }
    }
}
 
Example #4
Source File: BlockEventRegion.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onBucketFill(PlayerBucketFillEvent event) {
    if (!event.isCancelled() && filter.evaluate(event.getPlayer(), event.getBlockClicked().getRelative(event.getBlockFace()), 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 #5
Source File: BlockBreakRegion.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onBucketFill(PlayerBucketFillEvent event) {
    if (!event.isCancelled() && region.contains(new BlockRegion(null, event.getBlockClicked().getRelative(event.getBlockFace()).getLocation().toVector())) && filter.evaluate(event.getPlayer(), event.getBlockClicked().getRelative(event.getBlockFace()), event).equals(FilterState.DENY)) {
        event.setCancelled(true);
        ChatUtil.sendWarningMessage(event.getPlayer(), message);
    }
}
 
Example #6
Source File: BuildHeight.java    From CardinalPGM with MIT License 5 votes vote down vote up
@EventHandler
public void onFillBucket(PlayerBucketFillEvent event) {
    Block toEmpty = event.getBlockClicked().getRelative(event.getBlockFace());
    if (toEmpty.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 #7
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 onBucketFillEvent(PlayerBucketFillEvent 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);

        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 #8
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(PlayerBucketFillEvent event) {
    boolean cancel = shouldBlockAction(event.getBlockClicked().getLocation(), event.getPlayer(), "block_break");
    if (cancel) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(Civs.getPrefix() +
                LocaleManager.getInstance().getTranslationWithPlaceholders(event.getPlayer(), LocaleConstants.REGION_PROTECTED));
    }
}
 
Example #9
Source File: CancellableChunkEvents.java    From ClaimChunk with MIT License 5 votes vote down vote up
@EventHandler
public void onLiquidPlacePickup(PlayerBucketFillEvent e) {
    if (e != null) {
        BlockFace bf = e.getBlockFace();
        Vector v = new Vector(bf.getModX(), bf.getModY(), bf.getModZ());
        ChunkEventHelper.handleBlockEvent(e.getPlayer(), e.getBlockClicked().getLocation().add(v).getChunk(), e);
    }
}
 
Example #10
Source File: IslandGuard.java    From askyblock with GNU General Public License v2.0 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onBucketFill(final PlayerBucketFillEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (inWorld(e.getPlayer())) {
        // This permission bypasses protection
        if (VaultHelper.checkPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        Island island = plugin.getGrid().getProtectedIslandAt(e.getBlockClicked().getLocation());
        if (island != null) {
            if (island.getMembers().contains(e.getPlayer().getUniqueId())) {
                return;
            }
            if (island.getIgsFlag(SettingsFlag.COLLECT_LAVA) && e.getItemStack().getType().equals(Material.LAVA_BUCKET)) {
                return;
            }
            if (island.getIgsFlag(SettingsFlag.COLLECT_WATER) && e.getItemStack().getType().equals(Material.WATER_BUCKET)) {
                return;
            }
            if (island.getIgsFlag(SettingsFlag.MILKING) && e.getItemStack().getType().equals(Material.MILK_BUCKET)) {
                return;
            }
            if (island.getIgsFlag(SettingsFlag.BUCKET)) {
                return;
            }
        } else {
            // Null
            if (Settings.defaultWorldSettings.get(SettingsFlag.BUCKET)) {
                return;
            }
        }
        // Not allowed
        Util.sendMessage(e.getPlayer(), ChatColor.RED + plugin.myLocale(e.getPlayer().getUniqueId()).islandProtected);
        e.setCancelled(true);
    }
}
 
Example #11
Source File: GlobalProtectionListener.java    From DungeonsXL with GNU General Public License v3.0 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
    Player player = event.getPlayer();
    if (DPlayerListener.isCitizensNPC(player)) {
        return;
    }
    Block block = event.getBlockClicked();
    if (DPortal.getByBlock(plugin, block) != null) {
        event.setCancelled(true);
        // Workaround for a bug of Bukkit
        event.getPlayer().sendBlockChange(block.getLocation(), block.getType(), (byte) 0);
    }
}
 
Example #12
Source File: ExprTool.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public boolean setTime(final int time) {
	return super.setTime(time, getExpr(), PlayerItemHeldEvent.class, PlayerBucketFillEvent.class, PlayerBucketEmptyEvent.class);
}
 
Example #13
Source File: CoreObjective.java    From CardinalPGM with MIT License 4 votes vote down vote up
@EventHandler
public void onBucketFill(PlayerBucketFillEvent event) {
    if (lava.contains(event.getBlockClicked()))
        event.setCancelled(true);
}
 
Example #14
Source File: BucketAction.java    From FunnyGuilds with Apache License 2.0 4 votes vote down vote up
@EventHandler
public void onFill(PlayerBucketFillEvent e) {
    if (ProtectionSystem.build(e.getPlayer(), e.getBlockClicked().getLocation())) {
        e.setCancelled(true);
    }
}
 
Example #15
Source File: BucketsFilledListener.java    From Statz with GNU General Public License v3.0 4 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBucketFill(final PlayerBucketFillEvent event) {

	final PlayerStat stat = PlayerStat.BUCKETS_FILLED;

	// Get player
	final Player player = event.getPlayer();

	// Do general check
	if (!plugin.doGeneralCheck(player, stat))
		return;

	PlayerStatSpecification specification = new BucketsFilledSpecification(player.getUniqueId(), 1,
			player.getWorld().getName());


	// Update value to new stat.
	plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, specification.constructQuery());

}
 
Example #16
Source File: PlayerEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerBucketFillEvent(PlayerBucketFillEvent event) {
    onPlayerBucketEvent(event);
}
 
Example #17
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 PlayerBucketFillEvent event) {
    event.setCancelled(true);
}
 
Example #18
Source File: BlockTransformListener.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventWrapper
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
    BlockState state = event.getBlockClicked().getRelative(event.getBlockFace()).getState();
    this.callEvent(event, state, BlockStateUtils.toAir(state), event.getPlayer());
}
 
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 onBucketFill(final PlayerBucketFillEvent event) {
    if(freeze.isFrozen(event.getPlayer())) {
        event.setCancelled(true);
    }
}
 
Example #20
Source File: BlockTransformListener.java    From PGM with GNU Affero General Public License v3.0 4 votes vote down vote up
@EventWrapper
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
  BlockState state = event.getBlockClicked().getRelative(event.getBlockFace()).getState();
  this.callEvent(event, state, BlockStates.toAir(state), event.getPlayer());
}
 
Example #21
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 onBucketFill(final PlayerBucketFillEvent event) {
  if (freeze.isFrozen(event.getPlayer())) {
    event.setCancelled(true);
  }
}
 
Example #22
Source File: PlayerEventHandler.java    From GriefDefender with MIT License 4 votes vote down vote up
public void onPlayerBucketEvent(PlayerBucketEvent event) {
    final Player player = event.getPlayer();
    final Block clickedBlock = event.getBlockClicked();
    GDCauseStackManager.getInstance().pushCause(player);
    if (!GriefDefenderPlugin.getInstance().claimsEnabledForWorld(player.getWorld().getUID())) {
        return;
    }
    if (GriefDefenderPlugin.isTargetIdBlacklisted(Flags.INTERACT_BLOCK_SECONDARY.getName(), clickedBlock, player.getWorld().getUID())) {
        return;
    }

    GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.startTiming();
    final Object source = player;
    final Location location = clickedBlock.getLocation();
    final GDClaim claim = this.dataStore.getClaimAt(location);
    final TrustType trustType = NMSUtil.getInstance().isTileInventory(location) || clickedBlock != null && clickedBlock.getType() == Material.ENDER_CHEST ? TrustTypes.CONTAINER : TrustTypes.ACCESSOR;

    Tristate result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.INTERACT_BLOCK_SECONDARY, source, clickedBlock, player, trustType, true);
    if (result == Tristate.FALSE) {
        event.setCancelled(true);
        GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.stopTiming();
        return;
    }

    GDTimings.PLAYER_INTERACT_BLOCK_SECONDARY_EVENT.stopTiming();

    if (event instanceof PlayerBucketEmptyEvent) {
        // check block place
        result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.BLOCK_PLACE, source, event.getBucket().name().toLowerCase().replace("_bucket", ""), player, TrustTypes.BUILDER, true);
        if (result == Tristate.FALSE) {
            event.setCancelled(true);
            return;
        }
    } else if (event instanceof PlayerBucketFillEvent) {
        // check block break
        result = GDPermissionManager.getInstance().getFinalPermission(event, location, claim, Flags.BLOCK_BREAK, source, event.getBlockClicked(), player, TrustTypes.BUILDER, true);
        if (result == Tristate.FALSE) {
            event.setCancelled(true);
            return;
        }
    }
}