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


Java TNTPrimed類代碼示例

本文整理匯總了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);
                }
            }
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:17,代碼來源:ExplosiveListener.java

示例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();
        }
    }
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:20,代碼來源:SimpleExplosiveTracker.java

示例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;
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:22,代碼來源:TNTDamageResolver.java

示例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();
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:19,代碼來源:Pickup.java

示例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));
    }
  }
}
 
開發者ID:twizmwazin,項目名稱:OpenUHC,代碼行數:21,代碼來源:BlastMining.java

示例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));
                        }
                    }
                }
            }
        }
    }
 
開發者ID:Minehut,項目名稱:GamePlate,代碼行數:26,代碼來源:TntTracker.java

示例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);
    }
}
 
開發者ID:ShootGame,項目名稱:Arcade2,代碼行數:25,代碼來源:BlockTransformListeners.java

示例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;
	}
}
 
開發者ID:TheLimeGlass,項目名稱:Skellett,代碼行數:17,代碼來源:ExprFuseTime.java

示例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();
        }
    }
}
 
開發者ID:rutgerkok,項目名稱:BlockLocker,代碼行數:24,代碼來源:BlockDestroyListener.java

示例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);
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:25,代碼來源:MiningManager.java

示例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()));
    }
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:27,代碼來源:EntityListener.java

示例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);
    }
}
 
開發者ID:Pershonkey,項目名稱:McMMOPlus,代碼行數:28,代碼來源:EntityListener.java

示例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);
}
 
開發者ID:tatanpoker09,項目名稱:TCMinigames,代碼行數:23,代碼來源:COBUtils.java

示例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);
	}
}
 
開發者ID:ProjectRixor,項目名稱:Rixor,代碼行數:22,代碼來源:FilterEvents.java

示例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);
	}
}
 
開發者ID:ProjectRixor,項目名稱:Rixor,代碼行數:20,代碼來源:FilterEvents.java


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