Search in sources :

Example 76 with ChatColor

use of org.bukkit.ChatColor in project Essentials by EssentialsX.

the class Settings method _getOperatorColor.

private String _getOperatorColor() {
    final String colorName = config.getString("ops-name-color", null);
    if (colorName == null) {
        return ChatColor.RED.toString();
    } else if (colorName.equalsIgnoreCase("none") || colorName.isEmpty()) {
        return null;
    }
    try {
        return FormatUtil.parseHexColor(colorName);
    } catch (final NumberFormatException ignored) {
    }
    try {
        return ChatColor.valueOf(colorName.toUpperCase(Locale.ENGLISH)).toString();
    } catch (final IllegalArgumentException ignored) {
    }
    final ChatColor lastResort = ChatColor.getByChar(colorName);
    if (lastResort != null) {
        return lastResort.toString();
    }
    return null;
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 77 with ChatColor

use of org.bukkit.ChatColor in project Essentials by EssentialsX.

the class FormatUtil method stripColor.

static String stripColor(final String input, final Set<ChatColor> strip) {
    final StringBuffer builder = new StringBuffer();
    final Matcher matcher = STRIP_ALL_PATTERN.matcher(input);
    searchLoop: while (matcher.find()) {
        final char code = matcher.group(1).toLowerCase(Locale.ROOT).charAt(0);
        for (final ChatColor color : strip) {
            if (color.getChar() == code) {
                matcher.appendReplacement(builder, "");
                continue searchLoop;
            }
        }
        // Don't replace
        matcher.appendReplacement(builder, "$0");
    }
    matcher.appendTail(builder);
    return builder.toString();
}
Also used : Matcher(java.util.regex.Matcher) ChatColor(org.bukkit.ChatColor)

Example 78 with ChatColor

use of org.bukkit.ChatColor in project CitizensAPI by CitizensDev.

the class Messaging method prettify.

private static String prettify(String message) {
    String trimmed = message.trim();
    String messageColour = MESSAGE_COLOUR;
    if (!trimmed.isEmpty()) {
        if (trimmed.charAt(0) == ChatColor.COLOR_CHAR) {
            ChatColor test = ChatColor.getByChar(trimmed.substring(1, 2));
            if (test == null) {
                message = messageColour + message;
            } else
                messageColour = test.toString();
        } else {
            message = messageColour + message;
        }
    }
    message = HIGHLIGHT_MATCHER.matcher(message).replaceAll(HIGHLIGHT_COLOUR);
    message = ERROR_MATCHER.matcher(message).replaceAll(ERROR_COLOUR);
    return CHAT_NEWLINE.matcher(message).replaceAll("<br>]]").replace("]]", messageColour);
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 79 with ChatColor

use of org.bukkit.ChatColor in project RedProtect by FabioZumbi12.

the class BlockLimitCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length == 1 && (sender instanceof ConsoleCommandSender || RedProtect.get().getPermissionHandler().hasPerm(sender, "redprotect.command.admin.blocklimit"))) {
        Player offp = RedProtect.get().getServer().getPlayer(args[0]);
        if (offp == null) {
            RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.noplayer.thisname").replace("{player}", args[0]));
            return true;
        }
        int limit = RedProtect.get().getPermissionHandler().getPlayerBlockLimit(offp);
        if (limit < 0 || RedProtect.get().getPermissionHandler().hasPerm(offp, "redprotect.limits.blocks.unlimited")) {
            RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.nolimit"));
            return true;
        }
        int currentUsed = RedProtect.get().getRegionManager().getTotalRegionSize(offp.getUniqueId().toString(), offp.getWorld().getName());
        ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
        RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.yourarea") + color + currentUsed + RedProtect.get().getLanguageManager().get("general.color") + "/" + color + limit + RedProtect.get().getLanguageManager().get("general.color"));
        return true;
    } else if (sender instanceof Player) {
        Player player = (Player) sender;
        if (args.length == 0) {
            int limit = RedProtect.get().getPermissionHandler().getPlayerBlockLimit(player);
            if (limit < 0 || RedProtect.get().getPermissionHandler().hasPerm(player, "redprotect.limits.blocks.unlimited")) {
                RedProtect.get().getLanguageManager().sendMessage(player, "cmdmanager.nolimit");
                return true;
            }
            String uuid = player.getUniqueId().toString();
            int currentUsed = RedProtect.get().getRegionManager().getTotalRegionSize(uuid, player.getWorld().getName());
            ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
            RedProtect.get().getLanguageManager().sendMessage(player, RedProtect.get().getLanguageManager().get("cmdmanager.yourarea") + color + currentUsed + RedProtect.get().getLanguageManager().get("general.color") + "/" + color + limit + RedProtect.get().getLanguageManager().get("general.color"));
            return true;
        }
    }
    RedProtect.get().getLanguageManager().sendCommandHelp(sender, "blocklimit", true);
    return true;
}
Also used : Player(org.bukkit.entity.Player) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ChatColor(org.bukkit.ChatColor)

Example 80 with ChatColor

use of org.bukkit.ChatColor in project RedProtect by FabioZumbi12.

the class ClaimLimitCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    if (args.length == 2 && (sender instanceof ConsoleCommandSender || RedProtect.get().getPermissionHandler().hasPerm(sender, "redprotect.command.admin.claimlimit"))) {
        Player offp = RedProtect.get().getServer().getPlayer(args[0]);
        World w = RedProtect.get().getServer().getWorld(args[1]);
        if (w == null) {
            RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.region.invalidworld"));
            return true;
        }
        if (offp == null) {
            RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.noplayer.thisname").replace("{player}", args[0]));
            return true;
        }
        int limit = RedProtect.get().getPermissionHandler().getPlayerClaimLimit(offp);
        if (limit < 0 || RedProtect.get().getPermissionHandler().hasPerm(offp, "redprotect.limits.claim.unlimited")) {
            RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.nolimit"));
            return true;
        }
        int currentUsed = RedProtect.get().getRegionManager().getRegions(offp.getUniqueId().toString(), w.getName()).size();
        ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
        RedProtect.get().getLanguageManager().sendMessage(sender, RedProtect.get().getLanguageManager().get("cmdmanager.yourclaims") + color + currentUsed + RedProtect.get().getLanguageManager().get("general.color") + "/" + color + limit + RedProtect.get().getLanguageManager().get("general.color"));
        return true;
    } else if (sender instanceof Player) {
        Player player = (Player) sender;
        if (args.length == 0) {
            int limit = RedProtect.get().getPermissionHandler().getPlayerClaimLimit(player);
            if (limit < 0 || RedProtect.get().getPermissionHandler().hasPerm(player, "redprotect.limits.claim.unlimited")) {
                RedProtect.get().getLanguageManager().sendMessage(player, "cmdmanager.nolimit");
                return true;
            }
            int currentUsed = RedProtect.get().getRegionManager().getRegions(player.getUniqueId().toString(), player.getWorld().getName()).size();
            ChatColor color = currentUsed >= limit ? ChatColor.RED : ChatColor.GOLD;
            RedProtect.get().getLanguageManager().sendMessage(player, RedProtect.get().getLanguageManager().get("cmdmanager.yourclaims") + color + currentUsed + RedProtect.get().getLanguageManager().get("general.color") + "/" + color + limit + RedProtect.get().getLanguageManager().get("general.color"));
            return true;
        }
    }
    RedProtect.get().getLanguageManager().sendCommandHelp(sender, "claimlimit", true);
    return true;
}
Also used : Player(org.bukkit.entity.Player) World(org.bukkit.World) ConsoleCommandSender(org.bukkit.command.ConsoleCommandSender) ChatColor(org.bukkit.ChatColor)

Aggregations

ChatColor (org.bukkit.ChatColor)182 ArrayList (java.util.ArrayList)34 Player (org.bukkit.entity.Player)31 World (org.bukkit.World)12 Team (org.bukkit.scoreboard.Team)11 Matcher (java.util.regex.Matcher)10 ItemStack (org.bukkit.inventory.ItemStack)10 List (java.util.List)9 JSONObject (org.json.simple.JSONObject)9 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)8 DyeColor (org.bukkit.DyeColor)7 Material (org.bukkit.Material)7 ItemMeta (org.bukkit.inventory.meta.ItemMeta)7 HashMap (java.util.HashMap)6 Scoreboard (org.bukkit.scoreboard.Scoreboard)6 IOException (java.io.IOException)4 DecimalFormat (java.text.DecimalFormat)4 UUID (java.util.UUID)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 Score (org.bukkit.scoreboard.Score)4