當前位置: 首頁>>代碼示例>>Java>>正文


Java PlayerBucketEmptyEvent.getBlockClicked方法代碼示例

本文整理匯總了Java中org.bukkit.event.player.PlayerBucketEmptyEvent.getBlockClicked方法的典型用法代碼示例。如果您正苦於以下問題:Java PlayerBucketEmptyEvent.getBlockClicked方法的具體用法?Java PlayerBucketEmptyEvent.getBlockClicked怎麽用?Java PlayerBucketEmptyEvent.getBlockClicked使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.event.player.PlayerBucketEmptyEvent的用法示例。


在下文中一共展示了PlayerBucketEmptyEvent.getBlockClicked方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onBucketEmpty

import org.bukkit.event.player.PlayerBucketEmptyEvent; //導入方法依賴的package包/類
/**
 * Filters PlayerBucketEmptyEvent (placing down a block of liquid).
 *
 * <p>Applies to: block, block place and block place against.<p/>
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
  Match match = Cardinal.getMatch(event.getPlayer());
  if (match == null || !match.hasPlayer(event.getPlayer())) {
    return;
  }
  for (AppliedRegion reg : get(match, ApplyType.BLOCK, ApplyType.BLOCK_PLACE, ApplyType.BLOCK_PLACE_AGAINST)) {
    Block evaluating = reg.isType(ApplyType.BLOCK_PLACE_AGAINST)
        ? event.getBlockClicked() : event.getBlockClicked().getRelative(event.getBlockFace());

    if (apply(reg, evaluating.getLocation(), event.getPlayer(), event,
        event, getBucketResult(event.getBucket()), event.getPlayer())) {
      break;
    }
  }
}
 
開發者ID:CardinalDevelopment,項目名稱:Cardinal,代碼行數:22,代碼來源:AppliedModule.java

示例2: onPlayerBucketEmpty

import org.bukkit.event.player.PlayerBucketEmptyEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event) {
	if (event.isCancelled())
		return;

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

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

	if (nearestGate != null || nearestGateUp != null) {
		event.setCancelled(true);
	}
}
 
開發者ID:NoChanceSD,項目名稱:AncientGates,代碼行數:20,代碼來源:PluginBlockListener.java

示例3: onPlayerEmptyBucket

import org.bukkit.event.player.PlayerBucketEmptyEvent; //導入方法依賴的package包/類
/**
 * Prevent exiled players from using buckets
 * @param e The event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerEmptyBucket(PlayerBucketEmptyEvent e) {
	if (e.getBlockClicked() != null && Material.CAULDRON.equals(e.getBlockClicked().getType())) {
		checkAndCancelRule(ExileRule.FILL_CAULDRON, e, e.getPlayer());
	} else {
		checkAndCancelRule(ExileRule.USE_BUCKET, e, e.getPlayer());
	}
}
 
開發者ID:DevotedMC,項目名稱:ExilePearl,代碼行數:13,代碼來源:ExileListener.java

示例4: onFluidPlaced

import org.bukkit.event.player.PlayerBucketEmptyEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
  public void onFluidPlaced(PlayerBucketEmptyEvent event)
  {
Block block = event.getBlockClicked();
Chunk blockChunk = block.getChunk();
if (config.getClaimed(blockChunk))
{
	if(!config.isTrusted(blockChunk, event.getPlayer()))
	{
	event.getPlayer().sendMessage("This chunk is claimed by: "+config.getConfig().getString(LocationHandeler.toConfigHandler(blockChunk)+".owner")+" thus you cant empty buckets here.");
	event.setCancelled(true);
	}
}

  }
 
開發者ID:jediminer543,項目名稱:Plugin,代碼行數:16,代碼來源:ClaimListener.java

示例5: onEmpty

import org.bukkit.event.player.PlayerBucketEmptyEvent; //導入方法依賴的package包/類
@EventHandler
public void onEmpty(PlayerBucketEmptyEvent 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);
    }
}
 
開發者ID:sabersamus,項目名稱:Bytecraft,代碼行數:13,代碼來源:ZoneListener.java

示例6: onPlayerBucketEmptyEvent

import org.bukkit.event.player.PlayerBucketEmptyEvent; //導入方法依賴的package包/類
/**
 * Checks the player is allowed to empty the bucket.
 *
 * @param event     event being handled
 */
@EventHandler (priority = EventPriority.HIGH, ignoreCancelled = true)
public void onPlayerBucketEmptyEvent(PlayerBucketEmptyEvent event) {
    final Player player = event.getPlayer();
    final Block block = event.getBlockClicked();
    if (!canBuild(player, block)) {
        final Town town = plugin.getTown(block.getChunk());
        if (town == null) {
            player.sendMessage(plugin.getLocalisation().get(LocalisationEntry.MSG_CANNOT_BUILD_HERE));
        } else {
            player.sendMessage(plugin.getLocalisation().get(LocalisationEntry.MSG_ONLY_TOWN_MEMBERS_CAN_PLACE_BLOCKS, town.getName()));
        }
        event.setCancelled(true);
    }
}
 
開發者ID:JamesHealey94,項目名稱:SimpleTowns,代碼行數:20,代碼來源:STListener.java

示例7: onBucketEmpty

import org.bukkit.event.player.PlayerBucketEmptyEvent; //導入方法依賴的package包/類
/**
 * Prevents emptying of buckets outside of island space
 * @param e
 */
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onBucketEmpty(final PlayerBucketEmptyEvent e) {
    if (DEBUG) {
        plugin.getLogger().info(e.getEventName());
    }
    if (Util.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(), plugin.getLocale(e.getPlayer().getUniqueId()).get("biome.set").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(), plugin.getLocale(e.getPlayer().getUniqueId()).get("biome.set").replace("[biome]", "Nether"));
                        }
                    }
                }
                return;
            }
            // Not allowed
            Util.sendMessage(p, plugin.getLocale(p.getUniqueId()).get("island.protected"));
            e.setCancelled(true);
        }
    }
}
 
開發者ID:tastybento,項目名稱:bskyblock,代碼行數:46,代碼來源:IslandGuard.java

示例8: onBucketEmpty

import org.bukkit.event.player.PlayerBucketEmptyEvent; //導入方法依賴的package包/類
/**
 * Prevents emptying of buckets outside of island space
 * @param e
 */
@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);
        }
    }
}
 
開發者ID:tastybento,項目名稱:acidisland,代碼行數:46,代碼來源:IslandGuard.java


注:本文中的org.bukkit.event.player.PlayerBucketEmptyEvent.getBlockClicked方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。