!Rolled back API changes

This commit is contained in:
Indyuce 2020-12-24 00:40:28 +01:00
parent 050a44addd
commit 1150685c35
36 changed files with 397 additions and 341 deletions

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.gui.edition;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
@ -20,7 +21,6 @@ import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.item.template.TemplateModifier;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.gui.PluginInventory;
import net.Indyuce.mmoitems.stat.data.EmptyData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.util.AltChar;
@ -82,14 +82,15 @@ public abstract class EditionInventory extends PluginInventory {
* @param stat The stat which data we are looking for
* @return Optional which contains the corresponding random stat data
*/
public RandomStatData getEventualStatData(ItemStat stat) {
public Optional<RandomStatData> getEventualStatData(ItemStat stat) {
/*
* The item data map used to display what the player is currently
* editing. If he is editing a stat modifier, use the modifier item data
* map. Otherwise, use the base item data map
*/
Map<ItemStat, RandomStatData> map = editedModifier != null ? editedModifier.getItemData() : template.getBaseItemData();
return map.getOrDefault(stat, new EmptyData());
return map.containsKey(stat) ? Optional.of(map.get(stat)) : Optional.empty();
}
public void registerTemplateEdition() {

View File

@ -20,6 +20,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class ElementsEdition extends EditionInventory {
private static final int[] slots = { 19, 25, 20, 24, 28, 34, 29, 33, 30, 32, 37, 43, 38, 42, 39, 41 };
@ -38,10 +39,10 @@ public class ElementsEdition extends EditionInventory {
ItemMeta attackMeta = attack.getItemMeta();
attackMeta.setDisplayName(ChatColor.GREEN + element.getName() + " Damage");
List<String> attackLore = new ArrayList<>();
RandomStatData statData = getEventualStatData(ItemStats.ELEMENTS);
Optional<RandomStatData> statData = getEventualStatData(ItemStats.ELEMENTS);
attackLore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN
+ (statData.isPresent() && ((RandomElementListData) statData).hasDamage(element)
? ((RandomElementListData) statData).getDamage(element) + " (%)"
+ (statData.isPresent() && ((RandomElementListData) statData.get()).hasDamage(element)
? ((RandomElementListData) statData.get()).getDamage(element) + " (%)"
: "---"));
attackLore.add("");
attackLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
@ -54,8 +55,8 @@ public class ElementsEdition extends EditionInventory {
defenseMeta.setDisplayName(ChatColor.GREEN + element.getName() + " Defense");
List<String> defenseLore = new ArrayList<>();
defenseLore.add(ChatColor.GRAY + "Current Value: " + ChatColor.GREEN
+ (statData.isPresent() && ((RandomElementListData) statData).hasDefense(element)
? ((RandomElementListData) statData).getDefense(element) + " (%)"
+ (statData.isPresent() && ((RandomElementListData) statData.get()).hasDefense(element)
? ((RandomElementListData) statData.get()).getDefense(element) + " (%)"
: "---"));
defenseLore.add("");
defenseLore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.stat;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
@ -130,9 +131,9 @@ public class Abilities extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
lore.add(ChatColor.GRAY + "Current Abilities: " + ChatColor.GOLD
+ (statData.isPresent() ? ((RandomAbilityListData) statData).getAbilities().size() : 0));
+ (statData.isPresent() ? ((RandomAbilityListData) statData.get()).getAbilities().size() : 0));
lore.add("");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit the item abilities.");
}

View File

@ -1,8 +1,18 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
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 net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -18,13 +28,6 @@ import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial;
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 java.util.List;
public class ArrowParticles extends ItemStat {
public ArrowParticles() {
@ -124,9 +127,9 @@ public class ArrowParticles extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
ArrowParticlesData cast = (ArrowParticlesData) statData;
ArrowParticlesData cast = (ArrowParticlesData) statData.get();
lore.add(ChatColor.GRAY + "Current Value:");
lore.add(ChatColor.GRAY + "* Particle: " + ChatColor.GOLD
@ -140,8 +143,8 @@ public class ArrowParticles extends ItemStat {
"&7* Color: &c&l" + cast.getRed() + "&7 - &a&l" + cast.getGreen() + "&7 - &9&l" + cast.getBlue()));
else
lore.add(ChatColor.GRAY + "* Speed: " + ChatColor.WHITE + cast.getSpeed());
}
else lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
} else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
lore.add("");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit.");

View File

@ -1,8 +1,24 @@
package net.Indyuce.mmoitems.stat;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffectType;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -20,19 +36,6 @@ import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffectType;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class ArrowPotionEffects extends ItemStat {
private final DecimalFormat durationFormat = new DecimalFormat("0.#");
@ -95,10 +98,10 @@ public class ArrowPotionEffects extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
RandomPotionEffectListData data = (RandomPotionEffectListData) statData;
RandomPotionEffectListData data = (RandomPotionEffectListData) statData.get();
for (RandomPotionEffectData effect : data.getEffects())
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
+ ChatColor.GRAY + " Level: " + ChatColor.GREEN + effect.getAmplifier() + ChatColor.GRAY + " Duration: " + ChatColor.GREEN

View File

@ -1,9 +1,19 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -19,13 +29,6 @@ import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
public class Commands extends ItemStat {
private static final int max = 15;
@ -108,9 +111,9 @@ public class Commands extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
lore.add(ChatColor.GRAY + "Current Commands: " + ChatColor.RED
+ (statData.isPresent() ? ((CommandListData) statData).getCommands().size() : "0"));
+ (statData.isPresent() ? ((CommandListData) statData.get()).getCommands().size() : "0"));
lore.add("");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to edit item commands.");
}

View File

@ -1,7 +1,17 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -15,13 +25,6 @@ import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
public class CompatibleTypes extends ItemStat {
public CompatibleTypes() {
@ -67,11 +70,11 @@ public class CompatibleTypes extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
((StringListData) statData).getList().forEach(str -> lore.add(ChatColor.GRAY + str));
((StringListData) statData.get()).getList().forEach(str -> lore.add(ChatColor.GRAY + str));
} else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "Compatible with any item.");

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
@ -40,7 +41,7 @@ public class Crafting extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to access the crafting edition menu.");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove all crafting recipes.");
}

View File

@ -1,5 +1,15 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -16,14 +26,6 @@ import net.Indyuce.mmoitems.stat.type.GemStoneStat;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.List;
public class CustomSounds extends ItemStat implements GemStoneStat {
public CustomSounds() {
@ -80,11 +82,11 @@ public class CustomSounds extends ItemStat implements GemStoneStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
SoundListData data = (SoundListData) statData;
SoundListData data = (SoundListData) statData.get();
data.mapData()
.forEach((sound,
soundData) -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN

View File

@ -1,5 +1,15 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -12,14 +22,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import java.util.List;
public class DyeColor extends ItemStat {
public DyeColor() {
@ -62,8 +64,8 @@ public class DyeColor extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
lore.add(ChatColor.GRAY + "Current Value: " + (statData.isPresent() ? ChatColor.GREEN + statData.toString() : ChatColor.RED + "None"));
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
lore.add(ChatColor.GRAY + "Current Value: " + (statData.isPresent() ? ChatColor.GREEN + statData.get().toString() : ChatColor.RED + "None"));
lore.add("");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the dye color.");

View File

@ -1,9 +1,25 @@
package net.Indyuce.mmoitems.stat;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffectType;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -21,19 +37,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffectType;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class Effects extends ItemStat {
private final DecimalFormat durationFormat = new DecimalFormat("0.#");
@ -88,11 +91,11 @@ public class Effects extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
RandomPotionEffectListData data = (RandomPotionEffectListData) statData;
RandomPotionEffectListData data = (RandomPotionEffectListData) statData.get();
for (RandomPotionEffectData effect : data.getEffects())
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
+ ChatColor.GRAY + " Level: " + ChatColor.GREEN + effect.getAmplifier() + ChatColor.GRAY + " Duration: " + ChatColor.GREEN

View File

@ -1,5 +1,15 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -17,14 +27,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.List;
public class Elements extends ItemStat {
public Elements() {
@ -74,11 +76,11 @@ public class Elements extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
RandomElementListData data = (RandomElementListData) statData;
RandomElementListData data = (RandomElementListData) statData.get();
data.getDamageElements().forEach(
element -> lore.add(ChatColor.GRAY + "* " + element.getName() + " Damage: " + ChatColor.RED + data.getDamage(element) + " (%)"));
data.getDefenseElements().forEach(

View File

@ -1,5 +1,19 @@
package net.Indyuce.mmoitems.stat;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -14,18 +28,6 @@ import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class Enchants extends ItemStat {
public Enchants() {
@ -81,11 +83,11 @@ public class Enchants extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
RandomEnchantListData data = (RandomEnchantListData) statData;
RandomEnchantListData data = (RandomEnchantListData) statData.get();
data.getEnchants().forEach(enchant -> lore.add(ChatColor.GRAY + "* " + MMOUtils.caseOnWords(enchant.getKey().getKey().replace("_", " "))
+ " " + data.getLevel(enchant).toString()));

View File

@ -1,9 +1,20 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -17,14 +28,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
public class GemSockets extends ItemStat {
public GemSockets() {
@ -105,11 +108,11 @@ public class GemSockets extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
GemSocketsData data = (GemSocketsData) statData;
GemSocketsData data = (GemSocketsData) statData.get();
data.getEmptySlots().forEach(socket -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + socket + " Gem Socket"));
} else

View File

@ -1,7 +1,18 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -16,18 +27,11 @@ import net.Indyuce.mmoitems.stat.type.StringListStat;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
public class GrantedPermissions extends StringListStat implements GemStoneStat {
public GrantedPermissions() {
super("GRANTED_PERMISSIONS", Material.NAME_TAG, "Granted Permissions", new String[] { "A list of permissions that will,", "be granted by the item." }, new String[] { "all" });
super("GRANTED_PERMISSIONS", Material.NAME_TAG, "Granted Permissions",
new String[] { "A list of permissions that will,", "be granted by the item." }, new String[] { "all" });
}
@Override
@ -66,11 +70,11 @@ public class GrantedPermissions extends StringListStat implements GemStoneStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) statData;
StringListData data = (StringListData) statData.get();
data.getList().forEach(element -> lore.add(ChatColor.GRAY + MMOLib.plugin.parseColors(element)));
} else
@ -91,8 +95,8 @@ public class GrantedPermissions extends StringListStat implements GemStoneStat {
@Override
public void whenLoaded(ReadMMOItem mmoitem) {
if (mmoitem.getNBT().hasTag(getNBTPath())) {
mmoitem.setData(ItemStats.GRANTED_PERMISSIONS, new StringListData(
new JsonParser().parse(mmoitem.getNBT().getString(getNBTPath())).getAsJsonArray()));
mmoitem.setData(ItemStats.GRANTED_PERMISSIONS,
new StringListData(new JsonParser().parse(mmoitem.getNBT().getString(getNBTPath())).getAsJsonArray()));
}
}
}

View File

@ -1,7 +1,17 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
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.JsonParser;
import com.google.gson.JsonSyntaxException;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -17,13 +27,6 @@ import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial;
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 java.util.List;
public class ItemParticles extends ItemStat {
public ItemParticles() {
@ -48,7 +51,7 @@ public class ItemParticles extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to setup the item particles.");
}

View File

@ -1,5 +1,15 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
@ -13,14 +23,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.StringStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
public class ItemTypeRestriction extends StringStat {
public ItemTypeRestriction() {
@ -100,11 +102,11 @@ public class ItemTypeRestriction extends StringStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) statData;
StringListData data = (StringListData) statData.get();
data.getList().forEach(el -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + el));
} else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "Compatible with any type.");

View File

@ -1,7 +1,17 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -17,13 +27,6 @@ import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
public class Lore extends StringListStat implements GemStoneStat {
public Lore() {
@ -66,11 +69,11 @@ public class Lore extends StringListStat implements GemStoneStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) statData;
StringListData data = (StringListData) statData.get();
data.getList().forEach(element -> lore.add(ChatColor.GRAY + MMOLib.plugin.parseColors(element)));
} else

View File

@ -1,5 +1,12 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -18,12 +25,6 @@ import net.md_5.bungee.api.chat.ComponentBuilder;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.api.util.EnumUtils;
import net.mmogroup.mmolib.version.VersionMaterial;
import org.apache.commons.lang.Validate;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.List;
import java.util.Optional;
public class MaterialStat extends ItemStat {
public MaterialStat() {
@ -69,10 +70,10 @@ public class MaterialStat extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
lore.add(ChatColor.GRAY + "Current Value: "
+ (statData.isPresent()
? ChatColor.GREEN + MMOUtils.caseOnWords(((MaterialData) statData).getMaterial().name().toLowerCase().replace("_", " "))
? ChatColor.GREEN + MMOUtils.caseOnWords(((MaterialData) statData.get()).getMaterial().name().toLowerCase().replace("_", " "))
: ChatColor.RED + "None"));
lore.add("");

View File

@ -1,7 +1,18 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -14,14 +25,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.StringListStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
public class NBTTags extends StringListStat {
public NBTTags() {
@ -69,10 +72,10 @@ public class NBTTags extends StringListStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) statData;
StringListData data = (StringListData) statData.get();
data.getList().forEach(str -> lore.add(ChatColor.GRAY + str));
} else

View File

@ -1,8 +1,22 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffectType;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -20,22 +34,15 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.potion.PotionEffectType;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* This class has not been updated for the item generation update!!! The potion
* amplifier and duration are not numeric formulas but flat values.... TODO
*/
public class PermanentEffects extends ItemStat {
public PermanentEffects() {
super("PERM_EFFECTS", Material.POTION, "Permanent Effects",
new String[] { "The potion effects your", "item grants to the holder." }, new String[] { "!miscellaneous", "!block", "all" });
super("PERM_EFFECTS", Material.POTION, "Permanent Effects", new String[] { "The potion effects your", "item grants to the holder." },
new String[] { "!miscellaneous", "!block", "all" });
}
@Override
@ -69,7 +76,7 @@ public class PermanentEffects extends ItemStat {
inv.getEditedSection().set("perm-effects", null);
inv.registerTemplateEdition();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed " + last.substring(0, 1).toUpperCase()
+ last.substring(1).toLowerCase() + "<EFBFBD>7.");
+ last.substring(1).toLowerCase() + ".");
}
}
}
@ -92,10 +99,10 @@ public class PermanentEffects extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
RandomPotionEffectListData data = (RandomPotionEffectListData) statData;
RandomPotionEffectListData data = (RandomPotionEffectListData) statData.get();
for (RandomPotionEffectData effect : data.getEffects())
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().replace("_", " ").toLowerCase())
+ " " + effect.getAmplifier().toString());
@ -115,8 +122,8 @@ public class PermanentEffects extends ItemStat {
String permEffectFormat = ItemStat.translate("perm-effect");
((PotionEffectListData) data).getEffects().forEach(effect -> {
lore.add(permEffectFormat.replace("#", MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
+ " " + MMOUtils.intToRoman(effect.getLevel())));
lore.add(permEffectFormat.replace("#",
MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType()) + " " + MMOUtils.intToRoman(effect.getLevel())));
object.addProperty(effect.getType().getName(), effect.getLevel());
});
@ -130,13 +137,13 @@ public class PermanentEffects extends ItemStat {
PotionEffectListData effects = new PotionEffectListData();
JsonElement element = new JsonParser().parse(mmoitem.getNBT().getString("MMOITEMS_PERM_EFFECTS"));
if(!element.isJsonObject()) {
MMOItems.plugin.getLogger().warning("Couldn't load perm effects from " + mmoitem.getType()
+ "." + mmoitem.getId() + ", the NBTData isn't a json object!");
if (!element.isJsonObject()) {
MMOItems.plugin.getLogger().warning(
"Couldn't load perm effects from " + mmoitem.getType() + "." + mmoitem.getId() + ", the NBTData isn't a json object!");
return;
}
element.getAsJsonObject().entrySet().forEach(entry ->
effects.add(new PotionEffectData(PotionEffectType.getByName(entry.getKey()), entry.getValue().getAsInt())));
element.getAsJsonObject().entrySet()
.forEach(entry -> effects.add(new PotionEffectData(PotionEffectType.getByName(entry.getKey()), entry.getValue().getAsInt())));
mmoitem.setData(ItemStats.PERM_EFFECTS, effects);
}

View File

@ -1,5 +1,16 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -18,15 +29,6 @@ import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class Permission extends StringListStat implements ItemRestriction, GemStoneStat {
public Permission() {
@ -72,11 +74,11 @@ public class Permission extends StringListStat implements ItemRestriction, GemSt
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) statData;
StringListData data = (StringListData) statData.get();
data.getList().forEach(el -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + el));
} else

View File

@ -1,5 +1,15 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.PotionMeta;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -10,14 +20,6 @@ import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.StringStat;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.PotionMeta;
import java.util.List;
public class PotionColor extends StringStat {
public PotionColor() {
@ -61,9 +63,9 @@ public class PotionColor extends StringStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
lore.add(statData.isPresent() ? ChatColor.GREEN + statData.toString() : ChatColor.RED + "Uncolored");
lore.add(statData.isPresent() ? ChatColor.GREEN + statData.get().toString() : ChatColor.RED + "Uncolored");
lore.add("");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to change this value.");

View File

@ -1,5 +1,20 @@
package net.Indyuce.mmoitems.stat;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
@ -15,19 +30,6 @@ import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.PotionMeta;
import org.bukkit.potion.PotionEffectType;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
public class PotionEffects extends ItemStat {
private final DecimalFormat durationFormat = new DecimalFormat("0.#");
@ -88,11 +90,11 @@ public class PotionEffects extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
PotionEffectListData data = (PotionEffectListData) statData;
PotionEffectListData data = (PotionEffectListData) statData.get();
for (PotionEffectData effect : data.getEffects())
lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + MMOUtils.caseOnWords(effect.getType().getName().toLowerCase().replace("_", " "))
+ " " + MMOUtils.intToRoman(effect.getLevel()) + " " + ChatColor.GRAY + "(" + ChatColor.GREEN

View File

@ -1,5 +1,16 @@
package net.Indyuce.mmoitems.stat;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
@ -17,15 +28,6 @@ import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.item.NBTItem;
import net.mmogroup.mmolib.api.util.AltChar;
import net.mmogroup.mmolib.version.VersionMaterial;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
public class RequiredClass extends StringListStat implements ItemRestriction, GemStoneStat {
public RequiredClass() {
@ -77,11 +79,11 @@ public class RequiredClass extends StringListStat implements ItemRestriction, Ge
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) statData;
StringListData data = (StringListData) statData.get();
data.getList().forEach(el -> lore.add(ChatColor.GRAY + "* " + ChatColor.GREEN + el));
} else

View File

@ -1,5 +1,13 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
@ -10,12 +18,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.List;
public class RevisionID extends ItemStat {
public RevisionID() {
@ -60,9 +62,9 @@ public class RevisionID extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
NumericStatFormula data = (NumericStatFormula) statData;
NumericStatFormula data = (NumericStatFormula) statData.get();
lore.add(ChatColor.GRAY + "Current Revision ID: " + ChatColor.GREEN + ((int) data.getBase()));
} else
lore.add(ChatColor.GRAY + "Current Revision ID: " + ChatColor.GREEN + "1");

View File

@ -1,17 +1,10 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.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 net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.StringStat;
import net.mmogroup.mmolib.api.util.AltChar;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
@ -25,9 +18,18 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.meta.BlockStateMeta;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.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 net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.StringStat;
import net.mmogroup.mmolib.api.util.AltChar;
public class ShieldPatternStat extends StringStat {
public ShieldPatternStat() {
@ -126,11 +128,11 @@ public class ShieldPatternStat extends StringStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
ShieldPatternData data = (ShieldPatternData) statData;
ShieldPatternData data = (ShieldPatternData) statData.get();
lore.add(ChatColor.GRAY + "* Base Color: "
+ (data.getBaseColor() != null
? ChatColor.GREEN + MMOUtils.caseOnWords(data.getBaseColor().name().toLowerCase().replace("_", " "))

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmoitems.stat;
import java.util.List;
import java.util.Optional;
import java.util.Random;
import org.apache.commons.lang.Validate;
@ -116,7 +117,7 @@ public class UpgradeStat extends ItemStat implements ConsumableItemInteraction {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
lore.add(ChatColor.YELLOW + AltChar.listDash + " Left click to setup upgrading.");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to reset.");
}

View File

@ -1,17 +0,0 @@
package net.Indyuce.mmoitems.stat.data;
import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
public class EmptyData implements RandomStatData {
@Override
public StatData randomize(MMOItemBuilder builder) {
return null;
}
@Override
public boolean isPresent() {
return false;
}
}

View File

@ -17,8 +17,4 @@ public interface RandomStatData {
* base item template
*/
StatData randomize(MMOItemBuilder builder);
default boolean isPresent() {
return true;
}
}

View File

@ -1,5 +1,15 @@
package net.Indyuce.mmoitems.stat.type;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition;
@ -12,14 +22,6 @@ import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.text.DecimalFormat;
import java.util.List;
public class BooleanStat extends ItemStat {
private static final DecimalFormat digit = new DecimalFormat("0.#");
@ -78,10 +80,10 @@ public class BooleanStat extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
double chance = ((RandomBooleanData) statData).getChance();
double chance = ((RandomBooleanData) statData.get()).getChance();
lore.add(ChatColor.GRAY + "Current Value: " + (chance >= 1 ? ChatColor.GREEN + "True"
: chance <= 0 ? ChatColor.RED + "False" : ChatColor.GREEN + digit.format(chance * 100) + "% Chance"));

View File

@ -2,6 +2,7 @@ package net.Indyuce.mmoitems.stat.type;
import java.text.DecimalFormat;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;
import org.apache.commons.lang.Validate;
@ -140,9 +141,9 @@ public class DoubleStat extends ItemStat implements Upgradable {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
NumericStatFormula data = (NumericStatFormula) statData;
NumericStatFormula data = (NumericStatFormula) statData.get();
lore.add(ChatColor.GRAY + "Base Value: " + ChatColor.GREEN + digit.format(data.getBase())
+ (data.getScale() != 0 ? ChatColor.GRAY + " (+" + ChatColor.GREEN + digit.format(data.getScale()) + ChatColor.GRAY + ")" : ""));
if (data.getSpread() > 0)

View File

@ -1,6 +1,7 @@
package net.Indyuce.mmoitems.stat.type;
import java.util.List;
import java.util.Optional;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
@ -36,7 +37,7 @@ public abstract class InternalStat extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
// not supported
}
}

View File

@ -1,5 +1,14 @@
package net.Indyuce.mmoitems.stat.type;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
@ -7,13 +16,6 @@ import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public abstract class ItemStat {
private final String id, name;
@ -79,10 +81,10 @@ public abstract class ItemStat {
public abstract void whenClicked(EditionInventory inv, InventoryClickEvent event);
/**
* When inputing data using chat or anvil input in order to edit the edit in
* the GUI editor. IAE are handled and exception messages are sent back to
* the player. Stat edition is not canceled until a right input is given or
* the player inputs 'cancel'
* When inputing data using chat or anvil input in order to edit the item
* using the GUI editor. IAE are handled and exception messages are sent
* back to the player. Stat edition is not canceled until a right input is
* given or the player inputs 'cancel'
*
* @param inv Previously opened edition menu
* @param message Player input
@ -109,7 +111,7 @@ public abstract class ItemStat {
* @param statData Stat data being displayed, optional is empty if there is
* no stat data
*/
public abstract void whenDisplayed(List<String> lore, RandomStatData statData);
public abstract void whenDisplayed(List<String> lore, Optional<RandomStatData> statData);
public String getName() {
return name;

View File

@ -1,7 +1,18 @@
package net.Indyuce.mmoitems.stat.type;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonArray;
import com.google.gson.JsonParser;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
@ -13,14 +24,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.ArrayList;
import java.util.List;
public class StringListStat extends ItemStat {
public StringListStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) {
@ -77,10 +80,10 @@ public class StringListStat extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
lore.add(ChatColor.GRAY + "Current Value:");
StringListData data = (StringListData) statData;
StringListData data = (StringListData) statData.get();
data.getList().forEach(element -> lore.add(ChatColor.GRAY + MMOLib.plugin.parseColors(element)));
} else

View File

@ -1,5 +1,13 @@
package net.Indyuce.mmoitems.stat.type;
import java.util.List;
import java.util.Optional;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
@ -11,12 +19,6 @@ import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.mmogroup.mmolib.MMOLib;
import net.mmogroup.mmolib.api.item.ItemTag;
import net.mmogroup.mmolib.api.util.AltChar;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent;
import java.util.List;
public class StringStat extends ItemStat {
public StringStat(String id, Material mat, String name, String[] lore, String[] types, Material... materials) {
@ -59,7 +61,7 @@ public class StringStat extends ItemStat {
}
@Override
public void whenDisplayed(List<String> lore, RandomStatData statData) {
public void whenDisplayed(List<String> lore, Optional<RandomStatData> statData) {
if (statData.isPresent()) {
String value = MMOLib.plugin.parseColors(statData.toString());
value = value.length() > 40 ? value.substring(0, 40) + "..." : value;