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) {
|
public void registerTemplateEdition(ItemReference ref) {
|
||||||
|
|
||||||
/*
|
// Saves the changes before asking for a template update
|
||||||
* saves the changes before asking for a template update
|
|
||||||
*/
|
|
||||||
save();
|
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
|
* simply unloads the currently saved template and reloads it
|
||||||
*/
|
*/
|
||||||
MMOItems.plugin.getTemplates().requestTemplateUpdate(ref.getType(), ref.getId());
|
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))
|
if (MMOItems.plugin.getUpdater().hasData(ref))
|
||||||
MMOItems.plugin.getUpdater().getData(ref).setUniqueId(UUID.randomUUID());*/
|
MMOItems.plugin.getUpdater().getData(ref).setUniqueId(UUID.randomUUID());*/
|
||||||
}
|
}
|
||||||
|
@ -88,7 +88,7 @@ public class Consumable extends UseItem {
|
|||||||
/**
|
/**
|
||||||
* This dynamically updates the item lore
|
* 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 old = format.replace("{value}", String.valueOf(usesLeft + 1));
|
||||||
final String replaced = format.replace("{value}", String.valueOf(usesLeft));
|
final String replaced = format.replace("{value}", String.valueOf(usesLeft));
|
||||||
ItemStack newItem = new LoreUpdate(nbtItem.toItem(), old, replaced).updateLore();
|
ItemStack newItem = new LoreUpdate(nbtItem.toItem(), old, replaced).updateLore();
|
||||||
|
@ -243,7 +243,7 @@ public class DurabilityItem {
|
|||||||
ItemStack item = nbtItem.toItem();
|
ItemStack item = nbtItem.toItem();
|
||||||
|
|
||||||
// Item lore update
|
// 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 old = format.replace("{current}", String.valueOf(initialDurability));
|
||||||
final String replaced = format.replace("{current}", String.valueOf(durability));
|
final String replaced = format.replace("{current}", String.valueOf(durability));
|
||||||
return new LoreUpdate(item, old, replaced).updateLore();
|
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.event.ItemBuildEvent;
|
||||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
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.MaterialData;
|
||||||
import net.Indyuce.mmoitems.stat.data.StringListData;
|
import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||||
@ -203,10 +204,10 @@ public class ItemStackBuilder {
|
|||||||
|
|
||||||
// Display gem stone lore hint thing
|
// Display gem stone lore hint thing
|
||||||
if (builtMMOItem.getType() == Type.GEM_STONE)
|
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
|
// 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)
|
builtMMOItem.getStats().contains(ItemStats.DISPLAYED_TYPE) ? builtMMOItem.getData(ItemStats.DISPLAYED_TYPE)
|
||||||
.toString() : builtMMOItem.getType().getName()));
|
.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"),
|
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."),
|
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
|
// Item restrictions
|
||||||
NOT_ENOUGH_LEVELS("You don't have enough levels to use this item!", "cant-use-item"),
|
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"),
|
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 {
|
public class ConfigManager implements Reloadable {
|
||||||
|
|
||||||
// cached config files
|
// cached config files
|
||||||
private ConfigFile loreFormat, stats, dynLore;
|
private ConfigFile loreFormat, dynLore;
|
||||||
|
|
||||||
// Language
|
// Language
|
||||||
private final Map<TriggerType, String> triggerTypeNames = new HashMap<>();
|
private final Map<TriggerType, String> triggerTypeNames = new HashMap<>();
|
||||||
@ -43,7 +43,6 @@ public class ConfigManager implements Reloadable {
|
|||||||
|
|
||||||
// Cached config options
|
// Cached config options
|
||||||
public boolean replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate, opStatsEnabled, disableRemovedItems;
|
public boolean replaceMushroomDrops, worldGenEnabled, upgradeRequirementsCheck, keepSoulboundOnDeath, rerollOnItemUpdate, opStatsEnabled, disableRemovedItems;
|
||||||
public String abilitySplitter;
|
|
||||||
public double soulboundBaseDamage, soulboundPerLvlDamage, levelSpread;
|
public double soulboundBaseDamage, soulboundPerLvlDamage, levelSpread;
|
||||||
public NumericStatFormula defaultItemCapacity;
|
public NumericStatFormula defaultItemCapacity;
|
||||||
public ReforgeOptions revisionOptions, gemRevisionOptions, phatLootsOptions;
|
public ReforgeOptions revisionOptions, gemRevisionOptions, phatLootsOptions;
|
||||||
@ -124,6 +123,11 @@ public class ConfigManager implements Reloadable {
|
|||||||
}
|
}
|
||||||
messages.save();
|
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
|
// Potion effects
|
||||||
final LanguageFile potionEffects = new LanguageFile("potion-effects");
|
final LanguageFile potionEffects = new LanguageFile("potion-effects");
|
||||||
for (PotionEffectType effect : PotionEffectType.values())
|
for (PotionEffectType effect : PotionEffectType.values())
|
||||||
@ -154,7 +158,7 @@ public class ConfigManager implements Reloadable {
|
|||||||
MMOItems.plugin.reloadConfig();
|
MMOItems.plugin.reloadConfig();
|
||||||
|
|
||||||
loreFormat = new ConfigFile("/language", "lore-format");
|
loreFormat = new ConfigFile("/language", "lore-format");
|
||||||
stats = new ConfigFile("/language", "stats");
|
|
||||||
dynLore = new ConfigFile("/language", "dynamic-lore");
|
dynLore = new ConfigFile("/language", "dynamic-lore");
|
||||||
|
|
||||||
loadTranslations();
|
loadTranslations();
|
||||||
@ -166,7 +170,6 @@ public class ConfigManager implements Reloadable {
|
|||||||
replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops");
|
replaceMushroomDrops = MMOItems.plugin.getConfig().getBoolean("custom-blocks.replace-mushroom-drops");
|
||||||
worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen");
|
worldGenEnabled = MMOItems.plugin.getConfig().getBoolean("custom-blocks.enable-world-gen");
|
||||||
|
|
||||||
abilitySplitter = getStatFormat("ability-splitter");
|
|
||||||
soulboundBaseDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.base");
|
soulboundBaseDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.base");
|
||||||
soulboundPerLvlDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.per-lvl");
|
soulboundPerLvlDamage = MMOItems.plugin.getConfig().getDouble("soulbound.damage.per-lvl");
|
||||||
upgradeRequirementsCheck = MMOItems.plugin.getConfig().getBoolean("item-upgrade-requirements-check");
|
upgradeRequirementsCheck = MMOItems.plugin.getConfig().getBoolean("item-upgrade-requirements-check");
|
||||||
@ -209,15 +212,20 @@ public class ConfigManager implements Reloadable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Can this block material be broken by tool mechanics
|
* @return Can this block material be broken by tool mechanics
|
||||||
* like 'Bouncing Crack'
|
* like 'Bouncing Crack'
|
||||||
*/
|
*/
|
||||||
public boolean isBlacklisted(Material material) {
|
public boolean isBlacklisted(@NotNull Material material) {
|
||||||
return MMOItems.plugin.getConfig().getStringList("block-blacklist").contains(material.name());
|
return MMOItems.plugin.getConfig().getStringList("block-blacklist").contains(material.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Will be removed in the future.
|
||||||
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@Deprecated
|
||||||
public String getStatFormat(String path) {
|
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;
|
return found == null ? "<TranslationNotFound:" + path + ">" : found;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,6 @@ public class PluginUpdateManager {
|
|||||||
*/
|
*/
|
||||||
private final Map<Integer, PluginUpdate> updates = new HashMap<>();
|
private final Map<Integer, PluginUpdate> updates = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public PluginUpdateManager() {
|
public PluginUpdateManager() {
|
||||||
register(new PluginUpdate(1,
|
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."},
|
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
|
// Register custom stats
|
||||||
loadCustom();
|
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());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -100,9 +111,9 @@ public class StatManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection of all numeric stats like atk damage, crit strike
|
* @return Collection of all numeric stats like atk damage, crit strike
|
||||||
* chance, max mana... which can be applied on a gem stone. This is
|
* chance, max mana... which can be applied on a gem stone. This is
|
||||||
* used when applying gem stones to quickly access all the stats
|
* used when applying gem stones to quickly access all the stats
|
||||||
* which needs to be applied
|
* which needs to be applied
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<DoubleStat> getNumericStats() {
|
public List<DoubleStat> getNumericStats() {
|
||||||
@ -111,7 +122,7 @@ public class StatManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection of all stats which constitute an item restriction:
|
* @return Collection of all stats which constitute an item restriction:
|
||||||
* required level, required class, soulbound..
|
* required level, required class, soulbound..
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<ItemRestriction> getItemRestrictionStats() {
|
public List<ItemRestriction> getItemRestrictionStats() {
|
||||||
@ -120,7 +131,7 @@ public class StatManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection of all stats implementing a consumable action like
|
* @return Collection of all stats implementing a consumable action like
|
||||||
* deconstructing, identifying...
|
* deconstructing, identifying...
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<ConsumableItemInteraction> getConsumableActions() {
|
public List<ConsumableItemInteraction> getConsumableActions() {
|
||||||
@ -129,7 +140,7 @@ public class StatManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Collection of all stats implementing self consumable like
|
* @return Collection of all stats implementing self consumable like
|
||||||
* restore health, mana, hunger...
|
* restore health, mana, hunger...
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public List<PlayerConsumable> getPlayerConsumables() {
|
public List<PlayerConsumable> getPlayerConsumables() {
|
||||||
@ -151,7 +162,7 @@ public class StatManager {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Stat IDs are now stored in the stat instance directly.
|
* @deprecated Stat IDs are now stored in the stat instance directly.
|
||||||
* Please use StatManager#register(ItemStat) instead
|
* Please use StatManager#register(ItemStat) instead
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@ -33,189 +33,260 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData> {
|
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"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RandomAbilityListData whenInitialized(Object object) {
|
public RandomAbilityListData whenInitialized(Object object) {
|
||||||
Validate.isTrue(object instanceof ConfigurationSection, "Must specify a valid config section");
|
Validate.isTrue(object instanceof ConfigurationSection, "Must specify a valid config section");
|
||||||
ConfigurationSection config = (ConfigurationSection) object;
|
ConfigurationSection config = (ConfigurationSection) object;
|
||||||
RandomAbilityListData list = new RandomAbilityListData();
|
RandomAbilityListData list = new RandomAbilityListData();
|
||||||
|
|
||||||
for (String key : config.getKeys(false))
|
for (String key : config.getKeys(false))
|
||||||
list.add(new RandomAbilityData(config.getConfigurationSection(key)));
|
list.add(new RandomAbilityData(config.getConfigurationSection(key)));
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private String generalFormat, modifierForEach, modifierSplitter, abilitySplitter;
|
||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull AbilityListData data) {
|
private boolean legacyFormat, useAbilitySplitter;
|
||||||
|
private int modifiersPerLine;
|
||||||
|
|
||||||
//Modify Lore
|
@Deprecated
|
||||||
List<String> abilityLore = new ArrayList<>();
|
@Override
|
||||||
boolean splitter = !MMOItems.plugin.getLanguage().abilitySplitter.equals("");
|
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
|
||||||
|
|
||||||
String modifierFormat = ItemStat.translate("ability-modifier"), abilityFormat = ItemStat.translate("ability-format");
|
// 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");
|
||||||
|
|
||||||
data.getAbilities().forEach(ability -> {
|
} else {
|
||||||
abilityLore.add(abilityFormat.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger())).replace("{ability}", ability.getAbility().getName()));
|
legacyFormat = true;
|
||||||
|
generalFormat = legacyLanguageFile.getString("ability-format");
|
||||||
|
modifierForEach = legacyLanguageFile.getString("ability-modifier");
|
||||||
|
abilitySplitter = legacyLanguageFile.getString("ability-splitter");
|
||||||
|
useAbilitySplitter = abilitySplitter != null && !abilitySplitter.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (String modifier : ability.getModifiers()) {
|
@Override
|
||||||
item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier,
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull AbilityListData data) {
|
||||||
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier)));
|
|
||||||
abilityLore.add(modifierFormat.replace("{modifier}", ability.getAbility().getParameterName(modifier)).replace("{value}",
|
|
||||||
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier))));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (splitter)
|
// Modify Lore
|
||||||
abilityLore.add(MMOItems.plugin.getLanguage().abilitySplitter);
|
List<String> abilityLore = new ArrayList<>();
|
||||||
});
|
|
||||||
|
|
||||||
if (splitter && abilityLore.size() > 0)
|
// DEPRECATED CODE which supports old versions of the stats.yml config
|
||||||
abilityLore.remove(abilityLore.size() - 1);
|
if (legacyFormat) {
|
||||||
|
data.getAbilities().forEach(ability -> {
|
||||||
|
abilityLore.add(generalFormat
|
||||||
|
.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger()))
|
||||||
|
.replace("{ability}", ability.getAbility().getName()));
|
||||||
|
|
||||||
// Modify tags
|
for (String modifier : ability.getModifiers()) {
|
||||||
item.getLore().insert("abilities", abilityLore);
|
item.getLore().registerPlaceholder("ability_" + ability.getAbility().getHandler().getId().toLowerCase() + "_" + modifier,
|
||||||
item.addItemTag(getAppliedNBT(data));
|
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier)));
|
||||||
}
|
abilityLore.add(modifierForEach.replace("{modifier}", ability.getAbility().getParameterName(modifier)).replace("{value}",
|
||||||
|
MythicLib.plugin.getMMOConfig().decimals.format(ability.getParameter(modifier))));
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
if (useAbilitySplitter)
|
||||||
@Override
|
abilityLore.add(abilitySplitter);
|
||||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull AbilityListData data) {
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Make Array
|
// Up to date code
|
||||||
ArrayList<ItemTag> ret = new ArrayList<>();
|
else {
|
||||||
|
data.getAbilities().forEach(ability -> {
|
||||||
|
final StringBuilder builder = new StringBuilder(generalFormat
|
||||||
|
.replace("{trigger}", MMOItems.plugin.getLanguage().getCastingModeName(ability.getTrigger()))
|
||||||
|
.replace("{ability}", ability.getAbility().getName()));
|
||||||
|
|
||||||
// Convert to JSON
|
boolean modifierAppened = false;
|
||||||
JsonArray jsonArray = new JsonArray();
|
int lineCounter = 0;
|
||||||
for (AbilityData ab : data.getAbilities()) { jsonArray.add(ab.toJson()); }
|
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++;
|
||||||
|
|
||||||
// Put
|
if (modifiersPerLine > 0 && lineCounter >= modifiersPerLine) {
|
||||||
ret.add(new ItemTag(getNBTPath(), jsonArray.toString()));
|
lineCounter = 0;
|
||||||
|
modifierAppened = false;
|
||||||
|
abilityLore.add(builder.toString());
|
||||||
|
builder.setLength(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
if (modifierAppened) abilityLore.add(builder.toString());
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
if (useAbilitySplitter)
|
||||||
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
|
abilityLore.add(abilitySplitter);
|
||||||
new AbilityListEdition(inv.getPlayer(), inv.getEdited()).open(inv);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
if (useAbilitySplitter && abilityLore.size() > 0)
|
||||||
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
abilityLore.remove(abilityLore.size() - 1);
|
||||||
String configKey = (String) info[0];
|
|
||||||
String edited = (String) info[1];
|
|
||||||
|
|
||||||
String format = message.toUpperCase().replace("-", "_").replace(" ", "_").replaceAll("[^A-Z0-9_]", "");
|
// Modify tags
|
||||||
|
item.getLore().insert("abilities", abilityLore);
|
||||||
|
item.addItemTag(getAppliedNBT(data));
|
||||||
|
}
|
||||||
|
|
||||||
if (edited.equals("ability")) {
|
@Override
|
||||||
Validate.isTrue(MMOItems.plugin.getSkills().hasSkill(format),
|
public String getLegacyTranslationPath() {
|
||||||
"format is not a valid ability! You may check the ability list using /mi list ability.");
|
return "ability-format";
|
||||||
RegisteredSkill ability = MMOItems.plugin.getSkills().getSkill(format);
|
}
|
||||||
|
|
||||||
inv.getEditedSection().set("ability." + configKey, null);
|
@NotNull
|
||||||
inv.getEditedSection().set("ability." + configKey + ".type", format);
|
@Override
|
||||||
inv.registerTemplateEdition();
|
public ArrayList<ItemTag> getAppliedNBT(@NotNull AbilityListData data) {
|
||||||
inv.getPlayer().sendMessage(
|
|
||||||
MMOItems.plugin.getPrefix() + "Successfully set the ability to " + ChatColor.GOLD + ability.getName() + ChatColor.GRAY + ".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (edited.equals("mode")) {
|
// Make Array
|
||||||
|
ArrayList<ItemTag> ret = new ArrayList<>();
|
||||||
|
|
||||||
TriggerType castMode = TriggerType.valueOf(format);
|
// Convert to JSON
|
||||||
|
JsonArray jsonArray = new JsonArray();
|
||||||
|
for (AbilityData ab : data.getAbilities()) {
|
||||||
|
jsonArray.add(ab.toJson());
|
||||||
|
}
|
||||||
|
|
||||||
inv.getEditedSection().set("ability." + configKey + ".mode", castMode.name());
|
// Put
|
||||||
inv.registerTemplateEdition();
|
ret.add(new ItemTag(getNBTPath(), jsonArray.toString()));
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully set the trigger to " + ChatColor.GOLD + castMode.getName()
|
|
||||||
+ ChatColor.GRAY + ".");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new NumericStatFormula(message).fillConfigurationSection(inv.getEditedSection(), "ability." + configKey + "." + edited,
|
return ret;
|
||||||
FormulaSaveOption.NONE);
|
}
|
||||||
inv.registerTemplateEdition();
|
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GOLD + MMOUtils.caseOnWords(edited.replace("-", " ")) + ChatColor.GRAY
|
|
||||||
+ " successfully added.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenDisplayed(List<String> lore, Optional<RandomAbilityListData> statData) {
|
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
|
||||||
lore.add(ChatColor.GRAY + "Current Abilities: " + ChatColor.GOLD
|
new AbilityListEdition(inv.getPlayer(), inv.getEdited()).open(inv);
|
||||||
+ (statData.isPresent() ? ((RandomAbilityListData) statData.get()).getAbilities().size() : 0));
|
}
|
||||||
lore.add("");
|
|
||||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit the item abilities.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@Override
|
||||||
@Override
|
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
||||||
public AbilityListData getClearStatData() {
|
String configKey = (String) info[0];
|
||||||
return new AbilityListData();
|
String edited = (String) info[1];
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
String format = message.toUpperCase().replace("-", "_").replace(" ", "_").replaceAll("[^A-Z0-9_]", "");
|
||||||
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
|
||||||
|
|
||||||
// Get tags
|
if (edited.equals("ability")) {
|
||||||
ArrayList<ItemTag> relevantTags = new ArrayList<>();
|
Validate.isTrue(MMOItems.plugin.getSkills().hasSkill(format),
|
||||||
|
"format is not a valid ability! You may check the ability list using /mi list ability.");
|
||||||
|
RegisteredSkill ability = MMOItems.plugin.getSkills().getSkill(format);
|
||||||
|
|
||||||
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
inv.getEditedSection().set("ability." + configKey, null);
|
||||||
relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
inv.getEditedSection().set("ability." + configKey + ".type", format);
|
||||||
|
inv.registerTemplateEdition();
|
||||||
|
inv.getPlayer().sendMessage(
|
||||||
|
MMOItems.plugin.getPrefix() + "Successfully set the ability to " + ChatColor.GOLD + ability.getName() + ChatColor.GRAY + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
AbilityListData data = (AbilityListData) getLoadedNBT(relevantTags);
|
if (edited.equals("mode")) {
|
||||||
|
|
||||||
// Valid?
|
TriggerType castMode = TriggerType.valueOf(format);
|
||||||
if (data != null) {
|
|
||||||
|
|
||||||
// Set
|
inv.getEditedSection().set("ability." + configKey + ".mode", castMode.name());
|
||||||
mmoitem.setData(this, data);
|
inv.registerTemplateEdition();
|
||||||
}
|
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully set the trigger to " + ChatColor.GOLD + castMode.getName()
|
||||||
}
|
+ ChatColor.GRAY + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
new NumericStatFormula(message).fillConfigurationSection(inv.getEditedSection(), "ability." + configKey + "." + edited,
|
||||||
@Override
|
FormulaSaveOption.NONE);
|
||||||
public AbilityListData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
|
inv.registerTemplateEdition();
|
||||||
|
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GOLD + MMOUtils.caseOnWords(edited.replace("-", " ")) + ChatColor.GRAY
|
||||||
|
+ " successfully added.");
|
||||||
|
}
|
||||||
|
|
||||||
// Get Json Array thing
|
@Override
|
||||||
ItemTag jsonCompact = ItemTag.getTagAtPath(getNBTPath(), storedTags);
|
public void whenDisplayed(List<String> lore, Optional<RandomAbilityListData> statData) {
|
||||||
|
lore.add(ChatColor.GRAY + "Current Abilities: " + ChatColor.GOLD
|
||||||
|
+ (statData.isPresent() ? statData.get().getAbilities().size() : 0));
|
||||||
|
lore.add("");
|
||||||
|
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit the item abilities.");
|
||||||
|
}
|
||||||
|
|
||||||
// Found?
|
@NotNull
|
||||||
if (jsonCompact != null) {
|
@Override
|
||||||
|
public AbilityListData getClearStatData() {
|
||||||
|
return new AbilityListData();
|
||||||
|
}
|
||||||
|
|
||||||
// Attempt to parse
|
@Override
|
||||||
try {
|
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
||||||
|
|
||||||
// New ablity list data
|
// Get tags
|
||||||
AbilityListData list = new AbilityListData();
|
ArrayList<ItemTag> relevantTags = new ArrayList<>();
|
||||||
JsonArray ar = new JsonParser().parse((String) jsonCompact.getValue()).getAsJsonArray();
|
|
||||||
|
|
||||||
// Convert every object into an ability
|
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
||||||
for (JsonElement e : ar) {
|
relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
||||||
|
|
||||||
// For every object
|
AbilityListData data = getLoadedNBT(relevantTags);
|
||||||
if (e.isJsonObject()) {
|
|
||||||
|
|
||||||
// Get as object
|
// Valid?
|
||||||
JsonObject obj = e.getAsJsonObject();
|
if (data != null) {
|
||||||
|
|
||||||
// Add to abilit list
|
// Set
|
||||||
list.add(new AbilityData(obj));
|
mmoitem.setData(this, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Well that mus thave worked aye?
|
@Nullable
|
||||||
return list;
|
@Override
|
||||||
|
public AbilityListData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
|
||||||
|
|
||||||
} catch (JsonSyntaxException|IllegalStateException exception) {
|
// Get Json Array thing
|
||||||
/*
|
ItemTag jsonCompact = ItemTag.getTagAtPath(getNBTPath(), storedTags);
|
||||||
* OLD ITEM WHICH MUST BE UPDATED.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Did not work out
|
// Found?
|
||||||
return null;
|
if (jsonCompact != null) {
|
||||||
}
|
|
||||||
|
// Attempt to parse
|
||||||
|
try {
|
||||||
|
|
||||||
|
// New ablity list data
|
||||||
|
AbilityListData list = new AbilityListData();
|
||||||
|
JsonArray ar = new JsonParser().parse((String) jsonCompact.getValue()).getAsJsonArray();
|
||||||
|
|
||||||
|
// Convert every object into an ability
|
||||||
|
for (JsonElement e : ar) {
|
||||||
|
|
||||||
|
// For every object
|
||||||
|
if (e.isJsonObject()) {
|
||||||
|
|
||||||
|
// Get as object
|
||||||
|
JsonObject obj = e.getAsJsonObject();
|
||||||
|
|
||||||
|
// Add to abilit list
|
||||||
|
list.add(new AbilityData(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Well that mus thave worked aye?
|
||||||
|
return list;
|
||||||
|
|
||||||
|
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||||
|
/*
|
||||||
|
* OLD ITEM WHICH MUST BE UPDATED.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Did not work out
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -118,13 +118,13 @@ public class ArrowPotionEffects extends ItemStat<RandomPotionEffectListData, Pot
|
|||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
String permEffectFormat = ItemStat.translate("arrow-potion-effects");
|
String permEffectFormat = getGeneralStatFormat();
|
||||||
data.getEffects().forEach(effect -> {
|
data.getEffects().forEach(effect -> {
|
||||||
lore.add(permEffectFormat.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
|
lore.add(permEffectFormat.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
|
||||||
+ " " + MMOUtils.intToRoman(effect.getLevel()) + "(" + MythicLib.plugin.getMMOConfig().decimal.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(getPath(), lore);
|
||||||
|
|
||||||
// Add tags
|
// Add tags
|
||||||
item.addItemTag(getAppliedNBT(data));
|
item.addItemTag(getAppliedNBT(data));
|
||||||
|
@ -26,212 +26,216 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
public class Commands extends ItemStat<CommandListData, CommandListData> {
|
public class Commands extends ItemStat<CommandListData, CommandListData> {
|
||||||
private static final int MAXIMUM_COMMANDS = 15;
|
private static final int MAXIMUM_COMMANDS = 15;
|
||||||
|
|
||||||
public Commands() {
|
public Commands() {
|
||||||
super("COMMANDS", VersionMaterial.COMMAND_BLOCK_MINECART.toMaterial(), "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
|
@Override
|
||||||
public CommandListData whenInitialized(Object object) {
|
public CommandListData whenInitialized(Object object) {
|
||||||
Validate.isTrue(object instanceof ConfigurationSection, "Must specify a config section");
|
Validate.isTrue(object instanceof ConfigurationSection, "Must specify a config section");
|
||||||
ConfigurationSection config = (ConfigurationSection) object;
|
ConfigurationSection config = (ConfigurationSection) object;
|
||||||
|
|
||||||
CommandListData list = new CommandListData();
|
CommandListData list = new CommandListData();
|
||||||
|
|
||||||
for (String key : config.getKeys(false)) {
|
for (String key : config.getKeys(false)) {
|
||||||
ConfigurationSection section = config.getConfigurationSection(key);
|
ConfigurationSection section = config.getConfigurationSection(key);
|
||||||
list.add(new CommandData(section.getString("format"), section.getDouble("delay"), section.getBoolean("console"),
|
list.add(new CommandData(section.getString("format"), section.getDouble("delay"), section.getBoolean("console"),
|
||||||
section.getBoolean("op")));
|
section.getBoolean("op")));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
|
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
|
||||||
new CommandListEdition(inv.getPlayer(), inv.getEdited()).open(inv);
|
new CommandListEdition(inv.getPlayer(), inv.getEdited()).open(inv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
||||||
if (inv.getEditedSection().contains("commands"))
|
if (inv.getEditedSection().contains("commands"))
|
||||||
if (inv.getEditedSection().getConfigurationSection("commands").getKeys(false).size() >= MAXIMUM_COMMANDS) {
|
if (inv.getEditedSection().getConfigurationSection("commands").getKeys(false).size() >= MAXIMUM_COMMANDS) {
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Your item has reached the " + MAXIMUM_COMMANDS + " commands limit.");
|
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Your item has reached the " + MAXIMUM_COMMANDS + " commands limit.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
double delay = 0;
|
double delay = 0;
|
||||||
boolean console = false, op = false;
|
boolean console = false, op = false;
|
||||||
|
|
||||||
String[] split = message.split(" ");
|
String[] split = message.split(" ");
|
||||||
for (int j = 0; j < split.length && split[j].startsWith("-"); j++) {
|
for (int j = 0; j < split.length && split[j].startsWith("-"); j++) {
|
||||||
String arg = split[j];
|
String arg = split[j];
|
||||||
if (arg.startsWith("-d:")) {
|
if (arg.startsWith("-d:")) {
|
||||||
delay = MMOUtils.parseDouble(arg.substring(3));
|
delay = MMOUtils.parseDouble(arg.substring(3));
|
||||||
message = message.replaceFirst(arg + " ", "");
|
message = message.replaceFirst(arg + " ", "");
|
||||||
} else if (arg.equalsIgnoreCase("-c")) {
|
} else if (arg.equalsIgnoreCase("-c")) {
|
||||||
console = true;
|
console = true;
|
||||||
message = message.replaceFirst(arg + " ", "");
|
message = message.replaceFirst(arg + " ", "");
|
||||||
} else if (arg.equalsIgnoreCase("-op")) {
|
} else if (arg.equalsIgnoreCase("-op")) {
|
||||||
op = true;
|
op = true;
|
||||||
message = message.replaceFirst(arg + " ", "");
|
message = message.replaceFirst(arg + " ", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* determine the command ID based on the command IDs which have been
|
* determine the command ID based on the command IDs which have been
|
||||||
* registered before.
|
* registered before.
|
||||||
*/
|
*/
|
||||||
ConfigurationSection commands = inv.getEditedSection().getConfigurationSection("commands");
|
ConfigurationSection commands = inv.getEditedSection().getConfigurationSection("commands");
|
||||||
String path = "cmd" + (MAXIMUM_COMMANDS + 1);
|
String path = "cmd" + (MAXIMUM_COMMANDS + 1);
|
||||||
if (commands == null)
|
if (commands == null)
|
||||||
path = "cmd0";
|
path = "cmd0";
|
||||||
else
|
else
|
||||||
for (int j = 0; j < MAXIMUM_COMMANDS; j++)
|
for (int j = 0; j < MAXIMUM_COMMANDS; j++)
|
||||||
if (!commands.contains("cmd" + j)) {
|
if (!commands.contains("cmd" + j)) {
|
||||||
path = "cmd" + j;
|
path = "cmd" + j;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
inv.getEditedSection().set("commands." + path + ".format", message);
|
inv.getEditedSection().set("commands." + path + ".format", message);
|
||||||
inv.getEditedSection().set("commands." + path + ".delay", delay);
|
inv.getEditedSection().set("commands." + path + ".delay", delay);
|
||||||
inv.getEditedSection().set("commands." + path + ".console", console ? console : null);
|
inv.getEditedSection().set("commands." + path + ".console", console ? console : null);
|
||||||
inv.getEditedSection().set("commands." + path + ".op", op ? op : null);
|
inv.getEditedSection().set("commands." + path + ".op", op ? op : null);
|
||||||
inv.registerTemplateEdition();
|
inv.registerTemplateEdition();
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Command successfully registered.");
|
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Command successfully registered.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenDisplayed(List<String> lore, Optional<CommandListData> statData) {
|
public void whenDisplayed(List<String> lore, Optional<CommandListData> statData) {
|
||||||
lore.add(ChatColor.GRAY + "Current Commands: " + ChatColor.RED
|
lore.add(ChatColor.GRAY + "Current Commands: " + ChatColor.RED
|
||||||
+ (statData.isPresent() ? ((CommandListData) statData.get()).getCommands().size() : "0"));
|
+ (statData.isPresent() ? ((CommandListData) statData.get()).getCommands().size() : "0"));
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit item commands.");
|
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit item commands.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull CommandListData getClearStatData() {
|
public @NotNull CommandListData getClearStatData() {
|
||||||
return new CommandListData();
|
return new CommandListData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull CommandListData data) {
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull CommandListData data) {
|
||||||
|
|
||||||
// Add persistent tags onto item
|
// Add persistent tags onto item
|
||||||
item.addItemTag(getAppliedNBT(data));
|
item.addItemTag(getAppliedNBT(data));
|
||||||
|
|
||||||
// Addlore
|
// Addlore
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
String commandFormat = ItemStat.translate("command");
|
String commandFormat = getGeneralStatFormat();
|
||||||
((CommandListData) data).getCommands().forEach(command -> {
|
data.getCommands().forEach(command -> lore.add(commandFormat
|
||||||
|
.replace("{format}", "/" + command.getCommand())
|
||||||
|
.replace("{cooldown}", String.valueOf(command.getDelay()))));
|
||||||
|
item.getLore().insert("commands", lore);
|
||||||
|
}
|
||||||
|
|
||||||
lore.add(commandFormat.replace("{format}", "/" + command.getCommand()).replace("{cooldown}", String.valueOf(command.getDelay())));
|
@Override
|
||||||
});
|
public String getLegacyTranslationPath() {
|
||||||
item.getLore().insert("commands", lore);
|
return "command";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull CommandListData data) {
|
public ArrayList<ItemTag> getAppliedNBT(@NotNull CommandListData data) {
|
||||||
|
|
||||||
// Will end up returning this
|
// Will end up returning this
|
||||||
ArrayList<ItemTag> ret = new ArrayList<>();
|
ArrayList<ItemTag> ret = new ArrayList<>();
|
||||||
|
|
||||||
// But it contains only 1 tag: THIS
|
// But it contains only 1 tag: THIS
|
||||||
JsonArray array = new JsonArray();
|
JsonArray array = new JsonArray();
|
||||||
|
|
||||||
// Add each command
|
// Add each command
|
||||||
for (CommandData cd : data.getCommands()) {
|
for (CommandData cd : data.getCommands()) {
|
||||||
|
|
||||||
JsonObject object = new JsonObject();
|
JsonObject object = new JsonObject();
|
||||||
object.addProperty("Command", cd.getCommand());
|
object.addProperty("Command", cd.getCommand());
|
||||||
object.addProperty("Delay", cd.getDelay());
|
object.addProperty("Delay", cd.getDelay());
|
||||||
object.addProperty("Console", cd.isConsoleCommand());
|
object.addProperty("Console", cd.isConsoleCommand());
|
||||||
object.addProperty("Op", cd.hasOpPerms());
|
object.addProperty("Op", cd.hasOpPerms());
|
||||||
|
|
||||||
// Include object
|
// Include object
|
||||||
array.add(object);
|
array.add(object);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add that tag in there
|
// Add that tag in there
|
||||||
ret.add(new ItemTag(getNBTPath(), array.toString()));
|
ret.add(new ItemTag(getNBTPath(), array.toString()));
|
||||||
|
|
||||||
// Thats it
|
// Thats it
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
||||||
|
|
||||||
// Find the relevant tag
|
// Find the relevant tag
|
||||||
ArrayList<ItemTag> relevantTag = new ArrayList<>();
|
ArrayList<ItemTag> relevantTag = new ArrayList<>();
|
||||||
|
|
||||||
// Yes
|
// Yes
|
||||||
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
||||||
relevantTag.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
relevantTag.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
||||||
|
|
||||||
// Attempt to bake data
|
// Attempt to bake data
|
||||||
CommandListData data = (CommandListData) getLoadedNBT(relevantTag);
|
CommandListData data = (CommandListData) getLoadedNBT(relevantTag);
|
||||||
|
|
||||||
// Valid?
|
// Valid?
|
||||||
if (data != null) {
|
if (data != null) {
|
||||||
|
|
||||||
// yup
|
// yup
|
||||||
mmoitem.setData(this, data);
|
mmoitem.setData(this, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public CommandListData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
|
public CommandListData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
|
||||||
|
|
||||||
// Find relevant tag
|
// Find relevant tag
|
||||||
ItemTag relevant = ItemTag.getTagAtPath(getNBTPath(), storedTags);
|
ItemTag relevant = ItemTag.getTagAtPath(getNBTPath(), storedTags);
|
||||||
|
|
||||||
// Found it?
|
// Found it?
|
||||||
if (relevant != null) {
|
if (relevant != null) {
|
||||||
|
|
||||||
// Attempt to parse it
|
// Attempt to parse it
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// New data <3
|
// New data <3
|
||||||
CommandListData commands = new CommandListData();
|
CommandListData commands = new CommandListData();
|
||||||
|
|
||||||
// Parse array from it
|
// Parse array from it
|
||||||
JsonArray ar = new JsonParser().parse((String) relevant.getValue()).getAsJsonArray();
|
JsonArray ar = new JsonParser().parse((String) relevant.getValue()).getAsJsonArray();
|
||||||
|
|
||||||
// Examine every element
|
// Examine every element
|
||||||
for (JsonElement e : ar) {
|
for (JsonElement e : ar) {
|
||||||
|
|
||||||
// Valid?
|
// Valid?
|
||||||
if (e.isJsonObject()) {
|
if (e.isJsonObject()) {
|
||||||
|
|
||||||
// Get Key
|
// Get Key
|
||||||
JsonObject key = e.getAsJsonObject();
|
JsonObject key = e.getAsJsonObject();
|
||||||
|
|
||||||
// Interpret Command Data
|
// Interpret Command Data
|
||||||
CommandData cd = new CommandData(
|
CommandData cd = new CommandData(
|
||||||
key.get("Command").getAsString(),
|
key.get("Command").getAsString(),
|
||||||
key.get("Delay").getAsDouble(),
|
key.get("Delay").getAsDouble(),
|
||||||
key.get("Console").getAsBoolean(),
|
key.get("Console").getAsBoolean(),
|
||||||
key.get("Op").getAsBoolean());
|
key.get("Op").getAsBoolean());
|
||||||
|
|
||||||
// Register
|
// Register
|
||||||
commands.add(cd);
|
commands.add(cd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return commands;
|
return commands;
|
||||||
|
|
||||||
// Needs updating
|
// Needs updating
|
||||||
} catch (JsonSyntaxException|IllegalStateException exception) {
|
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||||
/*
|
/*
|
||||||
* OLD ITEM WHICH MUST BE UPDATED.
|
* OLD ITEM WHICH MUST BE UPDATED.
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
|
|||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
||||||
// Process Lore
|
// Process Lore
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
String effectFormat = ItemStat.translate("effect");
|
String effectFormat = getGeneralStatFormat();
|
||||||
data.getEffects().forEach(effect -> lore.add(effectFormat
|
data.getEffects().forEach(effect -> lore.add(effectFormat
|
||||||
.replace("{effect}",
|
.replace("{effect}",
|
||||||
MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
|
MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
|
||||||
@ -121,11 +121,16 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
|
|||||||
item.addItemTag(getAppliedNBT(data));
|
item.addItemTag(getAppliedNBT(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getLegacyTranslationPath() {
|
||||||
|
return "effect";
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {
|
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {
|
||||||
|
|
||||||
// Create aJson Array
|
// Create a Json Array
|
||||||
JsonArray array = new JsonArray();
|
JsonArray array = new JsonArray();
|
||||||
|
|
||||||
// For every effect
|
// For every effect
|
||||||
|
@ -29,9 +29,7 @@ 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;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
public class Elements extends ItemStat<RandomElementListData, ElementListData> implements Previewable<RandomElementListData, ElementListData> {
|
public class Elements extends ItemStat<RandomElementListData, ElementListData> implements Previewable<RandomElementListData, ElementListData> {
|
||||||
public Elements() {
|
public Elements() {
|
||||||
@ -77,7 +75,7 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
|||||||
|
|
||||||
inv.registerTemplateEdition();
|
inv.registerTemplateEdition();
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(elementPath.replace(".", " ")) + ChatColor.GRAY
|
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
|
@Override
|
||||||
@ -102,6 +100,32 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
|||||||
return new ElementListData();
|
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
|
@Override
|
||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ElementListData data) {
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull ElementListData data) {
|
||||||
|
|
||||||
@ -109,7 +133,7 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
|||||||
|
|
||||||
// Write Lore
|
// Write Lore
|
||||||
for (Pair<Element, ElementStatType> pair : data.getKeys()) {
|
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("{color}", pair.getKey().getColor())
|
||||||
.replace("{icon}", pair.getKey().getLoreIcon())
|
.replace("{icon}", pair.getKey().getLoreIcon())
|
||||||
.replace("{element}", pair.getKey().getName());
|
.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(currentData instanceof ElementListData, "Current Data is not ElementListData");
|
||||||
Validate.isTrue(templateData instanceof RandomElementListData, "Template Data is not RandomElementListData");
|
Validate.isTrue(templateData instanceof RandomElementListData, "Template Data is not RandomElementListData");
|
||||||
|
|
||||||
|
List<String> elementLore = new ArrayList<>();
|
||||||
|
|
||||||
// Examine every element stat possible
|
// Examine every element stat possible
|
||||||
for (Element element : Element.values())
|
for (Element element : Element.values())
|
||||||
for (ElementStatType statType : ElementStatType.values()) {
|
for (ElementStatType statType : ElementStatType.values()) {
|
||||||
@ -197,20 +223,20 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
|||||||
if (techMinimum != 0 || techMaximum != 0) {
|
if (techMinimum != 0 || techMaximum != 0) {
|
||||||
|
|
||||||
// Get path
|
// Get path
|
||||||
String path = element.getId().toLowerCase() + "-" + statType.name().toLowerCase().replace("_", "-");
|
|
||||||
|
|
||||||
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(statType.getConcatenatedTagPath(element), ItemStat.translate(path), true, techMinimum);
|
builtRange = DoubleStat.formatPath(statType.getConcatenatedTagPath(element), statFormat.get(statType), true, techMinimum);
|
||||||
} else {
|
} 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
|
// Just display normally
|
||||||
item.getLore().insert(path, builtRange);
|
elementLore.add(builtRange);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!elementLore.isEmpty()) item.getLore().insert(getPath(), elementLore);
|
||||||
|
|
||||||
// Add tags
|
// Add tags
|
||||||
item.addItemTag(getAppliedNBT(currentData));
|
item.addItemTag(getAppliedNBT(currentData));
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
|||||||
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;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.event.inventory.InventoryAction;
|
import org.bukkit.event.inventory.InventoryAction;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
|
||||||
@ -32,166 +33,192 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
public class GemSockets extends ItemStat<GemSocketsData, GemSocketsData> {
|
||||||
public GemSockets() {
|
public GemSockets() {
|
||||||
super("GEM_SOCKETS", Material.EMERALD, "Gem Sockets", new String[] { "The amount of gem", "sockets your weapon has." },
|
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" });
|
new String[]{"piercing", "slashing", "blunt", "catalyst", "range", "tool", "armor", "accessory", "!gem_stone"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public GemSocketsData whenInitialized(Object object) {
|
public GemSocketsData whenInitialized(Object object) {
|
||||||
Validate.isTrue(object instanceof List<?>, "Must specify a string list");
|
Validate.isTrue(object instanceof List<?>, "Must specify a string list");
|
||||||
return new GemSocketsData((List<String>) object);
|
return new GemSocketsData((List<String>) object);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private String emptyGemSocketFormat, filledGemSocketFormat;
|
||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull GemSocketsData sockets) {
|
|
||||||
|
|
||||||
// Append NBT Tags
|
@Override
|
||||||
item.addItemTag(getAppliedNBT(sockets));
|
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
|
||||||
|
|
||||||
// Edit Lore
|
// LEGACY CODE
|
||||||
String empty = ItemStat.translate("empty-gem-socket"), filled = ItemStat.translate("filled-gem-socket");
|
if (configObject instanceof String) {
|
||||||
List<String> lore = new ArrayList<>();
|
emptyGemSocketFormat = legacyLanguageFile.getString("empty-gem-socket");
|
||||||
for (GemstoneData gem : sockets.getGemstones()) {
|
filledGemSocketFormat = legacyLanguageFile.getString("filled-gem-socket");
|
||||||
String gemName = gem.getName();
|
}
|
||||||
|
|
||||||
// Upgrades?
|
// Up-to-date code
|
||||||
if (item.getMMOItem().hasUpgradeTemplate()) {
|
else {
|
||||||
|
Validate.isTrue(configObject instanceof ConfigurationSection, "Must be a config section");
|
||||||
|
final ConfigurationSection config = (ConfigurationSection) configObject;
|
||||||
|
emptyGemSocketFormat = config.getString("empty");
|
||||||
|
filledGemSocketFormat = config.getString("filled");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int iLvl = item.getMMOItem().getUpgradeLevel();
|
@Override
|
||||||
if (iLvl != 0) {
|
public String getLegacyTranslationPath() {
|
||||||
|
return "empty-gem-socket";
|
||||||
|
}
|
||||||
|
|
||||||
Integer gLvl = gem.getLevel();
|
@Override
|
||||||
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull GemSocketsData sockets) {
|
||||||
|
|
||||||
if (gLvl != null) {
|
// Append NBT Tags
|
||||||
|
item.addItemTag(getAppliedNBT(sockets));
|
||||||
|
|
||||||
int dLevel = iLvl - gLvl;
|
// Edit Lore
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
for (GemstoneData gem : sockets.getGemstones()) {
|
||||||
|
String gemName = gem.getName();
|
||||||
|
|
||||||
gemName = DisplayName.appendUpgradeLevel(gemName, dLevel);
|
// Upgrades?
|
||||||
}
|
if (item.getMMOItem().hasUpgradeTemplate()) {
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
lore.add(filled.replace("{name}", gemName));
|
int iLvl = item.getMMOItem().getUpgradeLevel();
|
||||||
}
|
if (iLvl != 0) {
|
||||||
sockets.getEmptySlots().forEach(slot -> lore.add(empty.replace("{name}", slot)));
|
|
||||||
item.getLore().insert("gem-stones", lore);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
Integer gLvl = gem.getLevel();
|
||||||
@Override
|
|
||||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull GemSocketsData sockets) {
|
|
||||||
|
|
||||||
// Well its just a Json tostring
|
if (gLvl != null) {
|
||||||
ArrayList<ItemTag> ret = new ArrayList<>();
|
|
||||||
ret.add(new ItemTag(getNBTPath(), sockets.toJson().toString()));
|
|
||||||
|
|
||||||
// Thats it
|
int dLevel = iLvl - gLvl;
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
gemName = DisplayName.appendUpgradeLevel(gemName, dLevel);
|
||||||
@NotNull public String getNBTPath() {
|
}
|
||||||
return "MMOITEMS_GEM_STONES";
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lore.add(filledGemSocketFormat.replace("{name}", gemName));
|
||||||
|
}
|
||||||
|
sockets.getEmptySlots().forEach(slot -> lore.add(emptyGemSocketFormat.replace("{name}", slot)));
|
||||||
|
item.getLore().insert("gem-stones", lore);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@NotNull
|
||||||
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
@Override
|
||||||
|
public ArrayList<ItemTag> getAppliedNBT(@NotNull GemSocketsData sockets) {
|
||||||
|
|
||||||
// Find relevant tags
|
// Well its just a Json tostring
|
||||||
ArrayList<ItemTag> relevantTags = new ArrayList<>();
|
ArrayList<ItemTag> ret = new ArrayList<>();
|
||||||
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
ret.add(new ItemTag(getNBTPath(), sockets.toJson().toString()));
|
||||||
relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
|
||||||
|
|
||||||
// Attempt to build
|
// Thats it
|
||||||
StatData data = getLoadedNBT(relevantTags);
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
// Valid?
|
@Override
|
||||||
if (data != null) { mmoitem.setData(this, data); }
|
@NotNull
|
||||||
}
|
public String getNBTPath() {
|
||||||
|
return "MMOITEMS_GEM_STONES";
|
||||||
|
}
|
||||||
|
|
||||||
@Nullable
|
@Override
|
||||||
@Override
|
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
||||||
public GemSocketsData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
|
|
||||||
|
|
||||||
// Find Tag
|
// Find relevant tags
|
||||||
ItemTag gTag = ItemTag.getTagAtPath(getNBTPath(), storedTags);
|
ArrayList<ItemTag> relevantTags = new ArrayList<>();
|
||||||
|
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
||||||
|
relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
||||||
|
|
||||||
// Found?
|
// Attempt to build
|
||||||
if (gTag != null) {
|
StatData data = getLoadedNBT(relevantTags);
|
||||||
|
|
||||||
try {
|
// Valid?
|
||||||
// Interpret as Json Object
|
if (data != null) {
|
||||||
JsonObject object = new JsonParser().parse((String) gTag.getValue()).getAsJsonObject();
|
mmoitem.setData(this, data);
|
||||||
GemSocketsData sockets = new GemSocketsData(object.getAsJsonArray("EmptySlots"));
|
}
|
||||||
|
}
|
||||||
|
|
||||||
JsonArray array = object.getAsJsonArray("Gemstones");
|
@Nullable
|
||||||
array.forEach(element -> sockets.add(new GemstoneData(element.getAsJsonObject())));
|
@Override
|
||||||
|
public GemSocketsData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
|
||||||
|
|
||||||
// Return built
|
// Find Tag
|
||||||
return sockets;
|
ItemTag gTag = ItemTag.getTagAtPath(getNBTPath(), storedTags);
|
||||||
|
|
||||||
} catch (JsonSyntaxException|IllegalStateException exception) {
|
// Found?
|
||||||
/*
|
if (gTag != null) {
|
||||||
* OLD ITEM WHICH MUST BE UPDATED.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Nope
|
try {
|
||||||
return null;
|
// Interpret as Json Object
|
||||||
}
|
JsonObject object = new JsonParser().parse((String) gTag.getValue()).getAsJsonObject();
|
||||||
|
GemSocketsData sockets = new GemSocketsData(object.getAsJsonArray("EmptySlots"));
|
||||||
|
|
||||||
@Override
|
JsonArray array = object.getAsJsonArray("Gemstones");
|
||||||
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
|
array.forEach(element -> sockets.add(new GemstoneData(element.getAsJsonObject())));
|
||||||
if (event.getAction() == InventoryAction.PICKUP_ALL)
|
|
||||||
new StatEdition(inv, ItemStats.GEM_SOCKETS).enable("Write in the chat the COLOR of the gem socket you want to add.");
|
|
||||||
|
|
||||||
if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
// Return built
|
||||||
if (inv.getEditedSection().contains(getPath())) {
|
return sockets;
|
||||||
List<String> lore = inv.getEditedSection().getStringList("" + getPath());
|
|
||||||
if (lore.size() < 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
String last = lore.get(lore.size() - 1);
|
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||||
lore.remove(last);
|
/*
|
||||||
inv.getEditedSection().set("" + getPath(), lore);
|
* OLD ITEM WHICH MUST BE UPDATED.
|
||||||
inv.registerTemplateEdition();
|
*/
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + last + ChatColor.GRAY + "'.");
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// Nope
|
||||||
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
return null;
|
||||||
List<String> lore = inv.getEditedSection().contains(getPath()) ? inv.getEditedSection().getStringList("" + getPath()) : new ArrayList<>();
|
}
|
||||||
lore.add(message);
|
|
||||||
inv.getEditedSection().set("" + getPath(), lore);
|
|
||||||
inv.registerTemplateEdition();
|
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + message + " successfully added.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenDisplayed(List<String> lore, Optional<GemSocketsData> statData) {
|
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
|
||||||
|
if (event.getAction() == InventoryAction.PICKUP_ALL)
|
||||||
|
new StatEdition(inv, ItemStats.GEM_SOCKETS).enable("Write in the chat the COLOR of the gem socket you want to add.");
|
||||||
|
|
||||||
if (statData.isPresent()) {
|
if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
||||||
lore.add(ChatColor.GRAY + "Current Value:");
|
if (inv.getEditedSection().contains(getPath())) {
|
||||||
GemSocketsData data = statData.get();
|
List<String> lore = inv.getEditedSection().getStringList("" + getPath());
|
||||||
data.getEmptySlots().forEach(socket -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + socket + " Gem Socket"));
|
if (lore.size() < 1)
|
||||||
|
return;
|
||||||
|
|
||||||
} else
|
String last = lore.get(lore.size() - 1);
|
||||||
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "No Sockets");
|
lore.remove(last);
|
||||||
|
inv.getEditedSection().set("" + getPath(), lore);
|
||||||
|
inv.registerTemplateEdition();
|
||||||
|
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed '" + last + ChatColor.GRAY + "'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
lore.add("");
|
@Override
|
||||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to add a gem socket.");
|
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
||||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the socket.");
|
List<String> lore = inv.getEditedSection().contains(getPath()) ? inv.getEditedSection().getStringList("" + getPath()) : new ArrayList<>();
|
||||||
}
|
lore.add(message);
|
||||||
|
inv.getEditedSection().set("" + getPath(), lore);
|
||||||
|
inv.registerTemplateEdition();
|
||||||
|
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + message + " successfully added.");
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@Override
|
||||||
@Override
|
public void whenDisplayed(List<String> lore, Optional<GemSocketsData> statData) {
|
||||||
public GemSocketsData getClearStatData() {
|
|
||||||
return new GemSocketsData(new ArrayList<>());
|
if (statData.isPresent()) {
|
||||||
}
|
lore.add(ChatColor.GRAY + "Current Value:");
|
||||||
|
GemSocketsData data = statData.get();
|
||||||
|
data.getEmptySlots().forEach(socket -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + socket + " Gem Socket"));
|
||||||
|
|
||||||
|
} else
|
||||||
|
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "No Sockets");
|
||||||
|
|
||||||
|
lore.add("");
|
||||||
|
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to add a gem socket.");
|
||||||
|
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the socket.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public GemSocketsData getClearStatData() {
|
||||||
|
return new GemSocketsData(new ArrayList<>());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,4 +61,9 @@ public class ItemDamage extends DoubleStat implements GemStoneStat {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public DoubleData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) { return null; }
|
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);
|
ItemTier tier = MMOItems.plugin.getTiers().get(path);
|
||||||
item.addItemTag(new ItemTag("MMOITEMS_TIER", 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
|
@Override
|
||||||
@ -35,7 +35,7 @@ public class ItemTierStat extends StringStat implements GemStoneStat {
|
|||||||
String format = message.toUpperCase().replace(" ", "_").replace("-", "_");
|
String format = message.toUpperCase().replace(" ", "_").replace("-", "_");
|
||||||
Validate.isTrue(MMOItems.plugin.getTiers().has(format), "Couldn't find the tier called '" + format + "'.");
|
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.registerTemplateEdition();
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Tier successfully changed to " + format + ".");
|
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));
|
item.addItemTag(new ItemTag(getNBTPath(), left));
|
||||||
|
|
||||||
String format = MMOItems.plugin.getLanguage().getStatFormat("max-consume").replace("{value}", String.valueOf(left));
|
String format = getGeneralStatFormat().replace("{value}", String.valueOf(left));
|
||||||
item.getLore().insert("max-consume", format);
|
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.ItemTag;
|
||||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||||
import net.Indyuce.mmoitems.ItemStats;
|
import net.Indyuce.mmoitems.ItemStats;
|
||||||
import net.Indyuce.mmoitems.MMOItems;
|
|
||||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
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.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -26,75 +26,81 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
* @author indyuce
|
* @author indyuce
|
||||||
*/
|
*/
|
||||||
public class MaximumDurability extends DoubleStat implements ItemRestriction, GemStoneStat, Upgradable {
|
public class MaximumDurability extends DoubleStat implements ItemRestriction, GemStoneStat, Upgradable {
|
||||||
public MaximumDurability() {
|
public MaximumDurability() {
|
||||||
super("MAX_DURABILITY", Material.SHEARS, "Maximum Durability", new String[]{"The amount of uses before your", "item becomes unusable/breaks."}, new String[]{"!block", "all"});
|
super("MAX_DURABILITY", Material.SHEARS, "Maximum Durability", new String[]{"The amount of uses before your", "item becomes unusable/breaks."}, new String[]{"!block", "all"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
||||||
whenApplied(item, currentData);
|
whenApplied(item, currentData);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
|
public void loadConfiguration(@NotNull ConfigurationSection legacyLanguageFile, @NotNull Object configObject) {
|
||||||
|
generalStatFormat = legacyLanguageFile.getString("item-damage");
|
||||||
|
if (generalStatFormat == null) generalStatFormat = legacyLanguageFile.getString("durability");
|
||||||
|
}
|
||||||
|
|
||||||
int max = (int) data.getValue();
|
@Override
|
||||||
int current = item.getMMOItem().hasData(ItemStats.CUSTOM_DURABILITY) ? (int) ((DoubleData) item.getMMOItem().getData(ItemStats.CUSTOM_DURABILITY)).getValue() : max;
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
|
||||||
|
|
||||||
item.addItemTag(new ItemTag(getNBTPath(), max));
|
int max = (int) data.getValue();
|
||||||
|
int current = item.getMMOItem().hasData(ItemStats.CUSTOM_DURABILITY) ? (int) ((DoubleData) item.getMMOItem().getData(ItemStats.CUSTOM_DURABILITY)).getValue() : max;
|
||||||
|
|
||||||
// Display durability in lore here.
|
item.addItemTag(new ItemTag(getNBTPath(), max));
|
||||||
String format = MMOItems.plugin.getLanguage().getStatFormat("durability").replace("{max}", String.valueOf(max)).replace("{current}", String.valueOf(current));
|
|
||||||
item.getLore().insert("durability", format);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// Display durability in lore here.
|
||||||
public void preprocess(@NotNull MMOItem item) {
|
String format = getGeneralStatFormat().replace("{max}", String.valueOf(max)).replace("{current}", String.valueOf(current));
|
||||||
|
item.getLore().insert("durability", format);
|
||||||
|
}
|
||||||
|
|
||||||
// If this has no Max Upgrade Data
|
@Override
|
||||||
if (!item.hasData(ItemStats.MAX_DURABILITY)) {
|
public void preprocess(@NotNull MMOItem item) {
|
||||||
|
|
||||||
// What durability will it have?
|
// If this has no Max Upgrade Data
|
||||||
int base = 400;
|
if (!item.hasData(ItemStats.MAX_DURABILITY)) {
|
||||||
|
|
||||||
// I mean bruh
|
// What durability will it have?
|
||||||
if (item.hasData(ItemStats.MATERIAL)) {
|
int base = 400;
|
||||||
|
|
||||||
// Use vanilla max durability
|
// I mean bruh
|
||||||
MaterialData data = (MaterialData) item.getData(ItemStats.MATERIAL);
|
if (item.hasData(ItemStats.MATERIAL)) {
|
||||||
|
|
||||||
// Get mat
|
// Use vanilla max durability
|
||||||
Material mat = data.getMaterial();
|
MaterialData data = (MaterialData) item.getData(ItemStats.MATERIAL);
|
||||||
base = mat.getMaxDurability();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Yea no
|
// Get mat
|
||||||
if (base < 8)
|
Material mat = data.getMaterial();
|
||||||
base = 400;
|
base = mat.getMaxDurability();
|
||||||
|
}
|
||||||
|
|
||||||
// Set max dura
|
// Yea no
|
||||||
item.setData(ItemStats.MAX_DURABILITY, new DoubleData(base));
|
if (base < 8)
|
||||||
/*item.setData(ItemStats.CUSTOM_DURABILITY, new DoubleData(base));*/
|
base = 400;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
// Set max dura
|
||||||
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
|
item.setData(ItemStats.MAX_DURABILITY, new DoubleData(base));
|
||||||
|
/*item.setData(ItemStats.CUSTOM_DURABILITY, new DoubleData(base));*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
@Override
|
||||||
* Items with no MMOITEMS_DURABILITY tag yet means that they still
|
public boolean canUse(RPGPlayer player, NBTItem item, boolean message) {
|
||||||
* have full durability
|
|
||||||
*/
|
|
||||||
if (!item.hasTag("MMOITEMS_DURABILITY"))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (item.getDouble(ItemStats.CUSTOM_DURABILITY.getNBTPath()) <= 0) {
|
/*
|
||||||
if (message) {
|
* Items with no MMOITEMS_DURABILITY tag yet means that they still
|
||||||
Message.ZERO_DURABILITY.format(ChatColor.RED).send(player.getPlayer());
|
* have full durability
|
||||||
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
*/
|
||||||
}
|
if (!item.hasTag("MMOITEMS_DURABILITY"))
|
||||||
return false;
|
return true;
|
||||||
}
|
|
||||||
return true;
|
if (item.getDouble(ItemStats.CUSTOM_DURABILITY.getNBTPath()) <= 0) {
|
||||||
}
|
if (message) {
|
||||||
|
Message.ZERO_DURABILITY.format(ChatColor.RED).send(player.getPlayer());
|
||||||
|
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,170 +43,177 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* amplifier and duration are not numeric formulas but flat values.... TODO
|
* amplifier and duration are not numeric formulas but flat values.... TODO
|
||||||
*/
|
*/
|
||||||
public class PermanentEffects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> {
|
public class PermanentEffects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> {
|
||||||
public PermanentEffects() {
|
public PermanentEffects() {
|
||||||
super("PERM_EFFECTS", Material.POTION, "Permanent Effects", new String[] { "The potion effects your", "item grants to the holder." },
|
super("PERM_EFFECTS", Material.POTION, "Permanent Effects", new String[]{"The potion effects your", "item grants to the holder."},
|
||||||
new String[] { "!miscellaneous", "!block", "all" });
|
new String[]{"!miscellaneous", "!block", "all"});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RandomPotionEffectListData whenInitialized(Object object) {
|
public RandomPotionEffectListData whenInitialized(Object object) {
|
||||||
Validate.isTrue(object instanceof ConfigurationSection, "Must specify a config section");
|
Validate.isTrue(object instanceof ConfigurationSection, "Must specify a config section");
|
||||||
ConfigurationSection config = (ConfigurationSection) object;
|
ConfigurationSection config = (ConfigurationSection) object;
|
||||||
|
|
||||||
RandomPotionEffectListData effects = new RandomPotionEffectListData();
|
RandomPotionEffectListData effects = new RandomPotionEffectListData();
|
||||||
|
|
||||||
for (String effect : config.getKeys(false)) {
|
for (String effect : config.getKeys(false)) {
|
||||||
PotionEffectType type = PotionEffectType.getByName(effect.toUpperCase().replace("-", "_").replace(" ", "_"));
|
PotionEffectType type = PotionEffectType.getByName(effect.toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||||
Validate.notNull(type, "Could not find potion effect type named '" + effect + "'");
|
Validate.notNull(type, "Could not find potion effect type named '" + effect + "'");
|
||||||
effects.add(new RandomPotionEffectData(type, new NumericStatFormula(config.get(effect))));
|
effects.add(new RandomPotionEffectData(type, new NumericStatFormula(config.get(effect))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return effects;
|
return effects;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
|
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
|
||||||
if (event.getAction() == InventoryAction.PICKUP_ALL)
|
if (event.getAction() == InventoryAction.PICKUP_ALL)
|
||||||
new StatEdition(inv, ItemStats.PERM_EFFECTS).enable("Write in the chat the permanent potion effect you want to add.",
|
new StatEdition(inv, ItemStats.PERM_EFFECTS).enable("Write in the chat the permanent potion effect you want to add.",
|
||||||
ChatColor.AQUA + "Format: {Effect Name} {Amplifier Numeric Formula}");
|
ChatColor.AQUA + "Format: {Effect Name} {Amplifier Numeric Formula}");
|
||||||
|
|
||||||
if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
if (event.getAction() == InventoryAction.PICKUP_HALF) {
|
||||||
if (inv.getEditedSection().contains("perm-effects")) {
|
if (inv.getEditedSection().contains("perm-effects")) {
|
||||||
Set<String> set = inv.getEditedSection().getConfigurationSection("perm-effects").getKeys(false);
|
Set<String> set = inv.getEditedSection().getConfigurationSection("perm-effects").getKeys(false);
|
||||||
String last = new ArrayList<>(set).get(set.size() - 1);
|
String last = new ArrayList<>(set).get(set.size() - 1);
|
||||||
inv.getEditedSection().set("perm-effects." + last, null);
|
inv.getEditedSection().set("perm-effects." + last, null);
|
||||||
if (set.size() <= 1)
|
if (set.size() <= 1)
|
||||||
inv.getEditedSection().set("perm-effects", null);
|
inv.getEditedSection().set("perm-effects", null);
|
||||||
inv.registerTemplateEdition();
|
inv.registerTemplateEdition();
|
||||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed " + last.substring(0, 1).toUpperCase()
|
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed " + last.substring(0, 1).toUpperCase()
|
||||||
+ last.substring(1).toLowerCase() + ".");
|
+ last.substring(1).toLowerCase() + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
||||||
String[] split = message.split(" ");
|
String[] split = message.split(" ");
|
||||||
Validate.isTrue(split.length >= 2, "Use this format: {Effect Name} {Effect Amplifier Numeric Formula}. Example: 'speed 1 0.3' "
|
Validate.isTrue(split.length >= 2, "Use this format: {Effect Name} {Effect Amplifier Numeric Formula}. Example: 'speed 1 0.3' "
|
||||||
+ "stands for Speed 1, plus 0.3 level per item level (rounded up to lower int)");
|
+ "stands for Speed 1, plus 0.3 level per item level (rounded up to lower int)");
|
||||||
|
|
||||||
PotionEffectType effect = PotionEffectType.getByName(split[0].replace("-", "_"));
|
PotionEffectType effect = PotionEffectType.getByName(split[0].replace("-", "_"));
|
||||||
Validate.notNull(effect, split[0] + " is not a valid potion effect. All potion effects can be found here: "
|
Validate.notNull(effect, split[0] + " is not a valid potion effect. All potion effects can be found here: "
|
||||||
+ "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html");
|
+ "https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html");
|
||||||
|
|
||||||
NumericStatFormula formula = new NumericStatFormula(message.substring(message.indexOf(" ") + 1));
|
NumericStatFormula formula = new NumericStatFormula(message.substring(message.indexOf(" ") + 1));
|
||||||
formula.fillConfigurationSection(inv.getEditedSection(), "perm-effects." + effect.getName());
|
formula.fillConfigurationSection(inv.getEditedSection(), "perm-effects." + effect.getName());
|
||||||
inv.registerTemplateEdition();
|
inv.registerTemplateEdition();
|
||||||
inv.getPlayer().sendMessage(
|
inv.getPlayer().sendMessage(
|
||||||
MMOItems.plugin.getPrefix() + ChatColor.GOLD + effect.getName() + " " + formula + ChatColor.GRAY + " successfully added.");
|
MMOItems.plugin.getPrefix() + ChatColor.GOLD + effect.getName() + " " + formula + ChatColor.GRAY + " successfully added.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenDisplayed(List<String> lore, Optional<RandomPotionEffectListData> statData) {
|
public void whenDisplayed(List<String> lore, Optional<RandomPotionEffectListData> statData) {
|
||||||
if (statData.isPresent()) {
|
if (statData.isPresent()) {
|
||||||
lore.add(ChatColor.GRAY + "Current Value:");
|
lore.add(ChatColor.GRAY + "Current Value:");
|
||||||
RandomPotionEffectListData data = statData.get();
|
RandomPotionEffectListData data = statData.get();
|
||||||
for (RandomPotionEffectData effect : data.getEffects())
|
for (RandomPotionEffectData effect : data.getEffects())
|
||||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().replace("_", " ").toLowerCase())
|
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().replace("_", " ").toLowerCase())
|
||||||
+ " " + effect.getAmplifier().toString());
|
+ " " + effect.getAmplifier().toString());
|
||||||
|
|
||||||
} else
|
} else
|
||||||
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
|
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
|
||||||
|
|
||||||
lore.add("");
|
lore.add("");
|
||||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to add an effect.");
|
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to add an effect.");
|
||||||
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the last effect.");
|
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the last effect.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public PotionEffectListData getClearStatData() {
|
public PotionEffectListData getClearStatData() {
|
||||||
return new PotionEffectListData();
|
return new PotionEffectListData();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
|
||||||
List<String> lore = new ArrayList<>();
|
List<String> lore = new ArrayList<>();
|
||||||
|
|
||||||
String permEffectFormat = ItemStat.translate("perm-effect");
|
String permEffectFormat = getGeneralStatFormat();
|
||||||
((PotionEffectListData) data).getEffects().forEach(effect -> {
|
data.getEffects().forEach(effect -> lore.add(permEffectFormat
|
||||||
lore.add(permEffectFormat.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType()) + " " + MMOUtils.intToRoman(effect.getLevel())));
|
.replace("{effect}", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
|
||||||
});
|
+ " " + MMOUtils.intToRoman(effect.getLevel()))));
|
||||||
|
|
||||||
item.getLore().insert("perm-effects", lore);
|
item.getLore().insert("perm-effects", lore);
|
||||||
|
|
||||||
// Yes
|
// Yes
|
||||||
item.addItemTag(getAppliedNBT(data));
|
item.addItemTag(getAppliedNBT(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@Override
|
||||||
@Override
|
public String getLegacyTranslationPath() {
|
||||||
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {
|
return "perm-effect";
|
||||||
|
}
|
||||||
|
|
||||||
// Them tags
|
@NotNull
|
||||||
ArrayList<ItemTag> ret = new ArrayList<>();
|
@Override
|
||||||
JsonObject object = new JsonObject();
|
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {
|
||||||
|
|
||||||
// For every registered effect
|
// Them tags
|
||||||
for (PotionEffectData effect : data.getEffects()) {
|
ArrayList<ItemTag> ret = new ArrayList<>();
|
||||||
|
JsonObject object = new JsonObject();
|
||||||
|
|
||||||
// Add Properies
|
// For every registered effect
|
||||||
object.addProperty(effect.getType().getName(), effect.getLevel());
|
for (PotionEffectData effect : data.getEffects()) {
|
||||||
}
|
|
||||||
|
|
||||||
// Add onto the list
|
// Add Properies
|
||||||
ret.add(new ItemTag(getNBTPath(), object.toString()));
|
object.addProperty(effect.getType().getName(), effect.getLevel());
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
// Add onto the list
|
||||||
}
|
ret.add(new ItemTag(getNBTPath(), object.toString()));
|
||||||
|
|
||||||
@Override
|
return ret;
|
||||||
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
}
|
||||||
|
|
||||||
// Find tags
|
@Override
|
||||||
ArrayList<ItemTag> rTag = new ArrayList<>();
|
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
|
||||||
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
|
||||||
rTag.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
|
||||||
|
|
||||||
// Build Data
|
// Find tags
|
||||||
StatData data = getLoadedNBT(rTag);
|
ArrayList<ItemTag> rTag = new ArrayList<>();
|
||||||
|
if (mmoitem.getNBT().hasTag(getNBTPath()))
|
||||||
|
rTag.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
|
||||||
|
|
||||||
// Add data, if valid
|
// Build Data
|
||||||
if (data != null) { mmoitem.setData(this, data); }
|
StatData data = getLoadedNBT(rTag);
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
// Add data, if valid
|
||||||
@Override
|
if (data != null) {
|
||||||
public PotionEffectListData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
|
mmoitem.setData(this, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Find tag
|
@Nullable
|
||||||
ItemTag oTag = ItemTag.getTagAtPath(getNBTPath(), storedTags);
|
@Override
|
||||||
|
public PotionEffectListData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
|
||||||
|
|
||||||
// Well
|
// Find tag
|
||||||
if (oTag != null) {
|
ItemTag oTag = ItemTag.getTagAtPath(getNBTPath(), storedTags);
|
||||||
|
|
||||||
// Parse as Json
|
// Well
|
||||||
try {
|
if (oTag != null) {
|
||||||
|
|
||||||
// A new effect
|
// Parse as Json
|
||||||
PotionEffectListData effects = new PotionEffectListData();
|
try {
|
||||||
|
|
||||||
JsonElement element = new JsonParser().parse((String) oTag.getValue());
|
// A new effect
|
||||||
|
PotionEffectListData effects = new PotionEffectListData();
|
||||||
|
|
||||||
element.getAsJsonObject().entrySet().forEach(entry ->
|
JsonElement element = new JsonParser().parse((String) oTag.getValue());
|
||||||
effects.add(new PotionEffectData(PotionEffectType.getByName(entry.getKey()), entry.getValue().getAsInt())));
|
|
||||||
|
|
||||||
// Thats it
|
element.getAsJsonObject().entrySet().forEach(entry ->
|
||||||
return effects;
|
effects.add(new PotionEffectData(PotionEffectType.getByName(entry.getKey()), entry.getValue().getAsInt())));
|
||||||
|
|
||||||
} catch (JsonSyntaxException |IllegalStateException exception) {
|
// Thats it
|
||||||
/*
|
return effects;
|
||||||
* OLD ITEM WHICH MUST BE UPDATED.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Noep
|
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||||
return null;
|
/*
|
||||||
}
|
* OLD ITEM WHICH MUST BE UPDATED.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Noep
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
|||||||
|
|
||||||
// Lore Management
|
// Lore Management
|
||||||
int lvl = (int) data.getValue();
|
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
|
// Insert NBT
|
||||||
item.addItemTag(getAppliedNBT(data));
|
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 {
|
public void whenPreviewed(@NotNull ItemStackBuilder item, @NotNull DoubleData currentData, @NotNull NumericStatFormula templateData) throws IllegalArgumentException {
|
||||||
|
|
||||||
// Get Value
|
// Get Value
|
||||||
double techMinimum = ((NumericStatFormula) templateData).calculate(0, -2.5);
|
double techMinimum = templateData.calculate(0, -2.5);
|
||||||
double techMaximum = ((NumericStatFormula) templateData).calculate(0, 2.5);
|
double techMaximum = templateData.calculate(0, 2.5);
|
||||||
|
|
||||||
// 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 (techMaximum < 0 && !handleNegativeStats()) {
|
if (techMaximum < 0 && !handleNegativeStats()) {
|
||||||
@ -61,11 +61,11 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
|||||||
if (techMinimum < 0 && !handleNegativeStats()) {
|
if (techMinimum < 0 && !handleNegativeStats()) {
|
||||||
techMinimum = 0;
|
techMinimum = 0;
|
||||||
}
|
}
|
||||||
if (techMinimum < ((NumericStatFormula) templateData).getBase() - ((NumericStatFormula) templateData).getMaxSpread()) {
|
if (techMinimum < templateData.getBase() - templateData.getMaxSpread()) {
|
||||||
techMinimum = ((NumericStatFormula) templateData).getBase() - ((NumericStatFormula) templateData).getMaxSpread();
|
techMinimum = templateData.getBase() - templateData.getMaxSpread();
|
||||||
}
|
}
|
||||||
if (techMaximum > ((NumericStatFormula) templateData).getBase() + ((NumericStatFormula) templateData).getMaxSpread()) {
|
if (techMaximum > templateData.getBase() + templateData.getMaxSpread()) {
|
||||||
techMaximum = ((NumericStatFormula) templateData).getBase() + ((NumericStatFormula) templateData).getMaxSpread();
|
techMaximum = templateData.getBase() + templateData.getMaxSpread();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add NBT Path
|
// Add NBT Path
|
||||||
@ -82,7 +82,7 @@ public class RequiredLevel extends DoubleStat implements ItemRestriction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Just display normally
|
// 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
|
// Make and bake
|
||||||
ArrayList<ItemTag> ret = new ArrayList<>();
|
ArrayList<ItemTag> ret = new ArrayList<>();
|
||||||
ret.add(new ItemTag(getNBTPath(), ((DoubleData) data).getValue()));
|
ret.add(new ItemTag(getNBTPath(), data.getValue()));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class UpgradeStat extends ItemStat<UpgradeData, UpgradeData> implements C
|
|||||||
// Show in lore
|
// Show in lore
|
||||||
if (data.getMaxUpgrades() > 0)
|
if (data.getMaxUpgrades() > 0)
|
||||||
item.getLore().insert(getPath(),
|
item.getLore().insert(getPath(),
|
||||||
MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("{value}", String.valueOf(data.getMaxUpgrades())));
|
getGeneralStatFormat().replace("{value}", String.valueOf(data.getMaxUpgrades())));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
@ -52,7 +52,7 @@ public class BooleanStat extends ItemStat<RandomBooleanData, BooleanData> {
|
|||||||
item.addItemTag(getAppliedNBT(data));
|
item.addItemTag(getAppliedNBT(data));
|
||||||
|
|
||||||
// Show in lore
|
// 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.random.RandomStatData;
|
||||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
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);
|
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
|
@NotNull
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@ -166,7 +187,7 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
|
|||||||
/**
|
/**
|
||||||
* @return The stat ID
|
* @return The stat ID
|
||||||
* @deprecated Use getId() instead. Type is no longer an util since they can
|
* @deprecated Use getId() instead. Type is no longer an util since they can
|
||||||
* now be registered from external plugins
|
* now be registered from external plugins
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@NotNull
|
@NotNull
|
||||||
@ -184,8 +205,8 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The NBT path used by the stat to save data in an item's NBTTags.
|
* @return The NBT path used by the stat to save data in an item's NBTTags.
|
||||||
* The format is 'MMOITEMS_' followed by the stat name in capital
|
* The format is 'MMOITEMS_' followed by the stat name in capital
|
||||||
* letters only using _
|
* letters only using _
|
||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public String getNBTPath() {
|
public String getNBTPath() {
|
||||||
@ -228,10 +249,9 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String formatNumericStat(double value, String... replace) {
|
public String formatNumericStat(double value, String... replace) {
|
||||||
String format = MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("<plus>", value > 0 ? "+" : "");
|
String format = getGeneralStatFormat().replace("<plus>", value > 0 ? "+" : "");
|
||||||
for (int j = 0; j < replace.length; j += 2) {
|
for (int j = 0; j < replace.length; j += 2)
|
||||||
format = format.replace(replace[j], replace[j + 1]);
|
format = format.replace(replace[j], replace[j + 1]);
|
||||||
}
|
|
||||||
return format;
|
return format;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,9 +268,9 @@ public abstract class ItemStat<R extends RandomStatData<S>, S extends StatData>
|
|||||||
return Objects.hash(id);
|
return Objects.hash(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public static String translate(String path) {
|
public static String translate(String path) {
|
||||||
String str = MMOItems.plugin.getLanguage().getStatFormat(path);
|
return MMOItems.plugin.getLanguage().getStatFormat(path);
|
||||||
return str == null ? "<TranslationNotFound:" + path + ">" : str;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,8 +39,8 @@ public abstract class RequiredLevelStat extends DoubleStat implements ItemRestri
|
|||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull DoubleData data) {
|
||||||
|
|
||||||
// Lore Management
|
// Lore Management
|
||||||
int lvl = (int) ((DoubleData) data).getValue();
|
int lvl = (int) data.getValue();
|
||||||
String format = MMOItems.plugin.getLanguage().getStatFormat(getPath()).replace("{value}", String.valueOf(lvl));
|
String format = getGeneralStatFormat().replace("{value}", String.valueOf(lvl));
|
||||||
item.getLore().insert(getPath(), format);
|
item.getLore().insert(getPath(), format);
|
||||||
|
|
||||||
// Insert NBT
|
// Insert NBT
|
||||||
|
@ -42,92 +42,16 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
|
|||||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringListData data) {
|
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringListData data) {
|
||||||
|
|
||||||
// Empty stuff
|
// Empty stuff
|
||||||
if (!(data instanceof StringListData)) { return; }
|
if (!(data instanceof StringListData)) return;
|
||||||
if (data.getList().size() == 0) { return; }
|
if (data.getList().size() == 0) return;
|
||||||
|
|
||||||
// Chop
|
// Chop
|
||||||
final String joined = String.join(", ", data.getList());
|
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);
|
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
|
// Display in lore
|
||||||
// item.getLore().insert(getPath(), SilentNumbers.chop(finalStr, 50, col.toString()));
|
// item.getLore().insert(getPath(), SilentNumbers.chop(finalStr, 50, col.toString()));
|
||||||
item.getLore().insert(getPath(), finalStr);
|
item.getLore().insert(getPath(), finalStr);
|
||||||
item.addItemTag(getAppliedNBT(data));
|
item.addItemTag(getAppliedNBT(data));
|
||||||
}
|
}
|
||||||
@ -140,7 +64,7 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
|
|||||||
JsonArray array = new JsonArray();
|
JsonArray array = new JsonArray();
|
||||||
|
|
||||||
// For every list entry
|
// For every list entry
|
||||||
for (String str : ((StringListData) data).getList()) {
|
for (String str : data.getList()) {
|
||||||
|
|
||||||
// Add to the array as-is
|
// Add to the array as-is
|
||||||
array.add(str);
|
array.add(str);
|
||||||
@ -196,7 +120,9 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
|
|||||||
StatData data = getLoadedNBT(relevantTags);
|
StatData data = getLoadedNBT(relevantTags);
|
||||||
|
|
||||||
// Valid?
|
// Valid?
|
||||||
if (data != null) { mmoitem.setData(this, data); }
|
if (data != null) {
|
||||||
|
mmoitem.setData(this, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@ -216,7 +142,7 @@ public class StringListStat extends ItemStat<StringListData, StringListData> {
|
|||||||
// Create String List Data
|
// Create String List Data
|
||||||
return new StringListData(array);
|
return new StringListData(array);
|
||||||
|
|
||||||
} catch (JsonSyntaxException |IllegalStateException exception) {
|
} catch (JsonSyntaxException | IllegalStateException exception) {
|
||||||
/*
|
/*
|
||||||
* OLD ITEM WHICH MUST BE UPDATED.
|
* 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}%'
|
projectile-damage: '&3 &7■ Projectile Damage: &f<plus>{value}%'
|
||||||
faction-damage-undead: '&3 &7■ Undead Faction Damage: &f<plus>{value}%'
|
faction-damage-undead: '&3 &7■ Undead Faction Damage: &f<plus>{value}%'
|
||||||
|
|
||||||
# Abilities
|
# Abilities (changed in MI 6.9.5)
|
||||||
ability-format: '&a>&8| &7{trigger} &8|&e|&8| &7&l{ability}'
|
ability:
|
||||||
ability-modifier: ' &3>&8|&7 {modifier}&8: &f{value}'
|
general-format: "&f䀐 &7{trigger} &8|&e|&8| &7&l{ability}\n"
|
||||||
ability-splitter: '&8'
|
modifier-foreach: "&7{modifier}&8: &f{value}"
|
||||||
|
modifier-splitter: " &8&l|&7 "
|
||||||
|
ability-splitter:
|
||||||
|
enabled: true
|
||||||
|
format: ''
|
||||||
|
|
||||||
# Armor Stats
|
# Armor Stats
|
||||||
block-power: '&3 &7■ Block Power: &f<plus>{value}%'
|
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}%'
|
additional-experience-woodcutting: '&7■ Additional Woodcutting Experience: &f<plus>{value}%'
|
||||||
|
|
||||||
# Extra Options
|
# Extra Options
|
||||||
perm-effect: '&3 &7■ Permanent &f{effect}'
|
perm-effects: '&3 &7■ Permanent &f{effect}'
|
||||||
command: '&3 &7■ Command: &f{format} &3 &7(&f{cooldown}&3 &7s)'
|
commands: '&3 &7■ Command: &f{format} &3 &7(&f{cooldown}&3 &7s)'
|
||||||
item-cooldown: '&3 &7■ &f{value}&3 &7s Cooldown'
|
item-cooldown: '&3 &7■ &f{value}&3 &7s Cooldown'
|
||||||
arrow-potion-effects: '&3 &7■ Arrow Effect: &f{effect}'
|
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-saturation: '&3 &7■ Restores &f{value} &7Saturation'
|
||||||
restore-mana: '&3 &7■ Restores &f{value} &7Mana'
|
restore-mana: '&3 &7■ Restores &f{value} &7Mana'
|
||||||
restore-stamina: '&3 &7■ Restores &f{value} &7Stamina'
|
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: '&3 &7■ Repair: &f{value}'
|
||||||
repair-percent: '&3 &7■ Repair: &f{value}%'
|
repair-percent: '&3 &7■ Repair: &f{value}%'
|
||||||
can-identify: '&3 &7■ Can identify items.'
|
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'
|
max-consume: '&3 &7■ &f{value} &7Uses Left'
|
||||||
|
|
||||||
# Gem Stones
|
# Gem Stones
|
||||||
empty-gem-socket: '&a◆ Empty {name} Gem Socket'
|
gem-sockets:
|
||||||
filled-gem-socket: '&a◆ {name}'
|
empty-gem-socket: '&a◆ Empty {name} Gem Socket'
|
||||||
when-applied: '&aWhen Applied:'
|
filled-gem-socket: '&a◆ {name}'
|
||||||
gem-stone-lore: '&8&l[&2&l*&8&l] &aDrag onto an item &7to apply!'
|
|
||||||
|
|
||||||
# Soulbound
|
# Soulbound
|
||||||
soulbinding-chance: '&3 &7■ Has a &a{value}% &7chance to bind your item.'
|
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'
|
autosmelt: '&3 &7■ &fAutosmelt'
|
||||||
bouncing-crack: '&3 &7■ &fBouncing Crack'
|
bouncing-crack: '&3 &7■ &fBouncing Crack'
|
||||||
pickaxe-power: '&3 &7■ &fPickaxe Power: &a{value}'
|
pickaxe-power: '&3 &7■ &fPickaxe Power: &a{value}'
|
||||||
durability: '&7Durability: {current} / {max}'
|
item-damage: '&7Durability: {current} / {max}'
|
||||||
|
|
||||||
# General
|
# General
|
||||||
item-type: '&c{type}'
|
|
||||||
tier: '&3 &7Tier: {value}'
|
tier: '&3 &7Tier: {value}'
|
||||||
required-class: '&3 &7{value} Item'
|
required-class: '&3 &7{value} Item'
|
||||||
required-level: '&eRequires Lvl {value}'
|
required-level: '&eRequires Lvl {value}'
|
||||||
@ -140,12 +142,13 @@ profession-smelting: '&eSmelting Level: &c{value}'
|
|||||||
profession-smithing: '&eSmithing Level: &c{value}'
|
profession-smithing: '&eSmithing Level: &c{value}'
|
||||||
profession-woodcutting: '&eWoodcutting Level: &c{value}'
|
profession-woodcutting: '&eWoodcutting Level: &c{value}'
|
||||||
|
|
||||||
# Elemental Stat Format
|
# Elemental Stat Formats
|
||||||
elemental-damage: '{color}{icon}&7 {value} {element} Damage'
|
element:
|
||||||
elemental-damage-percent: '{color}{icon}&7 +{value}% {element} Damage'
|
damage: '{color}{icon}&7 {value} {element} Damage'
|
||||||
elemental-defense: '{color}{icon}&7 {value} {element} Defense'
|
damage-percent: '{color}{icon}&7 +{value}% {element} Damage'
|
||||||
elemental-defense-percent: '{color}{icon}&7 +{value}% {element} Defense'
|
defense: '{color}{icon}&7 {value} {element} Defense'
|
||||||
elemental-weakness: '{color}{icon}&7 {value}% {element} Weakness'
|
defense-percent: '{color}{icon}&7 +{value}% {element} Defense'
|
||||||
|
weakness: '{color}{icon}&7 {value}% {element} Weakness'
|
||||||
|
|
||||||
# Custom stats
|
# Custom stats
|
||||||
custom-myluck: '&3 &7■ Luck: &f<plus>{value}'
|
custom-myluck: '&3 &7■ Luck: &f<plus>{value}'
|
Loading…
Reference in New Issue
Block a user