use of org.bukkit.ChatColor in project Spirits by xNuminousx.
the class Methods method setSpiritDescription.
/*
* Used to set a unique spirit description in chat
* which will appear in the '/b h' command.
*
* spiritType = The type of spirit color that will appear.
* abilityType = What type of ability the description is for.
*/
public static String setSpiritDescription(SpiritType spiritType, String abilityType) {
ChatColor titleColor = null;
ChatColor descColor = null;
if (spiritType == SpiritType.NEUTRAL) {
titleColor = ChatColor.BLUE;
descColor = ChatColor.DARK_AQUA;
} else if (spiritType == SpiritType.LIGHT) {
titleColor = ChatColor.AQUA;
descColor = ChatColor.WHITE;
} else if (spiritType == SpiritType.DARK) {
titleColor = ChatColor.DARK_GRAY;
descColor = ChatColor.DARK_RED;
}
return titleColor + "" + ChatColor.BOLD + abilityType + ": " + descColor;
}
use of org.bukkit.ChatColor in project MagicPlugin by elBukkit.
the class BaseMagicProperties method describe.
public void describe(CommandSender sender, @Nullable Set<String> ignoreProperties, @Nullable Set<String> overriddenProperties) {
ConfigurationSection itemConfig = getConfiguration();
Set<String> keys = itemConfig.getKeys(false);
for (String key : keys) {
Object value = itemConfig.get(key);
if (value != null && (ignoreProperties == null || !ignoreProperties.contains(key))) {
ChatColor propertyColor = ChatColor.GRAY;
if (overriddenProperties == null || !overriddenProperties.contains(key)) {
propertyColor = getAllPropertyKeys().contains(key) ? ChatColor.DARK_AQUA : ChatColor.DARK_GREEN;
}
sender.sendMessage(propertyColor.toString() + key + ChatColor.GRAY + ": " + ChatColor.WHITE + describeProperty(value));
}
}
}
use of org.bukkit.ChatColor in project Ublisk by Derkades.
the class FancyMessage method toOldMessageFormat.
/**
* Convert this message to a human-readable string with limited formatting.
* This method is used to send this message to clients without JSON formatting support.
* <p>
* Serialization of this message by using this message will include (in this order for each message part):
* <ol>
* <li>The color of each message part.</li>
* <li>The applicable stylizations for each message part.</li>
* <li>The core text of the message part.</li>
* </ol>
* The primary omissions are tooltips and clickable actions. Consequently, this method should be used only as a last resort.
* </p>
* <p>
* Color and formatting can be removed from the returned string by using {@link ChatColor#stripColor(String)}.</p>
*
* @return A human-readable string representing limited formatting in addition to the core text of this message.
*/
public String toOldMessageFormat() {
StringBuilder result = new StringBuilder();
for (MessagePart part : this) {
result.append(part.color == null ? "" : part.color);
for (ChatColor formatSpecifier : part.styles) {
result.append(formatSpecifier);
}
result.append(part.text);
}
return result.toString();
}
use of org.bukkit.ChatColor in project Ublisk by Derkades.
the class MessagePart method writeJson.
public void writeJson(JsonWriter json) {
try {
json.beginObject();
text.writeJson(json);
json.name("color").value(color.name().toLowerCase());
for (final ChatColor style : styles) {
json.name(stylesToNames.get(style)).value(true);
}
if (clickActionName != null && clickActionData != null) {
json.name("clickEvent").beginObject().name("action").value(clickActionName).name("value").value(clickActionData).endObject();
}
if (hoverActionName != null && hoverActionData != null) {
json.name("hoverEvent").beginObject().name("action").value(hoverActionName).name("value");
hoverActionData.writeJson(json);
json.endObject();
}
if (insertionData != null) {
json.name("insertion").value(insertionData);
}
if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) {
json.name("with").beginArray();
for (JsonRepresentedObject obj : translationReplacements) {
obj.writeJson(json);
}
json.endArray();
}
json.endObject();
} catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e);
}
}
use of org.bukkit.ChatColor in project TotalFreedomMod by TotalFreedom.
the class Command_colorme method run.
@Override
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
if (args.length != 1) {
return false;
}
if ("list".equalsIgnoreCase(args[0])) {
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
return true;
}
final String needle = args[0].trim().toLowerCase();
ChatColor color = null;
final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator();
while (it.hasNext()) {
final Map.Entry<String, ChatColor> entry = it.next();
if (entry.getKey().contains(needle)) {
color = entry.getValue();
break;
}
}
if (color == null) {
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
return true;
}
final String newNick = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE;
plugin.esb.setNickname(sender.getName(), newNick);
msg("Your nickname is now: " + newNick);
return true;
}
Aggregations