org.bukkit.entity.Entity#sendMessage ( )源码实例Demo

下面列出了org.bukkit.entity.Entity#sendMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Civs   文件: HealEffect.java
public boolean meetsRequirement() {
    Object target = getTarget();
    Entity origin = getOrigin();
    if (!(target instanceof LivingEntity)) {
        if (!this.silent && origin instanceof Player) {
            ((Player) origin).sendMessage(ChatColor.RED + Civs.getPrefix() + " target cant't be healed.");
        }
        return false;
    }
    LivingEntity livingEntity = (LivingEntity) target;
    if (livingEntity.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() - livingEntity.getHealth() < this.heal) {
        if (!this.silent && origin instanceof Player) {
            origin.sendMessage(ChatColor.RED + Civs.getPrefix() + " already has enough health.");
        }
        return false;
    }
    return true;
}
 
源代码2 项目: askyblock   文件: SafeSpotTeleport.java
private void tidyUp(Entity entity, String failureMessage) {
    // Nothing left to check and still not canceled
    task.cancel();
    // Check portal
    if (portal && bestSpot != null) {
        // No portals found, teleport to the best spot we found
        teleportEntity(bestSpot);
    } else if (entity instanceof Player && !failureMessage.isEmpty()) {
        // Failed, no safe spot
        entity.sendMessage(failureMessage);
    }
    if (entity instanceof Player && (plugin.getServer().getVersion().contains("1.7") || ((Player)entity).getGameMode().equals(GameMode.SPECTATOR))) {
        ((Player)entity).setGameMode(GameMode.SURVIVAL);
    }
    if (entity instanceof Player) {
        plugin.getPlayers().setInTeleport(entity.getUniqueId(), false);
    }
}
 
源代码3 项目: ce   文件: Shuffle.java
@Override
public void effect(Event e, ItemStack item, final int level) {
	if(e instanceof EntityDamageByEntityEvent) {
	EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
	Entity target = event.getEntity();
	Player p = (Player) ((Projectile) event.getDamager()).getShooter();
	
	if(target.getEntityId() == p.getEntityId())
		return;
	
	Location pLoc = p.getLocation();
	Location tLoc = target.getLocation();
	
	target.teleport(pLoc);
	p.teleport(tLoc);
	
	EffectManager.playSound(tLoc, "ENTITY_ENDERMAN_TELEPORT", 0.4f, 2f);
	EffectManager.playSound(pLoc, "ENTITY_ENDERMAN_TELEPORT", 0.4f, 2f);

	
	for(int i = 10; i>0; i--) {
		p.getWorld().playEffect(tLoc, Effect.ENDER_SIGNAL, 10);
		p.getWorld().playEffect(pLoc, Effect.ENDER_SIGNAL, 10);
	}
	
	if(target instanceof Player) {
		p.sendMessage(ChatColor.DARK_PURPLE + "You have switched positions with " + target.getName() + "!");
		target.sendMessage(ChatColor.DARK_PURPLE + "You have switched positions with " + p.getName() + "!");
	}
	
	
	}
}