本文整理汇总了Java中org.bukkit.entity.TNTPrimed类的典型用法代码示例。如果您正苦于以下问题:Java TNTPrimed类的具体用法?Java TNTPrimed怎么用?Java TNTPrimed使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TNTPrimed类属于org.bukkit.entity包,在下文中一共展示了TNTPrimed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onTNTChain
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
@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: clear
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
public void clear(@Nonnull World world) {
Preconditions.checkNotNull(world, "world");
// clear information about blocks in that world
for(Iterator<Map.Entry<Block, Player>> it = this.placedBlocks.entrySet().iterator(); it.hasNext(); ) {
Block block = it.next().getKey();
if(block.getWorld().equals(world)) {
it.remove();
}
}
// clear information about entities in that world
for(Iterator<Map.Entry<TNTPrimed, Player>> it = this.ownedTNTs.entrySet().iterator(); it.hasNext(); ) {
TNTPrimed tnt = it.next().getKey();
if(tnt.getWorld().equals(world)) {
it.remove();
}
}
}
示例3: resolve
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
if(damageEvent instanceof EntityDamageByEntityEvent) {
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) damageEvent;
if(event.getDamager() instanceof TNTPrimed) {
TNTPrimed tnt = (TNTPrimed) event.getDamager();
Player owner = null;
if(this.explosiveTracker.hasOwner(tnt)) {
owner = this.explosiveTracker.getOwner(tnt);
} else if(this.dispenserTracker.hasOwner(tnt)) {
// getPlayer() is temporary to keep owner uniform until other services use OfflinePlayer
owner = this.dispenserTracker.getOwner(tnt).getPlayer();
}
return new TNTDamageInfo(tnt, owner);
}
}
return null;
}
示例4: spawn
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
public void spawn() {
Location location = data.region().getRandom(match.getRandom()).toLocation(world);
effects(Sound.BLOCK_NOTE_BASEDRUM, Particle.CLOUD);
Entity entity = world.spawn(location, (Class) data.appearance().getEntityClass());
entity.setKnockbackReduction(1);
data.name().ifPresent(name -> {
entity.setCustomName(ChatColor.translateAlternateColorCodes('`', name));
entity.setCustomNameVisible(true);
});
switch(data.appearance()) { // TODO: Support more appearances later
case ENDER_CRYSTAL:
ifInstance(entity, EnderCrystal.class, crystal -> crystal.setShowingBottom(false)); break;
case PRIMED_TNT:
ifInstance(entity, TNTPrimed.class, tnt -> tnt.setFuseTicks(Integer.MAX_VALUE)); break;
}
this.entity = Optional.of(entity);
spawnAt = Optional.empty();
}
示例5: onBlockBreak
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
/**
* Spawns a creeper or primed TNT when a player breaks an ore block, by chance.
*
* @param event The event
*/
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
Block block = event.getBlock();
if (ORES.contains(block.getType())) {
double chance = Math.random();
Location location = block.getLocation().add(0.5, 0.5, 0.5);
if (0.05 > chance) {
TNTPrimed tnt = location.getWorld().spawn(location, TNTPrimed.class);
tnt.setFuseTicks(80);
} else if (0.1 > chance) {
Creeper creeper = location.getWorld().spawn(location, Creeper.class);
creeper.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 2));
}
}
}
示例6: onEntityExplode
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
if (event.getEntity() != null) {
if (event.getEntity().getType() == EntityType.PRIMED_TNT) {
for (Block block : event.blockList()) {
if (block.getType() == Material.TNT && getWhoPlaced(event.getEntity()) != null) {
Location location = block.getLocation();
tntPlaced.put(location.getBlockX() + "," + location.getBlockY() + "," + location.getBlockZ(), getWhoPlaced(event.getEntity()));
}
}
for (Entity entity : event.getEntity().getNearbyEntities(8, 8, 8)) {
// F.debug("Found tnt");
if (entity instanceof TNTPrimed) {
UUID playerUUID = getWhoPlaced(event.getEntity());
if(playerUUID != null) {
Dispenser dispenser;
// F.debug("found placer: " + Bukkit.getServer().getPlayer(playerUUID));
entity.setMetadata("source", new FixedMetadataValue(GamePlate.getInstance(), playerUUID));
}
}
}
}
}
}
示例7: onExplosionPrime
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) {
if (event.getEntity() instanceof TNTPrimed) {
Block block = event.getEntity().getLocation().getBlock();
if (!block.getType().equals(Material.TNT)) {
return;
}
Player player = null;
if (event instanceof ExplosionPrimeByEntityEvent) {
ExplosionPrimeByEntityEvent primeByEntity =
(ExplosionPrimeByEntityEvent) event;
Entity entity = primeByEntity.getPrimer();
if (entity instanceof Player) {
player = (Player) entity;
}
}
this.post(event,
block.getState(),
this.applyAir(block), player);
}
}
示例8: change
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
@Override
public void change(Event e, Object[] delta, Changer.ChangeMode mode){
if (entity.getSingle(e) instanceof TNTPrimed) {
Number ticks = (Number)delta[0];
Number ticksNow = ((TNTPrimed)entity.getSingle(e)).getFuseTicks();
if (mode == ChangeMode.SET) {
((TNTPrimed)entity.getSingle(e)).setFuseTicks(ticks.intValue());
} else if (mode == ChangeMode.ADD) {
((TNTPrimed)entity.getSingle(e)).setFuseTicks(ticksNow.intValue() + ticks.intValue());
} else if (mode == ChangeMode.REMOVE) {
((TNTPrimed)entity.getSingle(e)).setFuseTicks(ticksNow.intValue() - ticks.intValue());
}
} else {
return;
}
}
示例9: onEntityExplodeEvent
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onEntityExplodeEvent(EntityExplodeEvent event) {
AttackType attackType = AttackType.UNKNOWN;
Entity attacker = event.getEntity();
if (attacker instanceof TNTPrimed) {
attackType = AttackType.TNT;
} else if (attacker instanceof Creeper) {
attackType = AttackType.CREEPER;
} else if (attacker instanceof Fireball) {
if (((Fireball) attacker).getShooter() instanceof Ghast) {
attackType = AttackType.GHAST;
}
}
if (plugin.getChestSettings().allowDestroyBy(attackType)) {
return;
}
for (Iterator<Block> it = event.blockList().iterator(); it.hasNext();) {
Block block = it.next();
if (isProtected(block)) {
it.remove();
}
}
}
示例10: remoteDetonation
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
/**
* Detonate TNT for Blast Mining
*/
public void remoteDetonation() {
Player player = getPlayer();
Block targetBlock = player.getTargetBlock(BlockUtils.getTransparentBlocks(), BlastMining.MAXIMUM_REMOTE_DETONATION_DISTANCE);
if (targetBlock.getType() != Material.TNT || !EventUtils.simulateBlockBreak(targetBlock, player, true) || !blastMiningCooldownOver()) {
return;
}
TNTPrimed tnt = player.getWorld().spawn(targetBlock.getLocation(), TNTPrimed.class);
SkillUtils.sendSkillMessage(player, AbilityType.BLAST_MINING.getAbilityPlayer(player));
player.sendMessage(LocaleLoader.getString("Mining.Blast.Boom"));
tnt.setMetadata(mcMMO.tntMetadataKey, mcMMOPlayer.getPlayerMetadata());
tnt.setFuseTicks(0);
targetBlock.setType(Material.AIR);
mcMMOPlayer.setAbilityDATS(AbilityType.BLAST_MINING, System.currentTimeMillis());
mcMMOPlayer.setAbilityInformed(AbilityType.BLAST_MINING, false);
new AbilityCooldownTask(mcMMOPlayer, AbilityType.BLAST_MINING).runTaskLaterAsynchronously(mcMMO.p, AbilityType.BLAST_MINING.getCooldown() * Misc.TICK_CONVERSION_FACTOR);
}
示例11: onExplosionPrime
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
/**
* Handle ExplosionPrime events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onExplosionPrime(ExplosionPrimeEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
return;
}
// We can make this assumption because we (should) be the only ones using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBiggerBombs()) {
event.setRadius(miningManager.biggerBombs(event.getRadius()));
}
}
示例12: onEnitityExplode
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
/**
* Handle EntityExplode events that involve modifying the event.
*
* @param event The event to modify
*/
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onEnitityExplode(EntityExplodeEvent event) {
Entity entity = event.getEntity();
if (!(entity instanceof TNTPrimed) || !entity.hasMetadata(mcMMO.tntMetadataKey)) {
return;
}
// We can make this assumption because we (should) be the only ones using this exact metadata
Player player = plugin.getServer().getPlayerExact(entity.getMetadata(mcMMO.tntMetadataKey).get(0).asString());
if (!UserManager.hasPlayerDataKey(player)) {
return;
}
MiningManager miningManager = UserManager.getPlayer(player).getMiningManager();
if (miningManager.canUseBlastMining()) {
miningManager.blastMiningDropProcessing(event.getYield(), event.blockList());
event.setYield(0);
}
}
示例13: tntBarrage
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
private static void tntBarrage(CircleOfBoom circle){
COBUtils.setCircle(circle);
taskId = Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.getPlugin(), new Runnable() {
int distance = 1;
int x = (int)COBUtils.getCircle().getCenter().getX();
int z = (int)COBUtils.getCircle().getCenter().getZ();
World world = COBUtils.getCircle().getWorld();
@Override
public void run() {
if(distance<COBUtils.getCircle().getRadious()){
world.spawn(new Location(world, x+distance, COBUtils.getCircle().getCenter().getY()+20, z), TNTPrimed.class);
world.spawn(new Location(world, x-distance, COBUtils.getCircle().getCenter().getY()+20, z), TNTPrimed.class);
world.spawn(new Location(world, x, COBUtils.getCircle().getCenter().getY()+20, z+distance), TNTPrimed.class);
world.spawn(new Location(world, x, COBUtils.getCircle().getCenter().getY()+20, z-distance), TNTPrimed.class);
} else {
Bukkit.getScheduler().cancelTask(taskId);
}
distance++;
}
}, 0L, 5L);
}
示例14: onBlockPlace
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
@EventHandler(priority = EventPriority.LOW)
public void onBlockPlace(BlockPlaceEvent event) {
Player player = event.getPlayer();
Client client = Client.getClient(player);
if(client.isObserver() || !Rixor.getRotation().getSlot().getMatch().isCurrentlyRunning()) {
event.setCancelled(true);
return;
}
if (event.getBlockPlaced().getType() == Material.TNT && Rixor.getRotation().getSlot().getMap().getTntsettings().isInstantIgnite()){
event.getBlockPlaced().setType(Material.AIR);
TNTPrimed tnt = event.getBlockPlaced().getWorld().spawn(event.getBlockPlaced().getLocation(), TNTPrimed.class);
}
if(!client.isObserver()) {
Map map = Rixor.getRotation().getSlot().getMap();
BlockChangeEvent change = new BlockChangeEvent(event, map, client, event.getBlockReplacedState(), event.getBlockPlaced().getState());
Rixor.callEvent(change);
}
}
示例15: onEntityExplodeNormal
import org.bukkit.entity.TNTPrimed; //导入依赖的package包/类
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
public void onEntityExplodeNormal(EntityExplodeEvent event) {
Map map = Rixor.getRotation().getSlot().getMap();
Client client = null;
if(event.getEntity() instanceof TNTPrimed) {
TNTPrimed tnt = (TNTPrimed) event.getEntity();
if(tnt.getSource() instanceof Player)
client = Client.getClient((Player) tnt.getSource());
}
for(Block block : event.blockList()) {
BlockState newState = block.getState();
newState.setData(new MaterialData(Material.AIR, (byte) 0));
BlockChangeEvent change = new BlockChangeEvent(event, map, client, block.getState(), newState);
Rixor.callEvent(change);
}
}