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


Java TNTPrimed.setYield方法代碼示例

本文整理匯總了Java中org.bukkit.entity.TNTPrimed.setYield方法的典型用法代碼示例。如果您正苦於以下問題:Java TNTPrimed.setYield方法的具體用法?Java TNTPrimed.setYield怎麽用?Java TNTPrimed.setYield使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.entity.TNTPrimed的用法示例。


在下文中一共展示了TNTPrimed.setYield方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: run

import org.bukkit.entity.TNTPrimed; //導入方法依賴的package包/類
@Override
public boolean run(Player player, ConfigurationSection config) {
	Location loc = player.getTargetBlock(null, config.getInt("max_distence")).getLocation();
	final TNTPrimed tnt = player.getWorld().spawn(loc.add(0, 1, 0), TNTPrimed.class);
	tnt.setYield((float) config.getDouble("power"));
	tnt.setIsIncendiary(config.getBoolean("enable_fire"));
	tnt.setFuseTicks(0);
	bombSites.put(tnt, player.getName());
	Bukkit.getScheduler().scheduleSyncDelayedTask(RodsTwo.getInstance(), new Runnable(){
		@Override
		public void run() {
			bombSites.remove(tnt);
		}}, 10L);
	//player.getWorld().createExplosion(loc, (float) config.getDouble("power"), config.getBoolean("enable_fire"));
	return true; 
}
 
開發者ID:EvilKanoa,項目名稱:RodsTwo,代碼行數:17,代碼來源:Explosion.java

示例2: handleInstantActivation

import org.bukkit.entity.TNTPrimed; //導入方法依賴的package包/類
@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);
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:32,代碼來源:TNTMatchModule.java

示例3: setCustomProperties

import org.bukkit.entity.TNTPrimed; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void setCustomProperties(ExplosionPrimeEvent event) {
    if(event.getEntity() instanceof TNTPrimed) {
        TNTPrimed tnt = (TNTPrimed) event.getEntity();

        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
        }
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:15,代碼來源:TNTMatchModule.java

示例4: onThrowTNT

import org.bukkit.entity.TNTPrimed; //導入方法依賴的package包/類
@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);
		}
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:30,代碼來源:KitEvents.java

示例5: onPlayerInteract

import org.bukkit.entity.TNTPrimed; //導入方法依賴的package包/類
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
	Gamer g = Gamer.get(event.getPlayer());
	
	if (event.getAction() != Action.PHYSICAL)
		return;
	
	Block b = event.getClickedBlock();
	if (!b.hasMetadata("Mine"))
		return;
	
	Mine mine = Mine.getList().get(b.getMetadata("Mine").get(0).asInt());
	
	Team playerTeam = Nexus.getRotary().getCurrentMap().getTeam(g);
	Team targetTeam = Nexus.getRotary().getCurrentMap().getTeam(mine.getGamer());
	
	if (playerTeam == targetTeam)
		return;
	
	mine.setIgnited(true);
	
	TNTPrimed e = (TNTPrimed) event.getPlayer().getWorld().spawnEntity(event.getPlayer().getEyeLocation(), EntityType.PRIMED_TNT);
	e.setFuseTicks(10);
	e.setYield(2.7F);
	e.setMetadata("Player", new FixedMetadataValue(Nexus.getPlugin(), mine.getGamer().getName()));
	e.setMetadata("Cause", new FixedMetadataValue(Nexus.getPlugin(), CustomDamageCause.TNT_MINE.name()));
	event.getClickedBlock().setType(Material.AIR);
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:29,代碼來源:KitEvents.java

示例6: onBlockPlace

import org.bukkit.entity.TNTPrimed; //導入方法依賴的package包/類
@EventHandler
public void onBlockPlace(BlockPlaceEvent event) {
    Block block = event.getBlock();
    if (block.getType().equals(Material.TNT) && instantIgnite) {
        event.setCancelled(true);
        ItemStack tntStack = event.getPlayer().getItemInHand();
        tntStack.setAmount(tntStack.getAmount() - 1);
        event.getPlayer().setItemInHand(tntStack);
        TNTPrimed tnt = (TNTPrimed) GameHandler.getGameHandler().getMatchWorld().spawnEntity(block.getLocation().add(new Vector(0.5, 0.5, 0.5)), EntityType.PRIMED_TNT);
        tnt.setYield((float) power);
        Bukkit.getServer().getPluginManager().callEvent(new ExplosionPrimeEvent(tnt, (float) power * 10, false));
    }
}
 
開發者ID:dentmaged,項目名稱:Cardinal-Plus,代碼行數:14,代碼來源:Tnt.java

示例7: onExplosionPrime

import org.bukkit.entity.TNTPrimed; //導入方法依賴的package包/類
@EventHandler
public void onExplosionPrime(ExplosionPrimeEvent event) {
    if (event.getEntity() instanceof TNTPrimed) {
        TNTPrimed tnt = (TNTPrimed) event.getEntity();
        if (fuse != 4) {
            tnt.setFuseTicks(fuse);
        }
        if (power != 4.0) {
            tnt.setYield((float) power);
        }
    }
}
 
開發者ID:twizmwazin,項目名稱:CardinalPGM,代碼行數:13,代碼來源:Tnt.java


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