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


Java DamageCause.VOID屬性代碼示例

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


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

示例1: onPlayerDamage

@EventHandler
public void onPlayerDamage(EntityDamageEvent event) {
	if (!(event.getEntity() instanceof Player))
		return;
	event.setCancelled(true);
	
	if (event.getCause()==DamageCause.VOID) {
		Location l = event.getEntity().getWorld().getSpawnLocation();
		l.setX(14.5);
		l.setY(10.5);
		l.setZ(-795.5);
		l.setPitch(0.5F);
		l.setYaw(90 * RandomUtil.between(1, 4));
		event.getEntity().teleport(l);
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:16,代碼來源:Events.java

示例2: onCancell

@EventHandler
public void onCancell(EntityDamageEvent event){
Entity e = event.getEntity();
if(!(e instanceof Player)){
	return;
}
Player p = (Player)e;
Arena a = new ArenaManager().getArena(p);

if(a==null){
	event.setCancelled(true);
	return;
}
if(a.isEnd()){
	event.setCancelled(true);
	
}
if(a.fallMode()==true){
	if(event.getCause() == DamageCause.FALL||event.getCause() == DamageCause.VOID){
	event.setCancelled(true);
	}
}
}
 
開發者ID:SpikyBite,項目名稱:BiteSkywars,代碼行數:23,代碼來源:PlayerListener.java

示例3: onHit

@EventHandler
public void onHit(EntityDamageEvent event) {
    if (event.getEntity() instanceof IronGolem) {
        final IronGolem g = (IronGolem) event.getEntity();
        if (g.getCustomName() == null)
            return;

        final Boss b = plugin.getBossManager().bossNames.get(g
                .getCustomName());
        if (b == null)
            return;

        if (event.getCause() == DamageCause.VOID) {
            event.getEntity().remove();

            Bukkit.getScheduler().runTask(plugin, new Runnable() {
                public void run() {
                    Boss n = plugin.getBossManager().newBoss(b);
                    plugin.getBossManager().spawn(n);
                }
            });
            return;
        }
    }
}
 
開發者ID:cancabron,項目名稱:Annihilation,代碼行數:25,代碼來源:BossListener.java

示例4: onHit

@EventHandler
public void onHit(EntityDamageEvent event) {
    if (event.getEntity() instanceof IronGolem) {
        final IronGolem g = (IronGolem) event.getEntity();
        if (g.getCustomName() == null)
            return;

        final Golem b = plugin.getBossManager().bossNames.get(g
                .getCustomName());
        if (b == null)
            return;

        if (event.getCause() == DamageCause.VOID) {
            event.getEntity().remove();

            Bukkit.getScheduler().runTask(plugin, new Runnable() {
                @Override
                public void run() {
                    Golem n = plugin.getBossManager().newBoss(b);
                    plugin.getBossManager().spawn(n);
                }
            });
        }
    }
}
 
開發者ID:MCTyler,項目名稱:CrafterNexus,代碼行數:25,代碼來源:GolemListener.java

示例5: resolve

public @Nullable
DamageInfo resolve(@Nonnull LivingEntity entity, @Nonnull Lifetime lifetime, @Nonnull EntityDamageEvent damageEvent) {
    if(damageEvent.getCause() == DamageCause.VOID) {
        return new SimpleVoidDamageInfo(null);
    }

    return null;
}
 
開發者ID:WarzoneMC,項目名稱:Warzone,代碼行數:8,代碼來源:VoidDamageResolver.java

示例6: onEntityDamageEvent

@EventHandler
public void onEntityDamageEvent(EntityDamageEvent event) {
    if (event.getCause() == DamageCause.VOID && event.getEntity() instanceof Player) {
        if (lastVoid.containsKey(((Player) event.getEntity()).getName()) && System.currentTimeMillis() - lastVoid.get(((Player) event.getEntity()).getName()) < 5000)
            return;
        ((Player) event.getEntity()).sendMessage(ChatColor.RED + "Woah! Careful there, pal!");
        event.getEntity().setFallDistance(0);
        event.getEntity().teleport(event.getEntity().getWorld().getSpawnLocation());
        event.getEntity().setFallDistance(0);
    } else if (event.getCause() == DamageCause.VOID && MobManager.spawnedMobs.get(event.getEntity().getUniqueId()) != null) {
        MobData md = MobManager.spawnedMobs.get(event.getEntity().getUniqueId());
        event.getEntity().teleport(md.ai.originalLoc);
    }
}
 
開發者ID:edasaki,項目名稱:ZentrelaRPG,代碼行數:14,代碼來源:EnvironmentManager.java

示例7: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
	if (!(event.getEntity() instanceof Player))
		return;
	
	if (event.getCause() != DamageCause.VOID)
		return;
	
	Player p = (Player) event.getEntity();
	Gamer g = Gamer.get(p);
	if (g.getVariable("parkour") != null) {
		p.teleport(((Course) g.getVariable("parkour")).getStart());
	}
}
 
開發者ID:thekeenant,項目名稱:mczone,代碼行數:14,代碼來源:Parkour.java

示例8: 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

示例9: onDamage

@EventHandler
public void onDamage(EntityDamageEvent e) {
	if (e.getEntity() instanceof Player && e.getCause() != null && e.getCause() != DamageCause.VOID) {
		if (Zephyrus.getUser(((Player) e.getEntity()).getName()).isStateApplied(this)) {
			e.setDamage(e.getDamage() / 4D);
		}
	}
}
 
開發者ID:mcardy,項目名稱:Zephyrus-II,代碼行數:8,代碼來源:ArmorState.java

示例10: handle

@EventHandler
public void handle(EntityDamageEvent event) {
    if (Mgr.INSTANCE.isPortalVoid() && event.getEntityType() == EntityType.PLAYER && event.getCause() == DamageCause.VOID) {
        event.setCancelled(true);
        portal(Player.class.cast(event.getEntity()));
    }
}
 
開發者ID:caoli5288,項目名稱:LoginTeleport,代碼行數:7,代碼來源:Executor.java

示例11: onPlayerDamage

@EventHandler
public void onPlayerDamage(EntityDamageEvent e) {
    if (e.getEntity() instanceof Player) {
        if (e.getEntity().getWorld().getName().equals("lobby")) {
            e.setCancelled(true);

            if (e.getCause() == DamageCause.VOID)
                e.getEntity().teleport(
                        plugin.getMapManager().getLobbySpawnPoint());
        }
    }
}
 
開發者ID:cancabron,項目名稱:Annihilation,代碼行數:12,代碼來源:PlayerListener.java

示例12: onEntityDamage

@EventHandler
public void onEntityDamage(EntityDamageEvent event) {
    if (event.getEntity() instanceof Player) {
        if (event.getCause() == DamageCause.LAVA || event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK) {
            event.getEntity().setFireTicks(0);
        }
        if (event.getCause() != DamageCause.VOID) {
            event.setCancelled(true);
        }
    }
}
 
開發者ID:EyeOfEnder-Ltd,項目名稱:EOEHub,代碼行數:11,代碼來源:PlayerListener.java

示例13: onEntityDamage

@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onEntityDamage(EntityDamageEvent e)
{
	if (e.getEntity() instanceof Player && game.isPlaying((Player)e.getEntity()))
	{
		if (!game.isRunning && e.getCause() == DamageCause.VOID)
		{
			Challenger c = game.getPlayer((Player)e.getEntity());
			c.teleport(game.getRegion().getSpawn(c.getTeam()));
		}
		
		e.setCancelled(!isAllowedAction((Player)e.getEntity()));
	}
}
 
開發者ID:riking,項目名稱:GrandVide,代碼行數:14,代碼來源:Events.java

示例14: onDamage

@EventHandler
public void onDamage(EntityDamageEvent e) {
	try {
		if (e.getEntity() instanceof Player && e.getCause() != DamageCause.VOID) {
			Player player = (Player) e.getEntity();
			if (EffectHandler.hasEffect(player, EffectType.ARMOUR)) {
				e.setDamage(e.getDamage() / 4.0F);
			}
		}
	} catch (Exception ex) {
	}
}
 
開發者ID:mcardy,項目名稱:Zephyrus,代碼行數:12,代碼來源:ArmourEffect.java

示例15: damageEntity

@Override
public boolean damageEntity(DamageSource source, float damage) {
    if (invulnerable || noDamageTicks > 0) {
        return false;
    }

    DamageCause cause = null;
    org.bukkit.entity.Entity bEntity = null;
    if (source instanceof EntityDamageSource) {
        Entity damager = source.getEntity();
        cause = DamageCause.ENTITY_ATTACK;
        if (source instanceof EntityDamageSourceIndirect) {
            damager = ((EntityDamageSourceIndirect) source).getProximateDamageSource();
            if (damager.getBukkitEntity() instanceof ThrownPotion) {
                cause = DamageCause.MAGIC;
            } else if (damager.getBukkitEntity() instanceof Projectile) {
                cause = DamageCause.PROJECTILE;
            }
        }

        bEntity = damager.getBukkitEntity();
    } else if (source == DamageSource.FIRE)
        cause = DamageCause.FIRE;
    else if (source == DamageSource.STARVE)
        cause = DamageCause.STARVATION;
    else if (source == DamageSource.WITHER)
        cause = DamageCause.WITHER;
    else if (source == DamageSource.STUCK)
        cause = DamageCause.SUFFOCATION;
    else if (source == DamageSource.DROWN)
        cause = DamageCause.DROWNING;
    else if (source == DamageSource.BURN)
        cause = DamageCause.FIRE_TICK;
    else if (source == CraftEventFactory.MELTING)
        cause = DamageCause.MELTING;
    else if (source == CraftEventFactory.POISON)
        cause = DamageCause.POISON;
    else if (source == DamageSource.MAGIC) {
        cause = DamageCause.MAGIC;
    } else if (source == DamageSource.OUT_OF_WORLD) {
        cause = DamageCause.VOID;
    }

    if (cause != null) {
        NPCDamageEvent event = new NPCDamageEvent(npc, bEntity, cause, (double) damage);
        Bukkit.getPluginManager().callEvent(event);
        if (!event.isCancelled()) {
            return super.damageEntity(source, (float) event.getDamage());
        } else {
            return false;
        }
    }

    if (super.damageEntity(source, damage)) {
        if (bEntity != null) {
            Entity e = ((CraftEntity) bEntity).getHandle();
            double d0 = e.locX - this.locX;

            double d1;
            for (d1 = e.locZ - this.locZ; d0 * d0 + d1 * d1 < 0.0001D; d1 = (Math.random() - Math.random()) * 0.01D) {
                d0 = (Math.random() - Math.random()) * 0.01D;
            }

            a(e, damage, d0, d1);
        }

        return true;
    } else {
        return false;
    }
}
 
開發者ID:johnnywoof,項目名稱:NoHack,代碼行數:71,代碼來源:NPCEntity.java


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