forked from Upstream/mmocore
moved decimalFormat classes to configManager
This commit is contained in:
parent
19dc1161c2
commit
389d386d25
@ -1,15 +0,0 @@
|
||||
package net.Indyuce.mmocore.api.math.format;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public class MMOCoreDecimalFormat extends DecimalFormat {
|
||||
private static final long serialVersionUID = -2794789471349113852L;
|
||||
|
||||
public MMOCoreDecimalFormat(String str) {
|
||||
super(str);
|
||||
|
||||
setDecimalFormatSymbols(MMOCore.plugin.configManager.formatSymbols);
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package net.Indyuce.mmocore.api.player;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@ -15,15 +14,12 @@ import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.event.PlayerLevelUpEvent;
|
||||
import net.Indyuce.mmocore.api.experience.Profession;
|
||||
import net.Indyuce.mmocore.api.math.format.MMOCoreDecimalFormat;
|
||||
import net.Indyuce.mmocore.api.math.particle.SmallParticleEffect;
|
||||
|
||||
public class Professions {
|
||||
private final Map<String, Integer> exp = new HashMap<>();
|
||||
private final Map<String, Integer> level = new HashMap<>();
|
||||
private final PlayerData playerData;
|
||||
|
||||
private static final DecimalFormat decimal = new MMOCoreDecimalFormat("0.#");
|
||||
|
||||
public Professions(PlayerData playerData) {
|
||||
this.playerData = playerData;
|
||||
@ -112,6 +108,6 @@ public class Professions {
|
||||
int chars = (int) ((double) exp / needed * 20);
|
||||
for (int j = 0; j < 20; j++)
|
||||
bar += (j == chars ? "" + ChatColor.WHITE + ChatColor.BOLD : "") + "|";
|
||||
playerData.displayActionBar(MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio", decimal.format((double) exp / needed * 100)));
|
||||
playerData.displayActionBar(MMOCore.plugin.configManager.getSimpleMessage("exp-notification", "profession", profession.getName(), "progress", bar, "ratio", MMOCore.plugin.configManager.decimal.format((double) exp / needed * 100)));
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,9 @@
|
||||
package net.Indyuce.mmocore.api.player.stats;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.attribute.AttributeInstance;
|
||||
|
||||
import net.Indyuce.mmocore.api.math.format.MMOCoreDecimalFormat;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.stats.stat.modifier.StatModifier;
|
||||
|
||||
@ -22,8 +16,6 @@ public class PlayerStats {
|
||||
*/
|
||||
private final Map<String, StatInstance> extra = new HashMap<>();
|
||||
|
||||
private static final DecimalFormat decimal = new MMOCoreDecimalFormat("0.#");
|
||||
|
||||
public PlayerStats(PlayerData data) {
|
||||
this.data = data;
|
||||
}
|
||||
@ -41,23 +33,6 @@ public class PlayerStats {
|
||||
return ins;
|
||||
}
|
||||
|
||||
public String format(ChatColor color, Attribute attribute) {
|
||||
AttributeInstance instance = data.getPlayer().getAttribute(attribute);
|
||||
return format(color, instance.getBaseValue(), instance.getValue() - instance.getBaseValue(), decimal);
|
||||
}
|
||||
|
||||
public String format(ChatColor color, StatType stat) {
|
||||
return format(color, data.getProfess().calculateStat(stat, data.getLevel()), getExtraStat(stat), decimal);
|
||||
}
|
||||
|
||||
public String format(ChatColor color, StatType stat, DecimalFormat format) {
|
||||
return format(color, data.getProfess().calculateStat(stat, data.getLevel()), getExtraStat(stat), format);
|
||||
}
|
||||
|
||||
public String format(ChatColor color, double base, double extra, DecimalFormat format) {
|
||||
return "" + color + format.format(base + extra) + ChatColor.GRAY + " (" + color + decimal.format(base) + ChatColor.GRAY + "+" + color + decimal.format(extra) + ChatColor.GRAY + ")";
|
||||
}
|
||||
|
||||
/*
|
||||
* applies relative attributes on the base stat too
|
||||
*/
|
||||
|
@ -1,16 +1,13 @@
|
||||
package net.Indyuce.mmocore.api.player.stats.stat.modifier;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
||||
import net.Indyuce.mmocore.api.math.format.MMOCoreDecimalFormat;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
|
||||
public class StatModifier {
|
||||
private final double d;
|
||||
private final boolean relative;
|
||||
|
||||
private static final DecimalFormat digit = new MMOCoreDecimalFormat("0.#");
|
||||
|
||||
public StatModifier(double d) {
|
||||
this(d, false);
|
||||
@ -46,6 +43,6 @@ public class StatModifier {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return digit.format(d) + (relative ? "%" : "");
|
||||
return MMOCore.plugin.configManager.decimal.format(d) + (relative ? "%" : "");
|
||||
}
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.Indyuce.mmocore.command.rpg.booster;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -9,13 +7,10 @@ import org.bukkit.entity.Player;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.experience.Booster;
|
||||
import net.Indyuce.mmocore.api.math.format.DelayFormat;
|
||||
import net.Indyuce.mmocore.api.math.format.MMOCoreDecimalFormat;
|
||||
import net.Indyuce.mmocore.command.api.CommandEnd;
|
||||
import net.Indyuce.mmocore.command.api.CommandMap;
|
||||
|
||||
public class ListCommandMap extends CommandEnd {
|
||||
private static final DecimalFormat decimal = new MMOCoreDecimalFormat("0.##");
|
||||
|
||||
public ListCommandMap(CommandMap parent) {
|
||||
super(parent, "list");
|
||||
}
|
||||
@ -28,7 +23,7 @@ public class ListCommandMap extends CommandEnd {
|
||||
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
||||
for (Booster booster : MMOCore.plugin.boosterManager.getBoosters())
|
||||
if (!booster.isTimedOut())
|
||||
MMOCore.plugin.nms.sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD + decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - " + ChatColor.GOLD + (!booster.hasProfession() ? "Main" : booster.getProfession().getName()) + ChatColor.YELLOW + " - " + ChatColor.GOLD + new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis()) + "\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/mmocore booster remove " + booster.getUniqueId().toString() + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to remove.\"}}}");
|
||||
MMOCore.plugin.nms.sendJson((Player) sender, "{\"text\":\"" + ChatColor.YELLOW + "- " + ChatColor.GOLD + MMOCore.plugin.configManager.decimal.format((1 + booster.getExtra())) + "x" + ChatColor.YELLOW + " Booster - " + ChatColor.GOLD + (!booster.hasProfession() ? "Main" : booster.getProfession().getName()) + ChatColor.YELLOW + " - " + ChatColor.GOLD + new DelayFormat().format(booster.getCreationDate() + booster.getLength() - System.currentTimeMillis()) + "\",\"clickEvent\":{\"action\":\"suggest_command\",\"value\":\"/mmocore booster remove " + booster.getUniqueId().toString() + "\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"Click to remove.\"}}}");
|
||||
sender.sendMessage(ChatColor.YELLOW + "----------------------------------------------------");
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package net.Indyuce.mmocore.comp.placeholder;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -9,14 +7,12 @@ import org.bukkit.entity.Player;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.AltChar;
|
||||
import net.Indyuce.mmocore.api.math.format.MMOCoreDecimalFormat;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.PlayerQuests;
|
||||
import net.Indyuce.mmocore.api.player.Professions;
|
||||
import net.Indyuce.mmocore.api.player.stats.StatType;
|
||||
|
||||
public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
private static final DecimalFormat decimal = new MMOCoreDecimalFormat("0.#"), decimal2 = new MMOCoreDecimalFormat("0.##");
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
@ -42,14 +38,14 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
else if (identifier.equals("level_percent")) {
|
||||
PlayerData playerData = PlayerData.get(player);
|
||||
double current = playerData.getExperience(), next = MMOCore.plugin.configManager.getNeededExperience(playerData.getLevel() + 1);
|
||||
return decimal.format(current / next * 100);
|
||||
return MMOCore.plugin.configManager.decimal.format(current / next * 100);
|
||||
}
|
||||
|
||||
else if (identifier.equals("combat"))
|
||||
return String.valueOf(PlayerData.get(player).isInCombat());
|
||||
|
||||
else if (identifier.equals("health"))
|
||||
return decimal2.format(player.getHealth());
|
||||
return MMOCore.plugin.configManager.decimals.format(player.getHealth());
|
||||
|
||||
else if (identifier.startsWith("attribute_"))
|
||||
return String.valueOf(PlayerData.get(player).getAttributes().getAttribute(MMOCore.plugin.attributeManager.get(identifier.substring(10).toLowerCase().replace("_", "-"))));
|
||||
@ -61,14 +57,14 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
Professions professions = PlayerData.get(player).getCollectionSkills();
|
||||
String profession = identifier.substring(19).replace(" ", "-").replace("_", "-").toLowerCase();
|
||||
double current = professions.getExperience(profession), next = MMOCore.plugin.configManager.getNeededExperience(professions.getLevel(profession) + 1);
|
||||
return decimal.format(current / next * 100);
|
||||
return MMOCore.plugin.configManager.decimal.format(current / next * 100);
|
||||
}
|
||||
|
||||
else if (identifier.startsWith("profession_"))
|
||||
return "" + PlayerData.get(player).getCollectionSkills().getLevel(identifier.substring(11).replace(" ", "-").replace("_", "-").toLowerCase());
|
||||
|
||||
else if (identifier.equals("max_health"))
|
||||
return decimal2.format(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
return MMOCore.plugin.configManager.decimals.format(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue());
|
||||
|
||||
else if (identifier.equals("experience"))
|
||||
return "" + PlayerData.get(player).getExperience();
|
||||
@ -89,10 +85,10 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
return "" + PlayerData.get(player).getAttributeReallocationPoints();
|
||||
|
||||
else if (identifier.equals("mana"))
|
||||
return "" + decimal.format(PlayerData.get(player).getMana());
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getMana());
|
||||
|
||||
else if (identifier.equals("max_mana"))
|
||||
return "" + decimal.format(PlayerData.get(player).getStats().getStat(StatType.MAX_MANA));
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getStats().getStat(StatType.MAX_MANA));
|
||||
|
||||
else if (identifier.equals("mana_bar")) {
|
||||
String format = "";
|
||||
@ -104,10 +100,10 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
else if (identifier.equals("stamina"))
|
||||
return "" + decimal.format(PlayerData.get(player).getStamina());
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getStamina());
|
||||
|
||||
else if (identifier.equals("max_stamina"))
|
||||
return "" + decimal.format(PlayerData.get(player).getStats().getStat(StatType.MAX_STAMINA));
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getStats().getStat(StatType.MAX_STAMINA));
|
||||
|
||||
else if (identifier.equals("stamina_bar")) {
|
||||
String format = "";
|
||||
@ -119,10 +115,10 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
}
|
||||
|
||||
else if (identifier.equals("stellium"))
|
||||
return "" + decimal.format(PlayerData.get(player).getStellium());
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getStellium());
|
||||
|
||||
else if (identifier.equals("max_stellium"))
|
||||
return "" + decimal.format(PlayerData.get(player).getStats().getStat(StatType.MAX_STELLIUM));
|
||||
return MMOCore.plugin.configManager.decimal.format(PlayerData.get(player).getStats().getStat(StatType.MAX_STELLIUM));
|
||||
|
||||
else if (identifier.equals("stellium_bar")) {
|
||||
String format = "";
|
||||
@ -140,7 +136,7 @@ public class RPGPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
else if (identifier.equals("quest_progress")) {
|
||||
PlayerQuests data = PlayerData.get(player).getQuestData();
|
||||
return data.hasCurrent() ? decimal.format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100) : "0";
|
||||
return data.hasCurrent() ? MMOCore.plugin.configManager.decimal.format((int) (double) data.getCurrent().getObjectiveNumber() / data.getCurrent().getQuest().getObjectives().size() * 100) : "0";
|
||||
}
|
||||
|
||||
else if (identifier.equals("quest_objective")) {
|
||||
|
@ -10,7 +10,6 @@ import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.math.format.MMOCoreDecimalFormat;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.TriggerItem;
|
||||
|
||||
@ -26,7 +25,7 @@ public abstract class EditableInventory {
|
||||
*/
|
||||
private final Set<InventoryItem> items = new LinkedHashSet<>();
|
||||
|
||||
protected static final DecimalFormat decimal = new MMOCoreDecimalFormat("0.#");
|
||||
protected static final DecimalFormat decimal = MMOCore.plugin.configManager.decimal;
|
||||
|
||||
public EditableInventory(String id) {
|
||||
this.id = id;
|
||||
|
@ -5,6 +5,7 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.DecimalFormatSymbols;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -29,7 +30,8 @@ public class ConfigManager {
|
||||
public double expPartyBuff, regenPartyBuff;
|
||||
public String partyChatPrefix;
|
||||
|
||||
public final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
|
||||
private final DecimalFormatSymbols formatSymbols = new DecimalFormatSymbols();
|
||||
public final DecimalFormat decimal = new DecimalFormat("0.#", formatSymbols), decimals = new DecimalFormat("0.##", formatSymbols);
|
||||
|
||||
private List<Integer> neededExp = new ArrayList<>();
|
||||
private FileConfiguration messages;
|
||||
|
Loading…
Reference in New Issue
Block a user