下面列出了org.bukkit.entity.Entity#sendMessage ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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;
}
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);
}
}
@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() + "!");
}
}
}