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;
}
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();
}
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);
}
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;
}
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;
}
Aggregations