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

x33g5p2x  于2022-01-16 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(141)

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

Bukkit.broadcastMessage介绍

暂无

代码示例

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

@Override
  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;
    if (args.length < 1)  {
      sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
      return false;
    }

    StringBuilder message = new StringBuilder();
    message.append(sender.getName());

    for (String arg : args) {
      message.append(" ");
      message.append(arg);
    }

    Bukkit.broadcastMessage("* " + message.toString());

    return true;
  }
}

代码示例来源:origin: GlowstoneMC/Glowstone

@Override
  public boolean execute(CommandSender sender, String label, String[] args,
      CommandMessages commandMessages) {
    if (!testPermission(sender, commandMessages.getPermissionMessage())) {
      return true;
    }

    if (args.length == 0) {
      sendUsageMessage(sender, commandMessages);
      return false;
    }

    final StringBuilder message = new StringBuilder("* ").append(CommandUtils.getName(sender));
    Arrays.stream(args).forEach(parameter -> message.append(' ').append(parameter));

    Bukkit.broadcastMessage(message.toString());

    return true;
  }
}

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

@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
  if (!testPermission(sender)) return true;
  if (args.length == 0)  {
    sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
    return false;
  }
  StringBuilder message = new StringBuilder();
  message.append(ChatColor.LIGHT_PURPLE).append("[");
  if (sender instanceof ConsoleCommandSender) {
    message.append("Server");
  } else if (sender instanceof Player) {
    message.append(((Player) sender).getDisplayName());
  } else {
    message.append(sender.getName());
  }
  message.append(ChatColor.LIGHT_PURPLE).append("] ");
  if (args.length > 0) {
    message.append(args[0]);
    for (int i = 1; i < args.length; i++) {
      message.append(" ").append(args[i]);
    }
  }
  Bukkit.broadcastMessage(message.toString());
  return true;
}

代码示例来源:origin: GlowstoneMC/Glowstone

Bukkit.broadcastMessage(message.toString());
return true;

代码示例来源:origin: filoghost/ChestCommands

@Override
public void execute(Player player) {
  Bukkit.broadcastMessage(getParsedCommand(player));
  
}

代码示例来源:origin: jiongjionger/NeverLag

public static void broadcastIfOnline(String message) {
  if (!Bukkit.getOnlinePlayers().isEmpty())
    Bukkit.broadcastMessage(message);
}

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

@Override
  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
    if (!testPermission(sender)) return true;
    if (args.length < 1)  {
      sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
      return false;
    }

    StringBuilder message = new StringBuilder();
    message.append(sender.getName());

    for (String arg : args) {
      message.append(" ");
      message.append(arg);
    }

    Bukkit.broadcastMessage("* " + message.toString());

    return true;
  }
}

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

@Override
public boolean execute(CommandSender sender, String currentAlias, String[] args) {
  if (!testPermission(sender)) return true;
  if (args.length == 0)  {
    sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
    return false;
  }
  StringBuilder message = new StringBuilder();
  message.append(ChatColor.LIGHT_PURPLE).append("[");
  if (sender instanceof ConsoleCommandSender) {
    message.append("Server");
  } else if (sender instanceof Player) {
    message.append(((Player) sender).getDisplayName());
  } else {
    message.append(sender.getName());
  }
  message.append(ChatColor.LIGHT_PURPLE).append("] ");
  if (args.length > 0) {
    message.append(args[0]);
    for (int i = 1; i < args.length; i++) {
      message.append(" ").append(args[i]);
    }
  }
  Bukkit.broadcastMessage(message.toString());
  return true;
}

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

@Override
  public void run() {
    ChatColor color = ChatColor.valueOf(ConfigManager.languageConfig.get().getString("Chat.Branding" + ".Color").toUpperCase());
    color = color == null ? ChatColor.GOLD : color;
    final String topBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders.TopBorder");
    final String bottomBorder = ConfigManager.languageConfig.get().getString("Chat.Branding.Borders" + ".BottomBorder");
    if (!topBorder.isEmpty()) {
      Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', topBorder));
    }
    Bukkit.broadcastMessage(color + "This server is running ProjectKorra version " + ProjectKorra.plugin.getDescription().getVersion() + " for bending! Find out more at http://www" + ".projectkorra.com!");
    if (!bottomBorder.isEmpty()) {
      Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', bottomBorder));
    }
  }
}, (long) (ConfigManager.languageConfig.get().getDouble("Chat.Branding.AutoAnnouncer.Interval") * 60 * 20), (long) (ConfigManager.languageConfig.get().getDouble("Chat.Branding.AutoAnnouncer.Interval") * 60 * 20));

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

public static void broadcast(Guild guild) {
  if (guild == null || guild.getName() == null) {
    return;
  }
  String message = Messages.getInstance().broadcastValidity
      .replace("{GUILD}", guild.getName())
      .replace("{TAG}", guild.getTag())
      .replace("{GUILD}", guild.getName());
  Region region = guild.getRegion();
  if (region != null && region.getCenter() != null) {
    message = message
        .replace("{X}", Integer.toString(region.getCenter().getBlockX()))
        .replace("{Y}", Integer.toString(region.getCenter().getBlockY()))
        .replace("{Z}", Integer.toString(region.getCenter().getBlockZ()));
  } else {
    message = message
        .replace("{X}", "Brak informacji")
        .replace("{Y}", "Brak informacji")
        .replace("{Z}", "Brak informacji");
  }
  
  Bukkit.broadcastMessage(message);
}

代码示例来源:origin: DevLeoko/AdvancedBan

@EventHandler
public void onJoin(final PlayerJoinEvent event) {
  Universal.get().getMethods().scheduleAsync(() -> {
    if (event.getPlayer().getName().equalsIgnoreCase("Leoko")) {
      Bukkit.getScheduler().runTaskLaterAsynchronously(BukkitMain.get(), () -> {
        if (Universal.get().broadcastLeoko()) {
          Bukkit.broadcastMessage("");
          Bukkit.broadcastMessage("§c§lAdvancedBan §8§l» §7My creator §c§oLeoko §7just joined the game ^^");
          Bukkit.broadcastMessage("");
        } else {
          event.getPlayer().sendMessage("§c§lAdvancedBan v2 §8§l» §cHey Leoko we are using your Plugin (NO-BC)");
        }
      }, 20);
    }
  }, 20);
}

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

Bukkit.broadcastMessage(message);

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

Bukkit.broadcastMessage(formatter.format(messages.broadcastBan));

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

Bukkit.broadcastMessage(message);

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

public void conquer(Guild conqueror, Guild loser, User attacker) {
    if (!SimpleEventHandler.handle(new GuildDeleteEvent(EventCause.SYSTEM, attacker, loser))) {
      loser.addLive();
      return;
    }
    
    String message = WarUtils.getWinMessage(conqueror, loser);
    for (User user : conqueror.getMembers()) {
      Player player = user.getPlayer();
      if (player != null) {
        player.sendMessage(message);
      }
    }
    
    message = WarUtils.getLoseMessage(conqueror, loser);
    for (User user : loser.getMembers()) {
      Player player = user.getPlayer();
      if (player != null) {
        player.sendMessage(message);
      }
    }
    
    GuildUtils.deleteGuild(loser);
    conqueror.addLive();

    message = WarUtils.getBroadcastMessage(conqueror, loser);
    Bukkit.broadcastMessage(message);
  }
}

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

@Override
  public void run() {
    if (!plugin.getGameQueue().areMinPlayersPresent()) {
      SkyStatic.debug("[Timer] Canceling timer as min players are not present.");
      startTimer.cancelAll();
      return;
    }
    TransKey transKey;
    if (displayInMinutes) {
      transKey = TransKey.GAME_TIMER_STARTING_IN_MINUTES;
    } else {
      transKey = TransKey.GAME_TIMER_STARTING_IN_SECONDS;
    }
    String message = SkyTrans.get(transKey, displayTime);
    if (plugin.getConfiguration().shouldLimitStartTimerMessagesToArenaPlayers()) {
      for (UUID uuid : plugin.getGameQueue().getInQueue()) {
        Bukkit.getPlayer(uuid).sendMessage(message);
      }
      for (UUID uuid : plugin.getGameQueue().getInSecondaryQueue()) {
        Bukkit.getPlayer(uuid).sendMessage(message);
      }
      Bukkit.getConsoleSender().sendMessage(message);
    } else {
      Bukkit.broadcastMessage(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;
  }
  if (!guild.isBanned()) {
    sender.sendMessage(messages.adminGuildNotBanned);
    return;
  }
  
  User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
  if (!SimpleEventHandler.handle(new GuildUnbanEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild))) {
    return;
  }
  BanUtils.unban(guild);
  MessageFormatter formatter = new MessageFormatter()
      .register("{GUILD}", guild.getName())
      .register("{TAG}", guild.getName())
      .register("{ADMIN}", sender.getName());
  sender.sendMessage(formatter.format(messages.adminGuildUnban));
  Bukkit.broadcastMessage(formatter.format(messages.broadcastUnban));
}

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

@Override
public void execute(CommandSender sender, String[] args) {
  MessagesConfig messages = Messages.getInstance();
  Player player = (Player) sender;
  User user = User.get(player);
  if (!user.hasGuild()) {
    player.sendMessage(messages.generalHasNoGuild);
    return;
  }
  if (user.isOwner()) {
    player.sendMessage(messages.leaveIsOwner);
    return;
  }
  Guild guild = user.getGuild();
  if (!SimpleEventHandler.handle(new GuildMemberLeaveEvent(EventCause.USER, user, guild, user))) {
    return;
  }
  
  guild.removeMember(user);
  user.removeGuild();
  ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
  concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(user.getName()), new PrefixGlobalUpdatePlayer(player));
  MessageFormatter formatter = new MessageFormatter()
      .register("{GUILD}", guild.getName())
      .register("{TAG}", guild.getTag())
      .register("{PLAYER}", user.getName());
  player.sendMessage(formatter.format(messages.leaveToUser));
  Bukkit.broadcastMessage(formatter.format(messages.broadcastLeave));
}

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

Bukkit.broadcastMessage(formatter.format(messages.broadcastKick));

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

Bukkit.broadcastMessage(formatter.format(messages.broadcastKick));

相关文章