Java Code Examples for org.bukkit.Bukkit.broadcast()

The following are Jave code examples for showing how to use broadcast() of the org.bukkit.Bukkit class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ProjectAres   File: MatchManager.java   View Source Code Vote up 6 votes
private @Nullable Match cycleTo(@Nullable Match oldMatch, PGMMap map) {
    try {
        mapErrorTracker.clearErrors(map);

        if(map.shouldReload()) {
            Bukkit.broadcast(ChatColor.GREEN + "XML changes detected, reloading", Permissions.MAPERRORS);
            mapLoader.loadMap(map);
            mapLibrary.pushDirtyMaps();
        }

        return matchLoader.cycleTo(oldMatch, map);
    } catch(MapNotFoundException e) {
        // Maps are sometimes removed, must handle it gracefully
        log.warning("Skipping deleted map " + map.getName());
        try {
            loadMapsAndRotations();
        } catch(MapNotFoundException e2) {
            log.severe("No maps could be loaded, server cannot cycle");
        }
        return null;
    }
}
 
Example 2
Project: Chambers   File: GameSetCountdownCommand.java   View Source Code Vote up 6 votes
@Command(name = "game.setcountdown", description = "Set the countdown time of the game", aliases = { "managegame.setcountdown" }, usage = "/<command> <args>", requiresTeam = false, adminsOnly = true)
public void onCommand(CommandArgs commandArgs) {
    Game game = plugin.getGameManager().getGame();
    if (commandArgs.length() != 1) {
        commandArgs.getSender().sendMessage(ChatColor.RED + "Usage: /" + commandArgs.getLabel() + " <time>");
        return;
    }
    if (game.getStatus() != GameStatus.STARTING) {
        commandArgs.getPlayer().sendMessage(ChatColor.RED + "The countdown has already started.");
        return;
    }
    if (!MathUtil.isInt(commandArgs.getArgs(0))) {
        commandArgs.getSender().sendMessage(ChatColor.RED + "Please enter a valid integer.");
        return;
    }
    int time = Math.abs(Integer.valueOf(commandArgs.getArgs(1)));
    if (time == 0 || time > 120) {
        commandArgs.getSender().sendMessage(ChatColor.RED + "Please enter a time less than 120 and greater than 0.");
    }
    game.setCountdownTime(time);
    Bukkit.broadcast("chambers.staff", ChatColor.GREEN + commandArgs.getSender().getName() + ChatColor.YELLOW + " has set the countdown time to " + commandArgs.getArgs(1) + ".");
}
 
Example 3
Project: ProjectAres   File: ChatLogHandler.java   View Source Code Vote up 5 votes
@Override
public void publish(LogRecord record) {
    Bukkit.broadcast(formatMessage(record), permission);

    if(Bukkit.getConsoleSender().hasPermission(permission) &&
       record.getThrown() != null &&
       !(record instanceof ChatLogRecord && ((ChatLogRecord) record).suppressStackTrace())) {

        record.getThrown().printStackTrace();
    }
}
 
Example 4
Project: HCFCore   File: RawcastCommand.java   View Source Code Vote up 5 votes
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
  if (args.length < 1)
  {
    sender.sendMessage(ChatColor.RED + "Usage: " + "/rawcast");
    return true;
  }
  String arg;
  String requiredNode;
  int position = 0;
  if ((args.length > 2) && ((arg = args[0]).startsWith("-p")))
  {
    int position1 = 1;
    requiredNode = arg.substring(2, arg.length());
  }
  else
  {
    position = 0;
    requiredNode = null;
  }
  String message = StringUtils.join(args, ' ', position, args.length);
  if (message.length() < 3)
  {
    sender.sendMessage(ChatColor.RED + "Broadcasts must be at least 3 characters.");
    return true;
  }
  message = ChatColor.translateAlternateColorCodes('&', message);
  if (requiredNode != null) {
    Bukkit.broadcast(message, requiredNode);
  } else {
    Bukkit.broadcastMessage(message);
  }
  return true;
}
 
Example 5
Project: HCFCore   File: RawcastCommand.java   View Source Code Vote up 5 votes
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
{
  if (args.length < 1)
  {
    sender.sendMessage(ChatColor.RED + "Usage: " + "/rawcast");
    return true;
  }
  String arg;
  String requiredNode;
  int position = 0;
  if ((args.length > 2) && ((arg = args[0]).startsWith("-p")))
  {
    int position1 = 1;
    requiredNode = arg.substring(2, arg.length());
  }
  else
  {
    position = 0;
    requiredNode = null;
  }
  String message = StringUtils.join(args, ' ', position, args.length);
  if (message.length() < 3)
  {
    sender.sendMessage(ChatColor.RED + "Broadcasts must be at least 3 characters.");
    return true;
  }
  message = ChatColor.translateAlternateColorCodes('&', message);
  if (requiredNode != null) {
    Bukkit.broadcast(message, requiredNode);
  } else {
    Bukkit.broadcastMessage(message);
  }
  return true;
}
 
Example 6
Project: Chambers   File: GameStopCommand.java   View Source Code Vote up 5 votes
@Command(name = "game.stop", description = "Stop the game", aliases = { "managegame.stop" }, usage = "/<command> <args>", requiresTeam = false, adminsOnly = true)
public void onCommand(CommandArgs commandArgs) {
    Game game = plugin.getGameManager().getGame();
    if (!game.hasStarted()) {
        commandArgs.getPlayer().sendMessage(ChatColor.RED + "The game has not started yet.");
        return;
    }
    Team team = null;
    if (commandArgs.length() == 1) {
        team = plugin.getTeamManager().getTeamByName(commandArgs.getArgs(0));
    }
    plugin.getGameManager().stop(team);
    Bukkit.broadcast("chambers.staff", ChatColor.GREEN + commandArgs.getSender().getName() + ChatColor.YELLOW + " has forcefully stopped the game.");
}
 
Example 7
Project: Chambers   File: GameStartCommand.java   View Source Code Vote up 5 votes
@Command(name = "game.start", description = "Start the game", aliases = { "managegame.start" }, usage = "/<command>", requiresTeam = false, adminsOnly = true)
public void onCommand(CommandArgs commandArgs) {
    Game game = plugin.getGameManager().getGame();
    if (game.hasStarted()) {
        commandArgs.getPlayer().sendMessage(ChatColor.RED + "The game has already started.");
        return;
    }
    plugin.getGameManager().start();
    Bukkit.broadcast("chambers.staff", ChatColor.GREEN + commandArgs.getSender().getName() + ChatColor.YELLOW + " has forcefully started the countdown.");
}
 
Example 8
Project: ProjectAres   File: WorldProblemMatchModule.java   View Source Code Vote up 4 votes
void broadcastDeveloperWarning(String message) {
    logger.warning(message);
    Bukkit.broadcast(ChatColor.RED + message, Permissions.MAPERRORS);
}
 
Example 9
Project: Arc-v2   File: ArcPlayerManager.java   View Source Code Vote up 4 votes
/**
 * Schedule a ban.
 *
 * @param player the player.
 */
public void scheduleBan(Player player) {

    UUID uuid = player.getUniqueId();
    String name = player.getName();

    if (BAN_QUEUE.contains(uuid)) {
        return;
    }

    // add and broadcast.
    BAN_QUEUE.add(uuid);
    int time = Arc.getArcConfiguration().getBanTime();

    Bukkit.broadcast(ChatColor.DARK_GRAY + "[" + ChatColor.RED + "Arc" + ChatColor.DARK_GRAY + "] " + ChatColor.BLUE
            + player.getName() + ChatColor.WHITE + " is scheduled to be banned in " + ChatColor.RED + time
            + ChatColor.WHITE + " seconds.", "arc.notify");

    long timeScheduled = System.currentTimeMillis();

    new BukkitRunnable() {
        @Override
        public void run() {
            if (!BAN_QUEUE.contains(uuid)) {
                this.cancel();
            }
            if (System.currentTimeMillis() - timeScheduled >= time * 1000) {
                if (BAN_QUEUE.contains(uuid)) {
                    // get the ban data and ban the player.
                    String reason = ChatColor.RED + "You have been banned for cheating.";

                    Date date = Arc.getArcConfiguration().getBanDate();
                    BanList.Type type = Arc.getArcConfiguration().getBanType();
                    Bukkit.getBanList(type).addBan(name, reason, date, null);

                    if (Arc.getArcConfiguration().shouldBroadcastBan()) {
                        String message = Arc.getArcConfiguration().getBroadcastMessage().replace("%player%", player.getName());
                        Bukkit.broadcastMessage(message);
                    }

                    if (player.isOnline()) {
                        player.kickPlayer(reason);
                    }

                    // remove the player.
                    BAN_QUEUE.remove(uuid);
                }
            }
        }
    }.runTaskTimer(Arc.getPlugin(), 0, 20);

}
 
Example 10
Project: Kineticraft   File: Core.java   View Source Code Vote up 4 votes
/**
 * Broadcast a text component to in-game and discord.
 * @param baseComponents
 */
public static void broadcast(BaseComponent... baseComponents) {
    Bukkit.getConsoleSender().sendMessage(TextUtils.toLegacy(baseComponents));
    Bukkit.broadcast(baseComponents);
    DiscordAPI.sendGame(TextUtils.toLegacy(baseComponents));
}
 
Example 11
Project: ChatAssets   File: LogHandler.java   View Source Code Vote up 4 votes
public static void broadcastJoinMessage(String permission, PlayerJoinEvent event) {
	event.setJoinMessage(null);
	for (String x : joinmessage) {
		Bukkit.broadcast(Main.colorcode(x), permission);
	}
}
 
Example 12
Project: ChatAssets   File: LogHandler.java   View Source Code Vote up 4 votes
public static void broadcastQuitMessage(String permission, PlayerQuitEvent event) {
	event.setQuitMessage(null);
	for (String x : quitmessage) {
		Bukkit.broadcast(x, permission);
	}
}