Stat formatting

This commit is contained in:
Indyuce 2022-07-31 15:49:09 +02:00
parent 2a9265ddc6
commit 3e9222533f
17 changed files with 104 additions and 156 deletions

View File

@ -146,7 +146,7 @@
<dependency> <dependency>
<groupId>net.Indyuce</groupId> <groupId>net.Indyuce</groupId>
<artifactId>MMOCore</artifactId> <artifactId>MMOCore</artifactId>
<version>1.9.4</version> <version>1.9.5</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>

View File

@ -1,5 +1,6 @@
package net.Indyuce.mmoitems.api.item.util.crafting; package net.Indyuce.mmoitems.api.item.util.crafting;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.adventure.text.Component; import io.lumine.mythic.lib.adventure.text.Component;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
@ -17,7 +18,6 @@ import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -25,8 +25,6 @@ import java.util.ListIterator;
import java.util.Map; import java.util.Map;
public class CraftingRecipeDisplay extends ConfigItem { public class CraftingRecipeDisplay extends ConfigItem {
private static final DecimalFormat craftingTimeFormat = new DecimalFormat("0.#");
public CraftingRecipeDisplay() { public CraftingRecipeDisplay() {
super("CRAFTING_RECIPE_DISPLAY", Material.BARRIER, "&a&lCraft&f #name#", "{conditions}", "{conditions}&8Conditions:", "{crafting_time}", super("CRAFTING_RECIPE_DISPLAY", Material.BARRIER, "&a&lCraft&f #name#", "{conditions}", "{conditions}&8Conditions:", "{crafting_time}",
"{crafting_time}&7Crafting Time: &c#crafting-time#&7s", "", "&8Ingredients:", "#ingredients#", "", "&eLeft-Click to craft!", "{crafting_time}&7Crafting Time: &c#crafting-time#&7s", "", "&8Ingredients:", "#ingredients#", "", "&eLeft-Click to craft!",
@ -76,7 +74,7 @@ public class CraftingRecipeDisplay extends ConfigItem {
} }
replace.put(str, str.replace("{crafting_time}", "").replace("#crafting-time#", replace.put(str, str.replace("{crafting_time}", "").replace("#crafting-time#",
craftingTimeFormat.format(craftingRecipe.getCraftingTime()))); MythicLib.plugin.getMMOConfig().decimal.format(craftingRecipe.getCraftingTime())));
} }
if (str.startsWith("{conditions}")) { if (str.startsWith("{conditions}")) {

View File

@ -1,19 +1,14 @@
package net.Indyuce.mmoitems.api.player; package net.Indyuce.mmoitems.api.player;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.player.cooldown.CooldownInfo;
import io.lumine.mythic.lib.skill.SkillMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.stat.type.ItemRestriction; import net.Indyuce.mmoitems.stat.type.ItemRestriction;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.text.DecimalFormat;
/** /**
* Interface class between RPG core plugins like Heroes, MythicCore, SkillAPI * Interface class between RPG core plugins like Heroes, MythicCore, SkillAPI
* and MMOItems * and MMOItems

View File

@ -24,7 +24,7 @@ public class NumericStatFormula implements RandomStatData<DoubleData>, Updatable
private final double base, scale, spread, maxSpread; private final double base, scale, spread, maxSpread;
private static final Random RANDOM = new Random(); private static final Random RANDOM = new Random();
private static final DecimalFormat DIGIT = new DecimalFormat("0.####"); private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.####");
public static final NumericStatFormula ZERO = new NumericStatFormula(0, 0, 0, 0); public static final NumericStatFormula ZERO = new NumericStatFormula(0, 0, 0, 0);
@ -220,13 +220,13 @@ public class NumericStatFormula implements RandomStatData<DoubleData>, Updatable
public String toString() { public String toString() {
if (scale == 0 && spread == 0) if (scale == 0 && spread == 0)
return DIGIT.format(base); return DECIMAL_FORMAT.format(base);
if (scale == 0) if (scale == 0)
return "[" + DIGIT.format(base * (1 - maxSpread)) + " -> " + DIGIT.format(base * (1 + maxSpread)) + "] (" + DIGIT.format(spread * 100) return "[" + DECIMAL_FORMAT.format(base * (1 - maxSpread)) + " -> " + DECIMAL_FORMAT.format(base * (1 + maxSpread)) + "] (" + DECIMAL_FORMAT.format(spread * 100)
+ "% Spread) (" + DIGIT.format(base) + " Avg)"; + "% Spread) (" + DECIMAL_FORMAT.format(base) + " Avg)";
return "{Base=" + DIGIT.format(base) + (scale != 0 ? ",Scale=" + DIGIT.format(scale) : "") + (spread != 0 ? ",Spread=" + spread : "") return "{Base=" + DECIMAL_FORMAT.format(base) + (scale != 0 ? ",Scale=" + DECIMAL_FORMAT.format(scale) : "") + (spread != 0 ? ",Spread=" + spread : "")
+ (maxSpread != 0 ? ",Max=" + maxSpread : "") + "}"; + (maxSpread != 0 ? ",Max=" + maxSpread : "") + "}";
} }

View File

@ -14,6 +14,8 @@ import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
public class CheckAttributeCommandTreeNode extends CommandTreeNode { public class CheckAttributeCommandTreeNode extends CommandTreeNode {
private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.####");
public CheckAttributeCommandTreeNode(CommandTreeNode parent) { public CheckAttributeCommandTreeNode(CommandTreeNode parent) {
super(parent, "checkattribute"); super(parent, "checkattribute");
@ -40,7 +42,7 @@ public class CheckAttributeCommandTreeNode extends CommandTreeNode {
sender.sendMessage(ChatColor.AQUA + "Value = " + ChatColor.RESET + att.getValue()); sender.sendMessage(ChatColor.AQUA + "Value = " + ChatColor.RESET + att.getValue());
for (AttributeModifier mod : att.getModifiers()) for (AttributeModifier mod : att.getModifiers())
sender.sendMessage( sender.sendMessage(
mod.getName() + " " + new DecimalFormat("0.####").format(mod.getAmount()) + " " + mod.getOperation() + " " + mod.getSlot()); mod.getName() + " " + DECIMAL_FORMAT.format(mod.getAmount()) + " " + mod.getOperation() + " " + mod.getSlot());
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
player.sendMessage("Couldn't find attribute."); player.sendMessage("Couldn't find attribute.");
} }

View File

@ -4,13 +4,11 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.player.MMOPlayerData; import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.manager.StatManager;
import io.lumine.mythic.lib.parser.client.eval.DoubleEvaluator; import io.lumine.mythic.lib.parser.client.eval.DoubleEvaluator;
import io.lumine.mythic.lib.player.cooldown.CooldownInfo;
import me.clip.placeholderapi.expansion.PlaceholderExpansion; import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -20,16 +18,7 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
public class MMOItemsPlaceholders extends PlaceholderExpansion { public class MMOItemsPlaceholders extends PlaceholderExpansion {
private final DecimalFormat oneDigit = new DecimalFormat("0.#"), twoDigits = new DecimalFormat("0.##");
public MMOItemsPlaceholders() {
oneDigit.setDecimalFormatSymbols(MythicLib.plugin.getMMOConfig().formatSymbols);
twoDigits.setDecimalFormatSymbols(MythicLib.plugin.getMMOConfig().formatSymbols);
}
@Override @Override
public String getAuthor() { public String getAuthor() {
@ -64,7 +53,7 @@ public class MMOItemsPlaceholders extends PlaceholderExpansion {
// i don't register it in the starts with condition because it will mess // i don't register it in the starts with condition because it will mess
// with substring // with substring
if (identifier.equals("stat_defense_percent")) if (identifier.equals("stat_defense_percent"))
return twoDigits.format(100 - calculateDefense(MMOPlayerData.get(player))) + "%"; return MythicLib.plugin.getMMOConfig().decimal.format(100 - calculateDefense(MMOPlayerData.get(player))) + "%";
if (identifier.startsWith("stat_elements") && player.isOnline()) { if (identifier.startsWith("stat_elements") && player.isOnline()) {
// index 0 = element // index 0 = element
@ -83,20 +72,15 @@ public class MMOItemsPlaceholders extends PlaceholderExpansion {
} }
} }
return twoDigits.format(value); return MythicLib.plugin.getMMOConfig().decimal.format(value);
} }
} } else if (identifier.startsWith("stat_")) {
else if (identifier.startsWith("stat_")) { final String stat = identifier.substring(5).toUpperCase();
ItemStat stat = MMOItems.plugin.getStats().get(identifier.substring(5).toUpperCase()); return StatManager.format(stat, MMOPlayerData.get(player).getStatMap().getStat(stat));
if (stat != null)
return twoDigits.format(PlayerData.get(player).getStats().getStat(stat));
} }
if (identifier.startsWith("ability_cd_")) { if (identifier.startsWith("ability_cd_"))
MMOPlayerData data = MMOPlayerData.get(player); return MythicLib.plugin.getMMOConfig().decimal.format(MMOPlayerData.get(player).getCooldownMap().getCooldown("skill_" + identifier.substring(11)));
CooldownInfo info = data.getCooldownMap().getInfo("mmoitems_skill_" + identifier.substring(11));
return info == null ? "0" : oneDigit.format(info.getRemaining() / 1000d);
}
if(identifier.startsWith("type_")) { if(identifier.startsWith("type_")) {
String t = identifier.substring(5, identifier.lastIndexOf("_")).toUpperCase(); String t = identifier.substring(5, identifier.lastIndexOf("_")).toUpperCase();
@ -136,7 +120,7 @@ public class MMOItemsPlaceholders extends PlaceholderExpansion {
NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getPlayer().getInventory().getItemInMainHand()); NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getPlayer().getInventory().getItemInMainHand());
double durability = item.getDouble("MMOITEMS_DURABILITY"); double durability = item.getDouble("MMOITEMS_DURABILITY");
double maxDurability = item.getDouble("MMOITEMS_MAX_DURABILITY"); double maxDurability = item.getDouble("MMOITEMS_MAX_DURABILITY");
return oneDigit.format(durability / maxDurability * 100); return MythicLib.plugin.getMMOConfig().decimal.format(durability / maxDurability * 100);
} }
if (identifier.equals("durability_bar_square")) if (identifier.equals("durability_bar_square"))

View File

@ -1,7 +1,5 @@
package net.Indyuce.mmoitems.gui.edition; package net.Indyuce.mmoitems.gui.edition;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.skill.handler.SkillHandler;
import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
@ -34,7 +32,7 @@ public class AbilityEdition extends EditionInventory {
private RegisteredSkill ability; private RegisteredSkill ability;
private static final DecimalFormat modifierFormat = new DecimalFormat("0.###"); private static final DecimalFormat MODIFIER_FORMAT = new DecimalFormat("0.###");
private static final int[] slots = { 23, 24, 25, 32, 33, 34, 41, 42, 43, 50, 51, 52 }; private static final int[] slots = { 23, 24, 25, 32, 33, 34, 41, 42, 43, 50, 51, 52 };
public AbilityEdition(Player player, MMOItemTemplate template, String configKey) { public AbilityEdition(Player player, MMOItemTemplate template, String configKey) {
@ -109,12 +107,12 @@ public class AbilityEdition extends EditionInventory {
try { try {
modifierItemLore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GOLD modifierItemLore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GOLD
+ (section.contains(modifier) ? new NumericStatFormula(section.get(modifier)).toString() + (section.contains(modifier) ? new NumericStatFormula(section.get(modifier)).toString()
: modifierFormat.format(ability.getDefaultModifier(modifier)))); : MODIFIER_FORMAT.format(ability.getDefaultModifier(modifier))));
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
modifierItemLore.add(ChatColor.GRAY + "Could not read value. Using default"); modifierItemLore.add(ChatColor.GRAY + "Could not read value. Using default");
} }
modifierItemLore.add(ChatColor.GRAY + "Default Value: " + ChatColor.GOLD + modifierFormat.format(ability.getDefaultModifier(modifier))); modifierItemLore.add(ChatColor.GRAY + "Default Value: " + ChatColor.GOLD + MODIFIER_FORMAT.format(ability.getDefaultModifier(modifier)));
modifierItemLore.add(""); modifierItemLore.add("");
modifierItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value."); modifierItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
modifierItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to reset."); modifierItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to reset.");

View File

@ -40,10 +40,7 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerItemConsumeEvent; import org.bukkit.event.player.PlayerItemConsumeEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import java.text.DecimalFormat;
public class ItemUse implements Listener { public class ItemUse implements Listener {
private static final DecimalFormat DIGIT = new DecimalFormat("0.#");
@EventHandler @EventHandler
public void rightClickEffects(PlayerInteractEvent event) { public void rightClickEffects(PlayerInteractEvent event) {
@ -75,7 +72,7 @@ public class ItemUse implements Listener {
final String cooldownReference = getCooldownReference(useItem.getMMOItem()); final String cooldownReference = getCooldownReference(useItem.getMMOItem());
if (useItem.getPlayerData().getMMOPlayerData().getCooldownMap().isOnCooldown(cooldownReference)) { if (useItem.getPlayerData().getMMOPlayerData().getCooldownMap().isOnCooldown(cooldownReference)) {
Message.ITEM_ON_COOLDOWN Message.ITEM_ON_COOLDOWN
.format(ChatColor.RED, "#left#", DIGIT.format(useItem.getPlayerData().getMMOPlayerData().getCooldownMap().getCooldown(cooldownReference))) .format(ChatColor.RED, "#left#", MythicLib.plugin.getMMOConfig().decimal.format(useItem.getPlayerData().getMMOPlayerData().getCooldownMap().getCooldown(cooldownReference)))
.send(player); .send(player);
event.setUseItemInHand(Event.Result.DENY); event.setUseItemInHand(Event.Result.DENY);
return; return;
@ -326,7 +323,7 @@ public class ItemUse implements Listener {
final String cooldownReference = getCooldownReference(useItem.getMMOItem()); final String cooldownReference = getCooldownReference(useItem.getMMOItem());
if (useItem.getPlayerData().getMMOPlayerData().getCooldownMap().isOnCooldown(cooldownReference)) { if (useItem.getPlayerData().getMMOPlayerData().getCooldownMap().isOnCooldown(cooldownReference)) {
Message.ITEM_ON_COOLDOWN Message.ITEM_ON_COOLDOWN
.format(ChatColor.RED, "#left#", DIGIT.format(useItem.getPlayerData().getMMOPlayerData().getCooldownMap().getCooldown(cooldownReference))) .format(ChatColor.RED, "#left#", MythicLib.plugin.getMMOConfig().decimal.format(useItem.getPlayerData().getMMOPlayerData().getCooldownMap().getCooldown(cooldownReference)))
.send(player); .send(player);
event.setCancelled(true); event.setCancelled(true);
return; return;

View File

@ -25,7 +25,6 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.StandardCopyOption; import java.nio.file.StandardCopyOption;
import java.text.DecimalFormat;
import java.util.Base64; import java.util.Base64;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
@ -42,7 +41,6 @@ public class ConfigManager implements Reloadable {
// TODO remove ability-player-damage and add some WG flag or something // TODO remove ability-player-damage and add some WG flag or something
public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate; public boolean abilityPlayerDamage, dodgeKnockbackEnabled, replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate;
public String abilitySplitter; public String abilitySplitter;
public DecimalFormat healIndicatorDecimalFormat, damageIndicatorDecimalFormat;
public double dodgeKnockbackForce, soulboundBaseDamage, soulboundPerLvlDamage, levelSpread; public double dodgeKnockbackForce, soulboundBaseDamage, soulboundPerLvlDamage, levelSpread;
public NumericStatFormula defaultItemCapacity; public NumericStatFormula defaultItemCapacity;
public ReforgeOptions revisionOptions, phatLootsOptions; public ReforgeOptions revisionOptions, phatLootsOptions;
@ -195,8 +193,6 @@ public class ConfigManager implements Reloadable {
String healDecimal = MMOItems.plugin.getConfig().getString("game-indicators.heal.decimal-format"); String healDecimal = MMOItems.plugin.getConfig().getString("game-indicators.heal.decimal-format");
String harmDecimal = MMOItems.plugin.getConfig().getString("game-indicators.damage.decimal-format"); String harmDecimal = MMOItems.plugin.getConfig().getString("game-indicators.damage.decimal-format");
healIndicatorDecimalFormat = healDecimal != null ? new DecimalFormat(healDecimal) : new DecimalFormat("0.#");
damageIndicatorDecimalFormat = harmDecimal != null ? new DecimalFormat(harmDecimal) : new DecimalFormat("0.#");
abilitySplitter = getStatFormat("ability-splitter"); abilitySplitter = getStatFormat("ability-splitter");
dodgeKnockbackForce = MMOItems.plugin.getConfig().getDouble("mitigation.dodge.knockback.force"); dodgeKnockbackForce = MMOItems.plugin.getConfig().getDouble("mitigation.dodge.knockback.force");
dodgeKnockbackEnabled = MMOItems.plugin.getConfig().getBoolean("mitigation.dodge.knockback.enabled"); dodgeKnockbackEnabled = MMOItems.plugin.getConfig().getBoolean("mitigation.dodge.knockback.enabled");

View File

@ -1,20 +1,11 @@
package net.Indyuce.mmoitems.stat; package net.Indyuce.mmoitems.stat;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import com.google.gson.*; import com.google.gson.*;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.skill.RegisteredSkill;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
@ -23,21 +14,25 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula;
import net.Indyuce.mmoitems.api.util.NumericStatFormula.FormulaSaveOption; import net.Indyuce.mmoitems.api.util.NumericStatFormula.FormulaSaveOption;
import net.Indyuce.mmoitems.gui.edition.AbilityListEdition; import net.Indyuce.mmoitems.gui.edition.AbilityListEdition;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.skill.RegisteredSkill;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.stat.data.AbilityListData; import net.Indyuce.mmoitems.stat.data.AbilityListData;
import net.Indyuce.mmoitems.stat.data.random.RandomAbilityData; import net.Indyuce.mmoitems.stat.data.random.RandomAbilityData;
import net.Indyuce.mmoitems.stat.data.random.RandomAbilityListData; import net.Indyuce.mmoitems.stat.data.random.RandomAbilityListData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import io.lumine.mythic.lib.api.item.ItemTag; import org.apache.commons.lang.Validate;
import io.lumine.mythic.lib.api.util.AltChar; import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData> { import java.util.ArrayList;
private final DecimalFormat modifierFormat = new DecimalFormat("0.#"); import java.util.List;
import java.util.Optional;
public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData> {
public Abilities() { public Abilities() {
super("ABILITY", Material.BLAZE_POWDER, "Item Abilities", super("ABILITY", Material.BLAZE_POWDER, "Item Abilities",
new String[] { "Make your item cast amazing abilities", "to kill monsters or buff yourself." }, new String[] { "!block", "all" }); new String[] { "Make your item cast amazing abilities", "to kill monsters or buff yourself." }, new String[] { "!block", "all" });
@ -69,9 +64,9 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
for (String modifier : ability.getModifiers()) { for (String modifier : ability.getModifiers()) {
item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier, item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier,
this.modifierFormat.format(ability.getModifier(modifier))); MythicLib.plugin.getMMOConfig().decimal.format(ability.getModifier(modifier)));
abilityLore.add(modifierFormat.replace("#m", ability.getAbility().getModifierName(modifier)).replace("#v", abilityLore.add(modifierFormat.replace("#m", ability.getAbility().getModifierName(modifier)).replace("#v",
this.modifierFormat.format(ability.getModifier(modifier)))); MythicLib.plugin.getMMOConfig().decimal.format(ability.getModifier(modifier))));
} }
if (splitter) if (splitter)

View File

@ -1,25 +1,12 @@
package net.Indyuce.mmoitems.stat; package net.Indyuce.mmoitems.stat;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffectType;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
@ -31,18 +18,21 @@ import net.Indyuce.mmoitems.stat.data.PotionEffectData;
import net.Indyuce.mmoitems.stat.data.PotionEffectListData; import net.Indyuce.mmoitems.stat.data.PotionEffectListData;
import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData;
import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import io.lumine.mythic.lib.MythicLib; import org.apache.commons.lang.Validate;
import io.lumine.mythic.lib.api.item.ItemTag; import org.bukkit.ChatColor;
import io.lumine.mythic.lib.api.util.AltChar; import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class ArrowPotionEffects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> { import java.util.*;
private final DecimalFormat durationFormat = new DecimalFormat("0.#");
public class ArrowPotionEffects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> {
public ArrowPotionEffects() { public ArrowPotionEffects() {
super("ARROW_POTION_EFFECTS", Material.TIPPED_ARROW, "Arrow Potion Effects", super("ARROW_POTION_EFFECTS", Material.TIPPED_ARROW, "Arrow Potion Effects",
new String[] { "The effects to be applied when", "entities are shot by this bow" }, new String[] { "bow", "crossbow" }); new String[] { "The effects to be applied when", "entities are shot by this bow" }, new String[] { "bow", "crossbow" });
@ -131,7 +121,7 @@ public class ArrowPotionEffects extends ItemStat<RandomPotionEffectListData, Pot
String permEffectFormat = ItemStat.translate("arrow-potion-effects"); String permEffectFormat = ItemStat.translate("arrow-potion-effects");
data.getEffects().forEach(effect -> { data.getEffects().forEach(effect -> {
lore.add(permEffectFormat.replace("#", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType()) lore.add(permEffectFormat.replace("#", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
+ " " + MMOUtils.intToRoman(effect.getLevel()) + "(" + durationFormat.format(effect.getDuration()) + "s)")); + " " + MMOUtils.intToRoman(effect.getLevel()) + "(" + MythicLib.plugin.getMMOConfig().decimal.format(effect.getDuration()) + "s)"));
}); });
item.getLore().insert("arrow-potion-effects", lore); item.getLore().insert("arrow-potion-effects", lore);

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmoitems.stat; package net.Indyuce.mmoitems.stat;
import com.google.gson.*; import com.google.gson.*;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
@ -19,7 +20,6 @@ import net.Indyuce.mmoitems.stat.data.PotionEffectData;
import net.Indyuce.mmoitems.stat.data.PotionEffectListData; import net.Indyuce.mmoitems.stat.data.PotionEffectListData;
import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData;
import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.stat.type.PlayerConsumable; import net.Indyuce.mmoitems.stat.type.PlayerConsumable;
@ -34,12 +34,9 @@ import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.text.DecimalFormat;
import java.util.*; import java.util.*;
public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> implements PlayerConsumable { public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> implements PlayerConsumable {
private final DecimalFormat durationFormat = new DecimalFormat("0.#");
public Effects() { public Effects() {
super("EFFECTS", Material.POTION, "Effects", new String[]{"The potion effects your", "consumable item grants."}, super("EFFECTS", Material.POTION, "Effects", new String[]{"The potion effects your", "consumable item grants."},
new String[]{"consumable"}); new String[]{"consumable"});
@ -123,7 +120,7 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
.replace("#e", .replace("#e",
MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType()) MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
+ (effect.getLevel() < 2 ? "" : " " + MMOUtils.intToRoman(effect.getLevel()))) + (effect.getLevel() < 2 ? "" : " " + MMOUtils.intToRoman(effect.getLevel())))
.replace("#d", durationFormat.format(effect.getDuration()))); .replace("#d", MythicLib.plugin.getMMOConfig().decimal.format(effect.getDuration())));
}); });
item.getLore().insert("effects", lore); item.getLore().insert("effects", lore);

View File

@ -113,8 +113,8 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
.replace("#color", pair.getKey().getColor()) .replace("#color", pair.getKey().getColor())
.replace("#icon", pair.getKey().getLoreIcon()) .replace("#icon", pair.getKey().getLoreIcon())
.replace("#name", pair.getKey().getName()); .replace("#name", pair.getKey().getName());
double value = data.getStat(pair.getKey(), pair.getValue()); final double value = data.getStat(pair.getKey(), pair.getValue());
lore.add(DoubleStat.formatPath(format, true, value)); lore.add(DoubleStat.formatPath("ELEMENTAL_STAT", format, true, value));
} }
// Insert non-empty lore // Insert non-empty lore
@ -205,9 +205,9 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
String builtRange; String builtRange;
if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) { if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) {
builtRange = DoubleStat.formatPath(ItemStat.translate(path), true, techMinimum); builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), ItemStat.translate(path), true, techMinimum);
} else { } else {
builtRange = DoubleStat.formatPath(ItemStat.translate(path), true, techMinimum, techMaximum); builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), ItemStat.translate(path), true, techMinimum, techMaximum);
} }
// Just display normally // Just display normally

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmoitems.stat.data; package net.Indyuce.mmoitems.stat.data;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.player.cooldown.CooldownInfo; import io.lumine.mythic.lib.player.cooldown.CooldownInfo;
import io.lumine.mythic.lib.skill.Skill; import io.lumine.mythic.lib.skill.Skill;
@ -18,9 +19,7 @@ import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.text.DecimalFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
@ -92,7 +91,7 @@ public class AbilityData extends Skill {
String barChar = MMOItems.plugin.getConfig().getString("cooldown-progress-bar-char"); String barChar = MMOItems.plugin.getConfig().getString("cooldown-progress-bar-char");
for (int j = 0; j < 10; j++) for (int j = 0; j < 10; j++)
progressBar.append(progress >= j ? ChatColor.GREEN : ChatColor.WHITE).append(barChar); progressBar.append(progress >= j ? ChatColor.GREEN : ChatColor.WHITE).append(barChar);
Message.SPELL_ON_COOLDOWN.format(ChatColor.RED, "#left#", "" + new DecimalFormat("0.#").format(info.getRemaining() / 1000d), "#progress#", Message.SPELL_ON_COOLDOWN.format(ChatColor.RED, "#left#", MythicLib.plugin.getMMOConfig().decimal.format(info.getRemaining() / 1000d), "#progress#",
progressBar.toString(), "#s#", (info.getRemaining() > 1999 ? "s" : "")).send(player); progressBar.toString(), "#s#", (info.getRemaining() > 1999 ? "s" : "")).send(player);
} }
return false; return false;

View File

@ -1,10 +1,7 @@
package net.Indyuce.mmoitems.stat.data; package net.Indyuce.mmoitems.stat.data;
import org.apache.commons.lang.Validate;
import net.Indyuce.mmoitems.stat.data.type.Mergeable; import net.Indyuce.mmoitems.stat.data.type.Mergeable;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import org.jetbrains.annotations.NotNull;
public class DoubleData implements StatData, Mergeable<DoubleData> { public class DoubleData implements StatData, Mergeable<DoubleData> {
private double value; private double value;

View File

@ -1,12 +1,11 @@
package net.Indyuce.mmoitems.stat.type; package net.Indyuce.mmoitems.stat.type;
import java.text.DecimalFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import net.Indyuce.mmoitems.stat.data.DoubleData;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -21,16 +20,12 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.BooleanData; import net.Indyuce.mmoitems.stat.data.BooleanData;
import net.Indyuce.mmoitems.stat.data.random.RandomBooleanData; import net.Indyuce.mmoitems.stat.data.random.RandomBooleanData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
public class BooleanStat extends ItemStat<RandomBooleanData, BooleanData> { public class BooleanStat extends ItemStat<RandomBooleanData, BooleanData> {
private static final DecimalFormat digit = new DecimalFormat("0.#");
public BooleanStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) { public BooleanStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) {
super(id, mat, name, lore, types, materials); super(id, mat, name, lore, types, materials);
} }
@ -98,7 +93,7 @@ public class BooleanStat extends ItemStat<RandomBooleanData, BooleanData> {
inv.getEditedSection().set(getPath(), probability / 100); inv.getEditedSection().set(getPath(), probability / 100);
inv.registerTemplateEdition(); inv.registerTemplateEdition();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + getName() + " successfully changed to " + ChatColor.GREEN inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + getName() + " successfully changed to " + ChatColor.GREEN
+ digit.format(probability) + "% Chance" + ChatColor.GRAY + "."); + MythicLib.plugin.getMMOConfig().decimal.format(probability) + "% Chance" + ChatColor.GRAY + ".");
} }
@Override @Override
@ -142,9 +137,9 @@ public class BooleanStat extends ItemStat<RandomBooleanData, BooleanData> {
public void whenDisplayed(List<String> lore, Optional<RandomBooleanData> statData) { public void whenDisplayed(List<String> lore, Optional<RandomBooleanData> statData) {
if (statData.isPresent()) { if (statData.isPresent()) {
double chance = ((RandomBooleanData) statData.get()).getChance(); final double chance = statData.get().getChance();
lore.add(ChatColor.GRAY + "Current Value: " + (chance >= 1 ? ChatColor.GREEN + "True" lore.add(ChatColor.GRAY + "Current Value: " + (chance >= 1 ? ChatColor.GREEN + "True"
: chance <= 0 ? ChatColor.RED + "False" : ChatColor.GREEN + digit.format(chance * 100) + "% Chance")); : chance <= 0 ? ChatColor.RED + "False" : ChatColor.GREEN + MythicLib.plugin.getMMOConfig().decimal.format(chance * 100) + "% Chance"));
} else } else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "False"); lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "False");

View File

@ -8,6 +8,7 @@ import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackCategory;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider; import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import io.lumine.mythic.lib.api.util.ui.PlusMinusPercent; import io.lumine.mythic.lib.api.util.ui.PlusMinusPercent;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import io.lumine.mythic.lib.manager.StatManager;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.UpgradeTemplate; import net.Indyuce.mmoitems.api.UpgradeTemplate;
@ -18,7 +19,6 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula;
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems; import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.data.type.UpgradeInfo; import net.Indyuce.mmoitems.stat.data.type.UpgradeInfo;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
@ -41,7 +41,7 @@ import java.util.regex.Pattern;
public class DoubleStat extends ItemStat<NumericStatFormula, DoubleData> implements Upgradable, Previewable<NumericStatFormula, DoubleData> { public class DoubleStat extends ItemStat<NumericStatFormula, DoubleData> implements Upgradable, Previewable<NumericStatFormula, DoubleData> {
private final boolean moreIsBetter; private final boolean moreIsBetter;
private static final DecimalFormat digit = new DecimalFormat("0.####"); private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("0.####");
public DoubleStat(String id, Material mat, String name, String[] lore) { public DoubleStat(String id, Material mat, String name, String[] lore) {
this(id, mat, name, lore, new String[]{"!miscellaneous", "!block", "all"}, true); this(id, mat, name, lore, new String[]{"!miscellaneous", "!block", "all"}, true);
@ -93,7 +93,7 @@ public class DoubleStat extends ItemStat<NumericStatFormula, DoubleData> impleme
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
// Get Value // Get Value
double value = ((DoubleData) data).getValue(); double value = data.getValue();
// Cancel if it its NEGATIVE and this doesn't support negative stats. // Cancel if it its NEGATIVE and this doesn't support negative stats.
if (value < 0 && !handleNegativeStats()) { return; } if (value < 0 && !handleNegativeStats()) { return; }
@ -117,7 +117,7 @@ public class DoubleStat extends ItemStat<NumericStatFormula, DoubleData> impleme
// Display in lore // Display in lore
if (value != 0 || upgradeShift != 0) { if (value != 0 || upgradeShift != 0) {
String loreInsert = formatPath(MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter, value * multiplyWhenDisplaying()); String loreInsert = formatPath(getId(), MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter, value * multiplyWhenDisplaying());
if (upgradeShift != 0) if (upgradeShift != 0)
loreInsert += MythicLib.plugin.parseColors(UpgradeTemplate.getUpgradeChangeSuffix(plus(upgradeShift * multiplyWhenDisplaying()) + (MythicLib.plugin.getMMOConfig().decimals.format(upgradeShift * multiplyWhenDisplaying())), !isGood(upgradeShift * multiplyWhenDisplaying()))); loreInsert += MythicLib.plugin.parseColors(UpgradeTemplate.getUpgradeChangeSuffix(plus(upgradeShift * multiplyWhenDisplaying()) + (MythicLib.plugin.getMMOConfig().decimals.format(upgradeShift * multiplyWhenDisplaying())), !isGood(upgradeShift * multiplyWhenDisplaying())));
item.getLore().insert(getPath(), loreInsert); item.getLore().insert(getPath(), loreInsert);
@ -132,34 +132,39 @@ public class DoubleStat extends ItemStat<NumericStatFormula, DoubleData> impleme
if (data.getValue() != 0) { item.addItemTag(getAppliedNBT(data)); } if (data.getValue() != 0) { item.addItemTag(getAppliedNBT(data)); }
} }
@NotNull public static String formatPath(@NotNull String format, boolean moreIsBetter, double value) { @NotNull
@Deprecated
// Thats it public static String formatPath(@NotNull String format, boolean moreIsBetter, double value) {
return format return formatPath("ATTACK_DAMAGE", format, moreIsBetter, value);
// Replace conditional pluses with +value
.replace("<plus>#",getColorPrefix(value < 0 && moreIsBetter) + (value > 0 ? "+" : "") + MythicLib.plugin.getMMOConfig().decimals.format(value))
// Replace loose pounds with the value
.replace("#",getColorPrefix(value < 0 && moreIsBetter) + MythicLib.plugin.getMMOConfig().decimals.format(value))
// Replace loose <plus>es
.replace("<plus>", (value > 0 ? "+" : ""));
} }
@NotNull public static String formatPath(@NotNull String format, boolean moreIsBetter, double min, double max) { @NotNull
public static String formatPath(@NotNull String stat, @NotNull String format, boolean moreIsBetter, double value) {
// Thats it final String valueFormatted = StatManager.format(stat, value);
final String colorPrefix = getColorPrefix(value < 0 && moreIsBetter);
return format return format
.replace("<plus>#", colorPrefix + (value > 0 ? "+" : "") + valueFormatted) // Replace conditional pluses with +value
.replace("#", colorPrefix + valueFormatted) // Replace loose pounds with the value
.replace("<plus>", (value > 0 ? "+" : "")); // Replace loose <plus>es
}
// Replace conditional pluses with +value @NotNull
.replace("<plus>","") @Deprecated
public static String formatPath(@NotNull String format, boolean moreIsBetter, double min, double max) {
return formatPath("ATTACK_DAMAGE", format, moreIsBetter, min, max);
}
// Replace loose pounds with the value @NotNull
.replace("#", getColorPrefix(min < 0 && moreIsBetter) + public static String formatPath(@NotNull String stat, @NotNull String format, boolean moreIsBetter, double min, double max) {
(min > 0 ? "+" : "") + MythicLib.plugin.getMMOConfig().decimals.format(min) final String minFormatted = StatManager.format(stat, min), maxFormatted = StatManager.format(stat, max);
+ MMOItems.plugin.getConfig().getString("stats-displaying.range-dash", "") + getColorPrefix(max < 0 && moreIsBetter) + final String minPrefix = getColorPrefix(min < 0 && moreIsBetter), maxPrefix = getColorPrefix(max < 0 && moreIsBetter);
(min < 0 && max > 0 ? "+" : "") + MythicLib.plugin.getMMOConfig().decimals.format(max)); } return format
.replace("<plus>", "")
.replace("#",
minPrefix + (min > 0 ? "+" : "") + minFormatted
+ MMOItems.plugin.getConfig().getString("stats-displaying.range-dash", "") +
maxPrefix + (min < 0 && max > 0 ? "+" : "") + maxFormatted);
}
@Override @Override
public void whenPreviewed(@NotNull ItemStackBuilder item, @NotNull DoubleData currentData, @NotNull NumericStatFormula templateData) throws IllegalArgumentException { public void whenPreviewed(@NotNull ItemStackBuilder item, @NotNull DoubleData currentData, @NotNull NumericStatFormula templateData) throws IllegalArgumentException {
@ -182,10 +187,10 @@ public class DoubleStat extends ItemStat<NumericStatFormula, DoubleData> impleme
String builtRange; String builtRange;
if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) { if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) {
builtRange = formatPath(MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter(), techMaximum * multiplyWhenDisplaying()); builtRange = formatPath(getId(), MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter(), techMaximum * multiplyWhenDisplaying());
} else { } else {
builtRange = formatPath(MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter(), techMinimum * multiplyWhenDisplaying(), techMaximum * multiplyWhenDisplaying()); } builtRange = formatPath(getId(), MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter(), techMinimum * multiplyWhenDisplaying(), techMaximum * multiplyWhenDisplaying()); }
// Just display normally // Just display normally
item.getLore().insert(getPath(), builtRange); } item.getLore().insert(getPath(), builtRange); }
@ -327,11 +332,11 @@ public class DoubleStat extends ItemStat<NumericStatFormula, DoubleData> impleme
public void whenDisplayed(List<String> lore, Optional<NumericStatFormula> statData) { public void whenDisplayed(List<String> lore, Optional<NumericStatFormula> statData) {
if (statData.isPresent()) { if (statData.isPresent()) {
NumericStatFormula data = statData.get(); NumericStatFormula data = statData.get();
lore.add(ChatColor.GRAY + "Base Value: " + ChatColor.GREEN + digit.format(data.getBase()) lore.add(ChatColor.GRAY + "Base Value: " + ChatColor.GREEN + DECIMAL_FORMAT.format(data.getBase())
+ (data.getScale() != 0 ? ChatColor.GRAY + " (+" + ChatColor.GREEN + digit.format(data.getScale()) + ChatColor.GRAY + ")" : "")); + (data.getScale() != 0 ? ChatColor.GRAY + " (+" + ChatColor.GREEN + DECIMAL_FORMAT.format(data.getScale()) + ChatColor.GRAY + ")" : ""));
if (data.getSpread() > 0) if (data.getSpread() > 0)
lore.add(ChatColor.GRAY + "Spread: " + ChatColor.GREEN + digit.format(data.getSpread() * 100) + "%" + ChatColor.GRAY + " (Max: " lore.add(ChatColor.GRAY + "Spread: " + ChatColor.GREEN + DECIMAL_FORMAT.format(data.getSpread() * 100) + "%" + ChatColor.GRAY + " (Max: "
+ ChatColor.GREEN + digit.format(data.getMaxSpread() * 100) + "%" + ChatColor.GRAY + ")"); + ChatColor.GREEN + DECIMAL_FORMAT.format(data.getMaxSpread() * 100) + "%" + ChatColor.GRAY + ")");
} else } else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN + "---"); lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN + "---");