mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-01-18 08:52:07 +01:00
Stat for tooltips
This commit is contained in:
parent
4b759020f3
commit
d2033b8030
@ -25,6 +25,7 @@ public class ItemStats {
|
||||
LORE = new Lore(),
|
||||
NBT_TAGS = new NBTTags(),
|
||||
LORE_FORMAT = new LoreFormat(),
|
||||
TOOLTIP = new TooltipStat(),
|
||||
|
||||
// Block Specific Stats
|
||||
BLOCK_ID = new BlockID(),
|
||||
|
@ -12,7 +12,6 @@ import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.Indyuce.mmoitems.comp.MMOItemsMetrics;
|
||||
@ -66,7 +65,7 @@ public class MMOItems extends JavaPlugin {
|
||||
|
||||
private final PluginUpdateManager pluginUpdateManager = new PluginUpdateManager();
|
||||
private final CraftingManager stationRecipeManager = new CraftingManager();
|
||||
private final LoreFormatManager formatManager = new LoreFormatManager();
|
||||
private final LoreFormatManager loreManager = new LoreFormatManager();
|
||||
private final TemplateManager templateManager = new TemplateManager();
|
||||
private final SkillManager skillManager = new SkillManager();
|
||||
private final EntityManager entityManager = new EntityManager();
|
||||
@ -166,7 +165,7 @@ public class MMOItems extends JavaPlugin {
|
||||
* can be fully loaded
|
||||
*/
|
||||
statManager.loadElements();
|
||||
formatManager.reload();
|
||||
loreManager.reload();
|
||||
tierManager = new TierManager();
|
||||
setManager = new SetManager();
|
||||
upgradeManager = new UpgradeManager();
|
||||
@ -491,8 +490,13 @@ public class MMOItems extends JavaPlugin {
|
||||
return templateManager;
|
||||
}
|
||||
|
||||
public LoreFormatManager getLore(){
|
||||
return loreManager;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public LoreFormatManager getFormats() {
|
||||
return formatManager;
|
||||
return getLore();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
|
@ -1,11 +1,10 @@
|
||||
package net.Indyuce.mmoitems.api;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
|
||||
public enum CustomSound {
|
||||
ON_ATTACK(Material.IRON_SWORD, 19, "Plays when attacking an entity."),
|
||||
ON_RIGHT_CLICK(Material.STONE_HOE, 22, "Plays when item is right-clicked."),
|
||||
@ -33,7 +32,7 @@ public enum CustomSound {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return MMOUtils.caseOnWords(name().toLowerCase().replace('_', ' '));
|
||||
return UtilityMethods.caseOnWords(name().toLowerCase().replace('_', ' '));
|
||||
}
|
||||
|
||||
public String[] getLore() {
|
||||
|
@ -5,6 +5,7 @@ import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.droptable.DropTable;
|
||||
import net.Indyuce.mmoitems.tooltip.TooltipTexture;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -23,6 +24,9 @@ public class ItemTier {
|
||||
private final String unparsedName;
|
||||
private final UnidentificationInfo unidentificationInfo;
|
||||
|
||||
@Nullable
|
||||
private final TooltipTexture tooltip;
|
||||
|
||||
// Deconstruction
|
||||
@Nullable
|
||||
private final DropTable deconstructTable;
|
||||
@ -65,6 +69,8 @@ public class ItemTier {
|
||||
glowColor = null;
|
||||
}
|
||||
|
||||
tooltip = config.isConfigurationSection("tooltip") ? new TooltipTexture(config.getConfigurationSection("tooltip")) : null;
|
||||
|
||||
// What are the chances?
|
||||
chance = config.getDouble("generation.chance");
|
||||
capacity = config.contains("generation.capacity") ? new NumericStatFormula(config.get("generation.capacity")) : null;
|
||||
@ -89,6 +95,11 @@ public class ItemTier {
|
||||
return deconstructTable;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TooltipTexture getTooltip() {
|
||||
return tooltip;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Reads the deconstruction drop table. This may return a list
|
||||
* containing multiple items and they should all be added to the
|
||||
|
@ -6,10 +6,10 @@ import io.lumine.mythic.lib.damage.AttackMetadata;
|
||||
import io.lumine.mythic.lib.damage.DamageType;
|
||||
import io.lumine.mythic.lib.version.VersionSound;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
@ -141,7 +141,7 @@ public enum TypeSet {
|
||||
private TypeSet(SetAttackHandler attackHandler) {
|
||||
this.attackHandler = attackHandler;
|
||||
|
||||
this.name = MMOUtils.caseOnWords(name().toLowerCase());
|
||||
this.name = UtilityMethods.caseOnWords(name().toLowerCase());
|
||||
}
|
||||
|
||||
public boolean hasAttackEffect() {
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmoitems.api.crafting.ingredient;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.api.util.ui.QuickNumberRange;
|
||||
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
|
||||
@ -122,7 +123,7 @@ public class MMOItemIngredient extends Ingredient<MMOItemPlayerIngredient> {
|
||||
|
||||
// Try and take the material name
|
||||
else if (template.getBaseItemData().containsKey(ItemStats.MATERIAL))
|
||||
name = MMOUtils.caseOnWords(((MaterialData) template.getBaseItemData().get(ItemStats.MATERIAL)).getMaterial().name().toLowerCase().replace("_", " "));
|
||||
name = UtilityMethods.caseOnWords(((MaterialData) template.getBaseItemData().get(ItemStats.MATERIAL)).getMaterial().name().toLowerCase().replace("_", " "));
|
||||
|
||||
// Ultra rare case to avoid a NPE
|
||||
else name = "Unrecognized Item";
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmoitems.api.crafting.ingredient;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.mythic.lib.api.crafting.uifilters.VanillaUIFilter;
|
||||
import io.lumine.mythic.lib.api.crafting.uimanager.ProvidedUIFilter;
|
||||
@ -92,7 +93,7 @@ public class VanillaIngredient extends Ingredient<VanillaPlayerIngredient> {
|
||||
filter.setAmount(getAmount());
|
||||
|
||||
// Display is the name of the material, or whatever specified in the config.
|
||||
display = config.getString("display", MMOUtils.caseOnWords(material.toString().toLowerCase().replace("_", " ")));
|
||||
display = config.getString("display", UtilityMethods.caseOnWords(material.toString().toLowerCase().replace("_", " ")));
|
||||
//VING//MMOItems.log("\u00a78VING\u00a73 RD\u00a77 Determined\u00a73 " + material.toString());
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmoitems.api.item.build;
|
||||
|
||||
import com.google.gson.JsonArray;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.util.AdventureUtils;
|
||||
@ -11,9 +12,7 @@ import net.Indyuce.mmoitems.api.event.GenerateLoreEvent;
|
||||
import net.Indyuce.mmoitems.api.event.ItemBuildEvent;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.stat.data.MaterialData;
|
||||
import net.Indyuce.mmoitems.stat.data.StringListData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.Indyuce.mmoitems.stat.type.Previewable;
|
||||
import net.Indyuce.mmoitems.stat.type.StatHistory;
|
||||
@ -211,25 +210,22 @@ public class ItemStackBuilder {
|
||||
builtMMOItem.getStats().contains(ItemStats.DISPLAYED_TYPE) ? builtMMOItem.getData(ItemStats.DISPLAYED_TYPE)
|
||||
.toString() : builtMMOItem.getType().getName()));
|
||||
|
||||
// Calculate extra item lore with placeholders
|
||||
if (builtMMOItem.hasData(ItemStats.LORE)) {
|
||||
List<String> parsed = new ArrayList<>();
|
||||
((StringListData) builtMMOItem.getData(ItemStats.LORE)).getList().forEach(str -> parsed.add(lore.applySpecialPlaceholders(str)));
|
||||
lore.insert("lore", parsed);
|
||||
}
|
||||
|
||||
// Calculate and apply item lore
|
||||
List<String> unparsedLore = lore.getLore();
|
||||
List<String> parsedLore = lore.build();
|
||||
|
||||
final GenerateLoreEvent event = new GenerateLoreEvent(builtMMOItem, lore, parsedLore, unparsedLore);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
AdventureUtils.setLore(meta, event.getParsedLore().stream().map(s -> ChatColor.WHITE + s).toList());
|
||||
AdventureUtils.setLore(meta, event.getParsedLore());
|
||||
if (meta.hasDisplayName()) {
|
||||
|
||||
// Apply tooltip top
|
||||
String displayName = meta.getDisplayName();
|
||||
if (lore.hasTooltip()) displayName = lore.getTooltip().getTop() + displayName;
|
||||
displayName = MythicLib.plugin.getPlaceholderParser().parse(null, displayName);
|
||||
displayName = lore.applySpecialPlaceholders(displayName);
|
||||
if (lore.hasTooltip() && lore.getTooltip().getCenteringOptions() != null && lore.getTooltip().getCenteringOptions().displayName())
|
||||
displayName = lore.getTooltip().getCenteringOptions().centerName(displayName);
|
||||
AdventureUtils.setDisplayName(meta, ChatColor.WHITE + displayName);
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,12 @@ package net.Indyuce.mmoitems.api.item.build;
|
||||
import com.google.common.collect.Lists;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.tooltip.TooltipTexture;
|
||||
import net.Indyuce.mmoitems.util.Buildable;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@ -17,31 +19,29 @@ import java.util.*;
|
||||
* - Classic placeholders are like #attack-damage# are called static placeholders.
|
||||
* - Special placeholders are {placeholder-name}, they can be used inside of
|
||||
* the item lore, the one you get with {@link net.Indyuce.mmoitems.stat.Lore}
|
||||
* - Dynamic placeholders are %placeholder-name%, they
|
||||
* are used by custom durability, consumable uses left, etc.
|
||||
* - Dynamic placeholders are %placeholder-name%, they are used by custom durability, consumable uses left, etc.
|
||||
*
|
||||
* @author indyuce
|
||||
* @author Jules
|
||||
*/
|
||||
public class LoreBuilder {
|
||||
public class LoreBuilder extends Buildable<List<String>> {
|
||||
private final List<String> lore = new ArrayList<>();
|
||||
private final List<String> end = new ArrayList<>();
|
||||
private final TooltipTexture tooltip = null;
|
||||
private final Map<String, String> placeholders = new HashMap<>();
|
||||
|
||||
private boolean built;
|
||||
private final TooltipTexture tooltip;
|
||||
|
||||
@Deprecated
|
||||
public LoreBuilder(@NotNull Collection<String> format) {
|
||||
lore.addAll(format);
|
||||
tooltip = null;
|
||||
}
|
||||
/*
|
||||
@Deprecated
|
||||
public static final TooltipTexture TEST = new TooltipTexture(new ConfigFile("tooltips").getConfig().getConfigurationSection("test"));*/
|
||||
|
||||
public LoreBuilder(@NotNull MMOItem mmoitem) {
|
||||
lore.addAll(MMOItems.plugin.getFormats().getFormat(mmoitem));
|
||||
lore.addAll(MMOItems.plugin.getLore().getFormat(mmoitem));
|
||||
tooltip = mmoitem.getTooltip();
|
||||
|
||||
// TODO load tooltip
|
||||
registerPlaceholder("type", mmoitem.getType().getName());
|
||||
final ItemTier tier = mmoitem.getTier();
|
||||
registerPlaceholder("tier", tier != null ? tier.getName() : MMOItems.plugin.getLanguage().defaultTierName);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,8 +65,7 @@ public class LoreBuilder {
|
||||
*/
|
||||
public void insert(String path, String... add) {
|
||||
int index = lore.indexOf("#" + path + "#");
|
||||
if (index < 0)
|
||||
return;
|
||||
if (index < 0) return;
|
||||
|
||||
for (int j = 0; j < add.length; j++)
|
||||
lore.add(index + 1, add[add.length - j - 1]);
|
||||
@ -83,8 +82,7 @@ public class LoreBuilder {
|
||||
*/
|
||||
public void insert(@NotNull String path, @NotNull List<String> list) {
|
||||
int index = lore.indexOf("#" + path + "#");
|
||||
if (index < 0)
|
||||
return;
|
||||
if (index < 0) return;
|
||||
|
||||
Lists.reverse(list).forEach(string -> lore.add(index + 1, string));
|
||||
lore.remove(index);
|
||||
@ -113,9 +111,21 @@ public class LoreBuilder {
|
||||
@NotNull
|
||||
public String applySpecialPlaceholders(String str) {
|
||||
|
||||
while (str.contains("{") && str.substring(str.indexOf("{")).contains("}")) {
|
||||
String holder = str.substring(str.indexOf("{") + 1, str.indexOf("}"));
|
||||
str = str.replace("{" + holder + "}", placeholders.getOrDefault(holder, "PHE"));
|
||||
int min = str.indexOf("{");
|
||||
while (min >= 0) {
|
||||
int max = str.indexOf("}", min);
|
||||
if (max < 0) break;
|
||||
|
||||
// Compute and apply placeholder
|
||||
final String placeholder = str.substring(min + 1, max);
|
||||
final String value = placeholders.get(placeholder);
|
||||
if (value != null) {
|
||||
str = str.substring(0, min) + value + str.substring(max + 1);
|
||||
max += value.length() - placeholder.length() - 2;
|
||||
}
|
||||
|
||||
// Goto next placeholder
|
||||
min = str.indexOf("{", max + 1);
|
||||
}
|
||||
|
||||
return str;
|
||||
@ -126,19 +136,20 @@ public class LoreBuilder {
|
||||
*
|
||||
* @param str String to insert at the end
|
||||
*/
|
||||
@Deprecated
|
||||
public void end(@NotNull String str) {
|
||||
end.add(str);
|
||||
}
|
||||
|
||||
private static final String LINE_PREFIX = ChatColor.WHITE.toString();
|
||||
|
||||
/**
|
||||
* @return A built item lore. This method must be called after all lines
|
||||
* have been inserted in the lore. It cleans all unused static placeholders
|
||||
* as well as lore bars. The dynamic placeholders still remain however.
|
||||
*/
|
||||
@NotNull
|
||||
public List<String> build() {
|
||||
Validate.isTrue(!built, "Lore is already built");
|
||||
built = true;
|
||||
@Override
|
||||
protected List<String> whenBuilt() {
|
||||
|
||||
/*
|
||||
* First, filtering iteration.
|
||||
@ -151,38 +162,43 @@ public class LoreBuilder {
|
||||
String line = lore.get(n);
|
||||
|
||||
// Remove unused static lore placeholders
|
||||
if (line.startsWith("#"))
|
||||
lore.remove(n);
|
||||
if (line.startsWith("#")) lore.remove(n);
|
||||
|
||||
// Remove empty stat categories
|
||||
else if (line.startsWith("{bar}") && (n == lore.size() - 1 || isBar(lore.get(n + 1))))
|
||||
lore.remove(n);
|
||||
else if (line.startsWith("{bar}") && (n == lore.size() - 1 || isBar(lore.get(n + 1)))) lore.remove(n);
|
||||
|
||||
else
|
||||
j++;
|
||||
else j++;
|
||||
}
|
||||
|
||||
// Apply extra lore lines from tooltip
|
||||
final String tooltipSuffix = tooltip != null ? tooltip.getSuffix() : "";
|
||||
if (tooltip != null) {
|
||||
lore.add(tooltip.getBottom() + tooltipSuffix);
|
||||
if (tooltip.getLoreHeader() != null) lore.addAll(0, tooltip.getLoreHeader());
|
||||
}
|
||||
|
||||
/*
|
||||
* Second and last, functional step.
|
||||
* Second and last, functional iteration.
|
||||
*
|
||||
* Steps In-order:
|
||||
* - Clear bad codes
|
||||
* - Apply placeholders and math
|
||||
* - Apply \n line breaks
|
||||
* - Apply tooltip middle/bar and suffix
|
||||
* - Ignore the N first lines of the item lore
|
||||
*/
|
||||
final String effectiveSuffix = tooltip != null ? tooltip.getSuffix() : "";
|
||||
final int linesIgnored = tooltip != null ? tooltip.getFirstIgnored() : 0;
|
||||
for (int j = 0; j < lore.size(); ) {
|
||||
String currentLine = lore.get(j);
|
||||
|
||||
// Replace bar prefixes
|
||||
final boolean bar = currentLine.startsWith("{bar}"), superbar = currentLine.startsWith("{sbar}");
|
||||
if (bar) currentLine = currentLine.substring(5);
|
||||
if (superbar) currentLine = currentLine.substring(6);
|
||||
final LineType lineType = getType(j, currentLine);
|
||||
if (lineType == LineType.BAR) currentLine = currentLine.substring(5);
|
||||
if (lineType == LineType.SUPERBAR) currentLine = currentLine.substring(6);
|
||||
|
||||
// Apply tooltip prefixes if necessary
|
||||
if (tooltip != null)
|
||||
currentLine = (bar || superbar ? tooltip.getBar() : tooltip.getMiddle()) + currentLine;
|
||||
if (tooltip != null && lineType != LineType.BOTTOM)
|
||||
currentLine = (j < linesIgnored ? tooltip.getAlignText() : (lineType.isBar() ? tooltip.getBar() : tooltip.getMiddle())) + currentLine;
|
||||
|
||||
// Deprecated math. PAPI math expansion is now recommended
|
||||
final String match = StringUtils.substringBetween(currentLine, "MATH%", "%");
|
||||
@ -191,11 +207,14 @@ public class LoreBuilder {
|
||||
// Apply PAPI placeholders
|
||||
currentLine = MythicLib.plugin.getPlaceholderParser().parse(null, currentLine);
|
||||
|
||||
// Apply internal placeholders
|
||||
currentLine = applySpecialPlaceholders(currentLine);
|
||||
|
||||
// Need to break down the line into multiple
|
||||
if (currentLine.contains("\\n")) {
|
||||
String[] split = currentLine.split("\\\\n");
|
||||
final String[] split = currentLine.split("\n", -1);
|
||||
if (split.length > 1) {
|
||||
for (int k = split.length - 1; k >= 0; k -= 1)
|
||||
lore.add(j, split[k] + effectiveSuffix);
|
||||
lore.add(j, LINE_PREFIX + split[k] + (j < linesIgnored ? "" : tooltipSuffix));
|
||||
|
||||
// Remove the old element
|
||||
lore.remove(j + split.length);
|
||||
@ -206,21 +225,38 @@ public class LoreBuilder {
|
||||
} else
|
||||
|
||||
// Simple line
|
||||
lore.set(j++, currentLine + effectiveSuffix);
|
||||
lore.set(j++, LINE_PREFIX + currentLine + tooltipSuffix);
|
||||
}
|
||||
|
||||
// Apply tooltip bottom
|
||||
if (tooltip != null) {
|
||||
lore.add(tooltip.getBottom() + effectiveSuffix);
|
||||
|
||||
// Apply tooltip lore header
|
||||
if (tooltip.getLoreHeader() != null) lore.addAll(0, tooltip.getLoreHeader());
|
||||
}
|
||||
// Center lines
|
||||
if (tooltip != null && tooltip.getCenteringOptions() != null)
|
||||
for (int j = 0; j < tooltip.getCenteringOptions().getLoreLines(); j++)
|
||||
lore.set(j, tooltip.getCenteringOptions().centerLore(j, lore.get(j)));
|
||||
|
||||
lore.addAll(end);
|
||||
return lore;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param index Current line counter
|
||||
* @param line Current line
|
||||
* @return Type of current line lore.
|
||||
*/
|
||||
@NotNull
|
||||
private LineType getType(int index, String line) {
|
||||
if (index == lore.size() - 1) return LineType.BOTTOM;
|
||||
if (line.startsWith("{bar}") || line.startsWith("{sbar}")) return LineType.BAR;
|
||||
return LineType.MIDDLE;
|
||||
}
|
||||
|
||||
private enum LineType {
|
||||
MIDDLE, BAR, SUPERBAR, BOTTOM;
|
||||
|
||||
boolean isBar() {
|
||||
return this == BAR || this == SUPERBAR;
|
||||
}
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private String evaluate(String formula) {
|
||||
try {
|
||||
|
@ -16,13 +16,13 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.Indyuce.mmoitems.stat.type.NameData;
|
||||
import net.Indyuce.mmoitems.stat.type.StatHistory;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import net.Indyuce.mmoitems.util.Buildable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class MMOItemBuilder {
|
||||
public class MMOItemBuilder extends Buildable<MMOItem> {
|
||||
private final MMOItemTemplate template;
|
||||
private final MMOItem mmoitem;
|
||||
private final int level;
|
||||
@ -30,8 +30,6 @@ public class MMOItemBuilder {
|
||||
|
||||
private double capacity;
|
||||
|
||||
boolean built = false;
|
||||
|
||||
/**
|
||||
* Name modifiers, prefixes or suffixes, with priorities. They are saved
|
||||
* because they must be applied after the modifier selection process
|
||||
@ -72,10 +70,10 @@ public class MMOItemBuilder {
|
||||
// Apply base item data
|
||||
template.getBaseItemData().forEach((stat, random) -> applyData(stat, random.randomize(this)));
|
||||
|
||||
if (tier != null)
|
||||
mmoitem.setData(ItemStats.TIER, new StringData(tier.getId()));
|
||||
if (level > 0)
|
||||
mmoitem.setData(ItemStats.ITEM_LEVEL, new DoubleData(level));
|
||||
if (tier != null) mmoitem.setData(ItemStats.TIER, new StringData(tier.getId()));
|
||||
if (level > 0) mmoitem.setData(ItemStats.ITEM_LEVEL, new DoubleData(level));
|
||||
if (tier != null && tier.getTooltip() != null && !mmoitem.hasData(ItemStats.TOOLTIP))
|
||||
mmoitem.setData(ItemStats.TOOLTIP, new StringData(tier.getTooltip().getId()));
|
||||
|
||||
// Apply modifiers from the parent node
|
||||
if (!forDisplay && template.hasModifierGroup()) template.getModifierGroup().collect(this);
|
||||
@ -114,11 +112,8 @@ public class MMOItemBuilder {
|
||||
*
|
||||
* @return Built MMOItem instance
|
||||
*/
|
||||
@NotNull
|
||||
public MMOItem build() {
|
||||
Validate.isTrue(!built, "MMOItem already built");
|
||||
built = true;
|
||||
|
||||
@Override
|
||||
protected MMOItem whenBuilt() {
|
||||
if (!nameModifiers.isEmpty()) {
|
||||
|
||||
// Get name data
|
||||
|
@ -1,63 +0,0 @@
|
||||
package net.Indyuce.mmoitems.api.item.build;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TooltipTexture {
|
||||
|
||||
@NotNull
|
||||
private final String top, middle, bottom;
|
||||
|
||||
@Nullable
|
||||
private final String bar, suffix;
|
||||
|
||||
private final List<String> loreHeader;
|
||||
|
||||
public TooltipTexture(@NotNull ConfigurationSection config) {
|
||||
final String prefix = config.getString("prefix", "");
|
||||
top = prefix + config.getString("top");
|
||||
bar = config.contains("bar") && config.get("bar") != null ? prefix + config.getString("bar") : null;
|
||||
middle = prefix + config.getString("middle");
|
||||
bottom = prefix + config.getString("bottom");
|
||||
suffix = config.getString("suffix", "");
|
||||
loreHeader = config.getStringList("lore_header");
|
||||
|
||||
Validate.notNull(top, "Tooltip top portion cannot be null");
|
||||
Validate.notNull(middle, "Tooltip middle portion cannot be null");
|
||||
Validate.notNull(bottom, "Tooltip bottom portion cannot be null");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getMiddle() {
|
||||
return middle;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getBar() {
|
||||
return bar == null ? middle : bar;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getSuffix() {
|
||||
return suffix;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getLoreHeader() {
|
||||
return loreHeader;
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.UpgradeTemplate;
|
||||
import net.Indyuce.mmoitems.api.item.ItemReference;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.tooltip.TooltipTexture;
|
||||
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
|
||||
import net.Indyuce.mmoitems.stat.Enchants;
|
||||
import net.Indyuce.mmoitems.stat.data.*;
|
||||
@ -216,15 +217,25 @@ public class MMOItem implements ItemReference {
|
||||
mergeableStatHistory.put(stat, hist);
|
||||
}
|
||||
|
||||
//region Other API
|
||||
//region Other API
|
||||
|
||||
/**
|
||||
* @return The tier of this item, if it has one.
|
||||
*/
|
||||
@Nullable
|
||||
public ItemTier getTier() {
|
||||
return hasData(ItemStats.TIER) ? MMOItems.plugin.getTiers().get(stats.get(ItemStats.TIER).toString()) : null;
|
||||
}
|
||||
/**
|
||||
* @return The tier of this item, if it has any
|
||||
*/
|
||||
@Nullable
|
||||
public ItemTier getTier() {
|
||||
final StatData found = stats.get(ItemStats.TIER);
|
||||
return found != null ? MMOItems.plugin.getTiers().get(found.toString()) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Tooltip texture of this item, if it has any
|
||||
*/
|
||||
@Nullable
|
||||
public TooltipTexture getTooltip() {
|
||||
final StatData found = stats.get(ItemStats.TOOLTIP);
|
||||
return found != null ? MMOItems.plugin.getLore().getTooltip(found.toString()) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* A MMOItem from the template only has damage
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.api.item.template;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -29,7 +30,7 @@ public class NameModifier {
|
||||
|
||||
if (object instanceof ConfigurationSection) {
|
||||
ConfigurationSection config = (ConfigurationSection) object;
|
||||
Validate.isTrue(config.contains("format"), MMOUtils.caseOnWords(type.name().toLowerCase()) + " format cannot be null");
|
||||
Validate.isTrue(config.contains("format"), UtilityMethods.caseOnWords(type.name().toLowerCase()) + " format cannot be null");
|
||||
format = config.get("format").toString();
|
||||
priority = config.getInt("priority");
|
||||
return;
|
||||
|
@ -62,7 +62,7 @@ public class ReloadCommandTreeNode extends CommandTreeNode {
|
||||
MMOItems.plugin.getWorldGen().reload();
|
||||
MMOItems.plugin.getCustomBlocks().reload();
|
||||
MMOItems.plugin.getLayouts().reload();
|
||||
MMOItems.plugin.getFormats().reload();
|
||||
MMOItems.plugin.getLore().reload();
|
||||
MMOItems.plugin.getTemplates().reload();
|
||||
MMOItems.plugin.getStats().reload(true);
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + MMOItems.plugin.getName() + " "
|
||||
|
@ -1,23 +1,24 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import io.lumine.mythic.lib.command.api.CommandTreeNode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import io.lumine.mythic.lib.command.api.CommandTreeNode;
|
||||
|
||||
public class DebugCommandTreeNode extends CommandTreeNode {
|
||||
public DebugCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "debug");
|
||||
public DebugCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "debug");
|
||||
|
||||
addChild(new CheckStatCommandTreeNode(this));
|
||||
addChild(new CheckAttributeCommandTreeNode(this));
|
||||
addChild(new CheckTagCommandTreeNode(this));
|
||||
addChild(new SetTagCommandTreeNode(this));
|
||||
addChild(new CheckTagsCommandTreeNode(this));
|
||||
addChild(new InfoCommandTreeNode(this));
|
||||
}
|
||||
addChild(new CheckStatCommandTreeNode(this));
|
||||
addChild(new CheckAttributeCommandTreeNode(this));
|
||||
addChild(new CheckTagCommandTreeNode(this));
|
||||
addChild(new SetTagCommandTreeNode(this));
|
||||
addChild(new CheckTagsCommandTreeNode(this));
|
||||
addChild(new InfoCommandTreeNode(this));
|
||||
addChild(new HealCommandTreeNode(this));
|
||||
addChild(new TestCommandTreeNode(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
return CommandResult.THROW_USAGE;
|
||||
}
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
return CommandResult.THROW_USAGE;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,34 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems.debug;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.command.api.CommandTreeNode;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TestCommandTreeNode extends CommandTreeNode {
|
||||
public TestCommandTreeNode(CommandTreeNode parent) {
|
||||
super(parent, "test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandResult execute(CommandSender sender, String[] args) {
|
||||
|
||||
ItemStack stack = new ItemStack(Material.DIAMOND);
|
||||
ItemMeta meta = stack.getItemMeta();
|
||||
List<String> lore = new ArrayList<>();
|
||||
for (int i = 0; i < 30; i++) lore.add(ChatColor.WHITE + "\u0274" + UtilityMethods.getFontSpace(i) + "\u0274" + " -> " + i);
|
||||
meta.setLore(lore);
|
||||
stack.setItemMeta(meta);
|
||||
|
||||
((Player) sender).getInventory().addItem(stack);
|
||||
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
}
|
@ -21,116 +21,119 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MMOItemsPlaceholders extends PlaceholderExpansion {
|
||||
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "Indyuce";
|
||||
}
|
||||
@Override
|
||||
public String getAuthor() {
|
||||
return "Indyuce";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "mmoitems";
|
||||
}
|
||||
@Override
|
||||
public String getIdentifier() {
|
||||
return "mmoitems";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return MMOItems.plugin.getDescription().getVersion();
|
||||
}
|
||||
@Override
|
||||
public String getVersion() {
|
||||
return MMOItems.plugin.getDescription().getVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Because this is an internal class, you must override this method to let
|
||||
* PlaceholderAPI know to not unregister your expansion class when
|
||||
* PlaceholderAPI is reloaded
|
||||
*
|
||||
* @return true to persist through reloads
|
||||
*/
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* Because this is an internal class, you must override this method to let
|
||||
* PlaceholderAPI know to not unregister your expansion class when
|
||||
* PlaceholderAPI is reloaded
|
||||
*
|
||||
* @return true to persist through reloads
|
||||
*/
|
||||
@Override
|
||||
public boolean persist() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
|
||||
// registering before identifier.startsWith("stat_") to prevent issues
|
||||
// i don't register it in the starts with condition because it will mess
|
||||
// with substring
|
||||
if (identifier.equals("stat_defense_percent")) {
|
||||
final double defenseStat = MMOPlayerData.get(player).getStatMap().getStat("DEFENSE");
|
||||
final double damageReduction = 100 - new DefenseFormula().getAppliedDamage(defenseStat, 100);
|
||||
return MythicLib.plugin.getMMOConfig().decimal.format(damageReduction);
|
||||
}
|
||||
@Override
|
||||
public String onRequest(@Nullable OfflinePlayer player, @NotNull String identifier) {
|
||||
|
||||
if (identifier.startsWith("stat_")) {
|
||||
final String stat = UtilityMethods.enumName(identifier.substring(5));
|
||||
return StatManager.format(stat, MMOPlayerData.get(player));
|
||||
}
|
||||
|
||||
if (identifier.startsWith("ability_cd_"))
|
||||
return MythicLib.plugin.getMMOConfig().decimal.format(MMOPlayerData.get(player).getCooldownMap().getCooldown("skill_" + identifier.substring(11)));
|
||||
|
||||
if(identifier.startsWith("type_")) {
|
||||
String t = identifier.substring(5, identifier.lastIndexOf("_")).toUpperCase();
|
||||
if(!MMOItems.plugin.getTypes().has(t)) return "Invalid type";
|
||||
Type type = Type.get(t);
|
||||
String pholder = identifier.substring(6 + t.length()).toLowerCase();
|
||||
if ("total".equals(pholder))
|
||||
return "" + MMOItems.plugin.getTemplates().getTemplates(type).size();
|
||||
return type.getName();
|
||||
if (identifier.startsWith("type_")) {
|
||||
String t = identifier.substring(5, identifier.lastIndexOf("_")).toUpperCase();
|
||||
if (!MMOItems.plugin.getTypes().has(t)) return "Invalid type";
|
||||
Type type = Type.get(t);
|
||||
String pholder = identifier.substring(6 + t.length()).toLowerCase();
|
||||
if ("total".equals(pholder))
|
||||
return "" + MMOItems.plugin.getTemplates().getTemplates(type).size();
|
||||
return type.getName();
|
||||
/*switch(pholder) {
|
||||
case "total":
|
||||
return "" + MMOItems.plugin.getTemplates().getTemplates(type).size();
|
||||
default:
|
||||
return type.getName();
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
if(identifier.startsWith("tier_")) {
|
||||
String t = identifier.substring(5).toUpperCase();
|
||||
if(!MMOItems.plugin.getTiers().has(t)) return "Invalid tier";
|
||||
return MMOItems.plugin.getTiers().get(t).getName();
|
||||
}
|
||||
// Player-related placeholders
|
||||
if (player == null) return null;
|
||||
|
||||
if (!player.isOnline())
|
||||
return null;
|
||||
// registering before identifier.startsWith("stat_") to prevent issues
|
||||
// i don't register it in the starts with condition because it will mess
|
||||
// with substring
|
||||
if (identifier.equals("stat_defense_percent")) {
|
||||
final double defenseStat = MMOPlayerData.get(player).getStatMap().getStat("DEFENSE");
|
||||
final double damageReduction = 100 - new DefenseFormula().getAppliedDamage(defenseStat, 100);
|
||||
return MythicLib.plugin.getMMOConfig().decimal.format(damageReduction);
|
||||
}
|
||||
|
||||
if (identifier.equals("durability")) {
|
||||
NBTItem nbt = MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getPlayer().getInventory().getItemInMainHand());
|
||||
return String.valueOf(nbt.hasTag("MMOITEMS_DURABILITY") ? nbt.getInteger("MMOITEMS_DURABILITY") : nbt.getInteger("MMOITEMS_MAX_DURABILITY"));
|
||||
}
|
||||
if (identifier.startsWith("stat_")) {
|
||||
final String stat = UtilityMethods.enumName(identifier.substring(5));
|
||||
return StatManager.format(stat, MMOPlayerData.get(player));
|
||||
}
|
||||
|
||||
if (identifier.equals("durability_max"))
|
||||
return "" + (int) MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getPlayer().getInventory().getItemInMainHand())
|
||||
.getDouble("MMOITEMS_MAX_DURABILITY");
|
||||
if (identifier.startsWith("ability_cd_"))
|
||||
return MythicLib.plugin.getMMOConfig().decimal.format(MMOPlayerData.get(player).getCooldownMap().getCooldown("skill_" + identifier.substring(11)));
|
||||
|
||||
if (identifier.equals("durability_ratio")) {
|
||||
NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getPlayer().getInventory().getItemInMainHand());
|
||||
double durability = item.getDouble("MMOITEMS_DURABILITY");
|
||||
double maxDurability = item.getDouble("MMOITEMS_MAX_DURABILITY");
|
||||
return MythicLib.plugin.getMMOConfig().decimal.format(durability / maxDurability * 100);
|
||||
}
|
||||
if (identifier.startsWith("tier_")) {
|
||||
String t = identifier.substring(5).toUpperCase();
|
||||
if (!MMOItems.plugin.getTiers().has(t)) return "Invalid tier";
|
||||
return MMOItems.plugin.getTiers().get(t).getName();
|
||||
}
|
||||
|
||||
if (identifier.equals("durability_bar_square"))
|
||||
return getCurrentDurabilityBar(player.getPlayer().getInventory().getItemInMainHand(), AltChar.square, 10);
|
||||
if (!player.isOnline()) return null;
|
||||
|
||||
if (identifier.equals("durability_bar_diamond"))
|
||||
return getCurrentDurabilityBar(player.getPlayer().getInventory().getItemInMainHand(), AltChar.diamond, 15);
|
||||
if (identifier.equals("durability")) {
|
||||
NBTItem nbt = MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getPlayer().getInventory().getItemInMainHand());
|
||||
return String.valueOf(nbt.hasTag("MMOITEMS_DURABILITY") ? nbt.getInteger("MMOITEMS_DURABILITY") : nbt.getInteger("MMOITEMS_MAX_DURABILITY"));
|
||||
}
|
||||
|
||||
if (identifier.equals("durability_bar_thin"))
|
||||
return getCurrentDurabilityBar(player.getPlayer().getInventory().getItemInMainHand(), "|", 20);
|
||||
return null;
|
||||
}
|
||||
if (identifier.equals("durability_max"))
|
||||
return "" + (int) MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getPlayer().getInventory().getItemInMainHand())
|
||||
.getDouble("MMOITEMS_MAX_DURABILITY");
|
||||
|
||||
private String getCurrentDurabilityBar(ItemStack item, String barChar, int length) {
|
||||
NBTItem nbtItem = MythicLib.plugin.getVersion().getWrapper().getNBTItem(item);
|
||||
double durability = nbtItem.getDouble("MMOITEMS_DURABILITY");
|
||||
double maxDurability = nbtItem.getDouble("MMOITEMS_MAX_DURABILITY");
|
||||
long r = Math.round(durability / maxDurability * length);
|
||||
StringBuilder bar = new StringBuilder("" + ChatColor.GREEN);
|
||||
for (int j = 0; j < length; j++)
|
||||
bar.append(j == r ? ChatColor.WHITE : "").append(barChar);
|
||||
return bar.toString();
|
||||
}
|
||||
if (identifier.equals("durability_ratio")) {
|
||||
NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(player.getPlayer().getInventory().getItemInMainHand());
|
||||
double durability = item.getDouble("MMOITEMS_DURABILITY");
|
||||
double maxDurability = item.getDouble("MMOITEMS_MAX_DURABILITY");
|
||||
return MythicLib.plugin.getMMOConfig().decimal.format(durability / maxDurability * 100);
|
||||
}
|
||||
|
||||
private boolean hasItem(Player player, EquipmentSlot slot) {
|
||||
return player.getInventory().getItem(slot) != null && player.getInventory().getItem(slot).getType() != Material.AIR;
|
||||
}
|
||||
if (identifier.equals("durability_bar_square"))
|
||||
return getCurrentDurabilityBar(player.getPlayer().getInventory().getItemInMainHand(), AltChar.square, 10);
|
||||
|
||||
if (identifier.equals("durability_bar_diamond"))
|
||||
return getCurrentDurabilityBar(player.getPlayer().getInventory().getItemInMainHand(), AltChar.diamond, 15);
|
||||
|
||||
if (identifier.equals("durability_bar_thin"))
|
||||
return getCurrentDurabilityBar(player.getPlayer().getInventory().getItemInMainHand(), "|", 20);
|
||||
return null;
|
||||
}
|
||||
|
||||
private String getCurrentDurabilityBar(ItemStack item, String barChar, int length) {
|
||||
NBTItem nbtItem = MythicLib.plugin.getVersion().getWrapper().getNBTItem(item);
|
||||
double durability = nbtItem.getDouble("MMOITEMS_DURABILITY");
|
||||
double maxDurability = nbtItem.getDouble("MMOITEMS_MAX_DURABILITY");
|
||||
long r = Math.round(durability / maxDurability * length);
|
||||
StringBuilder bar = new StringBuilder("" + ChatColor.GREEN);
|
||||
for (int j = 0; j < length; j++)
|
||||
bar.append(j == r ? ChatColor.WHITE : "").append(barChar);
|
||||
return bar.toString();
|
||||
}
|
||||
|
||||
private boolean hasItem(Player player, EquipmentSlot slot) {
|
||||
return player.getInventory().getItem(slot) != null && player.getInventory().getItem(slot).getType() != Material.AIR;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmoitems.gui.edition;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||
@ -100,7 +101,7 @@ public class AbilityEdition extends EditionInventory {
|
||||
for (String modifier : ability.getHandler().getModifiers()) {
|
||||
ItemStack modifierItem = VersionMaterial.GRAY_DYE.toItem();
|
||||
ItemMeta modifierItemMeta = modifierItem.getItemMeta();
|
||||
modifierItemMeta.setDisplayName(ChatColor.GREEN + MMOUtils.caseOnWords(modifier.toLowerCase().replace("-", " ")));
|
||||
modifierItemMeta.setDisplayName(ChatColor.GREEN + UtilityMethods.caseOnWords(modifier.toLowerCase().replace("-", " ")));
|
||||
List<String> modifierItemLore = new ArrayList<>();
|
||||
modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "This is an ability modifier. Changing this");
|
||||
modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "value will slightly customize the ability.");
|
||||
@ -201,7 +202,7 @@ public class AbilityEdition extends EditionInventory {
|
||||
if (getEditedSection().contains("ability." + configKey + "." + tag)) {
|
||||
getEditedSection().set("ability." + configKey + "." + tag, null);
|
||||
registerTemplateEdition();
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reset " + ChatColor.GOLD + MMOUtils.caseOnWords(tag.replace("-", " "))
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reset " + ChatColor.GOLD + UtilityMethods.caseOnWords(tag.replace("-", " "))
|
||||
+ ChatColor.GRAY + ".");
|
||||
}
|
||||
}
|
||||
|
@ -68,11 +68,11 @@ public class AbilityListEdition extends EditionInventory {
|
||||
if (!modifier.equals("type") && !modifier.equals("mode") && ability.getHandler().getModifiers().contains(modifier))
|
||||
try {
|
||||
abilityItemLore.add(
|
||||
ChatColor.GRAY + "* " + MMOUtils.caseOnWords(modifier.toLowerCase().replace("-", " ")) + ": " + ChatColor.GOLD
|
||||
ChatColor.GRAY + "* " + UtilityMethods.caseOnWords(modifier.toLowerCase().replace("-", " ")) + ": " + ChatColor.GOLD
|
||||
+ new NumericStatFormula(getEditedSection().get("ability." + key + "." + modifier)).toString());
|
||||
check = true;
|
||||
} catch (IllegalArgumentException exception) {
|
||||
abilityItemLore.add(ChatColor.GRAY + "* " + MMOUtils.caseOnWords(modifier.toLowerCase().replace("-", " ")) + ": "
|
||||
abilityItemLore.add(ChatColor.GRAY + "* " + UtilityMethods.caseOnWords(modifier.toLowerCase().replace("-", " ")) + ": "
|
||||
+ ChatColor.GOLD + "Unreadable");
|
||||
}
|
||||
if (check)
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.gui.edition;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
@ -45,7 +46,7 @@ public class ArrowParticlesEdition extends EditionInventory {
|
||||
particleItemLore.add(ChatColor.GRAY + "" + ChatColor.ITALIC + "arrow. Fades away when the arrow lands.");
|
||||
particleItemLore.add("");
|
||||
particleItemLore.add(ChatColor.GRAY + "Current Value: " + (particle == null ? ChatColor.RED + "No particle selected."
|
||||
: ChatColor.GOLD + MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " "))));
|
||||
: ChatColor.GOLD + UtilityMethods.caseOnWords(particle.name().toLowerCase().replace("_", " "))));
|
||||
particleItemLore.add("");
|
||||
particleItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
|
||||
particleItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to reset.");
|
||||
@ -158,7 +159,7 @@ public class ArrowParticlesEdition extends EditionInventory {
|
||||
}
|
||||
|
||||
for (String string : new String[] { "amount", "offset", "speed" })
|
||||
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + MMOUtils.caseOnWords(string))) {
|
||||
if (item.getItemMeta().getDisplayName().equals(ChatColor.GREEN + UtilityMethods.caseOnWords(string))) {
|
||||
if (event.getAction() == InventoryAction.PICKUP_ALL)
|
||||
new StatEdition(this, ItemStats.ARROW_PARTICLES, string).enable("Write in the chat the " + string + " you want.");
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.gui.edition;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
@ -70,7 +71,7 @@ public class ParticlesEdition extends EditionInventory {
|
||||
for (String modifier : particleType.getModifiers()) {
|
||||
ItemStack modifierItem = VersionMaterial.GRAY_DYE.toItem();
|
||||
ItemMeta modifierItemMeta = modifierItem.getItemMeta();
|
||||
modifierItemMeta.setDisplayName(ChatColor.GREEN + MMOUtils.caseOnWords(modifier.toLowerCase().replace("-", " ")));
|
||||
modifierItemMeta.setDisplayName(ChatColor.GREEN + UtilityMethods.caseOnWords(modifier.toLowerCase().replace("-", " ")));
|
||||
List<String> modifierItemLore = new ArrayList<>();
|
||||
modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "This is a pattern modifier.");
|
||||
modifierItemLore.add("" + ChatColor.GRAY + ChatColor.ITALIC + "Changing this value will slightly");
|
||||
@ -101,7 +102,7 @@ public class ParticlesEdition extends EditionInventory {
|
||||
particleItemLore.add(ChatColor.GRAY + "in the particle effect.");
|
||||
particleItemLore.add("");
|
||||
particleItemLore.add(ChatColor.GRAY + "Current Value: " + (particle == null ? ChatColor.RED + "No particle selected."
|
||||
: ChatColor.GOLD + MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " "))));
|
||||
: ChatColor.GOLD + UtilityMethods.caseOnWords(particle.name().toLowerCase().replace("_", " "))));
|
||||
particleItemLore.add("");
|
||||
particleItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
|
||||
particleItemLore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to change this value.");
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.gui.edition;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
@ -11,7 +12,6 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
@ -97,7 +97,7 @@ public class SoundsEdition extends EditionInventory {
|
||||
}
|
||||
|
||||
registerTemplateEdition();
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(soundPath.replace("-", " ")) + " Sound"
|
||||
player.sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + UtilityMethods.caseOnWords(soundPath.replace("-", " ")) + " Sound"
|
||||
+ ChatColor.GRAY + " successfully removed.");
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.Indyuce.mmoitems.gui.edition.recipe.registry.burninglegacy;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.manager.RecipeManager;
|
||||
@ -45,7 +46,7 @@ public enum CraftingType {
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return MMOUtils.caseOnWords(name().toLowerCase());
|
||||
return UtilityMethods.caseOnWords(name().toLowerCase());
|
||||
}
|
||||
|
||||
public String getLore() {
|
||||
|
@ -47,7 +47,7 @@ public class ConfigManager implements Reloadable {
|
||||
public NumericStatFormula defaultItemCapacity;
|
||||
public ReforgeOptions revisionOptions, gemRevisionOptions, phatLootsOptions;
|
||||
public final List<String> opStats = new ArrayList<>();
|
||||
public String itemTypeLoreTag, gemStoneLoreTag;
|
||||
public String itemTypeLoreTag, gemStoneLoreTag, defaultTierName;
|
||||
|
||||
public ConfigManager() {
|
||||
mkdir("layouts");
|
||||
@ -179,6 +179,7 @@ public class ConfigManager implements Reloadable {
|
||||
rerollOnItemUpdate = MMOItems.plugin.getConfig().getBoolean("item-revision.reroll-when-updated");
|
||||
levelSpread = MMOItems.plugin.getConfig().getDouble("item-level-spread");
|
||||
disableRemovedItems = MMOItems.plugin.getConfig().getBoolean("disable-removed-items");
|
||||
defaultTierName = MMOItems.plugin.getConfig().getString("default-tier-name");
|
||||
|
||||
NumericStatFormula.RELATIVE_SPREAD = !MMOItems.plugin.getConfig().getBoolean("additive-spread-formula", false);
|
||||
|
||||
|
@ -3,12 +3,13 @@ package net.Indyuce.mmoitems.manager;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.item.build.TooltipTexture;
|
||||
import net.Indyuce.mmoitems.tooltip.TooltipTexture;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Collection;
|
||||
@ -38,7 +39,8 @@ public class LoreFormatManager implements Reloadable {
|
||||
final ConfigurationSection tooltipsConfig = new ConfigFile("tooltips").getConfig();
|
||||
for (String key : tooltipsConfig.getKeys(false))
|
||||
try {
|
||||
tooltips.put(key, new TooltipTexture(tooltipsConfig.getConfigurationSection(key)));
|
||||
final TooltipTexture tooltip = new TooltipTexture(tooltipsConfig.getConfigurationSection(key));
|
||||
tooltips.put(tooltip.getId(), tooltip);
|
||||
} catch (Exception exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load tooltip '" + key + "': " + exception.getMessage());
|
||||
}
|
||||
@ -48,10 +50,25 @@ public class LoreFormatManager implements Reloadable {
|
||||
return formats.containsKey(id);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<List<String>> getFormats() {
|
||||
return formats.values();
|
||||
}
|
||||
|
||||
public boolean hasTooltip(@NotNull String id) {
|
||||
return tooltips.containsKey(id);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Collection<TooltipTexture> getTooltips() {
|
||||
return tooltips.values();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TooltipTexture getTooltip(@NotNull String id) {
|
||||
return tooltips.get(id);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<String> getFormat(@NotNull MMOItem mmoitem) {
|
||||
if (mmoitem.hasData(ItemStats.LORE_FORMAT)) {
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.Indyuce.mmoitems.manager;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.skill.RegisteredSkill;
|
||||
import net.Indyuce.mmoitems.skill.ShulkerMissile;
|
||||
@ -108,9 +108,9 @@ public class SkillManager {
|
||||
for (SkillHandler<?> handler : MythicLib.plugin.getSkills().getHandlers()) {
|
||||
ConfigFile config = new ConfigFile("/skill", handler.getLowerCaseId());
|
||||
if (!config.exists()) {
|
||||
config.getConfig().set("name", MMOUtils.caseOnWords(handler.getId().replace("_", " ").replace("-", " ").toLowerCase()));
|
||||
config.getConfig().set("name", UtilityMethods.caseOnWords(handler.getId().replace("_", " ").replace("-", " ").toLowerCase()));
|
||||
for (String mod : handler.getModifiers()) {
|
||||
config.getConfig().set("modifier." + mod + ".name", MMOUtils.caseOnWords(mod.replace("-", " ").toLowerCase()));
|
||||
config.getConfig().set("modifier." + mod + ".name", UtilityMethods.caseOnWords(mod.replace("-", " ").toLowerCase()));
|
||||
config.getConfig().set("modifier." + mod + ".default-value", 0);
|
||||
}
|
||||
config.save();
|
||||
|
@ -1,22 +1,16 @@
|
||||
package net.Indyuce.mmoitems.particle.api;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.util.StringValue;
|
||||
import net.Indyuce.mmoitems.particle.*;
|
||||
import net.Indyuce.mmoitems.stat.data.ParticleData;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import net.Indyuce.mmoitems.api.util.StringValue;
|
||||
import net.Indyuce.mmoitems.particle.AuraParticles;
|
||||
import net.Indyuce.mmoitems.particle.DoubleRingsParticles;
|
||||
import net.Indyuce.mmoitems.particle.FirefliesParticles;
|
||||
import net.Indyuce.mmoitems.particle.GalaxyParticles;
|
||||
import net.Indyuce.mmoitems.particle.HelixParticles;
|
||||
import net.Indyuce.mmoitems.particle.OffsetParticles;
|
||||
import net.Indyuce.mmoitems.particle.VortexParticles;
|
||||
import net.Indyuce.mmoitems.stat.data.ParticleData;
|
||||
|
||||
public enum ParticleType {
|
||||
OFFSET(OffsetParticles::new, false, 5, "Some particles randomly spawning around your body.", new StringValue("amount", 5), new StringValue("vertical-offset", .5), new StringValue("horizontal-offset", .3), new StringValue("speed", 0), new StringValue("height", 1)),
|
||||
FIREFLIES(FirefliesParticles::new, true, 1, "Particles dashing around you at the same height.", new StringValue("amount", 3), new StringValue("speed", 0), new StringValue("rotation-speed", 1), new StringValue("radius", 1.3), new StringValue("height", 1)),
|
||||
@ -59,7 +53,7 @@ public enum ParticleType {
|
||||
}
|
||||
|
||||
public String getDefaultName() {
|
||||
return MMOUtils.caseOnWords(name().toLowerCase().replace("_", " "));
|
||||
return UtilityMethods.caseOnWords(name().toLowerCase().replace("_", " "));
|
||||
}
|
||||
|
||||
public double getModifier(String path) {
|
||||
|
@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import com.google.gson.*;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
@ -208,7 +209,7 @@ public class Abilities extends ItemStat<RandomAbilityListData, AbilityListData>
|
||||
new NumericStatFormula(message).fillConfigurationSection(inv.getEditedSection(), "ability." + configKey + "." + edited,
|
||||
FormulaSaveOption.NONE);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GOLD + MMOUtils.caseOnWords(edited.replace("-", " ")) + ChatColor.GRAY
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GOLD + UtilityMethods.caseOnWords(edited.replace("-", " ")) + ChatColor.GRAY
|
||||
+ " successfully added.");
|
||||
}
|
||||
|
||||
|
@ -1,36 +1,34 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.gui.edition.ArrowParticlesEdition;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.ArrowParticlesData;
|
||||
import net.Indyuce.mmoitems.stat.data.ParticleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public class ArrowParticles extends ItemStat<ArrowParticlesData, ArrowParticlesData> {
|
||||
public ArrowParticles() {
|
||||
super("ARROW_PARTICLES", VersionMaterial.LIME_STAINED_GLASS.toMaterial(), "Arrow Particles",
|
||||
@ -154,7 +152,7 @@ public class ArrowParticles extends ItemStat<ArrowParticlesData, ArrowParticlesD
|
||||
inv.getEditedSection().set("arrow-particles.particle", particle.name());
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Particle successfully set to " + ChatColor.GOLD
|
||||
+ MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " ")) + ChatColor.GRAY + ".");
|
||||
+ UtilityMethods.caseOnWords(particle.name().toLowerCase().replace("_", " ")) + ChatColor.GRAY + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -171,7 +169,7 @@ public class ArrowParticles extends ItemStat<ArrowParticlesData, ArrowParticlesD
|
||||
double value = MMOUtils.parseDouble(message);
|
||||
inv.getEditedSection().set("arrow-particles." + edited, value);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GOLD + MMOUtils.caseOnWords(edited.replace("-", " ")) + ChatColor.GRAY
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GOLD + UtilityMethods.caseOnWords(edited.replace("-", " ")) + ChatColor.GRAY
|
||||
+ " set to " + ChatColor.GOLD + value + ChatColor.GRAY + ".");
|
||||
}
|
||||
|
||||
@ -182,7 +180,7 @@ public class ArrowParticles extends ItemStat<ArrowParticlesData, ArrowParticlesD
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
|
||||
lore.add(ChatColor.GRAY + "* Particle: " + ChatColor.GOLD
|
||||
+ MMOUtils.caseOnWords(cast.getParticle().name().replace("_", " ").toLowerCase()));
|
||||
+ UtilityMethods.caseOnWords(cast.getParticle().name().replace("_", " ").toLowerCase()));
|
||||
lore.add(ChatColor.GRAY + "* Amount: " + ChatColor.WHITE + cast.getAmount());
|
||||
lore.add(ChatColor.GRAY + "* Offset: " + ChatColor.WHITE + cast.getOffset());
|
||||
lore.add("");
|
||||
|
@ -3,12 +3,12 @@ package net.Indyuce.mmoitems.stat;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.interaction.projectile.ArrowPotionEffectArrayItem;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
@ -20,6 +20,7 @@ import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -96,7 +97,7 @@ public class ArrowPotionEffects extends ItemStat<RandomPotionEffectListData, Pot
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
RandomPotionEffectListData data = statData.get();
|
||||
for (RandomPotionEffectData effect : data.getEffects())
|
||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
|
||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + UtilityMethods.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
|
||||
+ ChatColor.GRAY + " Level: " + ChatColor.GREEN + effect.getAmplifier() + ChatColor.GRAY + " Duration: " + ChatColor.GREEN
|
||||
+ effect.getDuration());
|
||||
} else
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
@ -82,7 +83,7 @@ public class CustomSounds extends ItemStat<SoundListData, SoundListData> impleme
|
||||
inv.getEditedSection().set("sounds." + soundsPath + ".pitch", pitch);
|
||||
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(soundsPath.replace(".", " ")) + ChatColor.GRAY
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + UtilityMethods.caseOnWords(soundsPath.replace(".", " ")) + ChatColor.GRAY
|
||||
+ " successfully changed to '" + soundName + "'.");
|
||||
}
|
||||
|
||||
@ -95,7 +96,7 @@ public class CustomSounds extends ItemStat<SoundListData, SoundListData> impleme
|
||||
data.mapData()
|
||||
.forEach((sound,
|
||||
soundData) -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN
|
||||
+ MMOUtils.caseOnWords(sound.getName().toLowerCase().replace("-", " ").replace("_", " ")) + ChatColor.GRAY + ": "
|
||||
+ UtilityMethods.caseOnWords(sound.getName().toLowerCase().replace("-", " ").replace("_", " ")) + ChatColor.GRAY + ": "
|
||||
+ ChatColor.RED + soundData.getVolume() + " " + soundData.getPitch()));
|
||||
} else
|
||||
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
|
||||
|
@ -2,13 +2,13 @@ package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import com.google.gson.*;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
@ -23,6 +23,7 @@ import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.Indyuce.mmoitems.stat.type.PlayerConsumable;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@ -90,7 +91,7 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
|
||||
statData.ifPresentOrElse(randomPotionEffectListData -> {
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
for (RandomPotionEffectData effect : randomPotionEffectListData.getEffects())
|
||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
|
||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + UtilityMethods.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
|
||||
+ ChatColor.GRAY + " Level: " + ChatColor.GREEN + effect.getAmplifier() + ChatColor.GRAY + " Duration: " + ChatColor.GREEN
|
||||
+ effect.getDuration());
|
||||
}, () -> lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None"));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
@ -75,7 +76,7 @@ public class Elements extends ItemStat<RandomElementListData, ElementListData> i
|
||||
}
|
||||
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + MMOUtils.caseOnWords(elementPath.replace(".", " ")) + ChatColor.GRAY
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.RED + UtilityMethods.caseOnWords(elementPath.replace(".", " ")) + ChatColor.GRAY
|
||||
+ " successfully changed to " + ChatColor.GOLD + formula + ChatColor.GRAY + ".");
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
@ -9,7 +10,6 @@ import io.lumine.mythic.lib.api.util.ui.PlusMinusPercent;
|
||||
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
@ -97,8 +97,8 @@ public class Enchants extends ItemStat<RandomEnchantListData, EnchantListData> i
|
||||
|
||||
if (statData.isPresent()) {
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
RandomEnchantListData data = (RandomEnchantListData) statData.get();
|
||||
data.getEnchants().forEach(enchant -> lore.add(ChatColor.GRAY + "* " + MMOUtils.caseOnWords(enchant.getKey().getKey().replace("_", " "))
|
||||
RandomEnchantListData data = statData.get();
|
||||
data.getEnchants().forEach(enchant -> lore.add(ChatColor.GRAY + "* " + UtilityMethods.caseOnWords(enchant.getKey().getKey().replace("_", " "))
|
||||
+ " " + data.getLevel(enchant).toString()));
|
||||
|
||||
} else
|
||||
|
@ -2,12 +2,12 @@ package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
@ -16,6 +16,7 @@ import net.Indyuce.mmoitems.particle.api.ParticleType;
|
||||
import net.Indyuce.mmoitems.stat.data.ParticleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Particle;
|
||||
@ -118,7 +119,7 @@ public class ItemParticles extends ItemStat<ParticleData, ParticleData> {
|
||||
inv.getEditedSection().set("item-particles.particle", particle.name());
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Particle successfully set to " + ChatColor.GOLD
|
||||
+ MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " ")) + ChatColor.GRAY + ".");
|
||||
+ UtilityMethods.caseOnWords(particle.name().toLowerCase().replace("_", " ")) + ChatColor.GRAY + ".");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -126,7 +127,7 @@ public class ItemParticles extends ItemStat<ParticleData, ParticleData> {
|
||||
|
||||
inv.getEditedSection().set("item-particles." + edited, value);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GOLD + MMOUtils.caseOnWords(edited.replace("-", " ")) + ChatColor.GRAY
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + ChatColor.GOLD + UtilityMethods.caseOnWords(edited.replace("-", " ")) + ChatColor.GRAY
|
||||
+ " set to " + ChatColor.GOLD + value + ChatColor.GRAY + ".");
|
||||
}
|
||||
|
||||
|
@ -35,8 +35,7 @@ public class Lore extends StringListStat implements GemStoneStat {
|
||||
|
||||
@Override
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringListData data) {
|
||||
|
||||
// Apply yes
|
||||
item.getLore().insert("lore", data.getList());
|
||||
item.addItemTag(getAppliedNBT(data));
|
||||
}
|
||||
|
||||
|
@ -24,14 +24,14 @@ public class LoreFormat extends StringStat implements GemStoneStat {
|
||||
@Override
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) {
|
||||
String path = data.toString();
|
||||
Validate.isTrue(MMOItems.plugin.getFormats().hasFormat(path), "Could not find lore format with ID '" + path + "'");
|
||||
Validate.isTrue(MMOItems.plugin.getLore().hasFormat(path), "Could not find lore format with ID '" + path + "'");
|
||||
|
||||
item.addItemTag(new ItemTag(getNBTPath(), path));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
||||
Validate.isTrue(MMOItems.plugin.getFormats().hasFormat(message), "Couldn't find lore format with ID '" + message + "'.");
|
||||
Validate.isTrue(MMOItems.plugin.getLore().hasFormat(message), "Couldn't find lore format with ID '" + message + "'.");
|
||||
|
||||
inv.getEditedSection().set(getPath(), message);
|
||||
inv.registerTemplateEdition();
|
||||
|
@ -1,12 +1,12 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import io.lumine.mythic.lib.api.util.EnumUtils;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
@ -72,7 +72,7 @@ public class MaterialStat extends ItemStat<MaterialData, MaterialData> {
|
||||
public void whenDisplayed(List<String> lore, Optional<MaterialData> statData) {
|
||||
lore.add(ChatColor.GRAY + "Current Value: "
|
||||
+ (statData.isPresent()
|
||||
? ChatColor.GREEN + MMOUtils.caseOnWords(statData.get().getMaterial().name().toLowerCase().replace("_", " "))
|
||||
? ChatColor.GREEN + UtilityMethods.caseOnWords(statData.get().getMaterial().name().toLowerCase().replace("_", " "))
|
||||
: ChatColor.RED + "None"));
|
||||
|
||||
lore.add("");
|
||||
|
@ -6,6 +6,7 @@ import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -107,7 +108,7 @@ public class PermanentEffects extends ItemStat<RandomPotionEffectListData, Potio
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
RandomPotionEffectListData data = statData.get();
|
||||
for (RandomPotionEffectData effect : data.getEffects())
|
||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().replace("_", " ").toLowerCase())
|
||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + UtilityMethods.caseOnWords(effect.getType().getName().replace("_", " ").toLowerCase())
|
||||
+ " " + effect.getAmplifier().toString());
|
||||
|
||||
} else
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
@ -104,7 +105,7 @@ public class PotionEffects extends ItemStat<RandomPotionEffectListData, PotionEf
|
||||
}
|
||||
|
||||
private String formatName(String input) {
|
||||
return MMOUtils.caseOnWords(input.replace("_", " ").toLowerCase());
|
||||
return UtilityMethods.caseOnWords(input.replace("_", " ").toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -114,7 +115,7 @@ public class PotionEffects extends ItemStat<RandomPotionEffectListData, PotionEf
|
||||
lore.add(ChatColor.GRAY + "Current Value:");
|
||||
RandomPotionEffectListData data = statData.get();
|
||||
for (RandomPotionEffectData effect : data.getEffects())
|
||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
|
||||
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + UtilityMethods.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
|
||||
+ " " + effect.getAmplifier().toString() + " " + ChatColor.GRAY + "(" + ChatColor.GREEN + effect.getDuration().toString()
|
||||
+ ChatColor.GRAY + "s)");
|
||||
} else
|
||||
|
@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.stat;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
@ -109,7 +110,7 @@ public class ProjectileParticles extends ItemStat<ProjectileParticlesData, Proje
|
||||
inv.getEditedSection().set("projectile-particles.color.blue", 0);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Particle successfully set to "
|
||||
+ MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " ")) + " with color " + red);
|
||||
+ UtilityMethods.caseOnWords(particle.name().toLowerCase().replace("_", " ")) + " with color " + red);
|
||||
} else {
|
||||
Validate.isTrue(msg.length == 4, "You must provide a color for this particle.\n"
|
||||
+ MMOItems.plugin.getPrefix() + ChatColor.AQUA + "Format: {Particle} {R G B}");
|
||||
@ -122,7 +123,7 @@ public class ProjectileParticles extends ItemStat<ProjectileParticlesData, Proje
|
||||
inv.getEditedSection().set("projectile-particles.color.blue", blue);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Particle successfully set to "
|
||||
+ MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " ")) + " with RGB color " + red + " " + green + " " + blue);
|
||||
+ UtilityMethods.caseOnWords(particle.name().toLowerCase().replace("_", " ")) + " with RGB color " + red + " " + green + " " + blue);
|
||||
}
|
||||
} else {
|
||||
Validate.isTrue(msg.length == 1, "That particle cannot be assigned a color");
|
||||
@ -132,7 +133,7 @@ public class ProjectileParticles extends ItemStat<ProjectileParticlesData, Proje
|
||||
inv.getEditedSection().set("projectile-particles.color.blue", 0);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Particle successfully set to "
|
||||
+ MMOUtils.caseOnWords(particle.name().toLowerCase().replace("_", " ")));
|
||||
+ UtilityMethods.caseOnWords(particle.name().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +1,15 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.ShieldPatternData;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemStat;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -19,19 +23,14 @@ import org.bukkit.event.inventory.InventoryAction;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.inventory.ItemFlag;
|
||||
import org.bukkit.inventory.meta.BlockStateMeta;
|
||||
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.util.MMOUtils;
|
||||
import net.Indyuce.mmoitems.api.edition.StatEdition;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.ShieldPatternData;
|
||||
import io.lumine.mythic.lib.api.util.AltChar;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class ShieldPatternStat extends ItemStat<ShieldPatternData, ShieldPatternData> {
|
||||
public ShieldPatternStat() {
|
||||
super("SHIELD_PATTERN", Material.SHIELD, "Shield Pattern", new String[] { "The color & patterns", "of your shield." },
|
||||
@ -125,7 +124,7 @@ public class ShieldPatternStat extends ItemStat<ShieldPatternData, ShieldPattern
|
||||
inv.getEditedSection().set("shield-pattern." + availableKey + ".color", dyeColor.name());
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(
|
||||
MMOItems.plugin.getPrefix() + MMOUtils.caseOnWords(patternType.name().toLowerCase().replace("_", " ")) + " successfully added.");
|
||||
MMOItems.plugin.getPrefix() + UtilityMethods.caseOnWords(patternType.name().toLowerCase().replace("_", " ")) + " successfully added.");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -143,7 +142,7 @@ public class ShieldPatternStat extends ItemStat<ShieldPatternData, ShieldPattern
|
||||
ShieldPatternData data = statData.get();
|
||||
lore.add(ChatColor.GRAY + "* Base Color: "
|
||||
+ (data.getBaseColor() != null
|
||||
? ChatColor.GREEN + MMOUtils.caseOnWords(data.getBaseColor().name().toLowerCase().replace("_", " "))
|
||||
? ChatColor.GREEN + UtilityMethods.caseOnWords(data.getBaseColor().name().toLowerCase().replace("_", " "))
|
||||
: ChatColor.RED + "None"));
|
||||
data.getPatterns().forEach(pattern -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + pattern.getPattern().name() + ChatColor.GRAY
|
||||
+ " - " + ChatColor.GREEN + pattern.getColor().name()));
|
||||
|
@ -0,0 +1,39 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.tooltip.TooltipTexture;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.StringData;
|
||||
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
|
||||
import net.Indyuce.mmoitems.stat.type.StringStat;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class TooltipStat extends StringStat implements GemStoneStat {
|
||||
public TooltipStat() {
|
||||
super("TOOLTIP", Material.BIRCH_SIGN, "Tooltip", new String[]{"The identifier of the custom tooltip texture", "you'd like to use. Check the wiki for usage!",
|
||||
"&9Tooltips are setup in the tooltips.yml file"}, new String[]{"all"});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) {
|
||||
final String format = UtilityMethods.enumName(data.toString());
|
||||
final TooltipTexture texture = MMOItems.plugin.getLore().getTooltip(format);
|
||||
Validate.notNull(texture, "Could not find tooltip with ID '" + format + "'");
|
||||
item.addItemTag(new ItemTag("MMOITEMS_TOOLTIP", texture.getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
|
||||
final String format = UtilityMethods.enumName(message);
|
||||
Validate.isTrue(MMOItems.plugin.getLore().hasTooltip(format), "Couldn't find tooltip with ID '" + format + "'");
|
||||
|
||||
inv.getEditedSection().set(getPath(), format);
|
||||
inv.registerTemplateEdition();
|
||||
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Tier successfully changed to " + format + ".");
|
||||
}
|
||||
}
|
@ -0,0 +1,108 @@
|
||||
package net.Indyuce.mmoitems.tooltip;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class CenteringOptions {
|
||||
|
||||
// Display name
|
||||
private final boolean name;
|
||||
private final double nameFontSize;
|
||||
private final int nameSpan;
|
||||
private final String namePrefix;
|
||||
|
||||
// Lore
|
||||
private final int loreLines;
|
||||
private final List<Double> loreFontSize;
|
||||
private final List<Integer> loreSpan;
|
||||
|
||||
private final Pattern regex;
|
||||
|
||||
private static final String DEFAULT_REGEX = "(?i)[^&§][a-z][a-z ]*[a-z]";
|
||||
private static final double SEPARATOR_SPACE = 1;
|
||||
|
||||
public CenteringOptions(@NotNull ConfigurationSection config) {
|
||||
|
||||
this.name = config.getBoolean("display_name.enabled");
|
||||
this.nameFontSize = config.getDouble("display_name.font_size");
|
||||
this.nameSpan = config.getInt("display_name.span");
|
||||
this.namePrefix = config.getString("display_name.prefix", "");
|
||||
|
||||
this.loreLines = config.getInt("lore.lines");
|
||||
this.loreFontSize = config.getDoubleList("lore.font_size");
|
||||
this.loreSpan = config.getIntegerList("lore.span");
|
||||
|
||||
Validate.isTrue(name || loreLines > 0, "Centering must be enabled for at least one lore line or the display name");
|
||||
|
||||
// Lore validation
|
||||
Validate.isTrue(loreLines >= 0, "Lore line count must be positive");
|
||||
if (loreLines > 0) {
|
||||
Validate.isTrue(!loreFontSize.isEmpty(), "You must provide at least one lore font size");
|
||||
Validate.isTrue(!loreSpan.isEmpty(), "You must provide at least one lore span");
|
||||
for (double d : loreFontSize) Validate.isTrue(d > 0, "Font size must be positive");
|
||||
for (double d : loreSpan) Validate.isTrue(d > 0, "Font size must be positive");
|
||||
}
|
||||
|
||||
// Name validation
|
||||
if (name) {
|
||||
Validate.isTrue(nameFontSize > 0, "Font size must be positive");
|
||||
Validate.isTrue(nameSpan > 0, "Name must be positive");
|
||||
}
|
||||
|
||||
this.regex = Pattern.compile(config.getString("regex", DEFAULT_REGEX));
|
||||
}
|
||||
|
||||
public boolean displayName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public int getLoreLines() {
|
||||
return loreLines;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String centerLore(int j, String line) {
|
||||
return center(line, "", loreFontSize.get(Math.min(j, loreFontSize.size() - 1)), loreSpan.get(Math.min(j, loreSpan.size() - 1)));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String centerName(@NotNull String line) {
|
||||
return center(line, namePrefix, nameFontSize, nameSpan);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String center(@NotNull String line, @NotNull String prefix, double fontSize, int span) {
|
||||
|
||||
// Find what to center
|
||||
final Matcher matcher = regex.matcher(line);
|
||||
if (!matcher.find()) return line;
|
||||
|
||||
final int start = matcher.start(), end = matcher.end();
|
||||
// Average character size + 1 pixel per space
|
||||
final int length = (int) (fontSize * (end - start) + SEPARATOR_SPACE * countSeparators(line.substring(start, end)));
|
||||
|
||||
// Cannot center as it's too big
|
||||
if (length >= span) return line;
|
||||
|
||||
// Either ceil or floor, not really important
|
||||
final int offset = (span - length) / 2;
|
||||
return line.substring(0, start) + UtilityMethods.getFontSpace(offset) + prefix + line.substring(start);
|
||||
}
|
||||
|
||||
private int countSeparators(@NotNull String str) {
|
||||
int count = 0;
|
||||
boolean prevSpace = true;
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
final boolean space = str.charAt(i) == ' ';
|
||||
if (!prevSpace && !space) count++;
|
||||
prevSpace = space;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
@ -0,0 +1,98 @@
|
||||
package net.Indyuce.mmoitems.tooltip;
|
||||
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class TooltipTexture {
|
||||
private final String id;
|
||||
|
||||
@NotNull
|
||||
private final String top, middle, bottom;
|
||||
|
||||
@Nullable
|
||||
private final String bar, hideVanilla, alignText;
|
||||
|
||||
private final List<String> loreHeader;
|
||||
private final int ignoreFirst;
|
||||
private final CenteringOptions centering;
|
||||
|
||||
public TooltipTexture(@NotNull ConfigurationSection config) {
|
||||
id = UtilityMethods.enumName(config.getName());
|
||||
|
||||
final String alignLeft = UtilityMethods.getFontSpace(config.getInt("align_texture"));
|
||||
alignText = UtilityMethods.getFontSpace(config.getInt("align_text"));
|
||||
hideVanilla = UtilityMethods.getFontSpace(config.getInt("hide_texture"));
|
||||
|
||||
top = alignLeft + config.getString("top") + alignText;
|
||||
loreHeader = config.getStringList("lore_header");
|
||||
middle = alignLeft + config.getString("middle") + alignText;
|
||||
bar = config.get("bar") != null ? alignLeft + config.getString("bar") : null;
|
||||
bottom = alignLeft + config.getString("bottom");
|
||||
|
||||
ignoreFirst = config.getInt("ignore_first");
|
||||
|
||||
try {
|
||||
centering = config.isConfigurationSection("center") ? new CenteringOptions(config.getConfigurationSection("center")) : null;
|
||||
} catch (RuntimeException exception) {
|
||||
throw new RuntimeException("Could not load centering options: " + exception.getMessage());
|
||||
}
|
||||
|
||||
Validate.notNull(top, "Tooltip top portion cannot be null");
|
||||
Validate.notNull(middle, "Tooltip middle portion cannot be null");
|
||||
Validate.notNull(bottom, "Tooltip bottom portion cannot be null");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getMiddle() {
|
||||
return middle;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getAlignText() {
|
||||
return alignText;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getBar() {
|
||||
return bar == null ? middle : bar;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getSuffix() {
|
||||
return hideVanilla;
|
||||
}
|
||||
|
||||
public int getFirstIgnored() {
|
||||
return ignoreFirst;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CenteringOptions getCenteringOptions() {
|
||||
return centering;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public List<String> getLoreHeader() {
|
||||
return loreHeader;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package net.Indyuce.mmoitems.util;
|
||||
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* This class unsures that the {@link #build()}
|
||||
* method is called at most once time.
|
||||
*
|
||||
* @param <B> Type of object built
|
||||
*/
|
||||
public abstract class Buildable<B> {
|
||||
private boolean lock = true;
|
||||
|
||||
protected abstract B whenBuilt();
|
||||
|
||||
public void validateNotBuilt() {
|
||||
Validate.isTrue(lock, "Has already been built");
|
||||
}
|
||||
|
||||
public boolean isBuilt() {
|
||||
return !lock;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public B build() {
|
||||
validateNotBuilt();
|
||||
lock = false;
|
||||
return whenBuilt();
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableMap;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.UtilityMethods;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
@ -104,24 +105,7 @@ public class MMOUtils {
|
||||
/**
|
||||
* Source: https://gist.github.com/Mystiflow/c42f45bac9916c84e381155f72a96d84
|
||||
*/
|
||||
private static final Map<ChatColor, Color> COLOR_MAPPINGS = ImmutableMap.<ChatColor, Color>builder()
|
||||
.put(ChatColor.BLACK, Color.fromRGB(0, 0, 0))
|
||||
.put(ChatColor.DARK_BLUE, Color.fromRGB(0, 0, 170))
|
||||
.put(ChatColor.DARK_GREEN, Color.fromRGB(0, 170, 0))
|
||||
.put(ChatColor.DARK_AQUA, Color.fromRGB(0, 170, 170))
|
||||
.put(ChatColor.DARK_RED, Color.fromRGB(170, 0, 0))
|
||||
.put(ChatColor.DARK_PURPLE, Color.fromRGB(170, 0, 170))
|
||||
.put(ChatColor.GOLD, Color.fromRGB(255, 170, 0))
|
||||
.put(ChatColor.GRAY, Color.fromRGB(170, 170, 170))
|
||||
.put(ChatColor.DARK_GRAY, Color.fromRGB(85, 85, 85))
|
||||
.put(ChatColor.BLUE, Color.fromRGB(85, 85, 255))
|
||||
.put(ChatColor.GREEN, Color.fromRGB(85, 255, 85))
|
||||
.put(ChatColor.AQUA, Color.fromRGB(85, 255, 255))
|
||||
.put(ChatColor.RED, Color.fromRGB(255, 85, 85))
|
||||
.put(ChatColor.LIGHT_PURPLE, Color.fromRGB(255, 85, 255))
|
||||
.put(ChatColor.YELLOW, Color.fromRGB(255, 255, 85))
|
||||
.put(ChatColor.WHITE, Color.fromRGB(255, 255, 255))
|
||||
.build();
|
||||
private static final Map<ChatColor, Color> COLOR_MAPPINGS = ImmutableMap.<ChatColor, Color>builder().put(ChatColor.BLACK, Color.fromRGB(0, 0, 0)).put(ChatColor.DARK_BLUE, Color.fromRGB(0, 0, 170)).put(ChatColor.DARK_GREEN, Color.fromRGB(0, 170, 0)).put(ChatColor.DARK_AQUA, Color.fromRGB(0, 170, 170)).put(ChatColor.DARK_RED, Color.fromRGB(170, 0, 0)).put(ChatColor.DARK_PURPLE, Color.fromRGB(170, 0, 170)).put(ChatColor.GOLD, Color.fromRGB(255, 170, 0)).put(ChatColor.GRAY, Color.fromRGB(170, 170, 170)).put(ChatColor.DARK_GRAY, Color.fromRGB(85, 85, 85)).put(ChatColor.BLUE, Color.fromRGB(85, 85, 255)).put(ChatColor.GREEN, Color.fromRGB(85, 255, 85)).put(ChatColor.AQUA, Color.fromRGB(85, 255, 255)).put(ChatColor.RED, Color.fromRGB(255, 85, 85)).put(ChatColor.LIGHT_PURPLE, Color.fromRGB(255, 85, 255)).put(ChatColor.YELLOW, Color.fromRGB(255, 255, 85)).put(ChatColor.WHITE, Color.fromRGB(255, 255, 255)).build();
|
||||
|
||||
@NotNull
|
||||
public static Color toRGB(ChatColor color) {
|
||||
@ -130,12 +114,10 @@ public class MMOUtils {
|
||||
|
||||
public static int getPickaxePower(Player player) {
|
||||
final ItemStack item = player.getInventory().getItemInMainHand();
|
||||
if (item == null || item.getType() == Material.AIR)
|
||||
return 0;
|
||||
if (item == null || item.getType() == Material.AIR) return 0;
|
||||
|
||||
final NBTItem nbt = NBTItem.get(item);
|
||||
if (nbt.hasTag("MMOITEMS_PICKAXE_POWER"))
|
||||
return nbt.getInteger("MMOITEMS_PICKAXE_POWER");
|
||||
if (nbt.hasTag("MMOITEMS_PICKAXE_POWER")) return nbt.getInteger("MMOITEMS_PICKAXE_POWER");
|
||||
|
||||
switch (item.getType().name()) {
|
||||
case "WOODEN_PICKAXE":
|
||||
@ -163,9 +145,9 @@ public class MMOUtils {
|
||||
* @throws IllegalArgumentException If this does not match any trigger type
|
||||
*/
|
||||
@NotNull
|
||||
@Deprecated
|
||||
public static TriggerType backwardsCompatibleTriggerType(@NotNull String name) throws IllegalArgumentException {
|
||||
if (name == null)
|
||||
throw new IllegalArgumentException("Trigger cannot be null");
|
||||
if (name == null) throw new IllegalArgumentException("Trigger cannot be null");
|
||||
|
||||
switch (name) {
|
||||
case "ON_HIT":
|
||||
@ -184,8 +166,7 @@ public class MMOUtils {
|
||||
* @return If the given item is the desired MMOItem
|
||||
*/
|
||||
public static boolean isMMOItem(@Nullable ItemStack item, @NotNull String type, @NotNull String id) {
|
||||
if (item == null)
|
||||
return false;
|
||||
if (item == null) return false;
|
||||
|
||||
// Make it into an NBT Item
|
||||
NBTItem asNBT = NBTItem.get(item);
|
||||
@ -194,12 +175,10 @@ public class MMOUtils {
|
||||
String itemID = getID(asNBT);
|
||||
|
||||
// Not a MMOItem
|
||||
if (itemID == null)
|
||||
return false;
|
||||
if (itemID == null) return false;
|
||||
|
||||
// ID matches?
|
||||
if (!itemID.equals(id))
|
||||
return false;
|
||||
if (!itemID.equals(id)) return false;
|
||||
|
||||
// If the type matches too, we are set.
|
||||
return asNBT.getType().equals(type);
|
||||
@ -211,8 +190,7 @@ public class MMOUtils {
|
||||
*/
|
||||
@Nullable
|
||||
public static Type getType(@Nullable NBTItem nbtItem) {
|
||||
if (nbtItem == null || !nbtItem.hasType())
|
||||
return null;
|
||||
if (nbtItem == null || !nbtItem.hasType()) return null;
|
||||
|
||||
// Try that one instead
|
||||
return MMOItems.plugin.getTypes().get(nbtItem.getType());
|
||||
@ -224,18 +202,16 @@ public class MMOUtils {
|
||||
*/
|
||||
@Nullable
|
||||
public static String getID(@Nullable NBTItem nbtItem) {
|
||||
if (nbtItem == null || !nbtItem.hasType())
|
||||
return null;
|
||||
if (nbtItem == null || !nbtItem.hasType()) return null;
|
||||
|
||||
ItemTag type = ItemTag.getTagAtPath("MMOITEMS_ITEM_ID", nbtItem, SupportedNBTTagValues.STRING);
|
||||
if (type == null)
|
||||
return null;
|
||||
if (type == null) return null;
|
||||
|
||||
return (String) type.getValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* * Returns either the normalized vector, or null vector if input is null
|
||||
* Returns either the normalized vector, or null vector if input is null
|
||||
* vector which cannot be normalized.
|
||||
*
|
||||
* @param vector Vector which can be of length 0
|
||||
@ -266,8 +242,7 @@ public class MMOUtils {
|
||||
*/
|
||||
@Nullable
|
||||
public static UUID UUIDFromString(@org.jetbrains.annotations.Nullable String anything) {
|
||||
if (anything == null)
|
||||
return null;
|
||||
if (anything == null) return null;
|
||||
|
||||
// Correct Format?
|
||||
if (anything.matches("[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}"))
|
||||
@ -290,8 +265,7 @@ public class MMOUtils {
|
||||
*/
|
||||
if (event.getDamager() instanceof Projectile) {
|
||||
Projectile proj = (Projectile) event.getDamager();
|
||||
if (proj.getShooter() instanceof LivingEntity)
|
||||
return (LivingEntity) proj.getShooter();
|
||||
if (proj.getShooter() instanceof LivingEntity) return (LivingEntity) proj.getShooter();
|
||||
}
|
||||
|
||||
return null;
|
||||
@ -316,28 +290,12 @@ public class MMOUtils {
|
||||
if (item == null) {
|
||||
return "null";
|
||||
}
|
||||
return (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) ?
|
||||
item.getItemMeta().getDisplayName() :
|
||||
caseOnWords(item.getType().name().toLowerCase().replace("_", " "));
|
||||
return (item.hasItemMeta() && item.getItemMeta().hasDisplayName()) ? item.getItemMeta().getDisplayName() : caseOnWords(item.getType().name().toLowerCase().replace("_", " "));
|
||||
}
|
||||
|
||||
/**
|
||||
* Super useful to display enum names like DIAMOND_SWORD in chat
|
||||
*
|
||||
* @param s String with lower cases and spaces only
|
||||
* @return Same string with capital letters at the beginning of each word.
|
||||
*/
|
||||
@Deprecated
|
||||
public static String caseOnWords(String s) {
|
||||
StringBuilder builder = new StringBuilder(s);
|
||||
boolean isLastSpace = true;
|
||||
for (int i = 0; i < builder.length(); i++) {
|
||||
char ch = builder.charAt(i);
|
||||
if (isLastSpace && ch >= 'a' && ch <= 'z') {
|
||||
builder.setCharAt(i, (char) (ch + ('A' - 'a')));
|
||||
isLastSpace = false;
|
||||
} else isLastSpace = ch == ' ';
|
||||
}
|
||||
return builder.toString();
|
||||
return UtilityMethods.caseOnWords(s);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,6 +48,10 @@ item-level-spread: 2
|
||||
# where left clicking a
|
||||
fix-left-click-interact: false
|
||||
|
||||
# An item with no tier will use this tier name
|
||||
# as its default tier name.
|
||||
default-tier-name: 'Common'
|
||||
|
||||
# When an item is generated with no tier,
|
||||
# this is the capacity formula it will use.
|
||||
default-item-capacity:
|
||||
|
Loading…
Reference in New Issue
Block a user