本文整理汇总了Java中org.bukkit.event.block.BlockDispenseEvent类的典型用法代码示例。如果您正苦于以下问题:Java BlockDispenseEvent类的具体用法?Java BlockDispenseEvent怎么用?Java BlockDispenseEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BlockDispenseEvent类属于org.bukkit.event.block包,在下文中一共展示了BlockDispenseEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onNetherDispenser
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
/**
* Prevents water from being dispensed in hell biomes
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW)
public void onNetherDispenser(final BlockDispenseEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!Util.inWorld(e.getBlock().getLocation()) || !e.getBlock().getBiome().equals(Biome.HELL)) {
return;
}
// plugin.getLogger().info("DEBUG: Item being dispensed is " +
// e.getItem().getType().toString());
if (e.getItem().getType().equals(Material.WATER_BUCKET)) {
e.setCancelled(true);
if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
} else {
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
}
}
}
示例2: onBlockDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@SuppressWarnings("deprecation")
public static void onBlockDispense(BlockDispenseEvent event) {
if( event.getBlock() != null && event.getBlock().getTypeId() == 23 )
{
//System.out.println("test1");
for (OneCannon onec : AimCannon.getCannons())
{
//System.out.println("test2");
if (onec.isThisCannon(event.getBlock().getLocation(), true))
{
//System.out.println("test3");
event.setCancelled(true);
return;
}
}
}
}
示例3: onBlockDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent e) {
if (!cm.isAntiNegativeItemDupe) {
return;
}
Inventory content = null;
if (e.getBlock().getState() instanceof InventoryHolder) {
content = ((InventoryHolder) e.getBlock().getState()).getInventory();
}
if (content == null || content.getSize() == 0) {
return;
}
for (ItemStack item : content.getContents()) {
if (item != null && item.getType() != Material.AIR) {
if (item.getAmount() <= 0) {
item.setType(Material.AIR);
}
}
}
}
示例4: onBlockDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent event) {
if (!this.isBucket(event.getItem().getType())) {
return;
}
Block target = event.getVelocity().toLocation(
event.getWorld()).getBlock();
Material content = this.getBucketContent(event.getItem().getType());
if (!content.equals(Material.AIR)) {
this.post(event,
target.getState(),
this.applyState(target, content));
}
}
示例5: onBlockDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
/**
* Handles players breaking join signs
*
* @param e an event indicating that a block has dispensed an item
* @see BlockDispenseEvent
* @since 4.0.4
*/
@EventHandler(ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent e) {
Location location = e.getBlock().getLocation();
for (Arena arena : ArenaManager.getInstance().getArenas()) {
for (Plot plot : arena.getPlots()) {
Region boundary = plot.getBoundary();
if (boundary == null)
continue;
if (boundary.isInside(location)) {
e.setCancelled(true);
return;
}
}
}
}
示例6: onBlockDispenseEvent
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL)
public void onBlockDispenseEvent(BlockDispenseEvent event) {
ItemStack stack = event.getItem();
if (stack != null) {
if (event.getItem().getType().equals(Material.POTION)) {
int effect = event.getItem().getDurability() & 0x000F;
if (effect == 0xE) {
event.setCancelled(true);
return;
}
}
if (event.getItem().getType().equals(Material.INK_SACK)) {
//if (event.getItem().getDurability() == 15) {
event.setCancelled(true);
return;
//}
}
}
}
示例7: onNetherDispenser
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
/**
* Prevents water from being dispensed in hell biomes
*
* @param e
*/
@EventHandler(priority = EventPriority.LOW)
public void onNetherDispenser(final BlockDispenseEvent e) {
if (DEBUG) {
plugin.getLogger().info(e.getEventName());
}
if (!inWorld(e.getBlock().getLocation()) || !e.getBlock().getBiome().equals(Biome.HELL)) {
return;
}
// plugin.getLogger().info("DEBUG: Item being dispensed is " +
// e.getItem().getType().toString());
if (e.getItem().getType().equals(Material.WATER_BUCKET)) {
e.setCancelled(true);
if (plugin.getServer().getVersion().contains("(MC: 1.8") || plugin.getServer().getVersion().contains("(MC: 1.7")) {
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.valueOf("FIZZ"), 1F, 2F);
} else {
e.getBlock().getWorld().playSound(e.getBlock().getLocation(), Sound.ENTITY_CREEPER_PRIMED, 1F, 2F);
}
}
}
示例8: onBlockDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventHandler
public void onBlockDispense(BlockDispenseEvent event) {
if (event.getBlock().getType() == Material.DISPENSER) {
Dispenser diq = (Dispenser) event.getBlock().getState();
Block maybeSign = event
.getBlock()
.getWorld()
.getBlockAt(event.getBlock().getX(),
event.getBlock().getY() - 1,
event.getBlock().getZ()); // TODO
if (maybeSign.getState() instanceof Sign) {
if (plugin.isUnlimitedSign(((Sign) maybeSign.getState())
.getLine(0))) {
diq.getInventory().addItem(new ItemStack(event.getItem()));
}
}
}
}
示例9: onPower
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventHandler
public void onPower(BlockDispenseEvent e) {
if(e.getBlock().getType() == Material.DISPENSER) {
if(hasNearbySign(e.getBlock())) {
org.bukkit.block.Sign sign = getSign(e.getBlock());
if(sign.getLine(0).equalsIgnoreCase(ChatColor.BLUE + "[Dispense]")) {
Dispenser disp = (Dispenser) e.getBlock().getState();
for(ItemStack stack : disp.getInventory().getContents()) {
if(stack != null) {
ItemStack clone = stack.clone();
clone.setAmount(64);
disp.getInventory().addItem(clone);
}
}
}
}
}
}
示例10: onDispenserDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventWrapper
public void onDispenserDispense(final BlockDispenseEvent event) {
if(Materials.isBucket(event.getItem())) {
// Yes, the location the dispenser is facing is stored in "velocity" for some ungodly reason
Block targetBlock = event.getVelocity().toLocation(event.getBlock().getWorld()).getBlock();
Material contents = Materials.materialInBucket(event.getItem());
if(Materials.isLiquid(contents) || (contents == Material.AIR && targetBlock.isLiquid())) {
callEvent(event, targetBlock.getState(), BlockStateUtils.cloneWithMaterial(targetBlock, contents), blockResolver.getOwner(event.getBlock()));
}
}
}
示例11: onArmorDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventHandler
public void onArmorDispense(BlockDispenseEvent event) {
// This covers armor being equipped by a dispenser, which does not call any of the other events
ItemStack stack = event.getItem();
if(applyRules(stack)) {
event.setItem(stack);
}
}
示例12: onBlockDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockDispense(final BlockDispenseEvent event) {
if (!event.isCancelled()) {
if (PermissionInterface.CheckEnabledWorld(event.getBlock().getLocation()) && (event.getItem().getType() == Material.EMERALD)) {
event.setCancelled(true);
}
}
if(!event.isCancelled())
AimCannonPlayerListener.onBlockDispense(event);
}
示例13: onDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onDispense(BlockDispenseEvent dispenseEvent)
{
//don't track in worlds where claims are not enabled
if(!GriefPrevention.instance.claimsEnabledForWorld(dispenseEvent.getBlock().getWorld())) return;
//from where?
Block fromBlock = dispenseEvent.getBlock();
Dispenser dispenser = new Dispenser(fromBlock.getType(), fromBlock.getData());
//to where?
Block toBlock = fromBlock.getRelative(dispenser.getFacing());
Claim fromClaim = this.dataStore.getClaimAt(fromBlock.getLocation(), false, null);
Claim toClaim = this.dataStore.getClaimAt(toBlock.getLocation(), false, fromClaim);
//into wilderness is NOT OK in creative mode worlds
Material materialDispensed = dispenseEvent.getItem().getType();
if((materialDispensed == Material.WATER_BUCKET || materialDispensed == Material.LAVA_BUCKET) && GriefPrevention.instance.creativeRulesApply(dispenseEvent.getBlock().getLocation()) && toClaim == null)
{
dispenseEvent.setCancelled(true);
return;
}
//wilderness to wilderness is OK
if(fromClaim == null && toClaim == null) return;
//within claim is OK
if(fromClaim == toClaim) return;
//everything else is NOT OK
dispenseEvent.setCancelled(true);
}
示例14: b
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
public ItemStack b(ISourceBlock isourceblock, ItemStack itemstack) {
World world = isourceblock.k();
IPosition iposition = BlockDispenser.a(isourceblock);
EnumFacing enumfacing = BlockDispenser.b(isourceblock.h());
IProjectile iprojectile = this.a(world, iposition);
// CraftBukkit start
ItemStack itemstack1 = itemstack.a(1);
org.bukkit.block.Block block = world.getWorld().getBlockAt(isourceblock.getBlockX(), isourceblock.getBlockY(), isourceblock.getBlockZ());
CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.getAdjacentX(), (double) ((float) enumfacing.getAdjacentY() + 0.1F), (double) enumfacing.getAdjacentZ()));
if (!BlockDispenser.eventFired) {
world.getServer().getPluginManager().callEvent(event);
}
if (event.isCancelled()) {
itemstack.count++;
return itemstack;
}
if (!event.getItem().equals(craftItem)) {
itemstack.count++;
// Chain to handler for new item
ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
IDispenseBehavior idispensebehavior = (IDispenseBehavior) BlockDispenser.a.get(eventStack.getItem());
if (idispensebehavior != IDispenseBehavior.a && idispensebehavior != this) {
idispensebehavior.a(isourceblock, eventStack);
return itemstack;
}
}
iprojectile.shoot(event.getVelocity().getX(), event.getVelocity().getY(), event.getVelocity().getZ(), this.b(), this.a());
((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) isourceblock.getTileEntity());
// CraftBukkit end
world.addEntity((Entity) iprojectile);
// itemstack.a(1); // CraftBukkit - Handled during event processing
return itemstack;
}
示例15: onDispense
import org.bukkit.event.block.BlockDispenseEvent; //导入依赖的package包/类
/**
* Prevents the tipping of liquids over the beacon using a dispenser
* @param event
*/
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true)
public void onDispense(final BlockDispenseEvent event) {
if (DEBUG)
getLogger().info("DEBUG: " + event.getEventName());
World world = event.getBlock().getWorld();
if (!world.equals(getBeaconzWorld())) {
return;
}
if (DEBUG)
getLogger().info("DEBUG: " + event.getItem().getType());
if (!event.getItem().getType().equals(Material.WATER_BUCKET) && !event.getItem().getType().equals(Material.LAVA_BUCKET)) {
return;
}
if (DEBUG)
getLogger().info("DEBUG: " + event.getBlock().getType());
if (!event.getBlock().getType().equals(Material.DISPENSER)) {
return;
}
Dispenser dispenser = (Dispenser)event.getBlock().getState().getData();
Block b = event.getBlock().getRelative(dispenser.getFacing());
if (DEBUG)
getLogger().info("DEBUG: " + b.getLocation());
if (getRegister().isAboveBeacon(b.getLocation())) {
world.playSound(b.getLocation(), Sound.BLOCK_STONE_BREAK, 1F, 2F);
event.setCancelled(true);
}
}