本文整理匯總了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;
}
}
}
示例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);
}
}
示例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());
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
}
示例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);
}
}
}