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


Java ProjectileHitEvent类代码示例

本文整理汇总了Java中cn.nukkit.event.entity.ProjectileHitEvent的典型用法代码示例。如果您正苦于以下问题:Java ProjectileHitEvent类的具体用法?Java ProjectileHitEvent怎么用?Java ProjectileHitEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: onProjectileHit

import cn.nukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler
public boolean onProjectileHit(ProjectileHitEvent event) {
    EntityProjectile entity = (EntityProjectile) event.getEntity();
    Location loc = NukkitUtil.getLocation(entity);
    if (!PS.get().hasPlotArea(loc.getWorld())) {
        return true;
    }
    PlotArea area = loc.getPlotArea();
    if (area == null) {
        return true;
    }
    Plot plot = area.getPlotAbs(loc);
    Entity shooter = entity.shootingEntity;
    if (shooter instanceof Player) {
        PlotPlayer pp = NukkitUtil.getPlayer((Player) shooter);
        if (plot == null) {
            if (!Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_UNOWNED)) {
                kill(entity, event);
                return false;
            }
            return true;
        }
        if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
            return true;
        }
        kill(entity, event);
        return false;
    }
    if (shooter == null) {
        kill(entity, event);
        return false;
    }
    return true;
}
 
开发者ID:IntellectualSites,项目名称:PlotSquared,代码行数:35,代码来源:PlayerEvents.java

示例2: onProjectileHit

import cn.nukkit.event.entity.ProjectileHitEvent; //导入依赖的package包/类
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = false) //DON'T FORGET THE ANNOTATION @EventHandler
	    public void onProjectileHit(ProjectileHitEvent event) throws Exception
{
	        Entity snowball = event.getEntity();
	        Position loc = snowball.getLocation();
	        Integer kind = null;
	        String who = null;
	        snowball.getLevel().removeEntity(snowball);
	        if(whodi.containsKey((int)snowball.getId())){
				  for (Map.Entry<Integer, String> e : whodi.get((int)snowball.getId()).entrySet()) {
					    kind = e.getKey();
					    who = e.getValue();
				  }
			}
	        if(who !=null){
	        Player wdi =Server.getInstance().getPlayer(who);
	        if(kind == 1 || kind == 4 || kind == 8){

	        	int ds = 3;
	        	if(kind == 8){
	        		ds = 2;
	        	}
	        	if(kind == 4){
	        		ds = 5;
	        	}

	    		int x=loc.getFloorX();
	    		int y=loc.getFloorY();
	    		int z=loc.getFloorZ();

	    		ExplodeSound sound = new ExplodeSound(new Vector3(x,y,z));//サウンドオブジェクトの生成
	    		loc.getLevel().addSound(sound);//サウンドを再生
	    		ExplodeParticle particle = new ExplodeParticle(new Vector3(x,y,z));
	    		int count = 20;
	    		for(int i = 0;i < count; ++i){
	    			loc.getLevel().addParticle(particle);
	    		}
	    		for(Player playera : Server.getInstance().getOnlinePlayers().values()){
	   			 	if(Math.abs(playera.getX()-x)<=ds & Math.abs(playera.getY()-y)<=ds & Math.abs(playera.getZ()-z)<=ds & wdi != playera){
	   			 		EntityDamageByEntityEvent ev = new EntityDamageByEntityEvent(wdi,playera, EntityDamageEvent.CAUSE_ENTITY_EXPLOSION, 8);//EntityDamageEvent::CAUSE_MAGICを変えることでダメージの種類を、1を変えることでダメージの強さが変更できます
	   			 		playera.attack(ev);

	    			 }
	    		}
	    	}}
	    }
 
开发者ID:haniokasai,项目名称:NuclearGunWars-plugin,代码行数:47,代码来源:gunsys.java


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