public TooltipBuilder addDurability(boolean textIfBroken) {
    if (ToolHelper.isBroken(stack) && textIfBroken) {
      tips.add(
          String.format(
              "%s: %s%s%s",
              Util.translate(HeadMaterialStats.LOC_Durability),
              TextFormatting.DARK_RED,
              TextFormatting.BOLD,
              Util.translate("tooltip.tool.broken")));
    } else {
      tips.add(
          HeadMaterialStats.formatDurability(
              ToolHelper.getCurrentDurability(stack), ToolHelper.getMaxDurability(stack)));
    }

    return this;
  }
  public TooltipBuilder addAmmo(boolean textIfEmpty) {
    if (stack.getItem() instanceof IAmmo) {
      if (ToolHelper.isBroken(stack) && textIfEmpty) {
        tips.add(
            String.format(
                "%s: %s%s%s",
                Util.translate(LOC_Ammo),
                TextFormatting.DARK_RED,
                TextFormatting.BOLD,
                Util.translate(LOC_Empty)));
      } else {
        IAmmo ammoItem = (IAmmo) stack.getItem();
        tips.add(formatAmmo(ammoItem.getCurrentAmmo(stack), ammoItem.getMaxAmmo(stack)));
      }
    }

    return this;
  }
 public static String formatAmmo(int durability, int ref) {
   return String.format(
           "%s: %s%s%s/%s%s",
           Util.translate(LOC_Ammo),
           CustomFontColor.valueToColorCode((float) durability / (float) ref),
           df.format(durability),
           TextFormatting.GRAY.toString(),
           COLOR_Durability,
           df.format(ref))
       + TextFormatting.RESET;
 }
Esempio n. 4
0
 public String getLocalizedName() {
   return Util.translate(LOC_Name, getIdentifier());
 }