org.apache.commons.lang.WordUtils Java Examples

The following examples show how to use org.apache.commons.lang.WordUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HelloConsole.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    Option msg = Option.builder("m")
        .longOpt("message")
        .hasArg()
        .desc("the message to capitalize")
        .build();
    Options options = new Options();
    options.addOption(msg);

    CommandLineParser parser = new DefaultParser();
    CommandLine line = parser.parse(options, args);

    String  message = line.getOptionValue("m", "Hello Ivy!");
    System.out.println("standard message : " + message);
    System.out.println("capitalized by " + WordUtils.class.getName()
        + " : " + WordUtils.capitalizeFully(message));
}
 
Example #2
Source File: NameSuffixAspect.java    From openregistry with Apache License 2.0 6 votes vote down vote up
@Around("set(@org.openregistry.core.domain.normalization.NameSuffix * *)")
public Object transformFieldValue(final ProceedingJoinPoint joinPoint) throws Throwable {
	final String value = (String) joinPoint.getArgs()[0];

       if (isDisabled() || value == null || value.isEmpty()) {
           return joinPoint.proceed();
       }

       final String overrideValue = getCustomMapping().get(value);

       if (overrideValue != null) {
          return joinPoint.proceed(new Object[] {overrideValue});
       }
        
       final String casifyValue;
       if (value.matches("^[IiVv]+$")) { //TODO Generalize II - VIII
       	casifyValue = value.toUpperCase();
       } else {
       	casifyValue = WordUtils.capitalizeFully(value);
       }

       return joinPoint.proceed(new Object[] {casifyValue});
   }
 
Example #3
Source File: KDMListener.java    From ProjectAres with GNU Affero General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.LOW)
public void onMatchEnd(MatchEndEvent event) {
    Match match = event.getMatch();
    Tourney plugin = Tourney.get();
    this.session.appendMatch(match, plugin.getMatchManager().getTeamManager().teamToEntrant(Iterables.getOnlyElement(event.getMatch().needMatchModule(VictoryMatchModule.class).winners(), null)));

    Entrant winningParticipation = this.session.calculateWinner();
    int matchesPlayed = this.session.getMatchesPlayed();
    if (winningParticipation != null) {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "A winner has been determined!");
        Bukkit.broadcastMessage(ChatColor.AQUA + WordUtils.capitalize(winningParticipation.team().name()) + ChatColor.RESET + ChatColor.YELLOW + " wins! Congratulations!");
        plugin.clearKDMSession();
    } else if (matchesPlayed < 3) {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "A winner has not yet been determined! Beginning match #" + (matchesPlayed + 1) + "...");
        match.needMatchModule(CycleMatchModule.class).startCountdown(Duration.ofSeconds(15), session.getMap());
    } else {
        Bukkit.broadcastMessage(ChatColor.YELLOW + "There is a tie! Congratulations to both teams!");
        Tourney.get().clearKDMSession();
    }
}
 
Example #4
Source File: ScoreboardModule.java    From CardinalPGM with MIT License 6 votes vote down vote up
public void renderObjective(GameObjective objective) {
    if (!objective.showOnScoreboard()) return;
    int score = currentScore;
    Team team = scoreboard.getTeam(objective.getScoreboardHandler().getNumber() + "-o");
    String prefix = objective.getScoreboardHandler().getPrefix(this.team);
    team.setPrefix(prefix);
    if (team.getEntries().size() > 0) {
        setScore(this.objective, new ArrayList<>(team.getEntries()).get(0), score);
    } else {
        String raw = (objective instanceof HillObjective ? "" : ChatColor.RESET) + " " + WordUtils.capitalizeFully(objective.getName().replaceAll("_", " "));
        while (used.contains(raw)) {
            raw =  raw + ChatColor.RESET;
        }
        team.addEntry(raw);
        setScore(this.objective, raw, score);
        used.add(raw);
    }
    currentScore++;
}
 
Example #5
Source File: CacheAdmin.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Override
public String getLongUsage() {
  TableListing listing = AdminHelper.getOptionDescriptionListing();

  listing.addRow("<name>", "Name of the pool to modify.");
  listing.addRow("<owner>", "Username of the owner of the pool");
  listing.addRow("<group>", "Groupname of the group of the pool.");
  listing.addRow("<mode>", "Unix-style permissions of the pool in octal.");
  listing.addRow("<limit>", "Maximum number of bytes that can be cached " +
      "by this pool.");
  listing.addRow("<maxTtl>", "The maximum allowed time-to-live for " +
      "directives being added to the pool.");

  return getShortUsage() + "\n" +
      WordUtils.wrap("Modifies the metadata of an existing cache pool. " +
      "See usage of " + AddCachePoolCommand.NAME + " for more details.",
      AdminHelper.MAX_LINE_WIDTH) + "\n\n" +
      listing.toString();
}
 
Example #6
Source File: WeatherPublisher.java    From openhab1-addons with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Publishes the item with the value.
 */
private void publishValue(String itemName, Object value, WeatherBindingConfig bindingConfig) {
    if (value == null) {
        context.getEventPublisher().postUpdate(itemName, UnDefType.UNDEF);
    } else if (value instanceof Calendar) {
        Calendar calendar = (Calendar) value;
        context.getEventPublisher().postUpdate(itemName, new DateTimeType(calendar));
    } else if (value instanceof Number) {
        context.getEventPublisher().postUpdate(itemName, new DecimalType(round(value.toString(), bindingConfig)));
    } else if (value instanceof String || value instanceof Enum) {
        if (value instanceof Enum) {
            String enumValue = WordUtils.capitalizeFully(StringUtils.replace(value.toString(), "_", " "));
            context.getEventPublisher().postUpdate(itemName, new StringType(enumValue));
        } else {
            context.getEventPublisher().postUpdate(itemName, new StringType(value.toString()));
        }
    } else {
        logger.warn("Unsupported value type {}", value.getClass().getSimpleName());
    }
}
 
Example #7
Source File: TableListing.java    From hadoop with Apache License 2.0 6 votes vote down vote up
/**
 * Return the ith row of the column as a set of wrapped strings, each at
 * most wrapWidth in length.
 */
String[] getRow(int idx) {
  String raw = rows.get(idx);
  // Line-wrap if it's too long
  String[] lines = new String[] {raw};
  if (wrap) {
    lines = WordUtils.wrap(lines[0], wrapWidth, "\n", true).split("\n");
  }
  for (int i=0; i<lines.length; i++) {
    if (justification == Justification.LEFT) {
      lines[i] = StringUtils.rightPad(lines[i], maxWidth);
    } else if (justification == Justification.RIGHT) {
      lines[i] = StringUtils.leftPad(lines[i], maxWidth);
    }
  }
  return lines;
}
 
Example #8
Source File: FirstNameAspect.java    From openregistry with Apache License 2.0 6 votes vote down vote up
@Around("set(@org.openregistry.core.domain.normalization.FirstName * *)")
public Object transformFieldValue(final ProceedingJoinPoint joinPoint) throws Throwable {
    final String value = (String) joinPoint.getArgs()[0];

    if (isDisabled() || value == null || value.isEmpty()) {
        return joinPoint.proceed();
    }

    final String overrideValue = getCustomMapping().get(value);

    if (overrideValue != null) {
        return joinPoint.proceed(new Object[] {overrideValue});
    }

    return joinPoint.proceed(new Object[] {WordUtils.capitalizeFully(value)});
}
 
Example #9
Source File: GoPubMedTripleRetrievalExecutor.java    From bioasq with Apache License 2.0 6 votes vote down vote up
private void addQueryWord(String s){
    if(s==null)return;
    if(s.length()==0)return;
    if(queryWords.contains(s))
        return;
    else
        queryWords.add(s);
    
    if(sb.length()>0) sb.append(" OR ");
    sb.append(s+"[obj] OR "+ s + "[subj]");
    List<String> ls = new LinkedList<String>();
    ls.add(s.toUpperCase());
    ls.add(s.toLowerCase());
    ls.add(WordUtils.capitalize(s));
    for(String x:ls){
        sb.append(" OR ");
        sb.append(x);
        sb.append("[obj] OR ");
        sb.append(x);
        sb.append("[subj]");
    }
}
 
Example #10
Source File: ExtractPaymentServiceImpl.java    From kfs with GNU Affero General Public License v3.0 6 votes vote down vote up
/**
  * @see org.kuali.kfs.pdp.batch.service.ExtractPaymentService#formatCheckNoteLines(java.lang.String)
  *
  * Long check stub note
  */
@Override
public List<String> formatCheckNoteLines(String checkNote) {
    List<String> formattedCheckNoteLines = new ArrayList<String>();

    if (StringUtils.isBlank(checkNote)) {
        return formattedCheckNoteLines;
    }

    String[] textLines = StringUtils.split(checkNote, BusinessObjectReportHelper.LINE_BREAK);
    int maxLengthOfNoteLine = dataDictionaryService.getAttributeMaxLength(PaymentNoteText.class, "customerNoteText");
    for (String textLine : textLines) {
        String text = WordUtils.wrap(textLine, maxLengthOfNoteLine, BusinessObjectReportHelper.LINE_BREAK, true);
        String[] wrappedTextLines = StringUtils.split(text, BusinessObjectReportHelper.LINE_BREAK);
        for (String wrappedText : wrappedTextLines) {
            formattedCheckNoteLines.add(wrappedText);
        }
    }
    return formattedCheckNoteLines;
}
 
Example #11
Source File: HelloIvy.java    From ant-ivy with Apache License 2.0 6 votes vote down vote up
public static void main(String[] args) throws Exception {
    String  message = "Hello Ivy!";
    System.out.println("standard message : " + message);
    System.out.println("capitalized by " + WordUtils.class.getName()
        + " : " + WordUtils.capitalizeFully(message));

    HttpClient client = new HttpClient();
    HeadMethod head = new HeadMethod("http://www.ibiblio.org/");
    client.executeMethod(head);

    int status = head.getStatusCode();
    System.out.println("head status code with httpclient: " + status);
    head.releaseConnection();

    System.out.println(
        "now check if httpclient dependency on commons-logging has been realized");
    Class<?> clss = Class.forName("org.apache.commons.logging.Log");
    System.out.println("found logging class in classpath: " + clss);
}
 
Example #12
Source File: TableListing.java    From big-c with Apache License 2.0 6 votes vote down vote up
/**
 * Return the ith row of the column as a set of wrapped strings, each at
 * most wrapWidth in length.
 */
String[] getRow(int idx) {
  String raw = rows.get(idx);
  // Line-wrap if it's too long
  String[] lines = new String[] {raw};
  if (wrap) {
    lines = WordUtils.wrap(lines[0], wrapWidth, "\n", true).split("\n");
  }
  for (int i=0; i<lines.length; i++) {
    if (justification == Justification.LEFT) {
      lines[i] = StringUtils.rightPad(lines[i], maxWidth);
    } else if (justification == Justification.RIGHT) {
      lines[i] = StringUtils.leftPad(lines[i], maxWidth);
    }
  }
  return lines;
}
 
Example #13
Source File: AbstractJavaDataPreparer.java    From dal with Apache License 2.0 6 votes vote down vote up
protected String getPojoClassName(String prefix, String suffix, String tableName) {
    String className = tableName;
    if (null != prefix && !prefix.isEmpty() && className.indexOf(prefix) == 0) {
        className = className.replaceFirst(prefix, "");
    }
    if (null != suffix && !suffix.isEmpty()) {
        className = className + WordUtils.capitalize(suffix);
    }

    StringBuilder result = new StringBuilder();
    for (String str : StringUtils.split(className, "_")) {
        result.append(WordUtils.capitalize(str));
    }

    return WordUtils.capitalize(result.toString());
}
 
Example #14
Source File: AbstractCSharpDataPreparer.java    From dal with Apache License 2.0 6 votes vote down vote up
protected String getPojoClassName(String prefix, String suffix, String table) {
    String className = table;
    if (null != prefix && !prefix.isEmpty() && className.indexOf(prefix) == 0) {
        className = className.replaceFirst(prefix, "");
    }
    if (null != suffix && !suffix.isEmpty()) {
        className = className + WordUtils.capitalize(suffix);
    }

    StringBuilder result = new StringBuilder();
    for (String str : StringUtils.split(className, "_")) {
        result.append(WordUtils.capitalize(str));
    }

    return WordUtils.capitalize(result.toString());
}
 
Example #15
Source File: CSharpDataPreparerOfFreeSqlProcessor.java    From dal with Apache License 2.0 6 votes vote down vote up
private void prepareDbFromFreeSql(CodeGenContext codeGenCtx, List<GenTaskByFreeSql> freeSqls) throws Exception {
    CSharpCodeGenContext ctx = (CSharpCodeGenContext) codeGenCtx;
    Map<String, DatabaseHost> _dbHosts = ctx.getDbHosts();
    Set<String> _freeDaos = ctx.getFreeDaos();
    for (GenTaskByFreeSql task : freeSqls) {
        addDatabaseSet(ctx, task.getDatabaseSetName());
        _freeDaos.add(WordUtils.capitalize(task.getClass_name()));
        if (!_dbHosts.containsKey(task.getAllInOneName())) {
            String provider = "sqlProvider";
            String dbType = DbUtils.getDbType(task.getAllInOneName());
            if (null != dbType && !dbType.equalsIgnoreCase("Microsoft SQL Server")) {
                provider = "mySqlProvider";
            }
            DatabaseHost host = new DatabaseHost();
            host.setAllInOneName(task.getAllInOneName());
            host.setProviderType(provider);
            host.setDatasetName(task.getDatabaseSetName());
            _dbHosts.put(task.getAllInOneName(), host);
        }
    }
}
 
Example #16
Source File: CSharpMethodHost.java    From dal with Apache License 2.0 6 votes vote down vote up
public String getParameterDeclaration() {
    List<String> paramsDeclaration = new ArrayList<>();
    for (CSharpParameterHost parameter : parameters) {
        ConditionType conditionType = parameter.getConditionType();
        if (conditionType == ConditionType.In || parameter.isInParameter()) {
            paramsDeclaration.add(String.format("List<%s> %s", parameter.getType(), WordUtils.uncapitalize(parameter.getAlias())));
        } else if (conditionType == ConditionType.IsNull || conditionType == ConditionType.IsNotNull
                || conditionType == ConditionType.And || conditionType == ConditionType.Or
                || conditionType == ConditionType.Not || conditionType == ConditionType.LeftBracket
                || conditionType == ConditionType.RightBracket) {
            continue;// is null、is not null don't hava param
        } else {
            paramsDeclaration.add(String.format("%s %s", parameter.getType(), WordUtils.uncapitalize(parameter.getAlias())));
        }
    }
    if (this.paging && this.crud_type.equalsIgnoreCase("select")) {
        paramsDeclaration.add("int pageNo");
        paramsDeclaration.add("int pageSize");
    }
    return StringUtils.join(paramsDeclaration, ", ");
}
 
Example #17
Source File: RSSUtils.java    From oodt with Apache License 2.0 6 votes vote down vote up
public static Element emitRSSTag(RSSTag tag, Metadata prodMet, Document doc,
    Element item) {
  String outputTag = tag.getName();
  if (outputTag.contains(" ")) {
    outputTag = StringUtils.join(WordUtils.capitalizeFully(outputTag).split(
        " "));
  }
  Element rssMetElem = XMLUtils.addNode(doc, item, outputTag);

  // first check if there is a source defined, if so, use that as the value
  if (tag.getSource() != null) {
    rssMetElem.appendChild(doc.createTextNode(StringEscapeUtils.escapeXml(PathUtils.replaceEnvVariables(
        tag.getSource(), prodMet))));
  }

  // check if there are attributes defined, and if so, add to the attributes
  for (RSSTagAttribute attr : tag.getAttrs()) {
    rssMetElem.setAttribute(attr.getName(), PathUtils.replaceEnvVariables(
        attr.getValue(), prodMet));
  }

  return rssMetElem;
}
 
Example #18
Source File: PetOwnerListener.java    From SonarPet with GNU General Public License v3.0 6 votes vote down vote up
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPlayerTeleport(final PlayerTeleportEvent event) {
    final Player p = event.getPlayer();
    final IPet pi = EchoPet.getManager().getPet(p);
    Iterator<IPet> i = EchoPet.getManager().getPets().iterator();
    while (i.hasNext()) {
        IPet pet = i.next();
        if (pet.getEntityPet() instanceof IEntityPacketPet && ((IEntityPacketPet) pet.getEntityPet()).hasInititiated()) {
            if (GeometryUtil.getNearbyEntities(event.getTo(), 50).contains(pet)) {
                ((IEntityPacketPet) pet.getEntityPet()).updatePosition();
            }
        }
    }
    if (pi != null) {
        if (!WorldUtil.allowPets(event.getTo())) {
            Lang.sendTo(p, Lang.PETS_DISABLED_HERE.toString().replace("%world%", WordUtils.capitalizeFully(event.getTo().getWorld().getName())));
            EchoPet.getManager().saveFileData("autosave", pi);
            EchoPet.getSqlManager().saveToDatabase(pi, false);
            EchoPet.getManager().removePet(pi, false);
        }
    }
}
 
Example #19
Source File: AbstractDataPreparer.java    From das with Apache License 2.0 6 votes vote down vote up
protected String getPojoClassName(String prefix, String suffix, String tableName) {
    String className = tableName;
    if (null != prefix && !prefix.isEmpty() && className.indexOf(prefix) == 0) {
        className = className.replaceFirst(prefix, "");
    }
    if (null != suffix && !suffix.isEmpty()) {
        className = className + WordUtils.capitalize(suffix);
    }

    StringBuilder result = new StringBuilder();
    for (String str : StringUtils.split(className, "_")) {
        result.append(WordUtils.capitalize(str));
    }

    return WordUtils.capitalize(result.toString());
}
 
Example #20
Source File: RepositoryCleanupUtil.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
/**
 * Format strings for command line output
 * 
 * @param unformattedText
 * @param indentFirstLine
 * @param indentBalance
 * @return
 */
private String indentFormat( String unformattedText, int indentFirstLine, int indentBalance ) {
  final int maxWidth = 79;
  String leadLine = WordUtils.wrap( unformattedText, maxWidth - indentFirstLine );
  StringBuilder result = new StringBuilder();
  result.append( "\n" );
  if ( leadLine.indexOf( NEW_LINE ) == -1 ) {
    result.append( NEW_LINE ).append( StringUtils.repeat( " ", indentFirstLine ) ).append( unformattedText );
  } else {
    int lineBreakPoint = leadLine.indexOf( NEW_LINE );
    String indentString = StringUtils.repeat( " ", indentBalance );
    result.append( NEW_LINE ).append( StringUtils.repeat( " ", indentFirstLine ) ).append(
        leadLine.substring( 0, lineBreakPoint ) );
    String formattedText = WordUtils.wrap( unformattedText.substring( lineBreakPoint ), maxWidth - indentBalance );
    for ( String line : formattedText.split( NEW_LINE ) ) {
      result.append( NEW_LINE ).append( indentString ).append( line );
    }
  }
  return result.toString();
}
 
Example #21
Source File: JavaParameterHost.java    From dal with Apache License 2.0 5 votes vote down vote up
public String getCamelCaseCapitalizedName() {
    String temp = name.replace("@", "");
    if (temp.contains("_")) {
        temp = WordUtils.capitalizeFully(temp.replace('_', ' ')).replace(" ", "");
    }
    return WordUtils.capitalize(temp);
}
 
Example #22
Source File: CacheAdmin.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override
public String getLongUsage() {
  return getShortUsage() + "\n" +
      WordUtils.wrap("Remove a cache pool. This also uncaches paths " +
          "associated with the pool.\n\n", AdminHelper.MAX_LINE_WIDTH) +
      "<name>  Name of the cache pool to remove.\n";
}
 
Example #23
Source File: ProximityCommand.java    From CardinalPGM with MIT License 5 votes vote down vote up
private static String getObjective(GameObjective objective, GameObjectiveProximityHandler proximityHandler) {
    String message = "  ";
    if (objective instanceof WoolObjective) message += MiscUtil.convertDyeColorToChatColor(((WoolObjective)objective).getColor());
    if (objective instanceof FlagObjective) message += ((FlagObjective) objective).getChatColor();
    message += WordUtils.capitalizeFully(objective.getName().replaceAll("_", " ")) + " ";
    message += objective.isComplete() ? ChatColor.GREEN + "COMPLETE " : objective.isTouched() ? ChatColor.YELLOW + "TOUCHED " : ChatColor.RED + "UNTOUCHED ";
    if (proximityHandler != null && !objective.isComplete()) {
        message += ChatColor.GRAY + proximityHandler.getProximityName() + ": ";
        message += ChatColor.AQUA + proximityHandler.getProximityAsString();
    }
    return message;
}
 
Example #24
Source File: _MailService.java    From jhipster-ribbon-hystrix with GNU General Public License v3.0 5 votes vote down vote up
@Async
public void sendSocialRegistrationValidationEmail(User user, String provider) {
    log.debug("Sending social registration validation e-mail to '{}'", user.getEmail());
    Locale locale = Locale.forLanguageTag(user.getLangKey());
    Context context = new Context(locale);
    context.setVariable("user", user);
    context.setVariable("provider", WordUtils.capitalize(provider));
    String content = templateEngine.process("socialRegistrationValidationEmail", context);
    String subject = messageSource.getMessage("email.social.registration.title", null, locale);
    sendEmail(user.getEmail(), subject, content, false, true);
}
 
Example #25
Source File: JavaParameterHost.java    From das with Apache License 2.0 5 votes vote down vote up
public String getUncapitalizedName() {
    String tempName = name.replace("@", "");
    // if (tempName.contains("_")) {
    // tempName = WordUtils.capitalizeFully(tempName.replace('_', ' ')).replace(" ", "");
    // }
    return WordUtils.uncapitalize(tempName);
}
 
Example #26
Source File: JavaParameterHost.java    From das with Apache License 2.0 5 votes vote down vote up
public String getCamelCaseCapitalizedName() {
    String temp = name.replace("@", "");
    if (temp.contains("_")) {
        temp = WordUtils.capitalizeFully(temp.replace('_', ' ')).replace(" ", "");
    }
    return WordUtils.capitalize(temp);
}
 
Example #27
Source File: JavaParameterHost.java    From das with Apache License 2.0 5 votes vote down vote up
public String getCapitalizedName() {
    String tempName = name.replace("@", "");
    // if (tempName.contains("_")) {
    // tempName = WordUtils.capitalizeFully(tempName.replace('_', ' ')).replace(" ", "");
    // }
    return WordUtils.capitalize(tempName);
}
 
Example #28
Source File: StringFormatter.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Capitalizes a string according to its type. The first letter is changed
 * to title case (no other letters are changed) if the string isn't supposed
 * to be in upper (e.g.: roman numeration) or lower case (e.g.: articles and
 * prepositions).
 * 
 * @param uglyWord
 *            the string to capitalize
 * @param originalWordEndsWithSpecialChar
 * @return the capitalized word
 */
public static String capitalizeWord(String uglyWord, boolean originalWordEndsWithSpecialChar) {
    StringBuilder prettyWord = new StringBuilder();

    if (allCapSet.contains(uglyWord)) {
        prettyWord.append(uglyWord.toUpperCase());
    } else {
        if (!originalWordEndsWithSpecialChar && allLowerSet.contains(uglyWord)) {
            prettyWord.append(uglyWord);
        } else {
            prettyWord.append(WordUtils.capitalize(uglyWord));
        }
    }
    return prettyWord.toString();
}
 
Example #29
Source File: ObserverModule.java    From CardinalPGM with MIT License 5 votes vote down vote up
public Inventory getFakeInventory(Player player, String locale) {
    Inventory inventory = Bukkit.createInventory(null, 45, player.getDisplayName().length() > 32 ? Teams.getTeamColorByPlayer(player) + player.getName() : player.getDisplayName());
    inventory.setItem(0, player.getInventory().getHelmet());
    inventory.setItem(1, player.getInventory().getChestplate());
    inventory.setItem(2, player.getInventory().getLeggings());
    inventory.setItem(3, player.getInventory().getBoots());
    inventory.setItem(4, player.getInventory().getItemInOffHand());

    ItemStack potion;
    if (player.getActivePotionEffects().size() > 0){
        ArrayList<String> effects = new ArrayList<>();
        for (PotionEffect effect : player.getActivePotionEffects()) {
            String effectName = WordUtils.capitalizeFully(effect.getType().getName().toLowerCase().replaceAll("_", " "));
            effects.add(ChatColor.YELLOW + effectName + " " + (effect.getAmplifier() + 1));
        }
        potion = Items.createItem(Material.POTION, 1, (short) 0, ChatColor.AQUA + "" + ChatColor.ITALIC + new LocalizedChatMessage(ChatConstant.UI_POTION_EFFECTS).getMessage(locale), effects);
    } else {
        potion = Items.createItem(Material.GLASS_BOTTLE, 1, (short) 0, ChatColor.AQUA + "" + ChatColor.ITALIC + new LocalizedChatMessage(ChatConstant.UI_POTION_EFFECTS).getMessage(locale), new ArrayList<>(Collections.singletonList(ChatColor.YELLOW + new LocalizedChatMessage(ChatConstant.UI_NO_POTION_EFFECTS).getMessage(locale))));
    }
    inventory.setItem(6, potion);
    ItemStack food = Items.createItem(Material.COOKED_BEEF, player.getFoodLevel(), (short) 0, ChatColor.AQUA + "" + ChatColor.ITALIC + new LocalizedChatMessage(ChatConstant.UI_HUNGER_LEVEL).getMessage(locale));
    inventory.setItem(7, food);
    ItemStack health = Items.createItem(Material.REDSTONE, (int) Math.ceil(player.getHealth()), (short) 0, ChatColor.AQUA + "" + ChatColor.ITALIC + new LocalizedChatMessage(ChatConstant.UI_HEALTH_LEVEL).getMessage(locale));
    inventory.setItem(8, health);
    for (int i = 36; i <= 44; i++) {
        inventory.setItem(i, player.getInventory().getItem(i - 36));
    }
    for (int i = 9; i <= 35; i++) {
        inventory.setItem(i, player.getInventory().getItem(i));
    }
    return inventory;
}
 
Example #30
Source File: Column.java    From code-generator with MIT License 5 votes vote down vote up
public void setColumnName(String columnName) {
    this.columnName = columnName;
    if (this.columnName != null) {
        this.uppercaseAttributeName = WordUtils.capitalizeFully(this.columnName.toLowerCase(), new char[]{'_'})
                .replace("_", "");
        this.attributeName = StringUtils.uncapitalize(this.uppercaseAttributeName);
    }
}