Search in sources :

Example 26 with ChatColor

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;
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 27 with ChatColor

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));
        }
    }
}
Also used : ChatColor(org.bukkit.ChatColor) ConfigurationSection(org.bukkit.configuration.ConfigurationSection)

Example 28 with ChatColor

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();
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 29 with ChatColor

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);
    }
}
Also used : IOException(java.io.IOException) ChatColor(org.bukkit.ChatColor)

Example 30 with ChatColor

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;
}
Also used : ChatColor(org.bukkit.ChatColor) Map(java.util.Map)

Aggregations

ChatColor (org.bukkit.ChatColor)128 ArrayList (java.util.ArrayList)23 Player (org.bukkit.entity.Player)17 Matcher (java.util.regex.Matcher)9 World (org.bukkit.World)9 JSONObject (org.json.simple.JSONObject)9 ItemStack (org.bukkit.inventory.ItemStack)8 DyeColor (org.bukkit.DyeColor)7 ConfigurationSection (org.bukkit.configuration.ConfigurationSection)7 ItemMeta (org.bukkit.inventory.meta.ItemMeta)7 Material (org.bukkit.Material)6 Team (org.bukkit.scoreboard.Team)6 Method (java.lang.reflect.Method)5 IOException (java.io.IOException)4 HashMap (java.util.HashMap)4 LinkedList (java.util.LinkedList)4 Mage (com.elmakers.mine.bukkit.api.magic.Mage)3 List (java.util.List)3 UUID (java.util.UUID)3 Scoreboard (org.bukkit.scoreboard.Scoreboard)3