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


Java EntityExplodeEvent.setYield方法代碼示例

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


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

示例1: onEntityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
    Lot lot = this.module.getLotManager().getLot(event.getEntity().getLocation());
    Town town = this.module.getLotManager().getTown(event.getEntity().getLocation());
    if(lot != null || town != null) {
        event.setYield(0);
        event.setCancelled(true);
        return;
    }

    for(Block block : event.blockList()) {
        Lot l = this.module.getLotManager().getLot(block.getLocation());
        Town t = this.module.getLotManager().getTown(block.getLocation());
        if(l != null || t != null) {
            event.setYield(0);
            event.setCancelled(true);
            break;
        }
    }
}
 
開發者ID:Steveice10,項目名稱:Peacecraft,代碼行數:21,代碼來源:LotsListener.java

示例2: fragBallExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler
public void fragBallExplode(EntityExplodeEvent e) {
    e.setCancelled(true);

    for(Block block : e.blockList()) {
        if(block.getRelative(BlockFace.UP).getType() == Material.AIR && block.getType().isSolid()) {
            FallingBlock fallingBlock = block.getWorld().spawnFallingBlock(block.getLocation().add(0, 1, 0), block.getType(), block.getData());
            double x = (block.getLocation().getX() - e.getLocation().getX()) / 3,
                    y = 1,
                    z = (block.getLocation().getZ() - e.getLocation().getZ()) / 3;
            fallingBlock.setVelocity(new Vector(x, y, z).normalize());
            fallingBlock.setMetadata("explode", new FixedMetadataValue(plugin, false));
            fallingBlock.setDropItem(false);
            e.setYield(0F);
        }
    }
}
 
開發者ID:ModernDayPlayer,項目名稱:SurvivalGamesX,代碼行數:18,代碼來源:BlockListener.java

示例3: onEnitityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的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

示例4: cancelExplosionIfConfig

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
public static void cancelExplosionIfConfig(EntityExplodeEvent e) {
	EntityType type = e.getEntityType();
	if(type.equals(EntityType.PRIMED_TNT) && Config.getBool("protection", "blockTnt")) {
		e.setYield(0);
		e.setCancelled(true);
	} else if(type.equals(EntityType.CREEPER) && Config.getBool("protection", "blockCreeper")) {
		e.setYield(0);
		e.setCancelled(true);
	}
}
 
開發者ID:cjburkey01,項目名稱:ClaimChunk,代碼行數:11,代碼來源:ChunkHelper.java

示例5: onEntityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.HIGHEST)
public void onEntityExplode(EntityExplodeEvent event) {
    if (GameHandler.getGameHandler().getMatch().isRunning() && event.getEntity() instanceof TNTPrimed) {
        if (!blockDamage) {
            event.blockList().clear();
        } else if (yield != 0.3){
            event.setYield((float)yield);
        }
        UUID player = TntTracker.getWhoPlaced(event.getEntity());
        for (Block block : event.blockList()) {
            if (block.getState() instanceof Dispenser) {
                Inventory inventory = ((Dispenser) block.getState()).getInventory();
                Location location = block.getLocation();
                double tntCount = 0;
                for (ItemStack itemstack : inventory.getContents()) {
                    if (itemstack != null && itemstack.getType() == Material.TNT) tntCount += itemstack.getAmount() * multiplier;
                    if (tntCount >= limit) {
                        tntCount = limit;
                        break;
                    }
                }
                inventory.remove(Material.TNT);
                if (tntCount > 0) {
                    Random random = new Random();
                    for (double i = tntCount; i > 0; i--) {
                        TNTPrimed tnt = event.getWorld().spawn(location, TNTPrimed.class);
                        Vector velocity = new Vector((1.5 * random.nextDouble()) - 0.75, (1.5 * random.nextDouble()) - 0.75, (1.5 * random.nextDouble()) - 0.75);
                        tnt.setVelocity(velocity);
                        tnt.setFuseTicks(random.nextInt(10) + 10);
                        if (player != null) {
                            tnt.setMetadata("source", new FixedMetadataValue(Cardinal.getInstance(), player));
                        }
                    }
                }
            }
        }
    }
}
 
開發者ID:twizmwazin,項目名稱:CardinalPGM,代碼行數:39,代碼來源:Tnt.java

示例6: onEntityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityExplode(final ExtendedEntityExplodeEvent ext) {
    final EntityExplodeEvent event = (EntityExplodeEvent)ext.getBaseEvent();
    for (final Block b : ext.getBlockRegionsMap().keySet()) {
        if (ext.getBlockRegionsMap().get(b).getFlag(Flag.EXPLOSION_BLOCK)) {
            event.blockList().remove(b);
        }
    }
    if (ext.getEntityRegion() != null) {
        final Integer blockDropRatio = ext.getEntityRegion().getIntegerAttribute(Attribute.EXPLOSION_BLOCK_DROP);
        if (blockDropRatio != null) {
            event.setYield(blockDropRatio / 100f);
        }
    }
}
 
開發者ID:Ribesg,項目名稱:NPlugins,代碼行數:16,代碼來源:ExplosionFlagListener.java

示例7: yieldSet

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler(ignoreCancelled = true)
public void yieldSet(EntityExplodeEvent event) {
    if(this.properties.yield != null && event.getEntity() instanceof TNTPrimed) {
        event.setYield(this.properties.yield);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:7,代碼來源:TNTMatchModule.java

示例8: onEntityExplode

import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
    event.setYield(0);
    event.blockList().clear();
}
 
開發者ID:Steveice10,項目名稱:Peacecraft,代碼行數:6,代碼來源:RestrictionsListener.java


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