本文整理汇总了Java中org.bukkit.Material.TNT属性的典型用法代码示例。如果您正苦于以下问题:Java Material.TNT属性的具体用法?Java Material.TNT怎么用?Java Material.TNT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.bukkit.Material
的用法示例。
在下文中一共展示了Material.TNT属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTNTChain
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTNTChain(EntityExplodeEvent event) {
if(!this.tracker.isEnabled(event.getEntity().getWorld())) return;
// Transfer ownership to chain-activated TNT
if(event.getEntity() instanceof TNTPrimed) {
Player owner = this.tracker.setOwner((TNTPrimed) event.getEntity(), null);
if(owner != null) {
for(Block block : event.blockList()) {
if(block.getType() == Material.TNT) {
this.tracker.setPlacer(block, owner);
}
}
}
}
}
示例2: onBlockPlace
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
if (Walls.getSpectators().contains(event.getPlayer().getName())) {
event.setCancelled(true);
return;
}
if (State.PVP)
return;
Block b = event.getBlock();
if (b.getType()==Material.TNT && !State.PVP) {
Chat.player(event.getPlayer(), "&cYou are not allowed to use TNT before the walls drop!");
event.setCancelled(true);
}
Team team = Team.getTeam(event.getPlayer());
if (b.getX() < team.getMin().getX() + 1 || b.getZ() < team.getMin().getZ() + 1) {
event.setCancelled(true);
}
if (b.getX() > team.getMax().getX() - 1 || b.getZ() > team.getMax().getZ() - 1) {
event.setCancelled(true);
}
}
示例3: onBlockPlace
/**
* Handle Towers
*
* @param event Event
*/
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
/*if (this.game.isPvPActivated() && event.getBlockPlaced().getY() > event.getBlock().getWorld().getHighestBlockYAt(event.getBlockPlaced().getX(), event.getBlockPlaced().getZ()) + 15)
{
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.DARK_RED + "[" + ChatColor.RED + "Tours" + ChatColor.DARK_RED + "] " + ChatColor.RED + "Les Tours sont interdites !");
return;
}*/
if (!this.game.isPvPActivated() && event.getBlock().getType() == Material.TNT)
{
event.setCancelled(true);
event.getPlayer().sendMessage(ChatColor.RED + "Vous ne pouvez pas utiliser de la TNT tant que le PvP est désactivé !");
}
}
示例4: onBlockPlace
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockPlace(BlockPlaceEvent event) {
if(!this.tracker.isEnabled(event.getBlock().getWorld())) return;
if(event.getBlock().getType() == Material.TNT) {
this.tracker.setPlacer(event.getBlock(), event.getPlayer());
}
}
示例5: handleInstantActivation
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void handleInstantActivation(BlockPlaceEvent event) {
if(this.properties.instantIgnite && event.getBlock().getType() == Material.TNT) {
World world = event.getBlock().getWorld();
TNTPrimed tnt = world.spawn(BlockUtils.base(event.getBlock()), TNTPrimed.class);
if(this.properties.fuse != null) {
tnt.setFuseTicks(this.getFuseTicks());
}
if(this.properties.power != null) {
tnt.setYield(this.properties.power); // Note: not related to EntityExplodeEvent.yield
}
if(callPrimeEvent(tnt, event.getPlayer(), true)) {
// Only cancel the block placement if the prime event is NOT cancelled.
// If priming is cancelled, the block is allowed to stay (unless some
// other handler has already cancelled the place event).
event.setCancelled(true);
world.playSound(tnt.getLocation(), Sound.ENTITY_TNT_PRIMED, 1, 1);
ItemStack inHand = event.getItemInHand();
if(inHand.getAmount() == 1) {
inHand = null;
} else {
inHand.setAmount(inHand.getAmount() - 1);
}
event.getPlayer().getInventory().setItem(event.getHand(), inHand);
}
}
}
示例6: dispenserNukes
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void dispenserNukes(BlockTransformEvent event) {
BlockState oldState = event.getOldState();
if(oldState instanceof Dispenser &&
this.properties.dispenserNukeLimit > 0 &&
this.properties.dispenserNukeMultiplier > 0 &&
event.getCause() instanceof EntityExplodeEvent) {
EntityExplodeEvent explodeEvent = (EntityExplodeEvent) event.getCause();
Dispenser dispenser = (Dispenser) oldState;
int tntLimit = Math.round(this.properties.dispenserNukeLimit / this.properties.dispenserNukeMultiplier);
int tntCount = 0;
for(ItemStack stack : dispenser.getInventory().contents()) {
if(stack != null && stack.getType() == Material.TNT) {
int transfer = Math.min(stack.getAmount(), tntLimit - tntCount);
if(transfer > 0) {
stack.setAmount(stack.getAmount() - transfer);
tntCount += transfer;
}
}
}
tntCount = (int) Math.ceil(tntCount * this.properties.dispenserNukeMultiplier);
for(int i = 0; i < tntCount; i++) {
TNTPrimed tnt = this.getMatch().getWorld().spawn(BlockUtils.base(dispenser), TNTPrimed.class);
tnt.setFuseTicks(10 + this.getMatch().getRandom().nextInt(10)); // between 0.5 and 1.0 seconds, same as vanilla TNT chaining
Random random = this.getMatch().getRandom();
Vector velocity = new Vector(random.nextGaussian(), random.nextGaussian(), random.nextGaussian()); // uniform random direction
velocity.normalize().multiply(0.5 + 0.5 * random.nextDouble());
tnt.setVelocity(velocity);
callPrimeEvent(tnt, explodeEvent.getEntity(), false);
}
}
}
示例7: onPrimeTNT
@EventWrapper
public void onPrimeTNT(ExplosionPrimeEvent event) {
if(event.getEntity() instanceof TNTPrimed && !(event instanceof InstantTNTPlaceEvent)) {
Block block = event.getEntity().getLocation().getBlock();
if(block.getType() == Material.TNT) {
ParticipantState player;
if(event instanceof ExplosionPrimeByEntityEvent) {
player = entityResolver.getOwner(((ExplosionPrimeByEntityEvent) event).getPrimer());
} else {
player = null;
}
callEvent(event, block.getState(), BlockStateUtils.toAir(block), player);
}
}
}
示例8: onEntityExplode
@EventWrapper
public void onEntityExplode(final EntityExplodeEvent event) {
ParticipantState playerState = entityResolver.getOwner(event.getEntity());
for(Block block : event.blockList()) {
if(block.getType() != Material.TNT) {
// Don't cancel the explosion when individual blocks are cancelled
callEvent(event, block.getState(), BlockStateUtils.toAir(block), playerState).setPropagateCancel(false);
}
}
}
示例9: onEntityChangeBlock
@EventWrapper
public void onEntityChangeBlock(final EntityChangeBlockEvent event) {
// Igniting TNT with an arrow is already handled from the ExplosionPrimeEvent
if(event.getEntity() instanceof Arrow &&
event.getBlock().getType() == Material.TNT &&
event.getTo() == Material.AIR) return;
callEvent(event, event.getBlock().getState(), BlockStateUtils.cloneWithMaterial(event.getBlock(), event.getToData()), entityResolver.getOwner(event.getEntity()));
}
示例10: onThrowTNT
@EventHandler
public void onThrowTNT(PlayerInteractEvent event) {
Player p = event.getPlayer();
Gamer g = Gamer.get(p.getName());
if (g.getVariable("spectator") != null)
return;
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
if (p.getItemInHand().getType() == Material.TNT) {
// Frag Grenades
TNTPrimed e = (TNTPrimed) event.getPlayer().getWorld().spawnEntity(p.getEyeLocation(), EntityType.PRIMED_TNT);
e.setFuseTicks(38);
e.setYield(2.5F);
e.setVelocity(event.getPlayer().getEyeLocation().getDirection());
e.setMetadata("Player", new FixedMetadataValue(Nexus.getPlugin(), g.getPlayer().getName()));
e.setMetadata("Cause", new FixedMetadataValue(Nexus.getPlugin(), CustomDamageCause.TNT_GRENADE.name()));
event.setUseItemInHand(Event.Result.DENY);
ItemStack stack = null;
if (event.getItem().getAmount() > 1) {
ItemStack s = event.getItem();
s.setAmount(event.getItem().getAmount() - 1);
stack = s;
}
p.getInventory().setItem(p.getInventory().getHeldItemSlot(), stack);
event.setCancelled(true);
}
}
}
示例11: onBlockPlace
/**
* Fire the TNT's automatically
*
* @param event Event
*/
@EventHandler
public void onBlockPlace(BlockPlaceEvent event)
{
if (this.game != null && this.game.isPvPActivated() && event.getBlock().getType() == Material.TNT)
{
event.getBlock().setType(Material.AIR);
TNTPrimed tnt = event.getBlock().getWorld().spawn(event.getBlock().getLocation(), TNTPrimed.class);
tnt.setFuseTicks(tnt.getFuseTicks() / 2);
}
}
示例12: registerRunes
private void registerRunes() {
Rune rune;
rune = new Rune("Freeze", Material.ICE, 15, -1);
rune.addDescription(ChatColor.GRAY + "Freezes target");
rune.addDescription(ChatColor.GRAY + "Range: " + ChatColor.RED + "10 blocks");
rune.addDescription(ChatColor.GRAY + "Freeze duration: " + ChatColor.RED + "3 second");
runes.add(rune);
rune = new Rune("Fire Storm", Material.BLAZE_POWDER, 25, 30);
rune.addDescription(ChatColor.GRAY + "Sets everyone around on fire");
rune.addDescription(ChatColor.GRAY + "Range: " + ChatColor.RED + "2 blocks");
rune.addDescription(ChatColor.GRAY + "Burning duration: " + ChatColor.RED + "2 seconds");
runes.add(rune);
rune = new Rune("Slowdown", Material.WEB, 15, 30);
rune.addDescription(ChatColor.GRAY + "Slows everyone around");
rune.addDescription(ChatColor.GRAY + "Range: " + ChatColor.RED + "3 blocks");
rune.addDescription(ChatColor.GRAY + "Slow Level: " + ChatColor.RED + "I");
rune.addDescription(ChatColor.GRAY + "Slow duration: " + ChatColor.RED + "5 seconds");
runes.add(rune);
rune = new Rune("Invisibility", Material.GRASS, 10, 5);
rune.addDescription(ChatColor.GRAY + "Gives uninterruptible invisibility");
runes.add(rune);
rune = new Rune("Lightning", Material.FIREWORK, 15, -1);
rune.addDescription(ChatColor.GRAY + "Strikes lightning at target position");
rune.addDescription(ChatColor.GRAY + "Range: " + ChatColor.RED + "20 blocks");
rune.addDescription(ChatColor.GRAY + "Damage: " + ChatColor.RED + "5 hearts");
runes.add(rune);
rune = new Rune("Detonate", Material.TNT, 20, -1);
rune.addDescription(ChatColor.GRAY + "Strikes explosion at your location");
rune.addDescription(ChatColor.GRAY + "Explosion range: " + ChatColor.RED + "4 blocks");
rune.addDescription(ChatColor.GRAY + "Damage: " + ChatColor.RED + "3 hearts");
runes.add(rune);
}
示例13: onPlace
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onPlace(ParticipantBlockTransformEvent event) {
if(event.getNewState().getMaterial() == Material.TNT) {
blocks().trackBlockState(event.getNewState(), new TNTInfo(event.getPlayerState(), event.getNewState().getLocation()));
}
}