本文整理汇总了Java中org.bukkit.entity.Entity.sendMessage方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.sendMessage方法的具体用法?Java Entity.sendMessage怎么用?Java Entity.sendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.sendMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: boost
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
private boolean boost(Entity source, Entity receiver) {
if (!(source instanceof Player) || !(receiver instanceof Player) || !isPlaying((Player) source) || !isPlaying((Player) receiver))
return false;
receiver.sendMessage(ChatColor.GREEN + "Whoosh!");
Vector toSender = source.getVelocity().subtract(receiver.getVelocity());
toSender.setY(0);
double distance = toSender.length();
if(distance > 0) {
toSender.multiply(1D / distance);
} else {
float yaw = source.getLocation().getYaw();
toSender.setX(-1 * Math.sin(toRad(yaw)));
toSender.setZ(Math.cos(toRad(yaw)));
}
toSender.multiply(2.5D);
toSender.setY(2);
receiver.setVelocity(toSender);
return true;
}
示例2: onEntityPickup
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
/**
* THIS METHOD IS FOR TESTING ONLY AND WILL NOT BE USED IN THE FINAL PRODUCTION
*/
@EventHandler
public void onEntityPickup (EntityPickupItemEvent event)
{
Entity player = event.getEntity ();
if (player instanceof Player)
{
player.sendMessage (event.getItem ().getName ());
// TODO: Use the below way to retrieve the Material Type from an Item.
player.sendMessage (event.getItem ().getItemStack ().getType ().toString ());
player.sendMessage (event.getItem ().getItemStack ().getData ().toString ());
player.sendMessage (event.getItem ().getItemStack ().getItemMeta ().toString ());
}
}
示例3: handleInteraction
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public void handleInteraction(Entity who, Entity with)
{
if (who instanceof Player && with instanceof Player)
{
if (this.waitingFirstInteraction && who.getUniqueId().equals(this.player.getUniqueId()))
{
this.playerTargeted = with.getUniqueId();
this.interactWith((Player) with);
this.playerWasFlying = this.player.getAllowFlight();
this.targetWasFlying = ((Player) with).getAllowFlight();
this.player.setFlying(false);
this.player.setAllowFlight(false);
((Player) with).setFlying(false);
((Player) with).setAllowFlight(false);
this.player.sendMessage(TAG + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " a provoqué " + ChatColor.GOLD + with.getName() + ChatColor.YELLOW + " en duel !");
with.sendMessage(TAG + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " a provoqué " + ChatColor.GOLD + with.getName() + ChatColor.YELLOW + " en duel !");
this.player.playSound(with.getLocation(), Sound.ENTITY_CAT_AMBIENT, 1.0F, 1.0F);
((Player) with).playSound(with.getLocation(), Sound.ENTITY_CAT_AMBIENT, 1.0F, 1.0F);
this.waitingFirstInteraction = false;
this.waitingSecondInteraction = true;
this.waitingInteractionTask = this.hub.getServer().getScheduler().runTaskLater(this.hub, () ->
{
this.player.sendMessage(TAG + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " remporte le duel contre " + ChatColor.GOLD + with.getName() + ChatColor.YELLOW + " !");
with.sendMessage(TAG + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " remporte le duel contre " + ChatColor.GOLD + with.getName() + ChatColor.YELLOW + " !");
if (this.hub.getServer().getPlayer(this.player.getUniqueId()) != null)
{
this.player.playSound(this.player.getLocation(), Sound.ENTITY_CAT_AMBIENT, 1.0F, 1.0F);
this.player.setAllowFlight(this.playerWasFlying);
}
if (this.hub.getServer().getPlayer(with.getUniqueId()) != null)
((Player) with).setAllowFlight(this.targetWasFlying);
this.waitingSecondInteraction = false;
this.end();
}, 20L * 60);
}
else if (this.waitingSecondInteraction && who.getUniqueId().equals(this.playerTargeted))
{
this.waitingInteractionTask.cancel();
this.player.sendMessage(TAG + ChatColor.GOLD + who.getName() + ChatColor.YELLOW + " remporte le duel contre " + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " !");
who.sendMessage(TAG + ChatColor.GOLD + who.getName() + ChatColor.YELLOW + " remporte le duel contre " + ChatColor.GOLD + this.player.getName() + ChatColor.YELLOW + " !");
if (this.hub.getServer().getPlayer(who.getUniqueId()) != null)
{
((Player) who).playSound(who.getLocation(), Sound.ENTITY_CAT_AMBIENT, 1.0F, 1.0F);
((Player) who).setAllowFlight(this.targetWasFlying);
}
if (this.hub.getServer().getPlayer(this.player.getUniqueId()) != null)
this.player.setAllowFlight(this.playerWasFlying);
this.waitingSecondInteraction = false;
this.end();
}
}
}