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


Java Entity.sendMessage方法代码示例

本文整理汇总了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;
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:20,代码来源:Boost.java

示例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 ());
    }
}
 
开发者ID:MagnaRisa,项目名称:CraftyProfessions,代码行数:18,代码来源:CoreListener.java

示例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();
        }
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:67,代码来源:PerchedCatDisplayer.java


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