mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-02-03 11:31:21 +01:00
Extra display options for abilities in lore
This commit is contained in:
parent
4a38952310
commit
c4ded8355c
@ -79,18 +79,16 @@ public class ConfigFile {
|
||||
|
||||
public void registerTemplateEdition(ItemReference ref) {
|
||||
|
||||
/*
|
||||
* saves the changes before asking for a template update
|
||||
*/
|
||||
// Saves the changes before asking for a template update
|
||||
save();
|
||||
|
||||
/*
|
||||
* goes for a template update once the change has been saved. this
|
||||
* Goes for a template update once the change has been saved. this
|
||||
* simply unloads the currently saved template and reloads it
|
||||
*/
|
||||
MMOItems.plugin.getTemplates().requestTemplateUpdate(ref.getType(), ref.getId());
|
||||
|
||||
/* update the database UUID for the dynamic item updater
|
||||
/* Update the database UUID for the dynamic item updater
|
||||
if (MMOItems.plugin.getUpdater().hasData(ref))
|
||||
MMOItems.plugin.getUpdater().getData(ref).setUniqueId(UUID.randomUUID());*/
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ public class Consumable extends UseItem {
|
||||
/**
|
||||
* This dynamically updates the item lore
|
||||
*/
|
||||
final String format = MythicLib.inst().parseColors(MMOItems.plugin.getLanguage().getStatFormat("max-consume"));
|
||||
final String format = MythicLib.inst().parseColors(ItemStats.MAX_CONSUME.getGeneralStatFormat());
|
||||
final String old = format.replace("{value}", String.valueOf(usesLeft + 1));
|
||||
final String replaced = format.replace("{value}", String.valueOf(usesLeft));
|
||||
ItemStack newItem = new LoreUpdate(nbtItem.toItem(), old, replaced).updateLore();
|
||||
|
@ -243,7 +243,7 @@ public class DurabilityItem {
|
||||
ItemStack item = nbtItem.toItem();
|
||||
|
||||
// Item lore update
|
||||
final String format = MythicLib.inst().parseColors(MMOItems.plugin.getLanguage().getStatFormat("durability").replace("{max}", String.valueOf(maxDurability)));
|
||||
final String format = MythicLib.inst().parseColors(ItemStats.ITEM_DAMAGE.getGeneralStatFormat().replace("{max}", String.valueOf(maxDurability)));
|
||||
final String old = format.replace("{current}", String.valueOf(initialDurability));
|
||||
final String replaced = format.replace("{current}", String.valueOf(durability));
|
||||
return new LoreUpdate(item, old, replaced).updateLore();
|
||||
|
@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.event.GenerateLoreEvent;
|
||||
import net.Indyuce.mmoitems.api.event.ItemBuildEvent;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.stat.data.MaterialData;
|
||||
import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
@ -203,10 +204,10 @@ public class ItemStackBuilder {
|
||||
|
||||
// Display gem stone lore hint thing
|
||||
if (builtMMOItem.getType() == Type.GEM_STONE)
|
||||
lore.insert("gem-stone-lore", ItemStat.translate("gem-stone-lore"));
|
||||
lore.insert("gem-stone-lore", Message.GEM_STONE_TAG.getUpdated());
|
||||
|
||||
// Display item type
|
||||
lore.insert("item-type", ItemStat.translate("item-type").replace("{type}",
|
||||
lore.insert("item-type", Message.ITEM_TYPE_TAG.getUpdated().replace("{type}",
|
||||
builtMMOItem.getStats().contains(ItemStats.DISPLAYED_TYPE) ? builtMMOItem.getData(ItemStats.DISPLAYED_TYPE)
|
||||
.toString() : builtMMOItem.getType().getName()));
|
||||
|
||||
|
@ -16,6 +16,10 @@ public enum Message {
|
||||
ITEM_ON_COOLDOWN("This item is on cooldown! Please wait #left# second#s#.", "item-cooldown"),
|
||||
NOT_ENOUGH_PERMS_COMMAND("You don't have enough permissions."),
|
||||
|
||||
// Item lore tags
|
||||
GEM_STONE_TAG("&8&l[&2&l*&8&l] &aDrag onto an item &7to apply!"),
|
||||
ITEM_TYPE_TAG("&c{type}"),
|
||||
|
||||
// Item restrictions
|
||||
NOT_ENOUGH_LEVELS("You don't have enough levels to use this item!", "cant-use-item"),
|
||||
SOULBOUND_RESTRICTION("This item is linked to another player, you can't use it!", "cant-use-item"),
|
||||
|
@ -35,7 +35,7 @@ import java.util.logging.Level;
|
||||
public class ConfigManager implements Reloadable {
|
||||
|
||||
// cached config files
|
||||
private ConfigFile loreFormat, stats, dynLore;
|
||||
private ConfigFile loreFormat, dynLore;
|
||||
|
||||
// Language
|
||||
private final Map<TriggerType, String> triggerTypeNames = new HashMap<>();
|
||||
@ -43,7 +43,6 @@ public class ConfigManager implements Reloadable {
|
||||
|
||||
// Cached config options
|
||||
public boolean replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate, opStatsEnabled, disableRemovedItems;
|
||||
public String abilitySplitter;
|
||||
public double soulboundBaseDamage, soulboundPerLvlDamage, levelSpread;
|
||||
public NumericStatFormula defaultItemCapacity;
|
||||
public ReforgeOptions revisionOptions, gemRevisionOptions, phatLootsOptions;
|
||||
@ -124,6 +123,11 @@ public class ConfigManager implements Reloadable {
|
||||
}
|
||||
messages.save();
|
||||
|
||||
// LEGACY CODE
|
||||
final ConfigurationSection statsConfig = new ConfigFile("stats").getConfig();
|
||||
if (statsConfig.contains("gem-stone-lore")) Message.GEM_STONE_TAG.setCurrent(statsConfig.getString("gem-stone-lore"));
|
||||
if (statsConfig.contains("item-type")) Message.ITEM_TYPE_TAG.setCurrent(statsConfig.getString("item-type"));
|
||||
|
||||
// Potion effects
|
||||
final LanguageFile potionEffects = new LanguageFile("potion-effects");
|
||||
for (PotionEffectType effect : PotionEffectType.values())
|
||||
@ -154,7 +158,7 @@ public class ConfigManager implements Reloadable {
|
||||
MMOItems.plugin.reloadConfig();
|
||||
|
||||
loreFormat = new ConfigFile("/language", "lore-format");
|
||||
stats = new ConfigFile("/language", "stats");
|
||||
|
||||
dynLore = new ConfigFile("/language", "dynamic-lore");
|
||||
|
||||
loadTranslations();
|
||||
@ -166,7 +170,6 @@ public class ConfigManager implements Reloadable {
|
||||
replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops");
|
||||
worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen");
|
||||
|
||||
abilitySplitter = getStatFormat("ability-splitter");
|
||||
soulboundBaseDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.base");
|
||||
soulboundPerLvlDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.per-lvl");
|
||||
upgradeRequirementsCheck = MMOItems.plugin.getConfig().getBoolean("item-upgrade-requirements-check");
|
||||
@ -211,13 +214,18 @@ public class ConfigManager implements Reloadable {
|
||||
* @return Can this block material be broken by tool mechanics
|
||||
* like 'Bouncing Crack'
|
||||
*/
|
||||
public boolean isBlacklisted(Material material) {
|
||||
public boolean isBlacklisted(@NotNull Material material) {
|
||||
return MMOItems.plugin.getConfig().getStringList("block-blacklist").contains(material.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Will be removed in the future.
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public String getStatFormat(String path) {
|
||||
String found = stats.getConfig().getString(path);
|
||||
final ConfigurationSection config = new ConfigFile("/language", "stats").getConfig();
|
||||
final String found = config.getString(path);
|
||||
return found == null ? "<TranslationNotFound:" + path + ">" : found;
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,6 @@ public class PluginUpdateManager {
|
||||
*/
|
||||
private final Map<Integer, PluginUpdate> updates = new HashMap<>();
|
||||
|
||||
|
||||
public PluginUpdateManager() {
|
||||
register(new PluginUpdate(1,
|
||||
new String[]{"Applies a fix for skull textures values in 4.7.1.", "Texture values data storage changed in 4.7.1 due to the UUID change."},
|
||||
|
@ -65,6 +65,17 @@ public class StatManager {
|
||||
|
||||
// Register custom stats
|
||||
loadCustom();
|
||||
|
||||
// Load stat translation objects
|
||||
final ConfigurationSection statOptions = new ConfigFile("/language", "stats").getConfig();
|
||||
for (ItemStat stat : getAll())
|
||||
try {
|
||||
@Nullable Object object = statOptions.get(stat.getPath());
|
||||
if (object == null) object = statOptions.get(stat.getLegacyTranslationPath());
|
||||
stat.loadConfiguration(statOptions, object != null ? object : "<TranslationNotFound:" + stat.getPath() + ">");
|
||||
} catch (RuntimeException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load options for stat '" + stat.getId() + "': " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -35,7 +35,7 @@ import java.util.Optional;
|
||||
public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData> {
|
||||
public 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"});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,30 +50,94 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
|
||||
return list;
|
||||
}
|
||||
|
||||
private String generalFormat, modifierForEach, modifierSplitter, abilitySplitter;
|
||||
private boolean legacyFormat, useAbilitySplitter;
|
||||
private int modifiersPerLine;
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
|
||||
|
||||
// MI <7 config
|
||||
if (configObject instanceof ConfigurationSection) {
|
||||
legacyFormat = false;
|
||||
final ConfigurationSection config = (ConfigurationSection) configObject;
|
||||
generalFormat = config.getString("general-format");
|
||||
modifierForEach = config.getString("modifier-foreach");
|
||||
modifierSplitter = config.getString("modifier-splitter");
|
||||
abilitySplitter = config.getString("ability-splitter.format");
|
||||
useAbilitySplitter = config.getBoolean("ability-splitter.enabled");
|
||||
modifiersPerLine = config.getInt("modifiers-per-line");
|
||||
|
||||
} else {
|
||||
legacyFormat = true;
|
||||
generalFormat = legacyLanguageFile.getString("ability-format");
|
||||
modifierForEach = legacyLanguageFile.getString("ability-modifier");
|
||||
abilitySplitter = legacyLanguageFile.getString("ability-splitter");
|
||||
useAbilitySplitter = abilitySplitter != null && !abilitySplitter.isEmpty();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull AbilityListData data) {
|
||||
|
||||
//Modify Lore
|
||||
// Modify Lore
|
||||
List<String> abilityLore = new ArrayList<>();
|
||||
boolean splitter = !MMOItems.plugin.getLanguage().abilitySplitter.equals("");
|
||||
|
||||
String modifierFormat = ItemStat.translate("ability-modifier"), abilityFormat = ItemStat.translate("ability-format");
|
||||
|
||||
// DEPRECATED CODE which supports old versions of the stats.yml config
|
||||
if (legacyFormat) {
|
||||
data.getAbilities().forEach(ability -> {
|
||||
abilityLore.add(abilityFormat.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger())).replace("{ability}", ability.getAbility().getName()));
|
||||
abilityLore.add(generalFormat
|
||||
.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger()))
|
||||
.replace("{ability}", ability.getAbility().getName()));
|
||||
|
||||
for (String modifier : ability.getModifiers()) {
|
||||
item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier,
|
||||
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier)));
|
||||
abilityLore.add(modifierFormat.replace("{modifier}", ability.getAbility().getParameterName(modifier)).replace("{value}",
|
||||
abilityLore.add(modifierForEach.replace("{modifier}", ability.getAbility().getParameterName(modifier)).replace("{value}",
|
||||
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier))));
|
||||
}
|
||||
|
||||
if (splitter)
|
||||
abilityLore.add(MMOItems.plugin.getLanguage().abilitySplitter);
|
||||
if (useAbilitySplitter)
|
||||
abilityLore.add(abilitySplitter);
|
||||
});
|
||||
}
|
||||
|
||||
if (splitter && abilityLore.size() > 0)
|
||||
// Up to date code
|
||||
else {
|
||||
data.getAbilities().forEach(ability -> {
|
||||
final StringBuilder builder = new StringBuilder(generalFormat
|
||||
.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger()))
|
||||
.replace("{ability}", ability.getAbility().getName()));
|
||||
|
||||
boolean modifierAppened = false;
|
||||
int lineCounter = 0;
|
||||
for (String modifier : ability.getModifiers()) {
|
||||
final String formattedValue = MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier));
|
||||
item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier, formattedValue);
|
||||
if (modifierAppened) builder.append(modifierSplitter);
|
||||
builder.append(modifierForEach
|
||||
.replace("{modifier}", ability.getAbility().getParameterName(modifier))
|
||||
.replace("{value}", formattedValue));
|
||||
modifierAppened = true;
|
||||
lineCounter++;
|
||||
|
||||
if (modifiersPerLine > 0 && lineCounter >= modifiersPerLine) {
|
||||
lineCounter = 0;
|
||||
modifierAppened = false;
|
||||
abilityLore.add(builder.toString());
|
||||
builder.setLength(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (modifierAppened) abilityLore.add(builder.toString());
|
||||
|
||||
if (useAbilitySplitter)
|
||||
abilityLore.add(abilitySplitter);
|
||||
});
|
||||
}
|
||||
|
||||
if (useAbilitySplitter && abilityLore.size() > 0)
|
||||
abilityLore.remove(abilityLore.size() - 1);
|
||||
|
||||
// Modify tags
|
||||
@ -81,6 +145,11 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
|
||||
item.addItemTag(getAppliedNBT(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTranslationPath() {
|
||||
return "ability-format";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull AbilityListData data) {
|
||||
@ -90,7 +159,9 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
|
||||
|
||||
// Convert to JSON
|
||||
JsonArray jsonArray = new JsonArray();
|
||||
for (AbilityData ab : data.getAbilities()) { jsonArray.add(ab.toJson()); }
|
||||
for (AbilityData ab : data.getAbilities()) {
|
||||
jsonArray.add(ab.toJson());
|
||||
}
|
||||
|
||||
// Put
|
||||
ret.add(new ItemTag(getNBTPath(), jsonArray.toString()));
|
||||
@ -144,7 +215,7 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
|
||||
@Override
|
||||
public void whenDisplayed(List<String> lore, Optional<RandomAbilityListData> statData) {
|
||||
lore.add(ChatColor.GRAY + "Current Abilities: " + ChatColor.GOLD
|
||||
+ (statData.isPresent() ? ((RandomAbilityListData) statData.get()).getAbilities().size() : 0));
|
||||
+ (statData.isPresent() ? statData.get().getAbilities().size() : 0));
|
||||
lore.add("");
|
||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit the item abilities.");
|
||||
}
|
||||
@ -164,7 +235,7 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
|
||||
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
||||
relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
||||
|
||||
AbilityListData data = (AbilityListData) getLoadedNBT(relevantTags);
|
||||
AbilityListData data = getLoadedNBT(relevantTags);
|
||||
|
||||
// Valid?
|
||||
if (data != null) {
|
||||
@ -208,7 +279,7 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
|
||||
// Well that mus thave worked aye?
|
||||
return list;
|
||||
|
||||
} catch (JsonSyntaxException|IllegalStateException exception) {
|
||||
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||
/*
|
||||
* OLD ITEM WHICH MUST BE UPDATED.
|
||||
*/
|
||||
|
@ -118,13 +118,13 @@ public class ArrowPotionEffects extends ItemStat<RandomPotionEffectListData, Pot
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
String permEffectFormat = ItemStat.translate("arrow-potion-effects");
|
||||
String permEffectFormat = getGeneralStatFormat();
|
||||
data.getEffects().forEach(effect -> {
|
||||
lore.add(permEffectFormat.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
|
||||
+ " " + MMOUtils.intToRoman(effect.getLevel()) + "(" + MythicLib.plugin.getMMOConfig().decimal.format(effect.getDuration()) + "s)"));
|
||||
});
|
||||
|
||||
item.getLore().insert("arrow-potion-effects", lore);
|
||||
item.getLore().insert(getPath(), lore);
|
||||
|
||||
// Add tags
|
||||
item.addItemTag(getAppliedNBT(data));
|
||||
|
@ -30,7 +30,7 @@ public class Commands extends ItemStat<CommandListData, CommandListData> {
|
||||
|
||||
public Commands() {
|
||||
super("COMMANDS", VersionMaterial.COMMAND_BLOCK_MINECART.toMaterial(), "Commands",
|
||||
new String[] { "The commands your item", "performs when right clicked." }, new String[] { "!armor", "!block", "!gem_stone", "all" });
|
||||
new String[]{"The commands your item", "performs when right clicked."}, new String[]{"!armor", "!block", "!gem_stone", "all"});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -124,14 +124,18 @@ public class Commands extends ItemStat<CommandListData, CommandListData> {
|
||||
|
||||
// Addlore
|
||||
List<String> lore = new ArrayList<>();
|
||||
String commandFormat = ItemStat.translate("command");
|
||||
((CommandListData) data).getCommands().forEach(command -> {
|
||||
|
||||
lore.add(commandFormat.replace("{format}", "/" + command.getCommand()).replace("{cooldown}", String.valueOf(command.getDelay())));
|
||||
});
|
||||
String commandFormat = getGeneralStatFormat();
|
||||
data.getCommands().forEach(command -> lore.add(commandFormat
|
||||
.replace("{format}", "/" + command.getCommand())
|
||||
.replace("{cooldown}", String.valueOf(command.getDelay()))));
|
||||
item.getLore().insert("commands", lore);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTranslationPath() {
|
||||
return "command";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull CommandListData data) {
|
||||
@ -225,7 +229,7 @@ public class Commands extends ItemStat<CommandListData, CommandListData> {
|
||||
return commands;
|
||||
|
||||
// Needs updating
|
||||
} catch (JsonSyntaxException|IllegalStateException exception) {
|
||||
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||
/*
|
||||
* OLD ITEM WHICH MUST BE UPDATED.
|
||||
*/
|
||||
|
@ -109,7 +109,7 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
||||
// Process Lore
|
||||
List<String> lore = new ArrayList<>();
|
||||
String effectFormat = ItemStat.translate("effect");
|
||||
String effectFormat = getGeneralStatFormat();
|
||||
data.getEffects().forEach(effect -> lore.add(effectFormat
|
||||
.replace("{effect}",
|
||||
MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
|
||||
@ -121,11 +121,16 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
|
||||
item.addItemTag(getAppliedNBT(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTranslationPath() {
|
||||
return "effect";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {
|
||||
|
||||
// Create aJson Array
|
||||
// Create a Json Array
|
||||
JsonArray array = new JsonArray();
|
||||
|
||||
// For every effect
|
||||
|
@ -29,9 +29,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.*;
|
||||
|
||||
public class Elements extends ItemStat<RandomElementListData, ElementListData> implements Previewable<RandomElementListData, ElementListData> {
|
||||
public Elements() {
|
||||
@ -77,7 +75,7 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
||||
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(elementPath.replace(".", " ")) + ChatColor.GRAY
|
||||
+ " successfully changed to " + ChatColor.GOLD + formula.toString() + ChatColor.GRAY + ".");
|
||||
+ " successfully changed to " + ChatColor.GOLD + formula + ChatColor.GRAY + ".");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -102,6 +100,32 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
||||
return new ElementListData();
|
||||
}
|
||||
|
||||
private Map<ElementStatType, String> statFormat = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
|
||||
|
||||
// LEGACY CODE
|
||||
if (configObject instanceof String) {
|
||||
for (ElementStatType statType : ElementStatType.values())
|
||||
statFormat.put(statType, legacyLanguageFile.getString("elemental-" + statType.lowerCaseName(), "<TranslationNotFound:" + statType.name().toLowerCase() + ">"));
|
||||
}
|
||||
|
||||
// Up-to-date code
|
||||
else {
|
||||
Validate.isTrue(configObject instanceof ConfigurationSection, "Must be a config section");
|
||||
final ConfigurationSection config = (ConfigurationSection) configObject;
|
||||
for (ElementStatType statType : ElementStatType.values())
|
||||
statFormat.put(statType, config.getString(statType.lowerCaseName(), "<TranslationNotFound:" + statType.lowerCaseName() + ">"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTranslationPath() {
|
||||
// Arbitrary
|
||||
return "elemental-damage";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ElementListData data) {
|
||||
|
||||
@ -109,7 +133,7 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
||||
|
||||
// Write Lore
|
||||
for (Pair<Element, ElementStatType> pair : data.getKeys()) {
|
||||
final String format = ItemStat.translate("elemental-" + pair.getValue().lowerCaseName())
|
||||
final String format = statFormat.get(pair.getValue())
|
||||
.replace("{color}", pair.getKey().getColor())
|
||||
.replace("{icon}", pair.getKey().getLoreIcon())
|
||||
.replace("{element}", pair.getKey().getName());
|
||||
@ -183,6 +207,8 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
||||
Validate.isTrue(currentData instanceof ElementListData, "Current Data is not ElementListData");
|
||||
Validate.isTrue(templateData instanceof RandomElementListData, "Template Data is not RandomElementListData");
|
||||
|
||||
List<String> elementLore = new ArrayList<>();
|
||||
|
||||
// Examine every element stat possible
|
||||
for (Element element : Element.values())
|
||||
for (ElementStatType statType : ElementStatType.values()) {
|
||||
@ -197,20 +223,20 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
||||
if (techMinimum != 0 || techMaximum != 0) {
|
||||
|
||||
// Get path
|
||||
String path = element.getId().toLowerCase() + "-" + statType.name().toLowerCase().replace("_", "-");
|
||||
|
||||
String builtRange;
|
||||
if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) {
|
||||
builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), ItemStat.translate(path), true, techMinimum);
|
||||
builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), statFormat.get(statType), true, techMinimum);
|
||||
} else {
|
||||
builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), ItemStat.translate(path), true, techMinimum, techMaximum);
|
||||
builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), statFormat.get(statType), true, techMinimum, techMaximum);
|
||||
}
|
||||
|
||||
// Just display normally
|
||||
item.getLore().insert(path, builtRange);
|
||||
elementLore.add(builtRange);
|
||||
}
|
||||
}
|
||||
|
||||
if (!elementLore.isEmpty()) item.getLore().insert(getPath(), elementLore);
|
||||
|
||||
// Add tags
|
||||
item.addItemTag(getAppliedNBT(currentData));
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ 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;
|
||||
|
||||
@ -33,8 +34,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
||||
public GemSockets() {
|
||||
super("GEM_SOCKETS", Material.EMERALD, "Gem Sockets", new String[] { "The amount of gem", "sockets your weapon has." },
|
||||
new String[] { "piercing", "slashing", "blunt", "catalyst", "range", "tool", "armor", "accessory", "!gem_stone" });
|
||||
super("GEM_SOCKETS", Material.EMERALD, "Gem Sockets", new String[]{"The amount of gem", "sockets your weapon has."},
|
||||
new String[]{"piercing", "slashing", "blunt", "catalyst", "range", "tool", "armor", "accessory", "!gem_stone"});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -44,6 +45,31 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
||||
return new GemSocketsData((List<String>) object);
|
||||
}
|
||||
|
||||
private String emptyGemSocketFormat, filledGemSocketFormat;
|
||||
|
||||
@Override
|
||||
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
|
||||
|
||||
// LEGACY CODE
|
||||
if (configObject instanceof String) {
|
||||
emptyGemSocketFormat = legacyLanguageFile.getString("empty-gem-socket");
|
||||
filledGemSocketFormat = legacyLanguageFile.getString("filled-gem-socket");
|
||||
}
|
||||
|
||||
// Up-to-date code
|
||||
else {
|
||||
Validate.isTrue(configObject instanceof ConfigurationSection, "Must be a config section");
|
||||
final ConfigurationSection config = (ConfigurationSection) configObject;
|
||||
emptyGemSocketFormat = config.getString("empty");
|
||||
filledGemSocketFormat = config.getString("filled");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTranslationPath() {
|
||||
return "empty-gem-socket";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull GemSocketsData sockets) {
|
||||
|
||||
@ -51,7 +77,6 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
||||
item.addItemTag(getAppliedNBT(sockets));
|
||||
|
||||
// Edit Lore
|
||||
String empty = ItemStat.translate("empty-gem-socket"), filled = ItemStat.translate("filled-gem-socket");
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (GemstoneData gem : sockets.getGemstones()) {
|
||||
String gemName = gem.getName();
|
||||
@ -73,9 +98,9 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
||||
}
|
||||
}
|
||||
|
||||
lore.add(filled.replace("{name}", gemName));
|
||||
lore.add(filledGemSocketFormat.replace("{name}", gemName));
|
||||
}
|
||||
sockets.getEmptySlots().forEach(slot -> lore.add(empty.replace("{name}", slot)));
|
||||
sockets.getEmptySlots().forEach(slot -> lore.add(emptyGemSocketFormat.replace("{name}", slot)));
|
||||
item.getLore().insert("gem-stones", lore);
|
||||
}
|
||||
|
||||
@ -92,11 +117,11 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull public String getNBTPath() {
|
||||
@NotNull
|
||||
public String getNBTPath() {
|
||||
return "MMOITEMS_GEM_STONES";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
||||
|
||||
@ -109,7 +134,9 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
||||
StatData data = getLoadedNBT(relevantTags);
|
||||
|
||||
// Valid?
|
||||
if (data != null) { mmoitem.setData(this, data); }
|
||||
if (data != null) {
|
||||
mmoitem.setData(this, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -133,7 +160,7 @@ public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
||||
// Return built
|
||||
return sockets;
|
||||
|
||||
} catch (JsonSyntaxException|IllegalStateException exception) {
|
||||
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||
/*
|
||||
* OLD ITEM WHICH MUST BE UPDATED.
|
||||
*/
|
||||
|
@ -61,4 +61,9 @@ public class ItemDamage extends DoubleStat implements GemStoneStat {
|
||||
@Nullable
|
||||
@Override
|
||||
public DoubleData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) { return null; }
|
||||
|
||||
@Override
|
||||
public String getLegacyTranslationPath() {
|
||||
return "durability";
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public class ItemTierStat extends StringStat implements GemStoneStat {
|
||||
|
||||
ItemTier tier = MMOItems.plugin.getTiers().get(path);
|
||||
item.addItemTag(new ItemTag("MMOITEMS_TIER", path));
|
||||
item.getLore().insert("tier", MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("{value}", tier.getName()));
|
||||
item.getLore().insert(getPath(), getGeneralStatFormat().replace("{value}", tier.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -35,7 +35,7 @@ public class ItemTierStat extends StringStat implements GemStoneStat {
|
||||
String format = message.toUpperCase().replace(" ", "_").replace("-", "_");
|
||||
Validate.isTrue(MMOItems.plugin.getTiers().has(format), "Couldn't find the tier called '" + format + "'.");
|
||||
|
||||
inv.getEditedSection().set("tier", format);
|
||||
inv.getEditedSection().set(getPath(), format);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Tier successfully changed to " + format + ".");
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ public class MaxConsume extends DoubleStat {
|
||||
|
||||
item.addItemTag(new ItemTag(getNBTPath(), left));
|
||||
|
||||
String format = MMOItems.plugin.getLanguage().getStatFormat("max-consume").replace("{value}", String.valueOf(left));
|
||||
item.getLore().insert("max-consume", format);
|
||||
String format = getGeneralStatFormat().replace("{value}", String.valueOf(left));
|
||||
item.getLore().insert(getPath(), format);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package net.Indyuce.mmoitems.stat;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
@ -18,6 +17,7 @@ import net.Indyuce.mmoitems.stat.type.Upgradable;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
@ -35,6 +35,12 @@ public class MaximumDurability extends DoubleStat implements ItemRestriction, Ge
|
||||
whenApplied(item, currentData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
|
||||
generalStatFormat = legacyLanguageFile.getString("item-damage");
|
||||
if (generalStatFormat == null) generalStatFormat = legacyLanguageFile.getString("durability");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
|
||||
|
||||
@ -44,7 +50,7 @@ public class MaximumDurability extends DoubleStat implements ItemRestriction, Ge
|
||||
item.addItemTag(new ItemTag(getNBTPath(), max));
|
||||
|
||||
// Display durability in lore here.
|
||||
String format = MMOItems.plugin.getLanguage().getStatFormat("durability").replace("{max}", String.valueOf(max)).replace("{current}", String.valueOf(current));
|
||||
String format = getGeneralStatFormat().replace("{max}", String.valueOf(max)).replace("{current}", String.valueOf(current));
|
||||
item.getLore().insert("durability", format);
|
||||
}
|
||||
|
||||
|
@ -44,8 +44,8 @@ import org.jetbrains.annotations.Nullable;
|
||||
*/
|
||||
public class PermanentEffects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> {
|
||||
public PermanentEffects() {
|
||||
super("PERM_EFFECTS", Material.POTION, "Permanent Effects", new String[] { "The potion effects your", "item grants to the holder." },
|
||||
new String[] { "!miscellaneous", "!block", "all" });
|
||||
super("PERM_EFFECTS", Material.POTION, "Permanent Effects", new String[]{"The potion effects your", "item grants to the holder."},
|
||||
new String[]{"!miscellaneous", "!block", "all"});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -128,10 +128,10 @@ public class PermanentEffects extends ItemStat<RandomPotionEffectListData, Potio
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
||||
List<String> lore = new ArrayList<>();
|
||||
|
||||
String permEffectFormat = ItemStat.translate("perm-effect");
|
||||
((PotionEffectListData) data).getEffects().forEach(effect -> {
|
||||
lore.add(permEffectFormat.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType()) + " " + MMOUtils.intToRoman(effect.getLevel())));
|
||||
});
|
||||
String permEffectFormat = getGeneralStatFormat();
|
||||
data.getEffects().forEach(effect -> lore.add(permEffectFormat
|
||||
.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
|
||||
+ " " + MMOUtils.intToRoman(effect.getLevel()))));
|
||||
|
||||
item.getLore().insert("perm-effects", lore);
|
||||
|
||||
@ -139,6 +139,11 @@ public class PermanentEffects extends ItemStat<RandomPotionEffectListData, Potio
|
||||
item.addItemTag(getAppliedNBT(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLegacyTranslationPath() {
|
||||
return "perm-effect";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {
|
||||
@ -172,7 +177,9 @@ public class PermanentEffects extends ItemStat<RandomPotionEffectListData, Potio
|
||||
StatData data = getLoadedNBT(rTag);
|
||||
|
||||
// Add data, if valid
|
||||
if (data != null) { mmoitem.setData(this, data); }
|
||||
if (data != null) {
|
||||
mmoitem.setData(this, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -199,7 +206,7 @@ public class PermanentEffects extends ItemStat<RandomPotionEffectListData, Potio
|
||||
// Thats it
|
||||
return effects;
|
||||
|
||||
} catch (JsonSyntaxException |IllegalStateException exception) {
|
||||
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||
/*
|
||||
* OLD ITEM WHICH MUST BE UPDATED.
|
||||
*/
|
||||
|
@ -41,7 +41,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
||||
|
||||
// Lore Management
|
||||
int lvl = (int) data.getValue();
|
||||
item.getLore().insert("required-level", formatNumericStat(lvl, "{value}", String.valueOf(lvl)));
|
||||
item.getLore().insert(getPath(), formatNumericStat(lvl, "{value}", String.valueOf(lvl)));
|
||||
|
||||
// Insert NBT
|
||||
item.addItemTag(getAppliedNBT(data));
|
||||
@ -51,8 +51,8 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
||||
public void whenPreviewed(@NotNull ItemStackBuilder item, @NotNull DoubleData currentData, @NotNull NumericStatFormula templateData) throws IllegalArgumentException {
|
||||
|
||||
// Get Value
|
||||
double techMinimum = ((NumericStatFormula) templateData).calculate(0, -2.5);
|
||||
double techMaximum = ((NumericStatFormula) templateData).calculate(0, 2.5);
|
||||
double techMinimum = templateData.calculate(0, -2.5);
|
||||
double techMaximum = templateData.calculate(0, 2.5);
|
||||
|
||||
// Cancel if it its NEGATIVE and this doesn't support negative stats.
|
||||
if (techMaximum < 0 && !handleNegativeStats()) {
|
||||
@ -61,11 +61,11 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
||||
if (techMinimum < 0 && !handleNegativeStats()) {
|
||||
techMinimum = 0;
|
||||
}
|
||||
if (techMinimum < ((NumericStatFormula) templateData).getBase() - ((NumericStatFormula) templateData).getMaxSpread()) {
|
||||
techMinimum = ((NumericStatFormula) templateData).getBase() - ((NumericStatFormula) templateData).getMaxSpread();
|
||||
if (techMinimum < templateData.getBase() - templateData.getMaxSpread()) {
|
||||
techMinimum = templateData.getBase() - templateData.getMaxSpread();
|
||||
}
|
||||
if (techMaximum > ((NumericStatFormula) templateData).getBase() + ((NumericStatFormula) templateData).getMaxSpread()) {
|
||||
techMaximum = ((NumericStatFormula) templateData).getBase() + ((NumericStatFormula) templateData).getMaxSpread();
|
||||
if (techMaximum > templateData.getBase() + templateData.getMaxSpread()) {
|
||||
techMaximum = templateData.getBase() + templateData.getMaxSpread();
|
||||
}
|
||||
|
||||
// Add NBT Path
|
||||
@ -82,7 +82,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
||||
}
|
||||
|
||||
// Just display normally
|
||||
item.getLore().insert("required-level", formatNumericStat(techMinimum, "{value}", builtRange));
|
||||
item.getLore().insert(getPath(), formatNumericStat(techMinimum, "{value}", builtRange));
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
||||
|
||||
// Make and bake
|
||||
ArrayList<ItemTag> ret = new ArrayList<>();
|
||||
ret.add(new ItemTag(getNBTPath(), ((DoubleData) data).getValue()));
|
||||
ret.add(new ItemTag(getNBTPath(), data.getValue()));
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,7 @@ public class UpgradeStat extends ItemStat<UpgradeData, UpgradeData> implements C
|
||||
// Show in lore
|
||||
if (data.getMaxUpgrades() > 0)
|
||||
item.getLore().insert(getPath(),
|
||||
MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("{value}", String.valueOf(data.getMaxUpgrades())));
|
||||
getGeneralStatFormat().replace("{value}", String.valueOf(data.getMaxUpgrades())));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
@ -52,7 +52,7 @@ public class BooleanStat extends ItemStat<RandomBooleanData, BooleanData> {
|
||||
item.addItemTag(getAppliedNBT(data));
|
||||
|
||||
// Show in lore
|
||||
item.getLore().insert(getPath(), MMOItems.plugin.getLanguage().getStatFormat(getPath()));
|
||||
item.getLore().insert(getPath(), getGeneralStatFormat());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -148,6 +149,26 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
|
||||
*/
|
||||
public abstract void whenDisplayed(List<String> lore, Optional<R> statData);
|
||||
|
||||
protected String generalStatFormat;
|
||||
|
||||
@Deprecated
|
||||
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
|
||||
loadConfiguration(configObject);
|
||||
}
|
||||
|
||||
public void loadConfiguration(@NotNull Object configObject) {
|
||||
generalStatFormat = configObject.toString();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public String getLegacyTranslationPath() {
|
||||
return getPath();
|
||||
}
|
||||
|
||||
public String getGeneralStatFormat() {
|
||||
return generalStatFormat;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getName() {
|
||||
return name;
|
||||
@ -228,10 +249,9 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
|
||||
}
|
||||
|
||||
public String formatNumericStat(double value, String... replace) {
|
||||
String format = MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("<plus>", value > 0 ? "+" : "");
|
||||
for (int j = 0; j < replace.length; j += 2) {
|
||||
String format = getGeneralStatFormat().replace("<plus>", value > 0 ? "+" : "");
|
||||
for (int j = 0; j < replace.length; j += 2)
|
||||
format = format.replace(replace[j], replace[j + 1]);
|
||||
}
|
||||
return format;
|
||||
}
|
||||
|
||||
@ -248,9 +268,9 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
|
||||
return Objects.hash(id);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static String translate(String path) {
|
||||
String str = MMOItems.plugin.getLanguage().getStatFormat(path);
|
||||
return str == null ? "<TranslationNotFound:" + path + ">" : str;
|
||||
return MMOItems.plugin.getLanguage().getStatFormat(path);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -39,8 +39,8 @@ public abstract class RequiredLevelStat extends DoubleStat implements ItemRestri
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
|
||||
|
||||
// Lore Management
|
||||
int lvl = (int) ((DoubleData) data).getValue();
|
||||
String format = MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("{value}", String.valueOf(lvl));
|
||||
int lvl = (int) data.getValue();
|
||||
String format = getGeneralStatFormat().replace("{value}", String.valueOf(lvl));
|
||||
item.getLore().insert(getPath(), format);
|
||||
|
||||
// Insert NBT
|
||||
|
@ -42,90 +42,14 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringListData data) {
|
||||
|
||||
// Empty stuff
|
||||
if (!(data instanceof StringListData)) { return; }
|
||||
if (data.getList().size() == 0) { return; }
|
||||
if (!(data instanceof StringListData)) return;
|
||||
if (data.getList().size() == 0) return;
|
||||
|
||||
// Chop
|
||||
final String joined = String.join(", ", data.getList());
|
||||
final String format = MMOItems.plugin.getLanguage().getStatFormat(getPath());
|
||||
final String format = getGeneralStatFormat();
|
||||
final String finalStr = format.replace("{value}", joined);
|
||||
|
||||
/*
|
||||
// Identify colour
|
||||
StringBuilder col = new StringBuilder(""); int pnd = format.indexOf('#');
|
||||
if (pnd > 0) {
|
||||
|
||||
// Everything before thay pound
|
||||
String input = format.substring(0, pnd);
|
||||
int length = input.length();
|
||||
|
||||
for(int index = length - 1; index > -1; --index) {
|
||||
|
||||
// Observe char
|
||||
char section = input.charAt(index);
|
||||
|
||||
boolean isSection = (section == '\u00a7' || section == '&');
|
||||
boolean isAngle = (section == '<');
|
||||
|
||||
// Is there at least one char, as for it to be a color code
|
||||
if (isSection && index < (length - 1)) {
|
||||
|
||||
// Observe next character
|
||||
char c = input.charAt(index + 1);
|
||||
ChatColor color = ChatColor.getByChar(c);
|
||||
|
||||
// Was it a color code?
|
||||
if (color != null) {
|
||||
|
||||
// That's our color
|
||||
col.insert(0, color.toString());
|
||||
|
||||
// If its a reset or a color character, that's the end
|
||||
if (color.isColor() || color == ChatColor.RESET) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If there is at least 10 chars, as for it to complete HEX######>
|
||||
} else if(isAngle && index < (length - 10)) {
|
||||
|
||||
// Observe tenth characters
|
||||
char aC = input.charAt(index + 10);
|
||||
|
||||
// Closing bracket
|
||||
if (aC == '>') {
|
||||
|
||||
// Observe hex
|
||||
char lH = input.charAt(index + 1);
|
||||
char lE = input.charAt(index + 2);
|
||||
char lX = input.charAt(index + 3);
|
||||
if (lH == 'H' && lE == 'E' && lX == 'X') {
|
||||
|
||||
// Get hex
|
||||
char c1 = input.charAt(index + 4);
|
||||
char c2 = input.charAt(index + 5);
|
||||
char c3 = input.charAt(index + 6);
|
||||
char c4 = input.charAt(index + 7);
|
||||
char c5 = input.charAt(index + 8);
|
||||
char c6 = input.charAt(index + 9);
|
||||
|
||||
col.insert(0, '>')
|
||||
.insert(0, c6)
|
||||
.insert(0, c5)
|
||||
.insert(0, c4)
|
||||
.insert(0, c3)
|
||||
.insert(0, c2)
|
||||
.insert(0, c1)
|
||||
.insert(0, "<HEX");
|
||||
|
||||
// Um yes that qualifies as a color code
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} */
|
||||
|
||||
// Display in lore
|
||||
// item.getLore().insert(getPath(), SilentNumbers.chop(finalStr, 50, col.toString()));
|
||||
item.getLore().insert(getPath(), finalStr);
|
||||
@ -140,7 +64,7 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
|
||||
JsonArray array = new JsonArray();
|
||||
|
||||
// For every list entry
|
||||
for (String str : ((StringListData) data).getList()) {
|
||||
for (String str : data.getList()) {
|
||||
|
||||
// Add to the array as-is
|
||||
array.add(str);
|
||||
@ -196,7 +120,9 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
|
||||
StatData data = getLoadedNBT(relevantTags);
|
||||
|
||||
// Valid?
|
||||
if (data != null) { mmoitem.setData(this, data); }
|
||||
if (data != null) {
|
||||
mmoitem.setData(this, data);
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@ -216,7 +142,7 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
|
||||
// Create String List Data
|
||||
return new StringListData(array);
|
||||
|
||||
} catch (JsonSyntaxException |IllegalStateException exception) {
|
||||
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||
/*
|
||||
* OLD ITEM WHICH MUST BE UPDATED.
|
||||
*/
|
||||
|
@ -30,10 +30,14 @@ physical-damage: '&3 &7■ Physical Damage: &f<plus>{value}%'
|
||||
projectile-damage: '&3 &7■ Projectile Damage: &f<plus>{value}%'
|
||||
faction-damage-undead: '&3 &7■ Undead Faction Damage: &f<plus>{value}%'
|
||||
|
||||
# Abilities
|
||||
ability-format: '&a>&8| &7{trigger} &8|&e|&8| &7&l{ability}'
|
||||
ability-modifier: ' &3>&8|&7 {modifier}&8: &f{value}'
|
||||
ability-splitter: '&8'
|
||||
# Abilities (changed in MI 6.9.5)
|
||||
ability:
|
||||
general-format: "&f䀐 &7{trigger} &8|&e|&8| &7&l{ability}\n"
|
||||
modifier-foreach: "&7{modifier}&8: &f{value}"
|
||||
modifier-splitter: " &8&l|&7 "
|
||||
ability-splitter:
|
||||
enabled: true
|
||||
format: ''
|
||||
|
||||
# Armor Stats
|
||||
block-power: '&3 &7■ Block Power: &f<plus>{value}%'
|
||||
@ -78,8 +82,8 @@ additional-experience-smithing: '&7■ Additional Smithing Experience: &f<plus>{
|
||||
additional-experience-woodcutting: '&7■ Additional Woodcutting Experience: &f<plus>{value}%'
|
||||
|
||||
# Extra Options
|
||||
perm-effect: '&3 &7■ Permanent &f{effect}'
|
||||
command: '&3 &7■ Command: &f{format} &3 &7(&f{cooldown}&3 &7s)'
|
||||
perm-effects: '&3 &7■ Permanent &f{effect}'
|
||||
commands: '&3 &7■ Command: &f{format} &3 &7(&f{cooldown}&3 &7s)'
|
||||
item-cooldown: '&3 &7■ &f{value}&3 &7s Cooldown'
|
||||
arrow-potion-effects: '&3 &7■ Arrow Effect: &f{effect}'
|
||||
|
||||
@ -89,7 +93,7 @@ restore-food: '&3 &7■ Restores &f{value} &7Food'
|
||||
restore-saturation: '&3 &7■ Restores &f{value} &7Saturation'
|
||||
restore-mana: '&3 &7■ Restores &f{value} &7Mana'
|
||||
restore-stamina: '&3 &7■ Restores &f{value} &7Stamina'
|
||||
effect: '&3 &7■ Grants &f{effect} &7for &f{duration} &7s'
|
||||
effects: '&3 &7■ Grants &f{effect} &7for &f{duration} &7s'
|
||||
repair: '&3 &7■ Repair: &f{value}'
|
||||
repair-percent: '&3 &7■ Repair: &f{value}%'
|
||||
can-identify: '&3 &7■ Can identify items.'
|
||||
@ -99,10 +103,9 @@ success-rate: '&3 &7■ Success Rate: &a&l{value}%'
|
||||
max-consume: '&3 &7■ &f{value} &7Uses Left'
|
||||
|
||||
# Gem Stones
|
||||
empty-gem-socket: '&a◆ Empty {name} Gem Socket'
|
||||
filled-gem-socket: '&a◆ {name}'
|
||||
when-applied: '&aWhen Applied:'
|
||||
gem-stone-lore: '&8&l[&2&l*&8&l] &aDrag onto an item &7to apply!'
|
||||
gem-sockets:
|
||||
empty-gem-socket: '&a◆ Empty {name} Gem Socket'
|
||||
filled-gem-socket: '&a◆ {name}'
|
||||
|
||||
# Soulbound
|
||||
soulbinding-chance: '&3 &7■ Has a &a{value}% &7chance to bind your item.'
|
||||
@ -113,10 +116,9 @@ soulbound-level: '&3 &7■ Level &e{value} &7Soulbound'
|
||||
autosmelt: '&3 &7■ &fAutosmelt'
|
||||
bouncing-crack: '&3 &7■ &fBouncing Crack'
|
||||
pickaxe-power: '&3 &7■ &fPickaxe Power: &a{value}'
|
||||
durability: '&7Durability: {current} / {max}'
|
||||
item-damage: '&7Durability: {current} / {max}'
|
||||
|
||||
# General
|
||||
item-type: '&c{type}'
|
||||
tier: '&3 &7Tier: {value}'
|
||||
required-class: '&3 &7{value} Item'
|
||||
required-level: '&eRequires Lvl {value}'
|
||||
@ -140,12 +142,13 @@ profession-smelting: '&eSmelting Level: &c{value}'
|
||||
profession-smithing: '&eSmithing Level: &c{value}'
|
||||
profession-woodcutting: '&eWoodcutting Level: &c{value}'
|
||||
|
||||
# Elemental Stat Format
|
||||
elemental-damage: '{color}{icon}&7 {value} {element} Damage'
|
||||
elemental-damage-percent: '{color}{icon}&7 +{value}% {element} Damage'
|
||||
elemental-defense: '{color}{icon}&7 {value} {element} Defense'
|
||||
elemental-defense-percent: '{color}{icon}&7 +{value}% {element} Defense'
|
||||
elemental-weakness: '{color}{icon}&7 {value}% {element} Weakness'
|
||||
# Elemental Stat Formats
|
||||
element:
|
||||
damage: '{color}{icon}&7 {value} {element} Damage'
|
||||
damage-percent: '{color}{icon}&7 +{value}% {element} Damage'
|
||||
defense: '{color}{icon}&7 {value} {element} Defense'
|
||||
defense-percent: '{color}{icon}&7 +{value}% {element} Defense'
|
||||
weakness: '{color}{icon}&7 {value}% {element} Weakness'
|
||||
|
||||
# Custom stats
|
||||
custom-myluck: '&3 &7■ Luck: &f<plus>{value}'
|
Loading…
Reference in New Issue
Block a user