Example #1
0
 // Setup the irc <-> minecraft color mappings.
 static {
   ircToMinecraftColor.put(Colors.WHITE, ChatColor.WHITE.toString()); // black
   ircToMinecraftColor.put(Colors.BLACK, ChatColor.BLACK.toString()); // white
   ircToMinecraftColor.put(Colors.DARK_BLUE, ChatColor.DARK_BLUE.toString()); // dark_blue
   ircToMinecraftColor.put(Colors.DARK_GREEN, ChatColor.DARK_GREEN.toString()); // dark_green
   ircToMinecraftColor.put(Colors.RED, ChatColor.RED.toString()); // red
   ircToMinecraftColor.put(Colors.BROWN, ChatColor.DARK_RED.toString()); // brown
   ircToMinecraftColor.put(Colors.PURPLE, ChatColor.DARK_PURPLE.toString()); // purple
   ircToMinecraftColor.put(Colors.OLIVE, ChatColor.GOLD.toString()); // olive
   ircToMinecraftColor.put(Colors.YELLOW, ChatColor.YELLOW.toString()); // yellow
   ircToMinecraftColor.put(Colors.GREEN, ChatColor.GREEN.toString()); // green
   ircToMinecraftColor.put(Colors.TEAL, ChatColor.DARK_AQUA.toString()); // teal
   ircToMinecraftColor.put(Colors.CYAN, ChatColor.AQUA.toString()); // cyan
   ircToMinecraftColor.put(Colors.BLUE, ChatColor.BLUE.toString()); // blue
   ircToMinecraftColor.put(Colors.MAGENTA, ChatColor.LIGHT_PURPLE.toString()); // magenta
   ircToMinecraftColor.put(Colors.DARK_GRAY, ChatColor.DARK_GRAY.toString()); // dark_gray
   ircToMinecraftColor.put(Colors.LIGHT_GRAY, ChatColor.GRAY.toString()); // light_gray
   minecraftToIrcColor.put(ChatColor.WHITE.toString(), Colors.WHITE); // black
   minecraftToIrcColor.put(ChatColor.BLACK.toString(), Colors.BLACK); // white
   minecraftToIrcColor.put(ChatColor.DARK_BLUE.toString(), Colors.DARK_BLUE); // dark_blue
   minecraftToIrcColor.put(ChatColor.DARK_GREEN.toString(), Colors.DARK_GREEN); // dark_green
   minecraftToIrcColor.put(ChatColor.RED.toString(), Colors.RED); // red
   minecraftToIrcColor.put(ChatColor.DARK_RED.toString(), Colors.BROWN); // brown
   minecraftToIrcColor.put(ChatColor.DARK_PURPLE.toString(), Colors.PURPLE); // purple
   minecraftToIrcColor.put(ChatColor.GOLD.toString(), Colors.OLIVE); // olive
   minecraftToIrcColor.put(ChatColor.YELLOW.toString(), Colors.YELLOW); // yellow
   minecraftToIrcColor.put(ChatColor.GREEN.toString(), Colors.GREEN); // green
   minecraftToIrcColor.put(ChatColor.DARK_AQUA.toString(), Colors.TEAL); // teal
   minecraftToIrcColor.put(ChatColor.AQUA.toString(), Colors.CYAN); // cyan
   minecraftToIrcColor.put(ChatColor.BLUE.toString(), Colors.BLUE); // blue
   minecraftToIrcColor.put(ChatColor.LIGHT_PURPLE.toString(), Colors.MAGENTA); // magenta
   minecraftToIrcColor.put(ChatColor.DARK_GRAY.toString(), Colors.DARK_GRAY); // dark_gray
   minecraftToIrcColor.put(ChatColor.GRAY.toString(), Colors.LIGHT_GRAY); // light_gray
 }
Example #2
0
 private String colorize(String string) {
   if (string.indexOf(ChatColor.COLOR_CHAR) < 0) {
     return string; // no colors in the message
   } else if ((!jLine || !reader.getTerminal().isAnsiSupported()) && jTerminal == null) {
     return ChatColor.stripColor(string); // color not supported
   } else {
     return string
             .replace(ChatColor.RED.toString(), "\033[1;31m")
             .replace(ChatColor.YELLOW.toString(), "\033[1;33m")
             .replace(ChatColor.GREEN.toString(), "\033[1;32m")
             .replace(ChatColor.AQUA.toString(), "\033[1;36m")
             .replace(ChatColor.BLUE.toString(), "\033[1;34m")
             .replace(ChatColor.LIGHT_PURPLE.toString(), "\033[1;35m")
             .replace(ChatColor.BLACK.toString(), "\033[0;0m")
             .replace(ChatColor.DARK_GRAY.toString(), "\033[1;30m")
             .replace(ChatColor.DARK_RED.toString(), "\033[0;31m")
             .replace(ChatColor.GOLD.toString(), "\033[0;33m")
             .replace(ChatColor.DARK_GREEN.toString(), "\033[0;32m")
             .replace(ChatColor.DARK_AQUA.toString(), "\033[0;36m")
             .replace(ChatColor.DARK_BLUE.toString(), "\033[0;34m")
             .replace(ChatColor.DARK_PURPLE.toString(), "\033[0;35m")
             .replace(ChatColor.GRAY.toString(), "\033[0;37m")
             .replace(ChatColor.WHITE.toString(), "\033[1;37m")
         + "\033[0m";
   }
 }
Example #3
0
  /**
   * Replace color macros in a string. The macros are in the form of `[char] where char represents
   * the color. R is for red, Y is for yellow, G is for green, C is for cyan, B is for blue, and P
   * is for purple. The uppercase versions of those are the darker shades, while the lowercase
   * versions are the lighter shades. For white, it's 'w', and 0-2 are black, dark grey, and grey,
   * respectively.
   *
   * @param str
   * @return color-coded string
   */
  public static String replaceColorMacros(String str) {
    str = str.replace("&r", ChatColor.RED.toString());
    str = str.replace("&R", ChatColor.DARK_RED.toString());

    str = str.replace("&y", ChatColor.YELLOW.toString());
    str = str.replace("&Y", ChatColor.GOLD.toString());

    str = str.replace("&g", ChatColor.GREEN.toString());
    str = str.replace("&G", ChatColor.DARK_GREEN.toString());

    str = str.replace("&c", ChatColor.AQUA.toString());
    str = str.replace("&C", ChatColor.DARK_AQUA.toString());

    str = str.replace("&b", ChatColor.BLUE.toString());
    str = str.replace("&B", ChatColor.DARK_BLUE.toString());

    str = str.replace("&p", ChatColor.LIGHT_PURPLE.toString());
    str = str.replace("&P", ChatColor.DARK_PURPLE.toString());

    str = str.replace("&0", ChatColor.BLACK.toString());
    str = str.replace("&1", ChatColor.DARK_GRAY.toString());
    str = str.replace("&2", ChatColor.GRAY.toString());
    str = str.replace("&w", ChatColor.WHITE.toString());

    return str;
  }
Example #4
0
 public String colorize(String string) {
   if (!string.contains("\u00A7")) {
     return string;
   } else if ((!jLine || !reader.getTerminal().isANSISupported()) && jTerminal == null) {
     return ChatColor.stripColor(string);
   } else {
     return string
             .replace(ChatColor.RED.toString(), "\033[1;31m")
             .replace(ChatColor.YELLOW.toString(), "\033[1;33m")
             .replace(ChatColor.GREEN.toString(), "\033[1;32m")
             .replace(ChatColor.AQUA.toString(), "\033[1;36m")
             .replace(ChatColor.BLUE.toString(), "\033[1;34m")
             .replace(ChatColor.LIGHT_PURPLE.toString(), "\033[1;35m")
             .replace(ChatColor.BLACK.toString(), "\033[0;0m")
             .replace(ChatColor.DARK_GRAY.toString(), "\033[1;30m")
             .replace(ChatColor.DARK_RED.toString(), "\033[0;31m")
             .replace(ChatColor.GOLD.toString(), "\033[0;33m")
             .replace(ChatColor.DARK_GREEN.toString(), "\033[0;32m")
             .replace(ChatColor.DARK_AQUA.toString(), "\033[0;36m")
             .replace(ChatColor.DARK_BLUE.toString(), "\033[0;34m")
             .replace(ChatColor.DARK_PURPLE.toString(), "\033[0;35m")
             .replace(ChatColor.GRAY.toString(), "\033[0;37m")
             .replace(ChatColor.WHITE.toString(), "\033[1;37m")
         + "\033[0m";
   }
 }
Example #5
0
  @Override
  public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    Player p = null;

    if (sender instanceof Player) {
      p = (Player) sender;
    }

    if (p != null) {
      if (!(p.isOp())) {
        return true;
      }
    }

    if (args.length == 0) {
      if (p != null) {
        if (!(p.isOp())) {
          return true;
        }
        p.sendMessage(
            ChatColor.RED
                + "Invalid Syntax. Please use /isay <msg> to send a local world messsage.");
        return true;
      }
    }

    String msg = "";
    for (String s : args) {
      msg += s + " ";
    }
    msg = msg.substring(0, msg.lastIndexOf(" "));

    msg = msg.replaceAll("&0", ChatColor.BLACK.toString());
    msg = msg.replaceAll("&1", ChatColor.DARK_BLUE.toString());
    msg = msg.replaceAll("&2", ChatColor.DARK_GREEN.toString());
    msg = msg.replaceAll("&3", ChatColor.DARK_AQUA.toString());
    msg = msg.replaceAll("&4", ChatColor.DARK_RED.toString());
    msg = msg.replaceAll("&5", ChatColor.DARK_PURPLE.toString());
    msg = msg.replaceAll("&6", ChatColor.GOLD.toString());
    msg = msg.replaceAll("&7", ChatColor.GRAY.toString());
    msg = msg.replaceAll("&8", ChatColor.DARK_GRAY.toString());
    msg = msg.replaceAll("&9", ChatColor.BLUE.toString());
    msg = msg.replaceAll("&a", ChatColor.GREEN.toString());
    msg = msg.replaceAll("&b", ChatColor.AQUA.toString());
    msg = msg.replaceAll("&c", ChatColor.RED.toString());
    msg = msg.replaceAll("&d", ChatColor.LIGHT_PURPLE.toString());
    msg = msg.replaceAll("&e", ChatColor.YELLOW.toString());
    msg = msg.replaceAll("&f", ChatColor.WHITE.toString());

    msg = msg.replaceAll("&u", ChatColor.UNDERLINE.toString());
    msg = msg.replaceAll("&s", ChatColor.BOLD.toString());
    msg = msg.replaceAll("&i", ChatColor.ITALIC.toString());
    msg = msg.replaceAll("&m", ChatColor.MAGIC.toString());

    if (sender instanceof BlockCommandSender) {
      BlockCommandSender cb = (BlockCommandSender) sender;
      for (Player pl : cb.getBlock().getWorld().getPlayers()) {
        pl.sendMessage(msg);
      }
    } else if (sender instanceof Player) {
      for (Player pl : p.getWorld().getPlayers()) {
        pl.sendMessage(msg);
      }
    }
    return true;
  }
Example #6
0
  /** Server Selector Listener */
  @EventHandler
  public void onInventoryClick(final InventoryClickEvent event) {
    if (event
        .getInventory()
        .getName()
        .contains(
            ChatColor.DARK_GREEN
                + SubPlugin.lang.get("Lang.GUI.Server-List-Title").replace("$Int$", ""))) {
      Player player = (Player) event.getWhoClicked();
      if (event.getCurrentItem() != null
          && event.getCurrentItem().getType() != Material.AIR
          && event.getCurrentItem().hasItemMeta()) {
        if (event
            .getCurrentItem()
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Exit"))) {
          player.closeInventory();
        } else if (event
            .getCurrentItem()
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.YELLOW.toString() + SubPlugin.lang.get("Lang.GUI.Back"))) {
          new SubGUI(
              player,
              (Integer.parseInt(
                      event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN.toString()
                                  + SubPlugin.lang
                                      .get("Lang.GUI.Server-List-Title")
                                      .replace("$Int$", ""),
                              ""))
                  - 2),
              null,
              SubPlugin);
        } else if (event
            .getCurrentItem()
            .getItemMeta()
            .getDisplayName()
            .equals(ChatColor.YELLOW.toString() + SubPlugin.lang.get("Lang.GUI.Next"))) {
          new SubGUI(
              player,
              Integer.parseInt(
                  event
                      .getClickedInventory()
                      .getName()
                      .replace(
                          ChatColor.DARK_GREEN.toString()
                              + SubPlugin.lang
                                  .get("Lang.GUI.Server-List-Title")
                                  .replace("$Int$", ""),
                          "")),
              null,
              SubPlugin);
        } else if (!event
            .getCurrentItem()
            .getItemMeta()
            .getDisplayName()
            .equals(
                ChatColor.GRAY
                    + SubPlugin.Plugin.getDescription().getName()
                    + " v"
                    + SubPlugin.Plugin.getDescription().getVersion())) {
          new SubGUI(
              player,
              0,
              event
                  .getCurrentItem()
                  .getItemMeta()
                  .getDisplayName()
                  .replace(ChatColor.YELLOW.toString(), ""),
              SubPlugin);
        }
      }
      event.setCancelled(true);
    }

    /** Server Editor Listener */
    if (event
        .getInventory()
        .getName()
        .contains(ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title"))) {
      final Player player = (Player) event.getWhoClicked();
      if (event.getCurrentItem() != null
          && event.getCurrentItem().getType() != Material.AIR
          && event.getCurrentItem().hasItemMeta()) {
        String displayName = event.getCurrentItem().getItemMeta().getDisplayName();
        if ((ChatColor.DARK_GREEN.toString() + SubPlugin.lang.get("Lang.GUI.Start"))
            .equals(displayName)) {
          if (player.hasPermission("SubServer.Command.start.*")
              || player.hasPermission(
                  "SubServer.Command.start."
                      + event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN
                                  + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                  + ChatColor.YELLOW,
                              ""))) {
            SubAPI.getSubServer(
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""))
                .start((Player) event.getWhoClicked());
            final SubGUI SubGUI;
            (SubGUI = new SubGUI(SubPlugin))
                .openLoader(
                    player,
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""),
                    "openServerWindow");
            new BukkitRunnable() {
              @Override
              public void run() {
                try {
                  Thread.sleep(1500);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
                SubAPI.getSubServer(
                            event
                                .getClickedInventory()
                                .getName()
                                .replace(
                                    ChatColor.DARK_GREEN
                                        + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                        + ChatColor.YELLOW,
                                    ""))
                        .Running =
                    true;
                SubGUI.stopLoader = true;
              }
            }.runTaskAsynchronously(SubPlugin.Plugin);
          }
        } else if ((ChatColor.RED.toString() + SubPlugin.lang.get("Lang.GUI.Stop"))
            .equals(displayName)) {
          if (player.hasPermission("SubServer.Command.stop.*")
              || player.hasPermission(
                  "SubServer.Command.stop."
                      + event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN
                                  + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                  + ChatColor.YELLOW,
                              ""))) {
            SubAPI.getSubServer(
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""))
                .stop((Player) event.getWhoClicked());
            final SubGUI SubGUI;
            (SubGUI = new SubGUI(SubPlugin))
                .openLoader(
                    player,
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""),
                    "openServerWindow");
            new BukkitRunnable() {
              @Override
              public void run() {
                try {
                  Thread.sleep(1500);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
                SubAPI.getSubServer(
                            event
                                .getClickedInventory()
                                .getName()
                                .replace(
                                    ChatColor.DARK_GREEN
                                        + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                        + ChatColor.YELLOW,
                                    ""))
                        .Running =
                    false;
                SubGUI.stopLoader = true;
              }
            }.runTaskAsynchronously(SubPlugin.Plugin);
          }
        } else if ((ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Terminate"))
            .equals(displayName)) {
          if (player.hasPermission("SubServer.Command.kill.*")
              || player.hasPermission(
                  "SubServer.Command.kill."
                      + event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN
                                  + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                  + ChatColor.YELLOW,
                              ""))) {
            SubAPI.getSubServer(
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""))
                .terminate((Player) event.getWhoClicked());
            final SubGUI SubGUI;
            (SubGUI = new SubGUI(SubPlugin))
                .openLoader(
                    player,
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""),
                    "openServerWindow");
            new BukkitRunnable() {
              @Override
              public void run() {
                try {
                  Thread.sleep(500);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }
                SubGUI.stopLoader = true;
                SubAPI.getSubServer(
                            event
                                .getClickedInventory()
                                .getName()
                                .replace(
                                    ChatColor.DARK_GREEN
                                        + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                        + ChatColor.YELLOW,
                                    ""))
                        .Running =
                    false;
                new SubGUI(
                    player,
                    0,
                    event
                        .getClickedInventory()
                        .getName()
                        .replace(
                            ChatColor.DARK_GREEN
                                + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                + ChatColor.YELLOW,
                            ""),
                    SubPlugin);
              }
            }.runTaskAsynchronously(SubPlugin.Plugin);
          }
        } else if ((ChatColor.RED.toString() + SubPlugin.lang.get("Lang.GUI.Back"))
            .equals(displayName)) {
          player.closeInventory();
          int i =
              (int)
                  Math.floor(
                      SubPlugin.SubServers.indexOf(
                              event
                                  .getClickedInventory()
                                  .getName()
                                  .replace(
                                      ChatColor.DARK_GREEN
                                          + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                          + ChatColor.YELLOW,
                                      ""))
                          / 18);
          new SubGUI(player, i, null, SubPlugin);
        } else if ((ChatColor.DARK_RED.toString() + SubPlugin.lang.get("Lang.GUI.Exit"))
            .equals(displayName)) {
          player.closeInventory();
        } else if ((ChatColor.AQUA.toString() + SubPlugin.lang.get("Lang.GUI.Send-CMD"))
            .equals(displayName)) {
          if (player.hasPermission("SubServer.Command.send.*")
              || player.hasPermission(
                  "SubServer.Command.send."
                      + event
                          .getClickedInventory()
                          .getName()
                          .replace(
                              ChatColor.DARK_GREEN
                                  + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                  + ChatColor.YELLOW,
                              ""))) {
            player.closeInventory();
            final SubGUIChat chat = new SubGUIChat(player, SubPlugin);
            chat.chatEnabled = false;
            player.sendMessage(
                ChatColor.AQUA + SubPlugin.lprefix + SubPlugin.lang.get("Lang.GUI.Enter-CMD"));
            new BukkitRunnable() {
              @Override
              public void run() {
                try {
                  do {
                    Thread.sleep(25);
                  } while (chat.chatEnabled == false);
                } catch (InterruptedException e) {
                  e.printStackTrace();
                }

                SubAPI.getSubServer(
                        event
                            .getClickedInventory()
                            .getName()
                            .replace(
                                ChatColor.DARK_GREEN
                                    + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                    + ChatColor.YELLOW,
                                ""))
                    .sendCommand((Player) event.getWhoClicked(), chat.chatText);
                chat.chatText = "";
                new SubGUI(SubPlugin)
                    .openSentCommand(
                        player,
                        event
                            .getClickedInventory()
                            .getName()
                            .replace(
                                ChatColor.DARK_GREEN
                                    + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                                    + ChatColor.YELLOW,
                                ""));
              }
            }.runTaskAsynchronously(SubPlugin.Plugin);
          }
        } else if ((ChatColor.DARK_GREEN.toString() + SubPlugin.lang.get("Lang.GUI.Online"))
            .equals(displayName)) {
          String server =
              event
                  .getClickedInventory()
                  .getName()
                  .replace(
                      ChatColor.DARK_GREEN
                          + SubPlugin.lang.get("Lang.GUI.Server-Admin-Title")
                          + ChatColor.YELLOW,
                      "");
          if ((player.hasPermission("SubServer.Command.teleport." + server)
                  || player.hasPermission("SubServer.Command.teleport.*"))
              && !server.equalsIgnoreCase("~Proxy")) {
            player.closeInventory();
            SubAPI.getSubServer(server).sendPlayer(player);
          }
        }
      }
      event.setCancelled(true);
    }

    /** Other Listeners */
    if (event
        .getInventory()
        .getName()
        .contains(ChatColor.DARK_GREEN + SubPlugin.lang.get("Lang.GUI.Success"))) {
      final Player player = (Player) event.getWhoClicked();
      if (event.getCurrentItem() != null
          && event.getCurrentItem().getType() != Material.AIR
          && event.getCurrentItem().hasItemMeta()) {
        player.closeInventory();
        new SubGUI(
            player,
            0,
            event
                .getClickedInventory()
                .getName()
                .replace(
                    ChatColor.DARK_GREEN
                        + SubPlugin.lang.get("Lang.GUI.Success")
                        + ChatColor.YELLOW,
                    ""),
            SubPlugin);
      }
      event.setCancelled(true);
    }
    if (event.getInventory().getName().equals(SubPlugin.lang.get("Lang.GUI.Loading"))) {
      event.setCancelled(true);
    }

    /** Seecret Listener */
    if (event.getInventory().getName().contains(":S:")) {
      if (event.getCurrentItem() != null
          && event.getCurrentItem().getType() != Material.AIR
          && event.getClickedInventory().contains(event.getCurrentItem())) {
        new SubGUI(SubPlugin).openSeecretWindow((Player) event.getWhoClicked());
        event.setCancelled(true);
      }
    }
  }
Example #7
0
  /**
   * Converts color codes into the simoleon code. Sort of a HTML format color code tag and `[code]
   *
   * <p>Color codes allowed: black, navy, green, teal, red, purple, gold, silver, gray, blue, lime,
   * aqua, rose, pink, yellow, white. Example:
   *
   * <blockquote
   *
   * <pre>
   *
   * Messaging.colorize(&quot;Hello &lt;green&gt;world!&quot;); // returns: Hello $world! </pre>
   *
   * </blockquote>
   *
   * @param string Original string to be parsed against group of color names.
   * @return <code>String</code> - The parsed string after conversion.
   */
  public static String colorize(String string) {
    if (iConomy.TerminalSupport)
      if (!(sender instanceof Player))
        string =
            string
                    .replace("`r", "\033[1;31m")
                    .replace("`R", "\033[0;31m")
                    .replace("`y", "\033[1;33m")
                    .replace("`Y", "\033[0;33m")
                    .replace("`g", "\033[1;32m")
                    .replace("`G", "\033[0;32m")
                    .replace("`a", "\033[1;36m")
                    .replace("`A", "\033[0;36m")
                    .replace("`b", "\033[1;34m")
                    .replace("`B", "\033[0;34m")
                    .replace("`p", "\033[1;35m")
                    .replace("`P", "\033[0;35m")
                    .replace("`k", "\033[0;0m")
                    .replace("`s", "\033[0;37m")
                    .replace("`S", "\033[1;30m")
                    .replace("`w", "\033[1;37m")
                    .replace("<r>", "\033[0m")
                    .replace("`e", "\033[0m")
                    .replace("<silver>", "\033[0;37m")
                    .replace("<gray>", "\033[1;30m")
                    .replace("<rose>", "\033[1;31m")
                    .replace("<lime>", "\033[1;32m")
                    .replace("<aqua>", "\033[1;36m")
                    .replace("<pink>", "\033[1;35m")
                    .replace("<yellow>", "\033[1;33m")
                    .replace("<blue>", "\033[1;34m")
                    .replace("<black>", "\033[0;0m")
                    .replace("<red>", "\033[0;31m")
                    .replace("<green>", "\033[0;32m")
                    .replace("<teal>", "\033[0;36m")
                    .replace("<navy>", "\033[0;34m")
                    .replace("<purple>", "\033[0;35m")
                    .replace("<gold>", "\033[0;33m")
                    .replace("<white>", "\033[1;37m")
                + "\033[0m";

    string =
        string
            .replace("`e", "")
            .replace("`r", ChatColor.RED.toString())
            .replace("`R", ChatColor.DARK_RED.toString())
            .replace("`y", ChatColor.YELLOW.toString())
            .replace("`Y", ChatColor.GOLD.toString())
            .replace("`g", ChatColor.GREEN.toString())
            .replace("`G", ChatColor.DARK_GREEN.toString())
            .replace("`a", ChatColor.AQUA.toString())
            .replace("`A", ChatColor.DARK_AQUA.toString())
            .replace("`b", ChatColor.BLUE.toString())
            .replace("`B", ChatColor.DARK_BLUE.toString())
            .replace("`p", ChatColor.LIGHT_PURPLE.toString())
            .replace("`P", ChatColor.DARK_PURPLE.toString())
            .replace("`k", ChatColor.BLACK.toString())
            .replace("`s", ChatColor.GRAY.toString())
            .replace("`S", ChatColor.DARK_GRAY.toString())
            .replace("`w", ChatColor.WHITE.toString());

    string =
        string
            .replace("<r>", "")
            .replace("<black>", "\u00A70")
            .replace("<navy>", "\u00A71")
            .replace("<green>", "\u00A72")
            .replace("<teal>", "\u00A73")
            .replace("<red>", "\u00A74")
            .replace("<purple>", "\u00A75")
            .replace("<gold>", "\u00A76")
            .replace("<silver>", "\u00A77")
            .replace("<gray>", "\u00A78")
            .replace("<blue>", "\u00A79")
            .replace("<lime>", "\u00A7a")
            .replace("<aqua>", "\u00A7b")
            .replace("<rose>", "\u00A7c")
            .replace("<pink>", "\u00A7d")
            .replace("<yellow>", "\u00A7e")
            .replace("<white>", "\u00A7f");

    return string;
  }