org.bukkit.Server.broadcastMessage()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.8k)|赞(0)|评价(0)|浏览(100)

本文整理了Java中org.bukkit.Server.broadcastMessage()方法的一些代码示例,展示了Server.broadcastMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Server.broadcastMessage()方法的具体详情如下:
包路径:org.bukkit.Server
类名称:Server
方法名:broadcastMessage

Server.broadcastMessage介绍

[英]Broadcast a message to all players.

This is the same as calling #broadcast(java.lang.String,java.lang.String) to #BROADCAST_CHANNEL_USERS
[中]向所有玩家广播一条消息。
这与调用#broadcast(java.lang.String,java.lang.String)给#broadcast_CHANNEL_用户相同

代码示例

代码示例来源:origin: Bukkit/Bukkit

/**
 * @see Server#broadcastMessage(String message)
 */
public static int broadcastMessage(String message) {
  return server.broadcastMessage(message);
}

代码示例来源:origin: webbukkit/dynmap

@Override
public void broadcastMessage(String msg) {
  getServer().broadcastMessage(msg);
}
@Override

代码示例来源:origin: SpigotMC/Spigot-API

/**
 * @see Server#broadcastMessage(String message)
 */
public static int broadcastMessage(String message) {
  return server.broadcastMessage(message);
}

代码示例来源:origin: BigScary/GriefPrevention

@Override
  public void run()
  {
    Bukkit.getServer().broadcastMessage(this.message);
  }    
}

代码示例来源:origin: EngineHub/CommandBook

@Command(aliases = {"broadcast"}, usage = "<message...>", desc = "Broadcast a message", min = 1, max = -1)
  @CommandPermissions({"commandbook.broadcast"})
  public void broadcast(CommandContext args, CommandSender sender) throws CommandException {
    BasePlugin.server().broadcastMessage(
        replaceColorMacros(config.broadcastFormat).replace(
            "%s", args.getJoinedStrings(0)));
  }
}

代码示例来源:origin: AddstarMC/Minigames

/**
 * Broadcasts a server message without a permission.
 * @param message - The message to be broadcasted (Can be manipulated with MinigamesBroadcastEvent)
 * @param minigame - The Minigame this broadcast is related to.
 * @param prefixColor - The color to be used in the prefix.
 */
public static void broadcast(String message, Minigame minigame, ChatColor prefixColor){
  MinigamesBroadcastEvent ev = new MinigamesBroadcastEvent(prefixColor + "[Minigames]" + ChatColor.WHITE, message, minigame);
  Bukkit.getPluginManager().callEvent(ev);
  Bukkit.getServer().broadcastMessage(ev.getMessageWithPrefix());
}

代码示例来源:origin: mcMMO-Dev/mcMMO

private void toggle(boolean enable, PrimarySkillType skill) {
    if (skill == null) {
      for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
        primarySkillType.setHardcoreVampirismEnabled(enable);
      }
    }
    else {
      skill.setHardcoreVampirismEnabled(enable);
    }

    mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.Vampirism.Name"), (skill == null ? "all skills" : skill)));
  }
}

代码示例来源:origin: mcMMO-Dev/mcMMO

private void toggle(boolean enable, PrimarySkillType skill) {
    if (skill == null) {
      for (PrimarySkillType primarySkillType : PrimarySkillType.NON_CHILD_SKILLS) {
        primarySkillType.setHardcoreStatLossEnabled(enable);
      }
    }
    else {
      skill.setHardcoreStatLossEnabled(enable);
    }

    mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Hardcore.Mode." + (enable ? "Enabled" : "Disabled"), LocaleLoader.getString("Hardcore.DeathStatLoss.Name"), (skill == null ? "all skills" : skill.getName())));
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * @param event a player leaving a server
 */
@EventHandler
public void onPlayerLeave(PlayerQuitEvent event) {
  Calendar eggcal = Calendar.getInstance();
  if (eggcal.after(plugin.getBeforeCal()) && eggcal.before(plugin.getAfterCal())) {
    String p = event.getPlayer().getName();
    if (p.equals(plugin.getTagConfig().getString("it"))) {
      // find a new player to make it
      Player newit = getRandomPlayer();
      plugin.getServer().broadcastMessage(plugin.getPluginName() + newit.getName() + " is now the " + ChatColor.RED + "'OOD'!");
      setConfig(newit.getName());
      long now = System.currentTimeMillis();
      long timewasit = now - plugin.getTagConfig().getLong("time");
      plugin.getServer().broadcastMessage(plugin.getPluginName() + p + " was 'OOD' for " + getHoursMinutesSeconds(timewasit) + " seconds.");
      setConfig(now);
      updateTagStats(p, timewasit);
    }
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * Informs the player that a game of tag in on. The date of the game can be set in tag.yml. It will also say happy
 * birthday to Doctor Who on the 23/11 of each year.
 * <p>
 * If no player is currently 'it' a random player is chosen (usually the first player to login).
 *
 * @param event a player joining a server
 */
@EventHandler
public void onPlayerTagJoin(PlayerJoinEvent event) {
  Calendar eggcal = Calendar.getInstance();
  if (eggcal.after(plugin.getBeforeCal()) && eggcal.before(plugin.getAfterCal())) {
    if (eggcal.get(Calendar.MONTH) == Calendar.NOVEMBER && eggcal.get(Calendar.DATE) == 23) { // zero based month
      int age = ((eggcal.get(Calendar.YEAR)) - 1963);
      String ordinal = getOrdinal(age);
      event.getPlayer().sendMessage(plugin.getPluginName() + "Happy " + age + ordinal + " Birthday Doctor Who!");
    }
    event.getPlayer().sendMessage(plugin.getPluginName() + "Today, and today only, you can play 'Tag the OOD'!");
    event.getPlayer().sendMessage(plugin.getPluginName() + "To see tag stats (and who is currently 'it'), use the command " + ChatColor.AQUA + "/tardis tagtheood");
    if (plugin.getTagConfig().get("it").equals("")) {
      Player startit = getRandomPlayer();
      plugin.getServer().broadcastMessage(plugin.getPluginName() + startit.getName() + " is now the " + ChatColor.RED + "'OOD'!");
      setConfig(startit.getName());
      setConfig(System.currentTimeMillis());
    }
  }
}

代码示例来源:origin: EngineHub/CommandBook

@Command(aliases = {"say"}, usage = "<message...>", desc = "Send a message", min = 1, max = -1)
@CommandPermissions({"commandbook.say"})
public void say(CommandContext args, CommandSender sender) throws CommandException {
  if (sender instanceof Player && sessions.getSession(AdministrativeSession.class, (Player) sender).isMute()) {
    sender.sendMessage(ChatColor.RED + "You are muted.");
    return;
  }
  String msg = args.getJoinedStrings(0);
  if (sender instanceof Player) {
    if (BasePlugin.callEvent(
        new AsyncPlayerChatEvent(false, (Player) sender, msg,
            new HashSet<Player>(BasePlugin.server().getOnlinePlayers()))).isCancelled()) {
      return;
    }
  }
  BasePlugin.callEvent(
      new CommandSenderMessageEvent(sender, msg));
  if (sender instanceof Player) {
    BasePlugin.server().broadcastMessage(
        "<" + ChatUtil.toColoredName(sender, ChatColor.RESET)
            + "> " + args.getJoinedStrings(0));
  } else {
    BasePlugin.server().broadcastMessage(
        replaceColorMacros(config.consoleSayFormat).replace(
            "%s", args.getJoinedStrings(0)));
  }
}

代码示例来源:origin: eccentricdevotion/TARDIS

/**
 * @param event a player right-clicking another player
 */
@EventHandler(ignoreCancelled = true)
public void onPlayerInteractPlayer(PlayerInteractEntityEvent event) {
  if (event.getRightClicked() instanceof Player) {
    Player clicked = (Player) event.getRightClicked();
    String p = clicked.getName();
    if (clicked.getName().equals(plugin.getTagConfig().getString("it"))) {
      Player newit = event.getPlayer();
      plugin.getServer().broadcastMessage(plugin.getPluginName() + newit.getName() + " is now the " + ChatColor.RED + "'OOD'!");
      setConfig(newit.getName());
      long now = System.currentTimeMillis();
      long timewasit = now - plugin.getTagConfig().getLong("time");
      plugin.getServer().broadcastMessage(plugin.getPluginName() + p + " was 'OOD' for " + getHoursMinutesSeconds(timewasit) + " seconds.");
      setConfig(now);
      updateTagStats(p, timewasit);
    }
  }
}

代码示例来源:origin: EngineHub/CommandBook

@Command(aliases = {"me"}, usage = "<message...>", desc = "Send an action message", min = 1, max = -1)
@CommandPermissions({"commandbook.say.me"})
public void me(CommandContext args, CommandSender sender) throws CommandException {
  if (sender instanceof Player && sessions.getSession(AdministrativeSession.class, sender).isMute()) {
    sender.sendMessage(ChatColor.RED + "You are muted.");
    return;
  }
  String name = ChatUtil.toColoredName(sender, ChatColor.YELLOW);
  String msg = args.getJoinedStrings(0);
  BasePlugin.callEvent(
      new SharedMessageEvent(name + " " + msg));
  BasePlugin.server().broadcastMessage("* " + name + " " + msg);
}

代码示例来源:origin: mcMMO-Dev/mcMMO

mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Stop.Subtitle"));
      10, 10*20, 20);
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.Start"));
mcMMO.p.getServer().broadcastMessage(LocaleLoader.getString("Commands.Event.XP", newXpRate));

代码示例来源:origin: EngineHub/CommandBook

BasePlugin.server().broadcastMessage(
      ChatColor.YELLOW + ChatUtil.toColoredName(sender, ChatColor.YELLOW)
      + " used Fireball attack on " + ChatUtil.toColoredName(player, ChatColor.YELLOW));
} else if (count == 3) {
  BasePlugin.server().broadcastMessage(
      ChatColor.YELLOW + ChatUtil.toColoredName(sender, ChatColor.YELLOW)
      + " used it on more people...");

代码示例来源:origin: EngineHub/CommandBook

BasePlugin.server().broadcastMessage(
      ChatColor.YELLOW + ChatUtil.toColoredName(sender, ChatColor.YELLOW)
      + " rocketed " + ChatUtil.toColoredName(player, ChatColor.YELLOW));
} else if (count == 3) {
  BasePlugin.server().broadcastMessage(
      ChatColor.YELLOW + ChatUtil.toColoredName(sender, ChatColor.YELLOW)
      + " rocketed more people...");

代码示例来源:origin: EngineHub/CommandBook

@Command(aliases = {"kick"}, usage = "<target> [reason...]", desc = "Kick a user",
    flags = "os", min = 1, max = -1)
@CommandPermissions({"commandbook.kick"})
public void kick(CommandContext args, CommandSender sender) throws CommandException {
  Iterable<Player> targets = InputUtil.PlayerParser.matchPlayers(sender, args.getString(0));
  String message = args.argsLength() >= 2 ? args.getJoinedStrings(1)
      : "Kicked!";
  String broadcastPlayers = "";
  for (Player player : targets) {
    if (CommandBook.inst().hasPermission(player, "commandbook.kick.exempt")
        && !(args.hasFlag('o') && CommandBook.inst().hasPermission(sender,
        "commandbook.kick.exempt.override"))) {
      sender.sendMessage(ChatColor.RED + "Player " + player.getName() + ChatColor.RED + " is exempt from being kicked!");
      continue;
    }
    player.kickPlayer(message);
    broadcastPlayers += ChatUtil.toColoredName(player, ChatColor.YELLOW) + " ";
    getBanDatabase().logKick(player, sender, message);
  }
  if (broadcastPlayers.length() > 0) {
    sender.sendMessage(ChatColor.YELLOW + "Player(s) kicked.");
    //Broadcast the Message
    if (config.broadcastKicks && !args.hasFlag('s')) {
      BasePlugin.server().broadcastMessage(ChatColor.YELLOW
          + ChatUtil.toColoredName(sender, ChatColor.YELLOW) + " has kicked " + broadcastPlayers
          + " - " + message);
    }
  }
}

代码示例来源:origin: EngineHub/CommandBook

CommandBook.server().broadcastMessage(ChatColor.YELLOW
    + ChatUtil.toColoredName(sender, ChatColor.YELLOW) + " has banned " + playerName
    + (message == null ? "" : " - " + message));

代码示例来源:origin: FunnyGuilds/FunnyGuilds

@Override
public void execute(CommandSender sender, String[] args) {
  MessagesConfig messages = Messages.getInstance();
  if (args.length < 1) {
    sender.sendMessage(messages.generalNoTagGiven);
    return;
  }
  Guild guild = GuildUtils.getByTag(args[0]);
  if (guild == null) {
    sender.sendMessage(messages.generalNoGuildFound);
    return;
  }
  User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
  if (!SimpleEventHandler.handle(new GuildDeleteEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild))) {
    return;
  }
  
  GuildUtils.deleteGuild(guild);
  Player owner = guild.getOwner().getPlayer();
  MessageFormatter formatter = new MessageFormatter()
      .register("{GUILD}", guild.getName())
      .register("{TAG}", guild.getTag())
      .register("{ADMIN}", sender.getName())
      .register("{PLAYER}", sender.getName());
  if (owner != null) {
    owner.sendMessage(formatter.format(messages.adminGuildBroken));
  }
  sender.sendMessage(formatter.format(messages.deleteSuccessful));
  Bukkit.getServer().broadcastMessage(formatter.format(messages.broadcastDelete));
}

代码示例来源:origin: FunnyGuilds/FunnyGuilds

Bukkit.getServer().broadcastMessage(formatter.format(messages.broadcastDelete));

相关文章

Server类方法