Java Code Examples for org.bukkit.event.player.PlayerBucketFillEvent

The following are top voted examples for showing how to use org.bukkit.event.player.PlayerBucketFillEvent. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Statz   File: BucketsFilledListener.java   View source code 6 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;

	// Update value to new stat.
	plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid",
			player.getUniqueId().toString(), "value", 1, "world", player.getWorld().getName()));

}
 
Example 2
Project: AdvancedAchievements   File: AchieveMilkLavaWaterListener.java   View source code 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
	Player player = event.getPlayer();

	Material resultBucket = event.getItemStack().getType();
	NormalAchievements category = getCategory(resultBucket);

	if (plugin.getDisabledCategorySet().contains(category.toString())) {
		return;
	}

	if (!shouldIncreaseBeTakenIntoAccount(player, category)
			|| isInCooldownPeriod(player, category.toString(), false, category)) {
		return;
	}

	updateStatisticAndAwardAchievementsIfAvailable(player, category, 1);
}
 
Example 3
Project: RedProtect   File: RPGlobalListener.java   View source code 6 votes vote down vote up
@EventHandler
public void onBucketFill(PlayerBucketFillEvent e){
   	if (e.isCancelled()) {
           return;
       }

   	Location l = e.getBlockClicked().getLocation();
	Region r = RedProtect.get().rm.getTopRegion(l);	
	if (r != null){
		return;
	}
	
	if (!RPUtil.canBuildNear(e.getPlayer(), l)){        	
           e.setCancelled(true);
       	return;    	
       }
	
   	if (!bypassBuild(e.getPlayer(), null, 0)) {
   		e.setCancelled(true);
	}
   }
 
Example 4
Project: AncientGates   File: PluginBlockListener.java   View source code 6 votes vote down vote up
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
	if (event.isCancelled())
		return;

	final Block block = event.getBlockClicked();
	final Block blockUp = block.getRelative(BlockFace.UP);

	// Ok so a player fills a bucket on a portal block
	// Find the nearest gate!
	final WorldCoord blockCoord = new WorldCoord(block);
	final WorldCoord blockCoordUp = new WorldCoord(blockUp);
	final Gate nearestGate = Gates.gateFromPortal(blockCoord);
	final Gate nearestGateUp = Gates.gateFromPortal(blockCoordUp);

	if (nearestGate != null || nearestGateUp != null) {
		event.setCancelled(true);
	}
}
 
Example 5
Project: acidisland   File: AcidInventory.java   View source code 6 votes vote down vote up
/**
 * If the player filled up the bucket themselves
 * 
 * @param e
 */
@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 6
Project: Factoid   File: PlayerListener.java   View source code 6 votes vote down vote up
/**
 * On player bucket fill.
 * 
 * @param event
 *            the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerBucketFill(PlayerBucketFillEvent event) {

	if (!playerConf.get(event.getPlayer()).isAdminMod()) {

		IDummyLand land = Factoid.getThisPlugin().iLands().getLandOrOutsideArea(
				event.getBlockClicked().getLocation());
		Material mt = event.getBlockClicked().getType();

		if ((land instanceof ILand && ((ILand) land).isBanned(event
				.getPlayer()))
				|| (mt == Material.LAVA_BUCKET && !checkPermission(land,
						event.getPlayer(),
						PermissionList.BUCKET_LAVA.getPermissionType()))
				|| (mt == Material.WATER_BUCKET && !checkPermission(land,
						event.getPlayer(),
						PermissionList.BUCKET_WATER.getPermissionType()))) {
			messagePermission(event.getPlayer());
			event.setCancelled(true);
		}
	}
}
 
Example 7
Project: askyblock   File: AcidInventory.java   View source code 6 votes vote down vote up
/**
 * If the player filled up the bucket themselves
 * 
 * @param e
 */
@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 8
Project: modules-extra   File: ListenerBucket.java   View source code 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerBucketFill(final PlayerBucketFillEvent event)
{
    BlockState oldState = event.getBlockClicked().getRelative(event.getBlockFace()).getState();
    if (oldState.getType() == WATER || oldState.getType() == STATIONARY_WATER || oldState.getType() == LAVA
        || oldState.getType() == STATIONARY_LAVA)
    {
        this.setAndLog(BucketFill.class, event.getPlayer(), oldState, AIR);
    }
    else // TODO better check
    {
        // milk
        BucketMilk action = this.newAction(BucketMilk.class, event.getPlayer().getWorld());
        if (action != null)
        {
            action.setPlayer(event.getPlayer());
            action.setLocation(oldState.getLocation());
            this.logAction(action);
        }
    }
}
 
Example 9
Project: TCMinigames   File: PlayerListener.java   View source code 6 votes vote down vote up
@EventHandler
public void onBucketFill(PlayerBucketFillEvent event){
	if(Minigame.getCurrentMinigame()!=null){
		switch(Minigame.getCurrentMinigame().getMap().getType()){
		case CIRCLE_OF_BOOM:
			event.setCancelled(true);
			break;
		case KEY_QUEST:
			break;
		case WATER_THE_MONUMENT:
			break;
		default:
			break;
		}
	}
}
 
Example 10
Project: ZentrelaRPG   File: EnvironmentManager.java   View source code 5 votes vote down vote up
@EventHandler
public void onBucketFill(PlayerBucketFillEvent event) {
    PlayerDataRPG pd = plugin.getPD(event.getPlayer());
    if (pd == null)
        event.setCancelled(true);
    if (event.getPlayer().getGameMode() != GameMode.CREATIVE)
        event.setCancelled(true);
    if (!canBuild(pd))
        event.setCancelled(true);
    event.getPlayer().updateInventory();
}
 
Example 11
Project: bskyblock   File: IslandGuard.java   View source code 5 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onBucketFill(final PlayerBucketFillEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (Util.inWorld(e.getPlayer())) {
        // This permission bypasses protection
        if (VaultHelper.hasPerm(e.getPlayer(), Settings.PERMPREFIX + "mod.bypassprotect")) {
            return;
        }
        Island island = plugin.getIslands().getProtectedIslandAt(e.getBlockClicked().getLocation());
        if (island != null) {
            if (island.getMembers().contains(e.getPlayer().getUniqueId())) {
                return;
            }
            if (island.getFlag(SettingsFlag.COLLECT_LAVA) && e.getItemStack().getType().equals(Material.LAVA_BUCKET)) {
                return;
            }
            if (island.getFlag(SettingsFlag.COLLECT_WATER) && e.getItemStack().getType().equals(Material.WATER_BUCKET)) {
                return;
            }
            if (island.getFlag(SettingsFlag.MILKING) && e.getItemStack().getType().equals(Material.MILK_BUCKET)) {
                return;
            }
            if (island.getFlag(SettingsFlag.BUCKET)) {
                return;
            }
        } else {
            // Null
            if (Settings.defaultWorldSettings.get(SettingsFlag.BUCKET)) {
                return;
            }
        }
        // Not allowed
        Util.sendMessage(e.getPlayer(), plugin.getLocale(e.getPlayer().getUniqueId()).get("island.protected"));
        e.setCancelled(true);
    }
}
 
Example 12
Project: ProjectAres   File: BlockTransformEvent.java   View source code 5 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 13
Project: OpenUHC   File: LobbyModule.java   View source code 5 votes vote down vote up
/**
 * Prevents lobby players from interacting in the world.
 *
 * @param event The event
 */
@EventHandler
public void onBucketFill(final PlayerBucketFillEvent event) {
  if (event.getBlockClicked().getWorld().equals(world)) {
    event.setCancelled(true);
  }
}
 
Example 14
Project: HCFCore   File: BorderListener.java   View source code 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBucketEmpty(final PlayerBucketFillEvent event) {
    if (!isWithinBorder(event.getBlockClicked().getLocation())) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "You cannot fill buckets past the border.");
    }
}
 
Example 15
Project: HCFCore   File: BorderListener.java   View source code 5 votes vote down vote up
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onBucketEmpty(final PlayerBucketFillEvent event) {
    if (!isWithinBorder(event.getBlockClicked().getLocation())) {
        event.setCancelled(true);
        event.getPlayer().sendMessage(ChatColor.RED + "You cannot fill buckets past the border.");
    }
}
 
Example 16
Project: GamePlate   File: BuildHeightModule.java   View source code 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(), ChatConstant.ERROR_BUILD_HEIGHT, ChatUtil.HIGHLIGHT.toString() + height + ChatColor.GRAY.toString());
    }
}
 
Example 17
Project: AthenaGM   File: BlockBreakListener.java   View source code 5 votes vote down vote up
/**
 * Prevents buckets from being filled
 */
@EventHandler
public void onBucketFill(PlayerBucketFillEvent event) {
    CuboidRegion region = regionHandler.getApplicableRegion(event.getBlockClicked().getLocation());
    if (!event.isCancelled() && region != null && !region.allows("destroy")) {
        event.setCancelled(true);
        warnPlayer(event.getPlayer());
    }
}
 
Example 18
Project: CommunityDrivenPlugin   File: PlaceBreakListener.java   View source code 5 votes vote down vote up
public void onFill(PlayerBucketFillEvent e) {
    Player p = e.getPlayer();
    int prot = plugin.getSettings().getProtectedSpawnRadius();
    if (p.getWorld().getSpawnLocation().distance(p.getLocation()) < prot) {
        e.setCancelled(true);
        p.sendMessage(ColoringUtil.colorText("&cNie mozesz ingerowac w bloki na spawnie!"));
    }
}
 
Example 19
Project: Arcade2   File: BlockTransformListeners.java   View source code 5 votes vote down vote up
@EventHandler(ignoreCancelled = true)
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
    Block block = event.getBlockClicked().getRelative(event.getBlockFace());
    this.post(event,
              block.getState(),
              this.applyAir(block),
              event.getPlayer());
}
 
Example 20
Project: Cardinal   File: AppliedModule.java   View source code 5 votes vote down vote up
/**
 * Filters PlayerBucketFillEvent (removing a block of liquid).
 *
 * <p>Applies to: block and block break.<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBucketFill(PlayerBucketFillEvent event) {
  Match match = Cardinal.getMatch(event.getPlayer());
  if (match == null || !match.hasPlayer(event.getPlayer())) {
    return;
  }
  for (AppliedRegion reg : get(match, ApplyType.BLOCK, ApplyType.BLOCK_BREAK)) {
    Block evaluating = event.getBlockClicked();

    if (apply(reg, evaluating.getLocation(), event.getPlayer(), event, event, evaluating, event.getPlayer())) {
      break;
    }
  }
}
 
Example 21
Project: ExilePearl   File: ExileListener.java   View source code 5 votes vote down vote up
/**
 * Prevent exiled players from using buckets
 * @param e The event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerFillBucket(PlayerBucketFillEvent e) {
	if (e.getItemStack() != null && Material.MILK_BUCKET.equals(e.getItemStack().getType())) {
		checkAndCancelRule(ExileRule.MILK_COWS, e, e.getPlayer());
	} else {
		checkAndCancelRule(ExileRule.FILL_BUCKET, e, e.getPlayer());
	}
}
 
Example 22
Project: Cardinal-Plus   File: BuildHeight.java   View source code 5 votes vote down vote up
@EventHandler
public void onFillBucket(PlayerBucketFillEvent event) {
    if (TeamUtils.getTeamByPlayer(event.getPlayer()).isObserver() || match.getState() != MatchState.PLAYING)
        return;
    Block toEmpty = event.getBlockClicked().getRelative(event.getBlockFace());
    if (toEmpty.getY() >= height && !event.isCancelled()) {
        event.setCancelled(true);
        ChatUtils.sendWarningMessage(event.getPlayer(), "You have reached the maximum build height! " + ChatColor.GRAY + "(" + height + " blocks)");
    }
}
 
Example 23
Project: Cardinal-Plus   File: BlockBreakRegion.java   View source code 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);
        ChatUtils.sendWarningMessage(event.getPlayer(), message);
    }
}
 
Example 24
Project: Cardinal-Plus   File: BlockEventRegion.java   View source code 5 votes vote down vote up
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);
        ChatUtils.sendWarningMessage(event.getPlayer(), message);
    }
}
 
Example 25
Project: SurvivalCG   File: PlayerBucketListeners.java   View source code 5 votes vote down vote up
@EventHandler
public void onBucketTake(PlayerBucketFillEvent e) {
    if(e.getPlayer().hasPermission("scg.cuboid.bypassplace")) {
        return;
    }
    Player p = e.getPlayer();
    User user = plugin.getManager().getUserManager().getUsers().get(p.getName());
    Guild guild = user.getGuild();
    Cuboid cuboid = user.getCurrentCuboid();
    if (cuboid != null) {
        if (guild != null) {
            if (!user.getGuild().equals(cuboid.getGuild())) {
                p.sendMessage(plugin.getManager().getMsgManager().getMsg("enemyguildblockplace"));
                e.setCancelled(true);
            }
        } else {
            p.sendMessage(plugin.getManager().getMsgManager().getMsg("enemyguildblockplace"));
            e.setCancelled(true);
        }
        //Bukkit.broadcastMessage("Gracz "+p.getName()+" robi cos na cuboidzie "+cuboid.getGuild().getGuildTag());

    } else {
        if (p.getLocation().distance(p.getWorld().getSpawnLocation()) <= plugin.getManager().getSettingsManager().getProtectedSpawnRadius()) {
            p.sendMessage(plugin.getManager().getMsgManager().getMsg("spawnplacecantbreak"));
        }
    }
}
 
Example 26
Project: RedProtect   File: RPPlayerListener.java   View source code 5 votes vote down vote up
@EventHandler
public void onBucketFill(PlayerBucketFillEvent e){
   	if (e.isCancelled()) {
           return;
       }
   	Player p = e.getPlayer();
   	Location l = e.getBlockClicked().getLocation();
	Region r = RedProtect.get().rm.getTopRegion(l);	
	
   	if (r != null && !r.canBuild(p) && (p.getItemInHand().getType().name().contains("BUCKET"))) {
   		e.setCancelled(true);
       }
   }
 
Example 27
Project: Peacecraft   File: LotsListener.java   View source code 5 votes vote down vote up
@EventHandler
public void onPlayerBucketFill(PlayerBucketFillEvent event) {
    Block block = event.getBlockClicked();
    Lot lot = this.module.getLotManager().getLot(block.getLocation());
    Town town = this.module.getLotManager().getTown(block.getLocation());
    if(((lot != null && !lot.canBuild(event.getPlayer())) || (lot == null && town != null)) && !event.getPlayer().hasPermission(LotPermissions.BUILD_ANYWHERE)) {
        sendMessage(event.getPlayer(), "lots.cannot-do");
        event.setCancelled(true);
    }
}
 
Example 28
Project: acidisland   File: IslandGuard.java   View source code 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 29
Project: UltimateSurvivalGames   File: PlayerListener.java   View source code 5 votes vote down vote up
@EventHandler
public void onPlayerWaterPlace(PlayerBucketFillEvent event) {
	for(Game game : SurvivalGames.gameManager.getGames()) {
		for(Arena arena : game.getArenas()) {
			if(arena.containsBlock(event.getBlockClicked().getLocation()))
				event.setCancelled(true);
		}
	}
}
 
Example 30
Project: askyblock   File: IslandGuard.java   View source code 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 31
Project: The-Plague   File: ArenaListener.java   View source code 5 votes vote down vote up
@EventHandler
public void bucketFill(PlayerBucketFillEvent event) {
    if (ArenaUtils.isProtectedLobby(event.getBlockClicked().getLocation())) {
        event.setCancelled(Arenas.findCreatorByName(event.getPlayer().getName()) == null);
    }
    if (ArenaUtils.isProtected(event.getBlockClicked().getLocation()) && Arenas.getCurrentArena(event.getPlayer()) == null)
        event.setCancelled(Arenas.findCreatorByName(event.getPlayer().getName()) == null);
}
 
Example 32
Project: PlotMe-Core   File: BukkitPlotListener.java   View source code 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 33
Project: AntiBuild   File: BucketFill.java   View source code 5 votes vote down vote up
/**
     * Checks if a player has permission to fill a bucket.
     *
     * @param event that triggered the listener.
     */
    @EventHandler(priority = EventPriority.LOW)
    public void NoBucketFill(PlayerBucketFillEvent event) {

        Player player = event.getPlayer();

        // Bucket check
        if (!player.hasPermission("antibuild.bypass")) {
            if (!player.hasPermission("antibuild.bucket")) {
                int source = event.getBlockClicked().getTypeId();
                if ((source == 8 || source == 9)
                        && !player.hasPermission("antibuild.bucket.water")) {
                    event.setCancelled(true);
                    PlayerMessenger.messageHandler(plugin.getConfigHandler().getNoBucketMessage(), player);
                } else if ((source == 10 || source == 11)
                        && !player.hasPermission("antibuild.bucket.lava")) {
                    event.setCancelled(true);
                    PlayerMessenger.messageHandler(plugin.getConfigHandler().getNoBucketMessage(), player);
                }
            }
        }

//        // World lock check
//        if (!event.isCancelled() && plugin.isUsingLock()) {
//            if (plugin.isLockedWorld(player.getWorld().getName())
//                    && !player.hasPermission("antibuild.lock.bypass") && !player.hasPermission("antibuild.lock
// .bypass" +
//                    "." + player.getWorld().getName())) {
//                event.setCancelled(true);
//                messageHandler(plugin.getLockedWorldMessage(), player);
//            }
//        }
    }
 
Example 34
Project: PlotSquared   File: PlayerEvents.java   View source code 5 votes vote down vote up
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBucketFill(PlayerBucketFillEvent event) {
    Block b = event.getBlockClicked();
    Location location = BukkitUtil.getLocation(b.getLocation());
    PlotArea area = location.getPlotArea();
    if (area == null) {
        return;
    }
    Player player = event.getPlayer();
    PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
    Plot plot = area.getPlot(location);
    if (plot == null) {
        if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_ROAD)) {
            return;
        }
        MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_ROAD);
        event.setCancelled(true);
    } else if (!plot.hasOwner()) {
        if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
            return;
        }
        MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
        event.setCancelled(true);
    } else if (!plot.isAdded(plotPlayer.getUUID())) {
        Optional<HashSet<PlotBlock>> use = plot.getFlag(Flags.USE);
        Block block = event.getBlockClicked();
        if (use.isPresent() && use.get().contains(PlotBlock.get(block.getTypeId(), block.getData()))) {
            return;
        }
        if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
            return;
        }
        MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
        event.setCancelled(true);
    }
}
 
Example 35
Project: Bytecraft   File: ZoneListener.java   View source code 5 votes vote down vote up
@EventHandler
public void onFill(PlayerBucketFillEvent event)
{
    BytecraftPlayer player = plugin.getPlayer(event.getPlayer());
    Block block = event.getBlockClicked();
    
    boolean bool = player.hasBlockPermission(block.getLocation(), true);
    if(!bool){
        player.setFireTicks(20 * 2);
        event.setCancelled(true);
    }
}
 
Example 36
Project: CardinalPGM   File: BuildHeight.java   View source code 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 37
Project: CardinalPGM   File: BlockBreakRegion.java   View source code 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 38
Project: CardinalPGM   File: BlockEventRegion.java   View source code 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 39
Project: NPlugins   File: BuildFlagListener.java   View source code 5 votes vote down vote up
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerBucketFill(final PlayerBucketFillEvent event) {
    final GeneralRegion region = this.getPlugin().getDb().getPriorByLocation(event.getBlockClicked().getLocation());
    if (region != null && region.getFlag(Flag.BUILD) && !region.isUser(event.getPlayer())) {
        event.setCancelled(true);
    }
}
 
Example 40
Project: simple-survival-games   File: SSGPlayerListener.java   View source code 5 votes vote down vote up
@EventHandler
public void onPlayerBucketFillEvent(PlayerBucketFillEvent event) {
	Player p = event.getPlayer();
	ArenaManager am = SimpleSurvivalGames.instance.getArenaManager();
	
	// TODO: Is the player allowed to get water
	
	// Is the current player playing
	if(am.isInArena(p)) {
		ArenaPlayer ap = am.getPlayer(p);
		
		// Is the player in the lobby of the arena
		if(ap.isInLobby()) {
			
			// Has the player a arena spawn assigned
			if(ap.hasAssignedAreanSpawn()) {
				
				// Cancel the event and send a status message
				event.setCancelled(true);
				p.sendMessage(ChatColor.DARK_RED + "You may not dehumidify the lobby in the lobby of an arena!");
			}
		}

		// Is the player an spectators
		if(ap.isSpectator()) {
			event.setCancelled(true);
			ap.sendMessage(ChatColor.DARK_RED + "You can't use buckets while spectating!");
		}
	}
}