Example #1
0
  public String getNick(final boolean longnick) {
    final StringBuilder prefix = new StringBuilder();
    String nickname;
    String suffix = "";
    final String nick = getNickname();
    if (ess.getSettings().isCommandDisabled("nick")
        || nick == null
        || nick.isEmpty()
        || nick.equals(getName())) {
      nickname = getName();
    } else if (nick.equalsIgnoreCase(getName())) {
      nickname = nick;
    } else {
      nickname = ess.getSettings().getNicknamePrefix() + nick;
      suffix = "§r";
    }

    if (this.getBase().isOp()) {
      try {
        final ChatColor opPrefix = ess.getSettings().getOperatorColor();
        if (opPrefix != null && opPrefix.toString().length() > 0) {
          prefix.insert(0, opPrefix.toString());
          suffix = "§r";
        }
      } catch (Exception e) {
      }
    }

    if (ess.getSettings().addPrefixSuffix()) {
      // These two extra toggles are not documented, because they are mostly redundant #EasterEgg
      if (!ess.getSettings().disablePrefix()) {
        final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
        prefix.insert(0, ptext);
        suffix = "§r";
      }
      if (!ess.getSettings().disableSuffix()) {
        final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
        suffix = stext + "§r";
        suffix = suffix.replace("§f§f", "§f").replace("§f§r", "§r").replace("§r§r", "§r");
      }
    }
    final String strPrefix = prefix.toString();
    String output = strPrefix + nickname + suffix;
    if (!longnick && output.length() > 16) {
      output = strPrefix + nickname;
    }
    if (!longnick && output.length() > 16) {
      output = FormatUtil.lastCode(strPrefix) + nickname;
    }
    if (!longnick && output.length() > 16) {
      output = FormatUtil.lastCode(strPrefix) + nickname.substring(0, 14);
    }
    if (output.charAt(output.length() - 1) == '§') {
      output = output.substring(0, output.length() - 1);
    }
    return output;
  }
Example #2
0
  @Override
  public String getListName(String senderId) {
    if (senderId == null) return null;

    // Try Our Map
    String ret = this.idToListName.get(senderId);

    // Try Bukkit
    if (ret == null) {
      Player player = Bukkit.getPlayerExact(senderId);
      if (player != null) {
        ret = player.getPlayerListName();
      }
    }

    // Try Fixed Id
    if (ret == null) {
      ret = Mixin.tryFix(senderId);
    }

    // Ensure Colored
    if (ChatColor.stripColor(ret).equals(ret)) {
      ret = DEFAULT_COLOR.toString() + ret;
    }

    return ret;
  }
Example #3
0
 public static String parseColors(String str) {
   for (ChatColor color : ChatColor.values()) {
     String name = "\\[" + color.name().toUpperCase() + "]";
     str = str.replaceAll(name, color.toString());
   }
   return str;
 }
  private static String removeColors(String source) {

    for (ChatColor cc : ChatColor.values()) {
      source = source.replace(cc.toString(), "");
    }
    return source;
  }
Example #5
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()) {
     return ChatColor.stripColor(string); // color not supported
   } else {
     // colorize or strip all colors
     for (ChatColor color : colors) {
       if (replacements.containsKey(color)) {
         string = string.replaceAll("(?i)" + color.toString(), replacements.get(color));
       } else {
         string = string.replaceAll("(?i)" + color.toString(), "");
       }
     }
     return string + Ansi.ansi().reset().toString();
   }
 }
 @Override
 @Localized("CRAZYCHATS.COMMAND.COLORHELP $ColorHelp$")
 public void command(final CommandSender sender, final String[] args) throws CrazyException {
   final StringBuilder builder = new StringBuilder();
   for (final ChatColor color : ChatColor.values())
     builder
         .append(color.toString())
         .append(Character.toUpperCase(color.getChar()))
         .append(color.getChar())
         .append(ChatColor.RESET);
   plugin.sendLocaleMessage("COMMAND.COLORHELP", sender, builder.toString());
 }
  public static String replaceColorCodes(String message) {
    ChatColor arr$[] = ChatColor.values();
    int len$ = arr$.length;
    for (int i$ = 0; i$ < len$; i$++) {
      ChatColor color = arr$[i$];
      message =
          message.replaceAll(
              String.format("&%c", new Object[] {Character.valueOf(color.getChar())}),
              color.toString());
    }

    return message;
  }
  private void colorPlayer(Player player, ChatColor color) {
    uncolorPlayer(player);

    playerColors.put(player.getUniqueId(), color);

    player.setDisplayName(color + player.getName() + ChatColor.RESET);

    Team team = scoreboard.registerNewTeam(player.getName());
    team.setDisplayName(player.getName());
    team.setPrefix(color.toString());
    team.setSuffix(ChatColor.RESET.toString());
    team.addEntry(player.getName());
    player.setScoreboard(scoreboard);
  }
Example #9
0
 /**
  * Replace colors of a message.
  *
  * @param text the text
  * @return the string
  */
 public static String replaceColors(String text) {
   for (final ChatColor c : ChatColor.values())
     text = text.replace("&" + c.getChar(), c.toString());
   return text;
 }