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


Java MutableMessageChannel类代码示例

本文整理汇总了Java中org.spongepowered.api.text.channel.MutableMessageChannel的典型用法代码示例。如果您正苦于以下问题:Java MutableMessageChannel类的具体用法?Java MutableMessageChannel怎么用?Java MutableMessageChannel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MutableMessageChannel类属于org.spongepowered.api.text.channel包,在下文中一共展示了MutableMessageChannel类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: awardPowerup

import org.spongepowered.api.text.channel.MutableMessageChannel; //导入依赖的package包/类
public void awardPowerup(Player player, ItemStack held) {

    ItemStack powerup;

    Optional<String> optSuffix = SkyFeather.getSuffix(held);
    if (optSuffix.isPresent() && optSuffix.get().equals("Doom")) {
      return;
    }

    int uses = 5;
    double radius = 3;
    double flight = 2;
    double pushBack = 4;

    if (Probability.getChance(2)) {
      radius = 5;
      pushBack = 6;
    } else {
      flight = 6;
    }

    if (Probability.getChance(50)) {
      uses = -1;
      radius = 7;
      flight = 6;
      pushBack = 6;
      MutableMessageChannel targets = getPlayerMessageChannel(PlayerClassifier.SPECTATOR).asMutable();
      targets.removeMember(player);
      targets.send(Text.of(TextColors.RED, player.getName(), " has been given a Doom feather!"));

      player.getInventory().clear();
    }

    powerup = newItemStack(CustomItemTypes.SKY_FEATHER);
    SkyFeather.setFeatherProperties(powerup, uses, radius, flight, pushBack);

    player.getInventory().offer(powerup);
    tf(player).inventoryContainer.detectAndSendChanges();

    // Display name doesn't need checked as all power ups have one assigned
    player.sendMessage(Text.of(TextColors.YELLOW, "You obtain a power-up!"));
  }
 
开发者ID:Skelril,项目名称:Skree,代码行数:43,代码来源:SkyWarsInstance.java


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