use of org.bukkit.ChatColor in project MassiveCore by MassiveCraft.
the class Mson method fromParsedMessage.
public static Mson fromParsedMessage(String message) {
if (message == null)
throw new NullPointerException("message");
// Everything must have a color.
// Because when we split, we assume that each part starts with a color code.
// Here we assure it starts with one.
message = ensureStartsWithColorCode(message);
// We split at color/format change.
String[] parts = PATTERN_PARSE_PREFIX.split(message);
// Since we start with a color, the first element will be empty.
// We don't want that empty element.
parts = Arrays.copyOfRange(parts, 1, parts.length);
List<Mson> msons = new MassiveList<>();
ChatColor latestColor = null;
Boolean bold = null;
Boolean italic = null;
Boolean underlined = null;
Boolean strikethrough = null;
Boolean obfuscated = null;
for (String part : parts) {
ChatColor color = ChatColor.getByChar(part.charAt(0));
String text = part.substring(1);
if ((color != null && color.isColor()) || color == ChatColor.RESET) {
latestColor = color;
bold = null;
italic = null;
underlined = null;
strikethrough = null;
obfuscated = null;
}
if (color == ChatColor.RESET)
latestColor = null;
else if (color == ChatColor.BOLD)
bold = true;
else if (color == ChatColor.ITALIC)
italic = true;
else if (color == ChatColor.UNDERLINE)
underlined = true;
else if (color == ChatColor.STRIKETHROUGH)
strikethrough = true;
else if (color == ChatColor.MAGIC)
obfuscated = true;
// Don't add empty msons.
if (text.isEmpty())
continue;
Mson mson = Mson.valueOf(text, latestColor, bold, italic, underlined, strikethrough, obfuscated, null, null, null, null, null);
msons.add(mson);
}
return Mson.mson(msons);
}
use of org.bukkit.ChatColor in project MassiveCore by MassiveCraft.
the class MUtil method getStackTraceString.
// -------------------------------------------- //
// STACK TRACE STRING: ONE
// -------------------------------------------- //
// Same as the Java8 source but with color option.
public static String getStackTraceString(StackTraceElement element, boolean color) {
ChatColor separatorColor = ChatColor.GRAY;
ChatColor classColor = ChatColor.YELLOW;
ChatColor methodColor = ChatColor.GREEN;
ChatColor fileColor = ChatColor.AQUA;
ChatColor lineColor = ChatColor.LIGHT_PURPLE;
String className = element.getClassName();
String methodName = element.getMethodName();
boolean nativeMethod = element.isNativeMethod();
String fileName = element.getFileName();
int lineNumber = element.getLineNumber();
StringBuilder ret = new StringBuilder();
if (color)
ret.append(classColor);
ret.append(className);
if (color)
ret.append(separatorColor);
ret.append(".");
if (color)
ret.append(methodColor);
ret.append(methodName);
if (color)
ret.append(separatorColor);
ret.append("(");
if (color)
ret.append(fileColor);
if (nativeMethod) {
ret.append("Native Method");
} else {
if (fileName != null && lineNumber >= 0) {
ret.append(fileName);
if (color)
ret.append(separatorColor);
ret.append(":");
if (color)
ret.append(lineColor);
ret.append(lineNumber);
} else {
if (fileName != null) {
ret.append(fileName);
} else {
ret.append("Unknown Source");
}
}
}
if (color)
ret.append(separatorColor);
ret.append(")");
return ret.toString();
}
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;
}
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 Bukkit_Bungee_PluginLib by GeorgH93.
the class MessageBuilder method style.
/**
* Sets the style of the current component.
*
* @param styles The array of styles to apply to the current component.
* @return The message builder instance (for chaining).
* @deprecated Use {@link at.pcgamingfreaks.Message.MessageBuilder#format(MessageFormat...)} or {@link at.pcgamingfreaks.Message.MessageBuilder#color(MessageColor)} instead!
*/
@Deprecated
public MessageBuilder style(ChatColor... styles) {
for (ChatColor style : styles) {
if (style == ChatColor.RESET) {
color(MessageColor.RESET);
format(MessageFormat.RESET);
} else if (style.isColor())
color(style);
else
format(style);
}
return this;
}
Aggregations