当前位置: 首页>>代码示例>>Java>>正文


Java DamageCause.BLOCK_EXPLOSION属性代码示例

本文整理汇总了Java中org.bukkit.event.entity.EntityDamageEvent.DamageCause.BLOCK_EXPLOSION属性的典型用法代码示例。如果您正苦于以下问题:Java DamageCause.BLOCK_EXPLOSION属性的具体用法?Java DamageCause.BLOCK_EXPLOSION怎么用?Java DamageCause.BLOCK_EXPLOSION使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.bukkit.event.entity.EntityDamageEvent.DamageCause的用法示例。


在下文中一共展示了DamageCause.BLOCK_EXPLOSION属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: parse

public static DisableDamageModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    SetMultimap<DamageCause, PlayerRelation> causes = HashMultimap.create();
    for(Element damageCauseElement : doc.getRootElement().getChildren("disabledamage")) {
        for(Element damageEl : damageCauseElement.getChildren("damage")) {
            DamageCause cause = XMLUtils.parseEnum(damageEl, DamageCause.class, "damage type");
            for(PlayerRelation damagerType : PlayerRelation.values()) {
                // Legacy syntax used "other" instead of "neutral"
                String attrName = damagerType.name().toLowerCase();
                Node attr = damagerType == PlayerRelation.NEUTRAL ? Node.fromAttr(damageEl, attrName, "other")
                                                                  : Node.fromAttr(damageEl, attrName);
                if(XMLUtils.parseBoolean(attr, true)) {
                    causes.put(cause, damagerType);

                    // Bukkit 1.7.10 changed TNT from BLOCK_EXPLOSION to ENTITY_EXPLOSION,
                    // so we include them both to keep old maps working.
                    if(cause == DamageCause.BLOCK_EXPLOSION) {
                        causes.put(DamageCause.ENTITY_EXPLOSION, damagerType);
                    }
                }
            }
        }
    }
    return new DisableDamageModule(causes);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:24,代码来源:DisableDamageModule.java

示例2: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if (damageTypes.contains(event.getCause()) && (event.getCause() != DamageCause.BLOCK_EXPLOSION || event.getCause() != DamageCause.ENTITY_EXPLOSION)) {
        event.setCancelled(true);
    } else if (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION) {
        if (event instanceof EntityDamageByEntityEvent) {
            if (event.getEntity() instanceof Player && TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager()) != null) {
                Player player = (Player) event.getEntity();
                UUID source = TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager());
                Match match = GameHandler.getGameHandler().getMatch();
                if (Bukkit.getOfflinePlayer(source).isOnline()) {
                    if (Bukkit.getPlayer(source).equals(player)) {
                        event.setCancelled(!blockExplosionSelf);
                    } else if (TeamUtils.getTeamByPlayer(Bukkit.getPlayer(source)) == TeamUtils.getTeamByPlayer(player)) {
                        event.setCancelled(!blockExplosionAlly);
                    } else if (TeamUtils.getTeamByPlayer(Bukkit.getPlayer(source)) != TeamUtils.getTeamByPlayer(player)) {
                        event.setCancelled(!blockExplosionEnemy);
                    } else {
                        event.setCancelled(!blockExplosionOther);
                    }
                }
            }
        } else if (damageTypes.contains(DamageCause.BLOCK_EXPLOSION)) event.setCancelled(true);
    }
}
 
开发者ID:dentmaged,项目名称:Cardinal-Plus,代码行数:25,代码来源:DisableDamage.java

示例3: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if (damageTypes.contains(event.getCause()) && (event.getCause() != DamageCause.BLOCK_EXPLOSION || event.getCause() != DamageCause.ENTITY_EXPLOSION)) {
        event.setCancelled(true);
    } else if (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION) {
        if (event instanceof EntityDamageByEntityEvent) {
            if (event.getEntity() instanceof Player && TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager()) != null) {
                Player player = (Player) event.getEntity();
                UUID source = TntTracker.getWhoPlaced(((EntityDamageByEntityEvent) event).getDamager());
                Match match = GameHandler.getGameHandler().getMatch();
                if (Bukkit.getOfflinePlayer(source).isOnline()) {
                    if (Bukkit.getPlayer(source).equals(player)) {
                        event.setCancelled(!blockExplosionSelf);
                    } else if (Teams.getTeamByPlayer(Bukkit.getPlayer(source)) == Teams.getTeamByPlayer(player)) {
                        event.setCancelled(!blockExplosionAlly);
                    } else if (Teams.getTeamByPlayer(Bukkit.getPlayer(source)) != Teams.getTeamByPlayer(player)) {
                        event.setCancelled(!blockExplosionEnemy);
                    } else {
                        event.setCancelled(!blockExplosionOther);
                    }
                }
            }
        } else if (damageTypes.contains(DamageCause.BLOCK_EXPLOSION)) event.setCancelled(true);
    }
}
 
开发者ID:twizmwazin,项目名称:CardinalPGM,代码行数:25,代码来源:DisableDamage.java

示例4: onDamage

@EventHandler
public void onDamage(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player) {
		if (e.getCause() == DamageCause.BLOCK_EXPLOSION || e.getCause() == DamageCause.ENTITY_EXPLOSION) {
			Player p = (Player) e.getEntity();
			e.setDamage(e.getDamage() * (1 - EnchantmentZ.calcInventoryPieceAmount(BLAST_PROTECTION, p.getInventory()) * 0.0625));
		}
	}
}
 
开发者ID:crazyhorse961,项目名称:NationZ,代码行数:9,代码来源:EnchantmentZ_BlastProtection.java

示例5: toBukkit

public static DamageCause toBukkit(cn.nukkit.event.entity.EntityDamageEvent.DamageCause nukkit) {
	// TODO Direct mapping via DamageCause.valueOf?
	switch (nukkit) {
		case CONTACT:
			return DamageCause.CONTACT;
		case ENTITY_ATTACK:
			return DamageCause.ENTITY_ATTACK;
		case PROJECTILE:
			return DamageCause.PROJECTILE;
		case SUFFOCATION:
			return DamageCause.SUFFOCATION;
		case FALL:
			return DamageCause.FALL;
		case FIRE:
			return DamageCause.FIRE;
		case FIRE_TICK:
			return DamageCause.FIRE_TICK;
		case LAVA:
			return DamageCause.LAVA;
		case DROWNING:
			return DamageCause.DROWNING;
		case BLOCK_EXPLOSION:
			return DamageCause.BLOCK_EXPLOSION;
		case ENTITY_EXPLOSION:
			return DamageCause.ENTITY_EXPLOSION;
		case VOID:
			return DamageCause.VOID;
		case SUICIDE:
			return DamageCause.SUICIDE;
		case MAGIC:
			return DamageCause.MAGIC;
		case LIGHTNING:
			return DamageCause.LIGHTNING;
		case CUSTOM:
		default:
			return DamageCause.CUSTOM;
	}
}
 
开发者ID:rutgerkok,项目名称:Pokkit,代码行数:38,代码来源:PokkitDamageCause.java

示例6: onEntityDamage

/**
 * On entity damage.
 *
 * @param event the event
 */
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent event) {

    if (conf.isOverrideExplosions()
            && event.getEntity() instanceof Hanging
            && (event.getCause() == DamageCause.BLOCK_EXPLOSION || event.getCause() == DamageCause.ENTITY_EXPLOSION
            || event.getCause() == DamageCause.PROJECTILE)) {
        // Check for ItemFrame
        Factoid.getThisPlugin().iLog().write("Cancel HangingBreak : " + event.getEntity() + ", Cause: " + event.getCause());
        event.setCancelled(true);
    }
}
 
开发者ID:Tabinol,项目名称:Factoid,代码行数:17,代码来源:WorldListener.java

示例7: onSteveHurt

@EventHandler
public void onSteveHurt(EntityDamageEvent e) {
	if(e.getEntity() instanceof Player) {
		Player p = (Player) e.getEntity();
		//p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
		if(e.getCause() == DamageCause.BLOCK_EXPLOSION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.DROWNING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.ENTITY_ATTACK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.ENTITY_EXPLOSION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FALL) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FALLING_BLOCK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.FIRE_TICK) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.LIGHTNING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.MELTING) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.POISON) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.PROJECTILE) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.STARVATION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.SUFFOCATION) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.SUICIDE) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.THORNS) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.VOID) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		} else if(e.getCause() == DamageCause.WITHER) {
			p.getWorld().playSound(p.getLocation(), Sound.HURT, 1, 1);
			return;
		}
	}
}
 
开发者ID:xize,项目名称:xEssentials_old_Source,代码行数:59,代码来源:steveHurtSound.java


注:本文中的org.bukkit.event.entity.EntityDamageEvent.DamageCause.BLOCK_EXPLOSION属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。