Search in sources :

Example 71 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 72 with ChatColor

use of org.bukkit.ChatColor in project MagicPlugin by elBukkit.

the class Wand method convertToHTML.

protected static String convertToHTML(String line) {
    int tagCount = 1;
    line = "<span style=\"color:white\">" + line;
    for (ChatColor c : ChatColor.values()) {
        tagCount += StringUtils.countMatches(line, c.toString());
        String replaceStyle = "";
        if (c == ChatColor.ITALIC) {
            replaceStyle = "font-style: italic";
        } else if (c == ChatColor.BOLD) {
            replaceStyle = "font-weight: bold";
        } else if (c == ChatColor.UNDERLINE) {
            replaceStyle = "text-decoration: underline";
        } else {
            String color = c.name().toLowerCase().replace("_", "");
            if (c == ChatColor.LIGHT_PURPLE) {
                color = "mediumpurple";
            }
            replaceStyle = "color:" + color;
        }
        line = line.replace(c.toString(), "<span style=\"" + replaceStyle + "\">");
    }
    for (int i = 0; i < tagCount; i++) {
        line += "</span>";
    }
    return line;
}
Also used : ChatColor(org.bukkit.ChatColor)

Example 73 with ChatColor

use of org.bukkit.ChatColor in project MagicPlugin by elBukkit.

the class MageCommandExecutor method onMageAttribute.

public boolean onMageAttribute(CommandSender sender, Player player, String[] args) {
    Mage mage = controller.getMage(player);
    Set<String> internalAttributes = api.getController().getInternalAttributes();
    Set<String> attributes = api.getController().getAttributes();
    if (attributes.isEmpty()) {
        sender.sendMessage(ChatColor.RED + "No attributes configured, see attributes.yml");
        return true;
    }
    if (args.length == 0) {
        sender.sendMessage(ChatColor.GOLD + "Attributes for: " + ChatColor.AQUA + player.getName());
        List<String> attributeList = new ArrayList<>(attributes);
        Collections.sort(attributeList);
        for (String key : attributeList) {
            ChatColor attributeType = internalAttributes.contains(key) ? ChatColor.DARK_AQUA : ChatColor.GRAY;
            Double value = mage.getAttribute(key);
            String valueDescription = value == null ? ChatColor.RED + "(not set)" : ChatColor.AQUA + Double.toString(value);
            sender.sendMessage(attributeType + key + ChatColor.BLUE + " = " + valueDescription);
        }
        return true;
    }
    String key = args[0];
    if (!attributes.contains(key)) {
        sender.sendMessage(ChatColor.RED + "Unknown attribute: " + ChatColor.YELLOW + key);
        return true;
    }
    if (args.length == 1) {
        Double value = mage.getAttribute(key);
        String valueDescription = value == null ? ChatColor.RED + "(not set)" : ChatColor.AQUA + Double.toString(value);
        sender.sendMessage(ChatColor.AQUA + player.getName() + " has " + ChatColor.DARK_AQUA + key + ChatColor.BLUE + " of " + valueDescription);
        return true;
    }
    MageClass activeClass = mage.getActiveClass();
    CasterProperties attributeProperties = mage.getProperties();
    if (activeClass != null && attributeProperties.getAttribute(key) == null) {
        attributeProperties = activeClass;
    }
    String value = args[1];
    for (int i = 2; i < args.length; i++) {
        value = value + " " + args[i];
    }
    if (value.equals("-")) {
        Double oldValue = attributeProperties.getAttribute(key);
        attributeProperties.setAttribute(key, null);
        String valueDescription = oldValue == null ? ChatColor.RED + "(not set)" : ChatColor.AQUA + Double.toString(oldValue);
        sender.sendMessage(ChatColor.BLUE + "Removed attribute " + ChatColor.DARK_AQUA + key + ChatColor.BLUE + ", was " + valueDescription);
        return true;
    }
    double transformed = Double.NaN;
    try {
        transformed = Double.parseDouble(value);
    } catch (Exception ex) {
        EquationTransform transform = EquationStore.getInstance().getTransform(value);
        if (transform.getException() == null) {
            Double property = attributeProperties.getAttribute(key);
            if (property == null || Double.isNaN(property)) {
                property = 0.0;
            }
            transform.setVariable("x", property);
            transformed = transform.get();
        }
    }
    if (Double.isNaN(transformed)) {
        sender.sendMessage(ChatColor.RED + "Could not set " + ChatColor.YELLOW + key + ChatColor.RED + " to " + ChatColor.YELLOW + value);
        return true;
    }
    attributeProperties.setAttribute(key, transformed);
    sender.sendMessage(ChatColor.GOLD + "Set " + ChatColor.DARK_AQUA + key + ChatColor.GOLD + " to " + ChatColor.AQUA + transformed + ChatColor.GOLD + " for " + ChatColor.DARK_AQUA + player.getDisplayName());
    return true;
}
Also used : CasterProperties(com.elmakers.mine.bukkit.api.magic.CasterProperties) EquationTransform(de.slikey.effectlib.math.EquationTransform) MageClass(com.elmakers.mine.bukkit.api.magic.MageClass) ArrayList(java.util.ArrayList) Mage(com.elmakers.mine.bukkit.api.magic.Mage) ChatColor(org.bukkit.ChatColor)

Example 74 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 75 with ChatColor

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

the class Commandgc method run.

@Override
protected void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
    final double tps = ess.getTimer().getAverageTPS();
    final ChatColor color;
    if (tps >= 18.0) {
        color = ChatColor.GREEN;
    } else if (tps >= 15.0) {
        color = ChatColor.YELLOW;
    } else {
        color = ChatColor.RED;
    }
    sender.sendMessage(tl("uptime", DateUtil.formatDateDiff(ManagementFactory.getRuntimeMXBean().getStartTime())));
    sender.sendMessage(tl("tps", "" + color + NumberUtil.formatDouble(tps)));
    sender.sendMessage(tl("gcmax", Runtime.getRuntime().maxMemory() / 1024 / 1024));
    sender.sendMessage(tl("gctotal", Runtime.getRuntime().totalMemory() / 1024 / 1024));
    sender.sendMessage(tl("gcfree", Runtime.getRuntime().freeMemory() / 1024 / 1024));
    final List<World> worlds = server.getWorlds();
    for (final World w : worlds) {
        String worldType = "World";
        switch(w.getEnvironment()) {
            case NETHER:
                worldType = "Nether";
                break;
            case THE_END:
                worldType = "The End";
                break;
        }
        int tileEntities = 0;
        try {
            for (final Chunk chunk : w.getLoadedChunks()) {
                tileEntities += chunk.getTileEntities().length;
            }
        } catch (final java.lang.ClassCastException ex) {
            Bukkit.getLogger().log(Level.SEVERE, "Corrupted chunk data on world " + w, ex);
        }
        sender.sendMessage(tl("gcWorld", worldType, w.getName(), w.getLoadedChunks().length, w.getEntities().size(), tileEntities));
    }
}
Also used : World(org.bukkit.World) Chunk(org.bukkit.Chunk) 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