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

The following examples show how to use org.bukkit.Bukkit#broadcast() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MatchManager.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
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
Source File: PGMPlugin.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void publish(LogRecord record) {
  final String message = format(record);

  if (message != null) {
    getLogger().log(Level.INFO, ChatColor.stripColor(message));
    Bukkit.broadcast(message, Permissions.DEBUG);
  }

  if (message == null || message.contains("Unhandled")) {
    getLogger()
        .log(record.getLevel(), record.getThrown().getMessage(), record.getThrown().getCause());
  }
}
 
Example 3
Source File: ChatLogHandler.java    From ProjectAres with GNU Affero General Public License v3.0 5 votes vote down vote up
@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
Source File: UpdateChecker.java    From skUtilities with GNU General Public License v3.0 5 votes vote down vote up
private void prSysU(String s) {
    if (broadcastUpdates) {
        String message = ChatColor.AQUA + "[" + plugin.getName() + ": Update] " + ChatColor.GRAY + s;
        Bukkit.broadcast(message, plugin.getName() + ".update");
    }
    skUtilities.prSysI(s);
}
 
Example 5
Source File: CloudServer.java    From CloudNet with Apache License 2.0 4 votes vote down vote up
private void addTeamEntry(Player target, Player all, PermissionGroup permissionGroup) {
    String teamName = permissionGroup.getTagId() + permissionGroup.getName();
    if (teamName.length() > 16) {
        teamName = teamName.substring(0, 16);
        CloudAPI.getInstance()
                .dispatchConsoleMessage("In order to prevent issues, the name (+ tagID) of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!");
        CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the name of the group in your perms.yml");
        Bukkit.broadcast("In order to prevent issues, the name (+ tagID) of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!",
                         "cloudnet.notify");
        Bukkit.broadcast("Please fix this issue by changing the name of the group in your perms.yml", "cloudnet.notify");
    }
    Team team = all.getScoreboard().getTeam(teamName);
    if (team == null) {
        team = all.getScoreboard().registerNewTeam(teamName);
    }

    if (permissionGroup.getPrefix().length() > 16) {
        permissionGroup.setPrefix(permissionGroup.getPrefix().substring(0, 16));
        CloudAPI.getInstance()
                .dispatchConsoleMessage("In order to prevent issues, the prefix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!");
        CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the prefix in your perms.yml");
        Bukkit.broadcast("In order to prevent issues, the prefix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!",
                         "cloudnet.notify");
        Bukkit.broadcast("Please fix this issue by changing the prefix in your perms.yml", "cloudnet.notify");
    }
    if (permissionGroup.getSuffix().length() > 16) {
        permissionGroup.setSuffix(permissionGroup.getSuffix().substring(0, 16));
        CloudAPI.getInstance()
                .dispatchConsoleMessage("In order to prevent issues, the suffix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!");
        CloudAPI.getInstance().dispatchConsoleMessage("Please fix this issue by changing the suffix in your perms.yml");
        Bukkit.broadcast("In order to prevent issues, the suffix of the group " + permissionGroup.getName() + " was temporarily shortened to 16 characters!",
                         "cloudnet.notify");
        Bukkit.broadcast("Please fix this issue by changing the suffix in your perms.yml", "cloudnet.notify");
    }

    try {
        Method setColor = team.getClass().getDeclaredMethod("setColor", ChatColor.class);
        setColor.setAccessible(true);
        if (permissionGroup.getColor().length() != 0) {
            setColor.invoke(team, ChatColor.getByChar(permissionGroup.getColor().replaceAll("&", "").replaceAll("§", "")));
        } else {
            setColor.invoke(team, ChatColor.getByChar(ChatColor.getLastColors(permissionGroup.getPrefix().replace('&', '§'))
                                                               .replaceAll("&", "")
                                                               .replaceAll("§", "")));
        }
    } catch (NoSuchMethodException ignored) {
    } catch (IllegalAccessException | InvocationTargetException e) {
        e.printStackTrace();
    }


    team.setPrefix(ChatColor.translateAlternateColorCodes('&', permissionGroup.getPrefix()));
    team.setSuffix(ChatColor.translateAlternateColorCodes('&', permissionGroup.getSuffix()));

    team.addEntry(target.getName());

    target.setDisplayName(ChatColor.translateAlternateColorCodes('&', permissionGroup.getDisplay() + target.getName()));
}
 
Example 6
Source File: WorldProblemMatchModule.java    From ProjectAres with GNU Affero General Public License v3.0 4 votes vote down vote up
void broadcastDeveloperWarning(String message) {
    logger.warning(message);
    Bukkit.broadcast(ChatColor.RED + message, Permissions.MAPERRORS);
}
 
Example 7
Source File: Skript.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
public static void adminBroadcast(final String message) {
	Bukkit.broadcast(SKRIPT_PREFIX + Utils.replaceEnglishChatStyles(message), "skript.admin");
}
 
Example 8
Source File: skUtilities.java    From skUtilities with GNU General Public License v3.0 4 votes vote down vote up
public static void prSysE(String s, String c) {
  Bukkit.getServer().getLogger().severe("[skUtilities] v" + getVer() + ": " + s + " (" + c + ".class)");
  if (Bukkit.getPluginManager().getPlugin("skUtilities").getConfig().getBoolean("broadcastErrors", true)) {
    Bukkit.broadcast(ChatColor.RED + "[skUtilities: WARN]" + ChatColor.GRAY + " v" + getVer() + ": " + s + " (" + c + ".class)", "skUtilities.error");
  }
}
 
Example 9
Source File: Skript.java    From Skript with GNU General Public License v3.0 2 votes vote down vote up
/**
 * @param message
 * @param permission
 * @see #adminBroadcast(String)
 */
public static void broadcast(final String message, final String permission) {
	Bukkit.broadcast(SKRIPT_PREFIX + Utils.replaceEnglishChatStyles(message), permission);
}