本文整理匯總了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;
}
}
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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));
}
}
}
}
}
}
}
示例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);
}
}
}
示例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);
}
}
示例8: onEntityExplode
import org.bukkit.event.entity.EntityExplodeEvent; //導入方法依賴的package包/類
@EventHandler
public void onEntityExplode(EntityExplodeEvent event) {
event.setYield(0);
event.blockList().clear();
}