Merge branch 'dev' into 725-repair-percent-is-not-work

This commit is contained in:
Roch 2022-10-24 15:53:24 +02:00
commit f22960b068
102 changed files with 1484 additions and 1449 deletions

10
.gitignore vendored
View File

@ -7,3 +7,13 @@
.project .project
MMOItems.eml MMOItems.eml
MMOItems.iml MMOItems.iml
MMOItems-API/target/
MMOItems-Dist/target/
MMOItems-Dist/.flattened-pom.xml
MMOItems-API/.flattened-pom.xml
MMOItems-Dist/dependency-reduced-pom.xml

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
<platformType>BUKKIT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>

View File

@ -118,7 +118,6 @@
the first wins when multiple classpaths match the first wins when multiple classpaths match
--> -->
<dependencies> <dependencies>
<!-- Spigot API --> <!-- Spigot API -->
<dependency> <dependency>
<groupId>org.spigotmc</groupId> <groupId>org.spigotmc</groupId>
@ -126,7 +125,6 @@
<version>1.18-R0.1-SNAPSHOT</version> <version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin --> <!-- https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin -->
<dependency> <dependency>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -134,211 +132,209 @@
<version>3.1.0</version> <version>3.1.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- AuthLib -->
<dependency> <dependency>
<groupId>com.mojang</groupId> <groupId>com.mojang</groupId>
<artifactId>authlib</artifactId> <artifactId>authlib</artifactId>
<version>1.5.21</version> <version>1.5.21</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- MMOCore Api -->
<dependency> <dependency>
<groupId>net.Indyuce</groupId> <groupId>net.Indyuce</groupId>
<artifactId>MMOCore-API</artifactId> <artifactId>MMOCore-API</artifactId>
<version>1.9.5-SNAPSHOT</version> <version>1.9.5-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- MythicEnchants -->
<dependency> <dependency>
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>MythicEnchants</artifactId> <artifactId>MythicEnchants</artifactId>
<version>0.0.1-SNAPSHOT</version> <version>0.0.1-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- PhatLoots -->
<dependency> <dependency>
<groupId>com.github.RednedEpic</groupId> <groupId>com.github.RednedEpic</groupId>
<artifactId>PhatLoots</artifactId> <artifactId>PhatLoots</artifactId>
<version>4.2.3</version> <version>4.2.3</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- placeholderapi -->
<dependency> <dependency>
<groupId>me.clip</groupId> <groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId> <artifactId>placeholderapi</artifactId>
<version>2.9.2</version> <version>2.9.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Mythic -->
<dependency> <dependency>
<groupId>io.lumine</groupId> <groupId>io.lumine</groupId>
<artifactId>Mythic-Dist</artifactId> <artifactId>Mythic-Dist</artifactId>
<version>5.1.2-SNAPSHOT</version> <version>5.1.2-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- WordGuard -->
<dependency> <dependency>
<groupId>com.sk89q.worldguard</groupId> <groupId>com.sk89q.worldguard</groupId>
<artifactId>worldguard-bukkit</artifactId> <artifactId>worldguard-bukkit</artifactId>
<version>7.0.2-SNAPSHOT</version> <version>7.0.2-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Vault -->
<dependency> <dependency>
<groupId>com.github.MilkBowl</groupId> <groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId> <artifactId>VaultAPI</artifactId>
<version>1.7</version> <version>1.7</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- SkillAPI -->
<!-- Local dependencies -->
<dependency> <dependency>
<groupId>com.github.Eniripsa96</groupId> <groupId>com.github.Eniripsa96</groupId>
<artifactId>SkillAPI</artifactId> <artifactId>SkillAPI</artifactId>
<version>master</version> <version>master</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- AE Api -->
<dependency> <dependency>
<groupId>n3kas</groupId> <groupId>n3kas</groupId>
<artifactId>ae.api</artifactId> <artifactId>ae.api</artifactId>
<version>5.7.6</version> <version>5.7.6</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- BossShop -->
<dependency> <dependency>
<groupId>org.black_ixx</groupId> <groupId>org.black_ixx</groupId>
<artifactId>BossShop</artifactId> <artifactId>BossShop</artifactId>
<version>2.0.9</version> <version>2.0.9</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Residence -->
<dependency> <dependency>
<groupId>com.bekvon.bukkit.residence</groupId> <groupId>com.bekvon.bukkit.residence</groupId>
<artifactId>Residence</artifactId> <artifactId>Residence</artifactId>
<version>4.8.7.2</version> <version>4.8.7.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Heroes -->
<dependency> <dependency>
<groupId>com.herocraftonline</groupId> <groupId>com.herocraftonline</groupId>
<artifactId>Heroes</artifactId> <artifactId>Heroes</artifactId>
<version>1.9.22</version> <version>1.9.22</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- mcMMO -->
<dependency> <dependency>
<groupId>com.gmail.nossr50</groupId> <groupId>com.gmail.nossr50</groupId>
<artifactId>mcMMO</artifactId> <artifactId>mcMMO</artifactId>
<version>2.1.104</version> <version>2.1.104</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- McRPG -->
<dependency> <dependency>
<groupId>us.eunoians</groupId> <groupId>us.eunoians</groupId>
<artifactId>McRPG</artifactId> <artifactId>McRPG</artifactId>
<version>1.1.2</version> <version>1.1.2</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Rpl -->
<dependency> <dependency>
<groupId>me.baks</groupId> <groupId>me.baks</groupId>
<artifactId>rpl</artifactId> <artifactId>rpl</artifactId>
<version>3.9.30</version> <version>3.9.30</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Skills -->
<dependency> <dependency>
<groupId>me.leothepro555</groupId> <groupId>me.leothepro555</groupId>
<artifactId>skills</artifactId> <artifactId>skills</artifactId>
<version>12.3.5</version> <version>12.3.5</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- SkillsPro -->
<dependency> <dependency>
<groupId>org.skills.main</groupId> <groupId>org.skills.main</groupId>
<artifactId>SkillsPro</artifactId> <artifactId>SkillsPro</artifactId>
<version>18.9.0.1</version> <version>18.9.0.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- BattleLevels -->
<dependency> <dependency>
<groupId>me.robin</groupId> <groupId>me.robin</groupId>
<artifactId>BattleLevels</artifactId> <artifactId>BattleLevels</artifactId>
<version>6.9.1</version> <version>6.9.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- TrHologram -->
<dependency> <dependency>
<groupId>me.arasple.mc</groupId> <groupId>me.arasple.mc</groupId>
<artifactId>TrHologram</artifactId> <artifactId>TrHologram</artifactId>
<version>1.11</version> <version>1.11</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- HolographicDisplays API -->
<dependency> <dependency>
<groupId>com.gmail.filoghost.holographicdisplays</groupId> <groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId> <artifactId>holographicdisplays-api</artifactId>
<version>2.4.0</version> <version>2.4.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- RacesAndClasses -->
<dependency> <dependency>
<groupId>de.tobiyas</groupId> <groupId>de.tobiyas</groupId>
<artifactId>RacesAndClasses</artifactId> <artifactId>RacesAndClasses</artifactId>
<version>1.2.6</version> <version>1.2.6</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Rpg Inventory -->
<dependency> <dependency>
<groupId>ru.endlesscode</groupId> <groupId>ru.endlesscode</groupId>
<artifactId>rpginventory</artifactId> <artifactId>rpginventory</artifactId>
<version>2.3.0</version> <version>2.3.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Holograms -->
<dependency> <dependency>
<groupId>com.sainttx.holograms</groupId> <groupId>com.sainttx.holograms</groupId>
<artifactId>Holograms</artifactId> <artifactId>Holograms</artifactId>
<version>2.9.1</version> <version>2.9.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Aurelium Skills -->
<dependency> <dependency>
<groupId>com.archyx</groupId> <groupId>com.archyx</groupId>
<artifactId>AureliumSkills</artifactId> <artifactId>AureliumSkills</artifactId>
<version>1.2.8</version> <version>1.2.8</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Crazy Enchantments -->
<dependency> <dependency>
<groupId>me.badbones69</groupId> <groupId>me.badbones69</groupId>
<artifactId>crazyenchantments</artifactId> <artifactId>crazyenchantments</artifactId>
<version>1.8-db9</version> <version>1.8-db9</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Citizens -->
<dependency> <dependency>
<groupId>net.citizensnpcs</groupId> <groupId>net.citizensnpcs</groupId>
<artifactId>Citizens</artifactId> <artifactId>Citizens</artifactId>
<version>2.0.25</version> <version>2.0.25</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Denizen -->
<dependency> <dependency>
<groupId>com.denizenscript</groupId> <groupId>com.denizenscript</groupId>
<artifactId>denizen</artifactId> <artifactId>denizen</artifactId>
<version>1.2.1-b1744-REL</version> <version>1.2.1-b1744-REL</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<!-- Denizen -->
<dependency> <dependency>
<groupId>com.denizenscript</groupId> <groupId>com.denizenscript</groupId>
<artifactId>depenizen</artifactId> <artifactId>depenizen</artifactId>
<version>2.0.0-b709</version> <version>2.0.0-b709</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmoitems.api;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
public enum CustomSound { public enum CustomSound {

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmoitems.api; package net.Indyuce.mmoitems.api;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.stat.data.AbilityData; import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.ParticleData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
@ -31,50 +31,55 @@ public class ItemSet {
this.loreTag = config.getStringList("lore-tag"); this.loreTag = config.getStringList("lore-tag");
this.name = config.getString("name"); this.name = config.getString("name");
Validate.isTrue(config.contains("bonuses"), "Could not find item set bonuses"); Validate.isTrue(config.isConfigurationSection("bonuses"), "Could not find item set bonuses");
for (int j = 2; j <= itemLimit; j++) for (int j = 2; j <= itemLimit; j++)
if (config.getConfigurationSection("bonuses").contains(String.valueOf(j))) { if (config.getConfigurationSection("bonuses").contains(String.valueOf(j))) {
SetBonuses bonuses = new SetBonuses(); final String bonusesKey = "bonuses.%d".formatted(j);
final SetBonuses bonuses = new SetBonuses();
final ConfigurationSection bonusesSection = config.getConfigurationSection(bonusesKey);
Validate.notNull(bonusesSection, "Item set '%s' is not a valid configuration section.".formatted(id));
// Add permissions // Add permissions
for (String perm : config.getConfigurationSection("bonuses." + j).getStringList("granted-permissions")) for (String perm : bonusesSection.getStringList("granted-permissions"))
bonuses.addPermission(perm); bonuses.addPermission(perm);
for (String key : config.getConfigurationSection("bonuses." + j).getKeys(false)) for (String key : bonusesSection.getKeys(false))
if (!key.equals("granted-permissions")) { if (!key.equals("granted-permissions")) {
try { try {
String format = key.toUpperCase().replace("-", "_").replace(" ", "_"); String format = key.toUpperCase().replace("-", "_").replace(" ", "_");
// ability // ability
if (key.startsWith("ability-")) { if (key.startsWith("ability-")) {
bonuses.addAbility(new AbilityData(config.getConfigurationSection("bonuses." + j + "." + key))); final ConfigurationSection section = config.getConfigurationSection("%s.%s".formatted(bonusesKey, key));
Validate.notNull(section, "Ability '%s' is not a valid configuration section.".formatted(key));
bonuses.addAbility(new AbilityData(section));
continue; continue;
} }
// potion effect // potion effect
if (key.startsWith("potion-")) { if (key.startsWith("potion-")) {
PotionEffectType potionEffectType = PotionEffectType.getByName(format.substring("potion-".length())); PotionEffectType potionEffectType = PotionEffectType.getByName(format.substring("potion-".length()));
Validate.notNull(potionEffectType, "Could not load potion effect type from '" + format + "'"); Validate.notNull(potionEffectType, "Could not load potion effect type from '%s'".formatted(format));
bonuses.addPotionEffect(new PotionEffect(potionEffectType, MMOUtils.getEffectDuration(potionEffectType), bonuses.addPotionEffect(new PotionEffect(potionEffectType, MMOUtils.getEffectDuration(potionEffectType),
config.getInt("bonuses." + j + "." + key) - 1, true, false)); config.getInt("%s.%s".formatted(bonusesKey, key)) - 1, true, false));
continue; continue;
} }
// particle effect // particle effect
if (key.startsWith("particle-")) { if (key.startsWith("particle-")) {
bonuses.addParticle(new ParticleData(config.getConfigurationSection("bonuses." + j + "." + key))); final ConfigurationSection section = config.getConfigurationSection("bonuses.%d.%s".formatted(j, key));
Validate.notNull(section, "Particle effect '%s' is not a valid configuration section.".formatted(key));
bonuses.addParticle(new ParticleData(section));
continue; continue;
} }
// stat // stat
ItemStat stat = MMOItems.plugin.getStats().get(format); ItemStat<?, ?> stat = MMOItems.plugin.getStats().get(format);
Validate.notNull(stat, "Could not find stat called '" + format + "'"); Validate.notNull(stat, "Could not find stat called '%s'".formatted(format));
bonuses.addStat(stat, config.getDouble("bonuses." + j + "." + key)); bonuses.addStat(stat, config.getDouble("bonuses.%d.%s".formatted(j, key)));
} catch (IllegalArgumentException exception) { } catch (IllegalArgumentException exception) {
throw new IllegalArgumentException("Could not load set bonus '" + key + "': " + exception.getMessage()); throw new IllegalArgumentException("Could not load set bonus '%s': %s".formatted(key, exception.getMessage()));
} }
} }
@ -103,13 +108,13 @@ public class ItemSet {
} }
public static class SetBonuses { public static class SetBonuses {
private final Map<ItemStat, Double> stats = new HashMap<>(); private final Map<ItemStat<?, ?>, Double> stats = new HashMap<>();
private final Map<PotionEffectType, PotionEffect> permEffects = new HashMap<>(); private final Map<PotionEffectType, PotionEffect> permEffects = new HashMap<>();
private final Set<AbilityData> abilities = new HashSet<>(); private final Set<AbilityData> abilities = new HashSet<>();
private final Set<ParticleData> particles = new HashSet<>(); private final Set<ParticleData> particles = new HashSet<>();
private final ArrayList<String> permissions = new ArrayList<>(); private final ArrayList<String> permissions = new ArrayList<>();
public void addStat(ItemStat stat, double value) { public void addStat(ItemStat<?, ?> stat, double value) {
stats.put(stat, value); stats.put(stat, value);
} }
@ -129,15 +134,15 @@ public class ItemSet {
permissions.add(permission); permissions.add(permission);
} }
public boolean hasStat(ItemStat stat) { public boolean hasStat(ItemStat<?, ?> stat) {
return stats.containsKey(stat); return stats.containsKey(stat);
} }
public double getStat(ItemStat stat) { public double getStat(ItemStat<?, ?> stat) {
return stats.get(stat); return stats.get(stat);
} }
public Map<ItemStat, Double> getStats() { public Map<ItemStat<?, ?>, Double> getStats() {
return stats; return stats;
} }

View File

@ -6,7 +6,7 @@ import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.version.VersionSound; import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon; import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType; import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;

View File

@ -6,7 +6,7 @@ import io.lumine.mythic.lib.api.util.ui.QuickNumberRange;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.crafting.ConfigMMOItem; import net.Indyuce.mmoitems.api.crafting.ConfigMMOItem;
import net.Indyuce.mmoitems.api.crafting.ingredient.inventory.MMOItemPlayerIngredient; import net.Indyuce.mmoitems.api.crafting.ingredient.inventory.MMOItemPlayerIngredient;

View File

@ -10,8 +10,7 @@ import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackCategory;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackMessage; import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackMessage;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider; import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.crafting.ingredient.inventory.VanillaPlayerIngredient; import net.Indyuce.mmoitems.api.crafting.ingredient.inventory.VanillaPlayerIngredient;
import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems; import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.api.crafting.recipe;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.crafting.ConfigMMOItem; import net.Indyuce.mmoitems.api.crafting.ConfigMMOItem;
import net.Indyuce.mmoitems.api.crafting.CraftingStation; import net.Indyuce.mmoitems.api.crafting.CraftingStation;
import net.Indyuce.mmoitems.api.crafting.ingredient.CheckedIngredient; import net.Indyuce.mmoitems.api.crafting.ingredient.CheckedIngredient;

View File

@ -8,67 +8,63 @@ import net.Indyuce.mmoitems.api.player.PlayerData;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
public class RepairItemEvent extends PlayerDataEvent { public class RepairItemEvent extends PlayerDataEvent {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private final VolatileMMOItem consumable; private final VolatileMMOItem consumable;
private final NBTItem target; private final NBTItem target;
private int repaired; private int repaired = -1;
private double repairedPercent; private double repairedPercent = -1;
/** /**
* Called when a player repairs an item using a consumable * Called when a player repairs an item using a consumable
* *
* @param playerData * @param playerData Player repairing the item
* Player repairing the item * @param consumable Consumable used to repair the item
* @param consumable * @param target Item being repaired
* Consumable used to repair the item * @param repaired Amount of durability being repaired
* @param target */
* Item being repaired public RepairItemEvent(PlayerData playerData, VolatileMMOItem consumable, NBTItem target, int repaired) {
* @param repaired super(playerData);
* Amount of durability being repaired
*/
public RepairItemEvent(PlayerData playerData, VolatileMMOItem consumable, NBTItem target, int repaired) {
super(playerData);
this.consumable = consumable; this.consumable = consumable;
this.target = target; this.target = target;
this.repaired = repaired; this.repaired = repaired;
} }
public RepairItemEvent(PlayerData playerData, VolatileMMOItem consumable, NBTItem target, double repaired) { public RepairItemEvent(PlayerData playerData, VolatileMMOItem consumable, NBTItem target, double repaired) {
super(playerData); super(playerData);
this.consumable = consumable; this.consumable = consumable;
this.target = target; this.target = target;
this.repairedPercent = repaired; this.repairedPercent = repaired;
} }
public VolatileMMOItem getConsumable() { public VolatileMMOItem getConsumable() {
return consumable; return consumable;
} }
public NBTItem getTargetItem() { public NBTItem getTargetItem() {
return target; return target;
} }
public int getRepaired() { public int getRepaired() {
return repaired; return repaired;
} }
public double getRepairedPercent(){ public double getRepairedPercent() {
return repairedPercent; return repairedPercent;
} }
public void setRepaired(int repaired) { public void setRepaired(int repaired) {
this.repaired = repaired; this.repaired = repaired;
} }
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
} }

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.api.interaction;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.ApplyGemStoneEvent; import net.Indyuce.mmoitems.api.event.item.ApplyGemStoneEvent;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;

View File

@ -5,7 +5,7 @@ import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.api.util.message.Message;

View File

@ -11,7 +11,7 @@ import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.version.VersionSound; import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.util.SoundReader; import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect; import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;

View File

@ -5,12 +5,10 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.util.SoundReader; import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -5,12 +5,10 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.util.SoundReader; import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -5,12 +5,10 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.util.SoundReader; import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -5,12 +5,10 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.util.SoundReader; import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -5,12 +5,10 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.util.SoundReader; import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData; import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
import org.bukkit.Location; import org.bukkit.Location;

View File

@ -4,11 +4,10 @@ import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.player.EquipmentSlot; import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;

View File

@ -4,11 +4,10 @@ import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.player.EquipmentSlot; import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;

View File

@ -4,12 +4,11 @@ import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.player.EquipmentSlot; import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType; import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.version.VersionSound; import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;

View File

@ -8,7 +8,7 @@ import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.version.VersionSound; import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; import org.bukkit.Sound;

View File

@ -2,12 +2,11 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.staff;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.player.EquipmentSlot; import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.damage.AttackMetadata;
import io.lumine.mythic.lib.damage.DamageMetadata; import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType; import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata; import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.skill.Shulker_Missile; import net.Indyuce.mmoitems.skill.ShulkerMissile;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.ShulkerBullet; import org.bukkit.entity.ShulkerBullet;
@ -34,6 +33,6 @@ public class VoidSpirit implements StaffAttackHandler {
shulkerBullet.setVelocity(vec); shulkerBullet.setVelocity(vec);
} }
}.runTaskTimer(MMOItems.plugin, 0, 1); }.runTaskTimer(MMOItems.plugin, 0, 1);
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new Shulker_Missile.ShulkerMissileEntityData(caster, new DamageMetadata(damage, DamageType.WEAPON, DamageType.MAGIC, DamageType.PROJECTILE), 0, nbt)); MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new ShulkerMissile.ShulkerMissileEntityData(caster, new DamageMetadata(damage, DamageType.WEAPON, DamageType.MAGIC, DamageType.PROJECTILE), 0, nbt));
} }
} }

View File

@ -1,7 +1,6 @@
package net.Indyuce.mmoitems.api.item.template; package net.Indyuce.mmoitems.api.item.template;
import io.lumine.mythic.lib.MythicLib; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.MMOUtils;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmoitems.api.item.util;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;

View File

@ -5,7 +5,7 @@ import io.lumine.mythic.lib.adventure.text.Component;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.LegacyComponent; import io.lumine.mythic.lib.api.util.LegacyComponent;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay; import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay;
import net.Indyuce.mmoitems.api.crafting.condition.CheckedCondition; import net.Indyuce.mmoitems.api.crafting.condition.CheckedCondition;
import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe; import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe;

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.adventure.text.Component;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.LegacyComponent; import io.lumine.mythic.lib.api.util.LegacyComponent;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay; import net.Indyuce.mmoitems.api.crafting.ConditionalDisplay;
import net.Indyuce.mmoitems.api.crafting.condition.CheckedCondition; import net.Indyuce.mmoitems.api.crafting.condition.CheckedCondition;
import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe; import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe;

View File

@ -8,7 +8,6 @@ import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.player.modifier.ModifierSource; import io.lumine.mythic.lib.player.modifier.ModifierSource;
import io.lumine.mythic.lib.player.modifier.ModifierType; import io.lumine.mythic.lib.player.modifier.ModifierType;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.player.inventory.EquippedItem; import net.Indyuce.mmoitems.api.player.inventory.EquippedItem;
import net.Indyuce.mmoitems.stat.type.AttackWeaponStat; import net.Indyuce.mmoitems.stat.type.AttackWeaponStat;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
@ -28,11 +27,11 @@ public class PlayerStats {
return playerData.getMMOPlayerData().getStatMap(); return playerData.getMMOPlayerData().getStatMap();
} }
public double getStat(ItemStat stat) { public double getStat(ItemStat<?, ?> stat) {
return getMap().getInstance(stat.getId()).getTotal(); return getMap().getInstance(stat.getId()).getTotal();
} }
public StatInstance getInstance(ItemStat stat) { public StatInstance getInstance(ItemStat<?, ?> stat) {
return getMap().getInstance(stat.getId()); return getMap().getInstance(stat.getId());
} }
@ -50,8 +49,7 @@ public class PlayerStats {
} }
public void updateStats() { public void updateStats() {
for (ItemStat<?, ?> stat : MMOItems.plugin.getStats().getNumericStats()) {
for (ItemStat stat : MMOItems.plugin.getStats().getNumericStats()) {
// Let MMOItems first add stat modifiers, and then update the stat instance // Let MMOItems first add stat modifiers, and then update the stat instance
StatInstance.ModifierPacket packet = getInstance(stat).newPacket(); StatInstance.ModifierPacket packet = getInstance(stat).newPacket();

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.api.recipe;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.manager.RecipeManager; import net.Indyuce.mmoitems.manager.RecipeManager;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;

View File

@ -5,7 +5,7 @@ import io.lumine.mythic.lib.command.api.CommandTreeNode;
import io.lumine.mythic.lib.command.api.Parameter; import io.lumine.mythic.lib.command.api.Parameter;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;

View File

@ -13,8 +13,8 @@ import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.comp.mmocore.stat.ExtraAttribute; import net.Indyuce.mmoitems.comp.mmocore.stat.ExtraAttribute;
import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Attribute; import net.Indyuce.mmoitems.comp.mmocore.stat.RequiredAttribute;
import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Profession; import net.Indyuce.mmoitems.comp.mmocore.stat.RequiredProfession;
import net.Indyuce.mmoitems.comp.rpg.RPGHandler; import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.DoubleStat;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -32,7 +32,7 @@ public class MMOCoreHook implements RPGHandler, Listener {
*/ */
public MMOCoreHook() { public MMOCoreHook() {
for (PlayerAttribute attribute : MMOCore.plugin.attributeManager.getAll()) { for (PlayerAttribute attribute : MMOCore.plugin.attributeManager.getAll()) {
MMOItems.plugin.getStats().register(new Required_Attribute(attribute)); MMOItems.plugin.getStats().register(new RequiredAttribute(attribute));
MMOItems.plugin.getStats().register(new ExtraAttribute(attribute)); MMOItems.plugin.getStats().register(new ExtraAttribute(attribute));
} }
@ -43,8 +43,7 @@ public class MMOCoreHook implements RPGHandler, Listener {
.replace('-', '_').replace(' ', '_').toUpperCase(Locale.ROOT), .replace('-', '_').replace(' ', '_').toUpperCase(Locale.ROOT),
VersionMaterial.EXPERIENCE_BOTTLE.toMaterial(), profession.getName() + ' ' + "Additional Experience (MMOCore)" VersionMaterial.EXPERIENCE_BOTTLE.toMaterial(), profession.getName() + ' ' + "Additional Experience (MMOCore)"
, new String[]{"Additional MMOCore profession " + profession.getName() + " experience in %."}, new String[]{"!block", "all"})); , new String[]{"Additional MMOCore profession " + profession.getName() + " experience in %."}, new String[]{"!block", "all"}));
MMOItems.plugin.getStats().register(new RequiredProfession(profession));
MMOItems.plugin.getStats().register(new Required_Profession(profession));
} }
} }

View File

@ -12,11 +12,11 @@ import net.Indyuce.mmoitems.stat.type.ItemRestriction;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Sound; import org.bukkit.Sound;
public class Required_Attribute extends DoubleStat implements ItemRestriction, GemStoneStat { public class RequiredAttribute extends DoubleStat implements ItemRestriction, GemStoneStat {
private final PlayerAttribute attribute; private final PlayerAttribute attribute;
// TODO merge with RequiredLevelStat // TODO merge with RequiredLevelStat
public Required_Attribute(PlayerAttribute attribute) { public RequiredAttribute(PlayerAttribute attribute) {
super("REQUIRED_" + attribute.getId().toUpperCase().replace("-", "_"), VersionMaterial.GRAY_DYE.toMaterial(), attribute.getName() + " Requirement (MMOCore)", new String[]{"Amount of " + attribute.getName() + " points the", "player needs to use the item."}, new String[]{"!block", "all"}); super("REQUIRED_" + attribute.getId().toUpperCase().replace("-", "_"), VersionMaterial.GRAY_DYE.toMaterial(), attribute.getName() + " Requirement (MMOCore)", new String[]{"Amount of " + attribute.getName() + " points the", "player needs to use the item."}, new String[]{"!block", "all"});
this.attribute = attribute; this.attribute = attribute;

View File

@ -12,11 +12,11 @@ import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
public class Required_Profession extends DoubleStat implements ItemRestriction, GemStoneStat { public class RequiredProfession extends DoubleStat implements ItemRestriction, GemStoneStat {
private final Profession profession; private final Profession profession;
// TODO merge with RequiredLevelStat // TODO merge with RequiredLevelStat
public Required_Profession(Profession profession) { public RequiredProfession(Profession profession) {
super("PROFESSION_" + profession.getId().toUpperCase().replace("-", "_"), Material.PINK_DYE, profession.getName() + " Requirement (MMOCore)", super("PROFESSION_" + profession.getId().toUpperCase().replace("-", "_"), Material.PINK_DYE, profession.getName() + " Requirement (MMOCore)",
new String[]{"Amount of " + profession.getName() + " levels the", "player needs to use the item."}, new String[]{"!block", "all"}); new String[]{"Amount of " + profession.getName() + " levels the", "player needs to use the item."}, new String[]{"!block", "all"});

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.ItemTier; import net.Indyuce.mmoitems.api.ItemTier;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -5,7 +5,7 @@ import io.lumine.mythic.lib.adventure.text.Component;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.LegacyComponent; import io.lumine.mythic.lib.api.util.LegacyComponent;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.crafting.ingredient.CheckedIngredient; import net.Indyuce.mmoitems.api.crafting.ingredient.CheckedIngredient;
import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe; import net.Indyuce.mmoitems.api.crafting.recipe.CheckedRecipe;
import net.Indyuce.mmoitems.api.crafting.recipe.CraftingRecipe; import net.Indyuce.mmoitems.api.crafting.recipe.CraftingRecipe;

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.SmartGive; import io.lumine.mythic.lib.api.util.SmartGive;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.crafting.CraftingStation; import net.Indyuce.mmoitems.api.crafting.CraftingStation;
import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue; import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue;
import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue.CraftingInfo; import net.Indyuce.mmoitems.api.crafting.CraftingStatus.CraftingQueue.CraftingInfo;

View File

@ -7,7 +7,7 @@ import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.edition.NewItemEdition; import net.Indyuce.mmoitems.api.edition.NewItemEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmoitems.gui.edition;
import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.NumericStatFormula;

View File

@ -17,7 +17,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.NumericStatFormula;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.gui.edition;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.ParticleData;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.gui.edition;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;

View File

@ -5,7 +5,7 @@ import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.element.Element; import io.lumine.mythic.lib.element.Element;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.stat.data.random.RandomElementListData; import net.Indyuce.mmoitems.stat.data.random.RandomElementListData;

View File

@ -5,7 +5,7 @@ import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.stat.type.InternalStat; import net.Indyuce.mmoitems.stat.type.InternalStat;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.gui.edition;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.particle.api.ParticleType; import net.Indyuce.mmoitems.particle.api.ParticleType;

View File

@ -5,14 +5,12 @@ import io.lumine.mythic.lib.version.VersionMaterial;
import io.lumine.mythic.lib.api.util.ItemFactory; import io.lumine.mythic.lib.api.util.ItemFactory;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.util.MMOItemReforger; import net.Indyuce.mmoitems.api.util.MMOItemReforger;
import net.Indyuce.mmoitems.stat.RevisionID; import net.Indyuce.mmoitems.stat.RevisionID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction; import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.gui.edition;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.CustomSound; import net.Indyuce.mmoitems.api.CustomSound;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.gui.edition;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;

View File

@ -15,7 +15,7 @@ import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.api.recipe.CraftingType; import net.Indyuce.mmoitems.api.recipe.CraftingType;

View File

@ -2,15 +2,13 @@ package net.Indyuce.mmoitems.gui.listener;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate; import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
import net.Indyuce.mmoitems.gui.ItemBrowser; import net.Indyuce.mmoitems.gui.ItemBrowser;
import net.Indyuce.mmoitems.gui.PluginInventory; import net.Indyuce.mmoitems.gui.PluginInventory;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.gui.edition.ItemEdition; import net.Indyuce.mmoitems.gui.edition.ItemEdition;
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeBrowserGUI; import net.Indyuce.mmoitems.gui.edition.recipe.RecipeBrowserGUI;
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeEdition;
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeListEdition;
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeListGUI; import net.Indyuce.mmoitems.gui.edition.recipe.RecipeListGUI;
import net.Indyuce.mmoitems.gui.edition.recipe.recipes.RecipeMakerGUI; import net.Indyuce.mmoitems.gui.edition.recipe.recipes.RecipeMakerGUI;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.ConfigFile; import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.ReforgeOptions; import net.Indyuce.mmoitems.api.ReforgeOptions;
import net.Indyuce.mmoitems.api.item.util.ConfigItem; import net.Indyuce.mmoitems.api.item.util.ConfigItem;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.manager;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.ConfigFile; import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.block.CustomBlock; import net.Indyuce.mmoitems.api.block.CustomBlock;
import net.Indyuce.mmoitems.api.droptable.DropTable; import net.Indyuce.mmoitems.api.droptable.DropTable;

View File

@ -3,6 +3,7 @@ package net.Indyuce.mmoitems.manager;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ConfigFile; import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.ItemSet; import net.Indyuce.mmoitems.api.ItemSet;
import org.bukkit.configuration.ConfigurationSection;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
@ -10,37 +11,40 @@ import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
public class SetManager implements Reloadable { public class SetManager implements Reloadable {
private final Map<String, ItemSet> itemSets = new HashMap<>(); private final Map<String, ItemSet> itemSets = new HashMap<>();
public SetManager() { public SetManager() {
reload(); reload();
} }
public void reload() { public void reload() {
itemSets.clear(); itemSets.clear();
ConfigFile config = new ConfigFile("item-sets"); ConfigFile config = new ConfigFile("item-sets");
for (String id : config.getConfig().getKeys(false)) for (String id : config.getConfig().getKeys(false))
try { try {
itemSets.put(id, new ItemSet(config.getConfig().getConfigurationSection(id))); final ConfigurationSection section = config.getConfig().getConfigurationSection(id);
} catch (IllegalArgumentException exception) { if (section == null)
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load item set '" + id + "': " + exception.getMessage()); throw new IllegalStateException("Item set '%s' is not a valid configuration section.".formatted(id));
} itemSets.put(id, new ItemSet(section));
} } catch (IllegalArgumentException exception) {
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load item set '%s': %s".formatted(id, exception.getMessage()));
}
}
public void register(ItemSet set) { public void register(ItemSet set) {
itemSets.put(set.getId(), set); itemSets.put(set.getId(), set);
} }
public boolean has(String id) { public boolean has(String id) {
return itemSets.containsKey(id); return itemSets.containsKey(id);
} }
public Collection<ItemSet> getAll() { public Collection<ItemSet> getAll() {
return itemSets.values(); return itemSets.values();
} }
public ItemSet get(String id) { public ItemSet get(String id) {
return itemSets.getOrDefault(id, null); return itemSets.getOrDefault(id, null);
} }
} }

View File

@ -3,10 +3,10 @@ package net.Indyuce.mmoitems.manager;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.skill.handler.SkillHandler; import io.lumine.mythic.lib.skill.handler.SkillHandler;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.ConfigFile; import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.skill.RegisteredSkill; import net.Indyuce.mmoitems.skill.RegisteredSkill;
import net.Indyuce.mmoitems.skill.Shulker_Missile; import net.Indyuce.mmoitems.skill.ShulkerMissile;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -81,7 +81,7 @@ public class SkillManager {
if (clearBefore) if (clearBefore)
skills.clear(); skills.clear();
MythicLib.plugin.getSkills().registerSkillHandler(new Shulker_Missile()); MythicLib.plugin.getSkills().registerSkillHandler(new ShulkerMissile());
File skillFolder = new File(MMOItems.plugin.getDataFolder() + "/skill"); File skillFolder = new File(MMOItems.plugin.getDataFolder() + "/skill");
if (!skillFolder.exists()) { if (!skillFolder.exists()) {

View File

@ -14,148 +14,160 @@ import java.util.*;
import java.util.logging.Level; import java.util.logging.Level;
public class StatManager { public class StatManager {
private final Map<String, ItemStat> stats = new LinkedHashMap<>(); private final Map<String, ItemStat<?, ?>> stats = new LinkedHashMap<>();
/* /*
* These lists are sets of stats collected when the stats are registered for * These lists are sets of stats collected when the stats are registered for
* the first time to make their access easier. Check the classes * the first time to make their access easier. Check the classes
* individually to understand better * individually to understand better
*/ */
private final Set<DoubleStat> numeric = new HashSet<>(); private final Set<DoubleStat> numeric = new HashSet<>();
private final Set<ItemRestriction> itemRestriction = new HashSet<>(); private final Set<ItemRestriction> itemRestriction = new HashSet<>();
private final Set<ConsumableItemInteraction> consumableActions = new HashSet<>(); private final Set<ConsumableItemInteraction> consumableActions = new HashSet<>();
private final Set<PlayerConsumable> playerConsumables = new HashSet<>(); private final Set<PlayerConsumable> playerConsumables = new HashSet<>();
/** /**
* Load default stats using java reflection, get all public static final * Load default stats using java reflection, get all public static final
* fields in the ItemStat and register them as stat instances * fields in the ItemStat and register them as stat instances
*/ */
public void load() { public void load() {
for (Field field : ItemStats.class.getFields()) for (Field field : ItemStats.class.getFields())
try { try {
if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.get(null) instanceof ItemStat) if (Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()) && field.get(null) instanceof ItemStat)
register((ItemStat) field.get(null)); register((ItemStat<?, ?>) field.get(null));
} catch (IllegalArgumentException | IllegalAccessException exception) { } catch (IllegalArgumentException | IllegalAccessException exception) {
MMOItems.plugin.getLogger().log(Level.WARNING, "Couldn't register stat called '" + field.getName() + "': " + exception.getMessage()); MMOItems.plugin.getLogger().log(Level.WARNING, "Couldn't register stat called '%s'".formatted(field.getName()), exception.getMessage());
} }
} }
/** /**
* @see FictiveNumericStat * @see FictiveNumericStat
* @deprecated * @deprecated
*/ */
@Deprecated @Deprecated
public void reload(boolean cleanFirst) { public void reload(boolean cleanFirst) {
// Clean fictive numeric stats before
if (cleanFirst)
numeric.removeIf(stat -> stat instanceof FictiveNumericStat);
// Clean fictive numeric stats before // Register elemental stats
if (cleanFirst) loadElements();
for (Iterator<DoubleStat> ite = numeric.iterator(); ite.hasNext(); ) { }
DoubleStat stat = ite.next();
if (stat instanceof FictiveNumericStat)
ite.remove();
}
// Register elemental stats /**
for (ElementStatType type : ElementStatType.values()) * Register all MythicLib elements as stats
for (Element element : MythicLib.plugin.getElements().getAll()) */
numeric.add(new FictiveNumericStat(element, type)); public void loadElements() {
} for (ElementStatType type : ElementStatType.values()) {
for (Element element : MythicLib.plugin.getElements().getAll()) {
numeric.add(new FictiveNumericStat(element, type));
}
}
}
public Collection<ItemStat> getAll() { public Collection<ItemStat<?, ?>> getAll() {
return stats.values(); return stats.values();
} }
/** /**
* @return Collection of all numeric stats like atk damage, crit strike * @return Collection of all numeric stats like atk damage, crit strike
* chance, max mana... which can be applied on a gem stone. This is * chance, max mana... which can be applied on a gem stone. This is
* used when applying gem stones to quickly access all the stats * used when applying gem stones to quickly access all the stats
* which needs to be applied * which needs to be applied
*/ */
public Set<DoubleStat> getNumericStats() { public Set<DoubleStat> getNumericStats() {
return numeric; return numeric;
} }
/** /**
* @return Collection of all stats which constitute an item restriction: * @return Collection of all stats which constitute an item restriction:
* required level, required class, soulbound.. * required level, required class, soulbound..
*/ */
public Set<ItemRestriction> getItemRestrictionStats() { public Set<ItemRestriction> getItemRestrictionStats() {
return itemRestriction; return itemRestriction;
} }
/** /**
* @return Collection of all stats implementing a consumable action like * @return Collection of all stats implementing a consumable action like
* deconstructing, identifying... * deconstructing, identifying...
*/ */
public Set<ConsumableItemInteraction> getConsumableActions() { public Set<ConsumableItemInteraction> getConsumableActions() {
return consumableActions; return consumableActions;
} }
/** /**
* @return Collection of all stats implementing self consumable like * @return Collection of all stats implementing self consumable like
* restore health, mana, hunger... * restore health, mana, hunger...
*/ */
public Set<PlayerConsumable> getPlayerConsumables() { public Set<PlayerConsumable> getPlayerConsumables() {
return playerConsumables; return playerConsumables;
} }
public boolean has(String id) { public boolean has(String id) {
return stats.containsKey(id); return stats.containsKey(id);
} }
public ItemStat get(String id) { public ItemStat<?, ?> get(String id) {
return stats.getOrDefault(id, null); ItemStat<?, ?> stat = stats.getOrDefault(id, null);
} if (stat == null)
stat = numeric.stream()
.filter(doubleStat -> doubleStat.getId().equals(id))
.findFirst()
.orElse(null);
return stat;
}
/** /**
* Registers a stat in MMOItems * Registers a stat in MMOItems
* *
* @param id Useless. * @param id Useless.
* @param stat The stat instance * @param stat The stat instance
* @deprecated Stat IDs are now stored in the stat instance directly. * @deprecated Stat IDs are now stored in the stat instance directly.
* Please use StatManager#register(ItemStat) instead * Please use StatManager#register(ItemStat) instead
*/ */
@Deprecated @Deprecated
@SuppressWarnings("unused") @SuppressWarnings("unused")
public void register(String id, ItemStat stat) { public void register(String id, ItemStat<?, ?> stat) {
register(stat); register(stat);
} }
/** /**
* Registers a stat in MMOItems. It must be done right after MMOItems loads * Registers a stat in MMOItems. It must be done right after MMOItems loads
* before any manager is initialized because stats are commonly used when * before any manager is initialized because stats are commonly used when
* loading configs. * loading configs.
* *
* @param stat The stat to register * @param stat The stat to register
*/ */
public void register(ItemStat stat) { public void register(ItemStat<?, ?> stat) {
if (!stat.isEnabled()) if (!stat.isEnabled())
return; return;
stats.put(stat.getId(), stat); stats.put(stat.getId(), stat);
if (stat instanceof DoubleStat && !(stat instanceof GemStoneStat) && stat.isCompatible(Type.GEM_STONE)) if (stat instanceof DoubleStat && !(stat instanceof GemStoneStat) && stat.isCompatible(Type.GEM_STONE))
numeric.add((DoubleStat) stat); numeric.add((DoubleStat) stat);
if (stat instanceof ItemRestriction) if (stat instanceof ItemRestriction)
itemRestriction.add((ItemRestriction) stat); itemRestriction.add((ItemRestriction) stat);
if (stat instanceof ConsumableItemInteraction) if (stat instanceof ConsumableItemInteraction)
consumableActions.add((ConsumableItemInteraction) stat); consumableActions.add((ConsumableItemInteraction) stat);
if (stat instanceof PlayerConsumable) if (stat instanceof PlayerConsumable)
playerConsumables.add((PlayerConsumable) stat); playerConsumables.add((PlayerConsumable) stat);
/** /*
* Cache stat for every type which may have this stat. Really important * Cache stat for every type which may have this stat. Really important
* otherwise the stat will NOT be used anywhere in the plugin. This * otherwise the stat will NOT be used anywhere in the plugin. This
* process is also done in the TypeManager when registering new types * process is also done in the TypeManager when registering new types
* but since stats can be registered after types are loaded, we must * but since stats can be registered after types are loaded, we must
* take it into account * take it into account
*/ */
if (MMOItems.plugin.getTypes() != null) if (MMOItems.plugin.getTypes() != null)
for (Type type : MMOItems.plugin.getTypes().getAll()) MMOItems.plugin.getTypes()
if (stat.isCompatible(type)) .getAll()
type.getAvailableStats().add(stat); .stream()
} .filter(stat::isCompatible)
.forEach(type -> type.getAvailableStats().add(stat));
}
} }

View File

@ -5,7 +5,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.function.BiFunction; import java.util.function.BiFunction;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.StringValue; import net.Indyuce.mmoitems.api.util.StringValue;
import net.Indyuce.mmoitems.particle.AuraParticles; import net.Indyuce.mmoitems.particle.AuraParticles;

View File

@ -26,16 +26,18 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public class Shulker_Missile extends SkillHandler<VectorSkillResult> implements Listener { public class ShulkerMissile extends SkillHandler<VectorSkillResult> implements Listener {
public Shulker_Missile() { public ShulkerMissile() {
super(); super();
registerModifiers("damage", "effect-duration", "duration"); registerModifiers("damage", "effect-duration", "duration");
} }
@NotNull
@Override @Override
public VectorSkillResult getResult(SkillMetadata meta) { public VectorSkillResult getResult(SkillMetadata meta) {
return new VectorSkillResult(meta); return new VectorSkillResult(meta);

View File

@ -7,7 +7,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.NumericStatFormula;

View File

@ -5,28 +5,24 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import net.Indyuce.mmoitems.stat.data.StringData;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Item;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.ArrowParticlesEdition; import net.Indyuce.mmoitems.gui.edition.ArrowParticlesEdition;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.ArrowParticlesData; import net.Indyuce.mmoitems.stat.data.ArrowParticlesData;
import net.Indyuce.mmoitems.stat.data.ParticleData; import net.Indyuce.mmoitems.stat.data.ParticleData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;

View File

@ -8,7 +8,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.interaction.projectile.ArrowPotionEffectArrayItem; import net.Indyuce.mmoitems.api.interaction.projectile.ArrowPotionEffectArrayItem;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;

View File

@ -11,7 +11,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.ItemTier; import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.DeconstructItemEvent; import net.Indyuce.mmoitems.api.event.item.DeconstructItemEvent;

View File

@ -7,7 +7,7 @@ import io.lumine.mythic.lib.api.util.SmartGive;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;

View File

@ -7,7 +7,7 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.IdentifyItemEvent; import net.Indyuce.mmoitems.api.event.item.IdentifyItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;

View File

@ -2,11 +2,8 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.DeconstructItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
@ -18,16 +15,12 @@ import net.Indyuce.mmoitems.stat.data.GemstoneData;
import net.Indyuce.mmoitems.stat.type.BooleanStat; import net.Indyuce.mmoitems.stat.type.BooleanStat;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.util.Pair; import net.Indyuce.mmoitems.util.Pair;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**

View File

@ -5,17 +5,14 @@ import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.CommandListEdition; import net.Indyuce.mmoitems.gui.edition.CommandListEdition;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.CommandData; import net.Indyuce.mmoitems.stat.data.CommandData;
import net.Indyuce.mmoitems.stat.data.CommandListData; import net.Indyuce.mmoitems.stat.data.CommandListData;
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.Indyuce.mmoitems.stat.type.ItemStat;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;

View File

@ -5,7 +5,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.CustomSound; import net.Indyuce.mmoitems.api.CustomSound;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
@ -14,8 +14,6 @@ import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.gui.edition.SoundsEdition; import net.Indyuce.mmoitems.gui.edition.SoundsEdition;
import net.Indyuce.mmoitems.stat.data.SoundData; import net.Indyuce.mmoitems.stat.data.SoundData;
import net.Indyuce.mmoitems.stat.data.SoundListData; import net.Indyuce.mmoitems.stat.data.SoundListData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.GemStoneStat;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.stat.type.PlayerConsumable; import net.Indyuce.mmoitems.stat.type.PlayerConsumable;

View File

@ -8,7 +8,7 @@ import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider; import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
@ -37,200 +37,189 @@ import org.jetbrains.annotations.Nullable;
import java.util.*; import java.util.*;
public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> implements PlayerConsumable { public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectListData> implements PlayerConsumable {
public Effects() { public Effects() {
super("EFFECTS", Material.POTION, "Effects", new String[]{"The potion effects your", "consumable item grants."}, super("EFFECTS", Material.POTION, "Effects", new String[]{"The potion effects your", "consumable item grants."},
new String[]{"consumable"}); new String[]{"consumable"});
} }
@Override @Override
public RandomPotionEffectListData whenInitialized(Object object) { public RandomPotionEffectListData whenInitialized(Object object) {
Validate.isTrue(object instanceof ConfigurationSection, "Must specify a config section"); Validate.isTrue(object instanceof ConfigurationSection, "Must specify a config section");
return new RandomPotionEffectListData((ConfigurationSection) object); return new RandomPotionEffectListData((ConfigurationSection) object);
} }
@Override @Override
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) { public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent event) {
if (event.getAction() == InventoryAction.PICKUP_ALL) if (event.getAction() == InventoryAction.PICKUP_ALL)
new StatEdition(inv, ItemStats.EFFECTS).enable("Write in the chat the permanent potion effect you want to add.", new StatEdition(inv, ItemStats.EFFECTS).enable("Write in the chat the permanent potion effect you want to add.",
ChatColor.AQUA + "Format: {Potion Effect Name}|{Duration Numeric Formula}|{Amplifier Numeric Formula}", ChatColor.DARK_RED + "Note: " + ChatColor.RED + "The '|' lines are literal."); ChatColor.AQUA + "Format: {Potion Effect Name}|{Duration Numeric Formula}|{Amplifier Numeric Formula}", ChatColor.DARK_RED + "Note: " + ChatColor.RED + "The '|' lines are literal.");
if (event.getAction() == InventoryAction.PICKUP_HALF) { if (event.getAction() == InventoryAction.PICKUP_HALF) {
if (inv.getEditedSection().contains("effects")) { if (inv.getEditedSection().contains("effects")) {
Set<String> set = inv.getEditedSection().getConfigurationSection("effects").getKeys(false); Set<String> set = inv.getEditedSection().getConfigurationSection("effects").getKeys(false);
String last = Arrays.asList(set.toArray(new String[0])).get(set.size() - 1); String last = Arrays.asList(set.toArray(new String[0])).get(set.size() - 1);
inv.getEditedSection().set("effects." + last, null); inv.getEditedSection().set("effects." + last, null);
if (set.size() <= 1) if (set.size() <= 1)
inv.getEditedSection().set("effects", null); inv.getEditedSection().set("effects", null);
inv.registerTemplateEdition(); inv.registerTemplateEdition();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed " + last.substring(0, 1).toUpperCase() inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + "Successfully removed " + last.substring(0, 1).toUpperCase()
+ last.substring(1).toLowerCase() + ChatColor.GRAY + "."); + last.substring(1).toLowerCase() + ChatColor.GRAY + ".");
} }
} }
} }
@Override @Override
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
String[] split = message.split("\\|"); String[] split = message.split("\\|");
Validate.isTrue(split.length > 1, FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(),"Use this format: $e{Potion Effect Name}|{Duration Numeric Formula}|{Amplifier Numeric Formula}$b.")); Validate.isTrue(split.length > 1, FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(), "Use this format: $e{Potion Effect Name}|{Duration Numeric Formula}|{Amplifier Numeric Formula}$b."));
PotionEffectType effect = PotionEffectType.getByName(split[0].replace("-", "_").replace(" ", "_").toUpperCase()); PotionEffectType effect = PotionEffectType.getByName(split[0].replace("-", "_").replace(" ", "_").toUpperCase());
Validate.notNull(effect, split[0] + FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get()," is not a valid potion effect. All potion effects can be found here:$e https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html")); Validate.notNull(effect, split[0] + FriendlyFeedbackProvider.quickForConsole(FFPMMOItems.get(), " is not a valid potion effect. All potion effects can be found here:$e https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/potion/PotionEffectType.html"));
NumericStatFormula duration = new NumericStatFormula(split[1]); NumericStatFormula duration = new NumericStatFormula(split[1]);
NumericStatFormula amplifier = split.length > 2 ? new NumericStatFormula(split[2]) : new NumericStatFormula(1, 0, 0, 0); NumericStatFormula amplifier = split.length > 2 ? new NumericStatFormula(split[2]) : new NumericStatFormula(1, 0, 0, 0);
duration.fillConfigurationSection(inv.getEditedSection(), "effects." + effect.getName() + ".duration"); duration.fillConfigurationSection(inv.getEditedSection(), "effects." + effect.getName() + ".duration");
amplifier.fillConfigurationSection(inv.getEditedSection(), "effects." + effect.getName() + ".amplifier"); amplifier.fillConfigurationSection(inv.getEditedSection(), "effects." + effect.getName() + ".amplifier");
inv.registerTemplateEdition(); inv.registerTemplateEdition();
inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + effect.getName() + " " + amplifier + " successfully added."); inv.getPlayer().sendMessage(MMOItems.plugin.getPrefix() + effect.getName() + " " + amplifier + " successfully added.");
} }
@Override @Override
public void whenDisplayed(List<String> lore, Optional<RandomPotionEffectListData> statData) { public void whenDisplayed(List<String> lore, Optional<RandomPotionEffectListData> statData) {
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("_", " "))
+ ChatColor.GRAY + " Level: " + ChatColor.GREEN + effect.getAmplifier() + ChatColor.GRAY + " Duration: " + ChatColor.GREEN
+ effect.getDuration());
}, () -> lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None"));
lore.add("");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to add an effect.");
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the last effect.");
}
if (statData.isPresent()) { @NotNull
lore.add(ChatColor.GRAY + "Current Value:"); @Override
RandomPotionEffectListData data = statData.get(); public PotionEffectListData getClearStatData() {
for (RandomPotionEffectData effect : data.getEffects()) return new PotionEffectListData();
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
+ effect.getDuration());
} else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
lore.add(""); @Override
lore.add(ChatColor.YELLOW + AltChar.listDash + " Click to add an effect."); public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
lore.add(ChatColor.YELLOW + AltChar.listDash + " Right click to remove the last effect."); // Process Lore
} List<String> lore = new ArrayList<>();
String effectFormat = ItemStat.translate("effect");
data.getEffects().forEach(effect -> lore.add(effectFormat
.replace("{effect}",
MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
+ (effect.getLevel() < 2 ? "" : " " + MMOUtils.intToRoman(effect.getLevel())))
.replace("{duration}", MythicLib.plugin.getMMOConfig().decimal.format(effect.getDuration()))));
item.getLore().insert("effects", lore);
@NotNull // Add tags to item
@Override item.addItemTag(getAppliedNBT(data));
public PotionEffectListData getClearStatData() { }
return new PotionEffectListData();
}
@Override @NotNull
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) { @Override
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) {
// Process Lore // Create aJson Array
List<String> lore = new ArrayList<>(); JsonArray array = new JsonArray();
String effectFormat = ItemStat.translate("effect");
data.getEffects().forEach(effect -> {
lore.add(effectFormat
.replace("{effect}",
MMOItems.plugin.getLanguage().getPotionEffectName(effect.getType())
+ (effect.getLevel() < 2 ? "" : " " + MMOUtils.intToRoman(effect.getLevel())))
.replace("{duration}", MythicLib.plugin.getMMOConfig().decimal.format(effect.getDuration())));
});
item.getLore().insert("effects", lore);
// Add tags to item // For every effect
item.addItemTag(getAppliedNBT(data)); for (PotionEffectData effect : data.getEffects()) {
} // Convert to Json Object
JsonObject object = new JsonObject();
object.addProperty("Type", effect.getType().getName());
object.addProperty("Duration", effect.getDuration());
object.addProperty("Level", effect.getLevel());
array.add(object);
}
@NotNull // Make the tag
@Override ArrayList<ItemTag> ret = new ArrayList<>();
public ArrayList<ItemTag> getAppliedNBT(@NotNull PotionEffectListData data) { ret.add(new ItemTag(getNBTPath(), array.toString()));
// Create aJson Array // Thats it
JsonArray array = new JsonArray(); return ret;
}
// For every effect @Override
for (PotionEffectData effect : data.getEffects()) { public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
// Find relevant tag
ArrayList<ItemTag> relevantTags = new ArrayList<>();
if (mmoitem.getNBT().hasTag(getNBTPath()))
relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING));
// Convert to Json Object // Attempt to build data
JsonObject object = new JsonObject(); StatData data = getLoadedNBT(relevantTags);
object.addProperty("Type", effect.getType().getName());
object.addProperty("Duration", effect.getDuration());
object.addProperty("Level", effect.getLevel());
array.add(object);
}
// Make the tag // Valid? Append.
ArrayList<ItemTag> ret = new ArrayList<>(); if (data != null)
ret.add(new ItemTag(getNBTPath(), array.toString())); mmoitem.setData(this, data);
}
// Thats it @Nullable
return ret; @Override
} public PotionEffectListData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
@Override // Find tag
public void whenLoaded(@NotNull ReadMMOItem mmoitem) { ItemTag rTag = ItemTag.getTagAtPath(getNBTPath(), storedTags);
// Find relevant tag // Found?
ArrayList<ItemTag> relevantTags = new ArrayList<>(); if (rTag == null)
if (mmoitem.getNBT().hasTag(getNBTPath())) return null;
relevantTags.add(ItemTag.getTagAtPath(getNBTPath(), mmoitem.getNBT(), SupportedNBTTagValues.STRING)); // Must be Json Array, attempt to parse.
try {
PotionEffectListData effects = new PotionEffectListData();
// Attempt to build data // Get as Array
StatData data = getLoadedNBT(relevantTags); JsonArray array = new JsonParser().parse((String) rTag.getValue()).getAsJsonArray();
// Valid? Append. // BUild each element
if (data != null) { mmoitem.setData(this, data); } for (JsonElement e : array) {
}
@Nullable // Must be object
@Override if (e.isJsonObject()) {
public PotionEffectListData getLoadedNBT(@NotNull ArrayList<ItemTag> storedTags) {
// Find tag // Extract
ItemTag rTag = ItemTag.getTagAtPath(getNBTPath(), storedTags); JsonObject key = e.getAsJsonObject();
// Found? effects.add(new PotionEffectData(PotionEffectType.getByName(
if (rTag != null) { key.get("Type").getAsString()),
key.get("Duration").getAsDouble(),
key.get("Level").getAsInt()));
}
}
// Must be Json Array, attempt to parse. // Success
try { return effects;
PotionEffectListData effects = new PotionEffectListData();
// Get as Array } catch (JsonSyntaxException | IllegalStateException exception) {
JsonArray array = new JsonParser().parse((String) rTag.getValue()).getAsJsonArray(); /*
* OLD ITEM WHICH MUST BE UPDATED.
*/
}
return null;
}
// BUild each element @Override
for (JsonElement e : array) { public void onConsume(@NotNull VolatileMMOItem mmo, @NotNull Player player, boolean vanillaEating) {
// Does it have effects?
if (!mmo.hasData(ItemStats.EFFECTS))
return;
// Must be object // Get Data
if (e.isJsonObject()) { PotionEffectListData pelData = (PotionEffectListData) mmo.getData(ItemStats.EFFECTS);
// Extract // Apply
JsonObject key = e.getAsJsonObject(); for (PotionEffectData ped : pelData.getEffects()) {
if (ped == null)
effects.add(new PotionEffectData(PotionEffectType.getByName( continue;
key.get("Type").getAsString()), player.removePotionEffect(ped.getType());
key.get("Duration").getAsDouble(), player.addPotionEffect(ped.toEffect());
key.get("Level").getAsInt())); }
} }
}
// Success
return effects;
} catch (JsonSyntaxException|IllegalStateException exception) {
/*
* OLD ITEM WHICH MUST BE UPDATED.
*/
}
}
return null;
}
@Override
public void onConsume(@NotNull VolatileMMOItem mmo, @NotNull Player player, boolean vanillaEating) {
// Does it have effects?
if (!mmo.hasData(ItemStats.EFFECTS))
return;
// Get Data
PotionEffectListData pelData = (PotionEffectListData) mmo.getData(ItemStats.EFFECTS);
// Apply
for (PotionEffectData ped : pelData.getEffects())
if (ped != null) {
player.removePotionEffect(ped.getType());
player.addPotionEffect(ped.toEffect());
}
}
} }

View File

@ -6,7 +6,7 @@ import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import io.lumine.mythic.lib.element.Element; import io.lumine.mythic.lib.element.Element;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.NumericStatFormula;

View File

@ -9,7 +9,7 @@ import io.lumine.mythic.lib.api.util.ui.PlusMinusPercent;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
@ -20,7 +20,6 @@ import net.Indyuce.mmoitems.comp.enchants.EnchantPlugin;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.EnchantListData; import net.Indyuce.mmoitems.stat.data.EnchantListData;
import net.Indyuce.mmoitems.stat.data.random.RandomEnchantListData; import net.Indyuce.mmoitems.stat.data.random.RandomEnchantListData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.data.type.UpgradeInfo; import net.Indyuce.mmoitems.stat.data.type.UpgradeInfo;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;

View File

@ -7,7 +7,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;

View File

@ -1,15 +1,13 @@
package net.Indyuce.mmoitems.stat; package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.ItemTag;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemSet; import net.Indyuce.mmoitems.api.ItemSet;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; 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.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.StringData; import net.Indyuce.mmoitems.stat.data.StringData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.GemStoneStat; import net.Indyuce.mmoitems.stat.type.GemStoneStat;
import net.Indyuce.mmoitems.stat.type.StringStat; import net.Indyuce.mmoitems.stat.type.StringStat;
import io.lumine.mythic.lib.api.item.ItemTag;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
@ -20,64 +18,67 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
public class ItemSetStat extends StringStat implements GemStoneStat { public class ItemSetStat extends StringStat implements GemStoneStat {
public ItemSetStat() { public ItemSetStat() {
super("SET", Material.LEATHER_CHESTPLATE, "Item Set", super("SET", Material.LEATHER_CHESTPLATE, "Item Set",
new String[] { "Item sets can give to the player extra", "bonuses that depend on how many items", "from the same set your wear." }, new String[]{"Item sets can give to the player extra", "bonuses that depend on how many items", "from the same set your wear."},
new String[] { "!gem_stone", "!consumable", "!material", "!block", "!miscellaneous", "all" }); new String[]{"!gem_stone", "!consumable", "!material", "!block", "!miscellaneous", "all"});
} }
@Override @Override
public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent e) { public void whenClicked(@NotNull EditionInventory inv, @NotNull InventoryClickEvent e) {
super.whenClicked(inv, e); super.whenClicked(inv, e);
if (e.getAction() != InventoryAction.PICKUP_HALF) { if (e.getAction() != InventoryAction.PICKUP_HALF) {
inv.getPlayer().sendMessage(ChatColor.GREEN + "Available Item Sets:"); inv.getPlayer().sendMessage(ChatColor.GREEN + "Available Item Sets:");
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
for (ItemSet set : MMOItems.plugin.getSets().getAll()) for (ItemSet set : MMOItems.plugin.getSets().getAll())
builder.append(ChatColor.GREEN).append(set.getId()).append(ChatColor.GRAY) builder.append(ChatColor.GREEN).append(set.getId()).append(ChatColor.GRAY)
.append(" (").append(set.getName()).append(ChatColor.GRAY).append("), "); .append(" (").append(set.getName()).append(ChatColor.GRAY).append("), ");
if(builder.length() > 1) if (builder.length() > 1)
builder.setLength(builder.length() - 2); builder.setLength(builder.length() - 2);
inv.getPlayer().sendMessage(builder.toString()); inv.getPlayer().sendMessage(builder.toString());
} }
} }
@Override @Override
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) { public void whenApplied(@NotNull ItemStackBuilder item, @NotNull StringData data) {
// Display in lore // Display in lore
ItemSet set = MMOItems.plugin.getSets().get(data.toString()); ItemSet set = MMOItems.plugin.getSets().get(data.toString());
// Apply lore // Apply lore
if (set != null) { item.getLore().insert("set", set.getLoreTag()); } if (set != null)
item.getLore().insert("set", set.getLoreTag());
// Add NBT // Add NBT
item.addItemTag(getAppliedNBT(data)); item.addItemTag(getAppliedNBT(data));
} }
@NotNull @NotNull
@Override @Override
public ArrayList<ItemTag> getAppliedNBT(@NotNull StringData data) { public ArrayList<ItemTag> getAppliedNBT(@NotNull StringData data) {
ItemSet set = MMOItems.plugin.getSets().get(data.toString());
Validate.notNull(set, "Could not find item set with ID '%s'".formatted(data));
ItemSet set = MMOItems.plugin.getSets().get(data.toString()); // Make Array
Validate.notNull(set, "Could not find item set with ID '" + data.toString() + "'"); ArrayList<ItemTag> ret = new ArrayList<>();
// Make Array // Add that tag
ArrayList<ItemTag> ret = new ArrayList<>(); ret.add(new ItemTag(getNBTPath(), data.toString()));
// Add that tag // Thats it
ret.add(new ItemTag(getNBTPath(), data.toString())); return ret;
}
// Thats it @Override
return ret; @NotNull
} public String getNBTPath() {
return "MMOITEMS_ITEM_SET";
}
@Override @Override
@NotNull public String getNBTPath() { return "MMOITEMS_ITEM_SET"; } public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
ItemSet set = MMOItems.plugin.getSets().get(message);
@Override Validate.notNull(set, "Couldn't find the set named '%s'.".formatted(message));
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) { super.whenInput(inv, message, info);
ItemSet set = MMOItems.plugin.getSets().get(message); }
Validate.notNull(set, "Couldn't find the set named '" + message + "'.");
super.whenInput(inv, message, info);
}
} }

View File

@ -6,14 +6,12 @@ import io.lumine.mythic.lib.api.util.EnumUtils;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.MaterialData; import net.Indyuce.mmoitems.stat.data.MaterialData;
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.Indyuce.mmoitems.stat.type.ItemStat;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;

View File

@ -21,7 +21,7 @@ import com.google.gson.JsonParser;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
@ -31,7 +31,6 @@ import net.Indyuce.mmoitems.stat.data.PotionEffectData;
import net.Indyuce.mmoitems.stat.data.PotionEffectListData; import net.Indyuce.mmoitems.stat.data.PotionEffectListData;
import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData;
import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData; import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectListData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;

View File

@ -9,7 +9,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;

View File

@ -1,86 +1,67 @@
package net.Indyuce.mmoitems.stat; package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.listener.CustomSoundListener; import io.lumine.mythic.lib.api.item.NBTItem;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.RepairItemEvent; import net.Indyuce.mmoitems.api.event.item.RepairItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem; import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.listener.CustomSoundListener;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.DoubleStat;
import io.lumine.mythic.lib.api.item.NBTItem; import net.Indyuce.mmoitems.util.RepairUtils;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class RepairPower extends DoubleStat implements ConsumableItemInteraction { public class RepairPower extends DoubleStat implements ConsumableItemInteraction {
public RepairPower() { public RepairPower() {
super("REPAIR", Material.ANVIL, "Repair", new String[] { "The amount of durability your item", "can repair when set an item." }, super("REPAIR", Material.ANVIL, "Repair", new String[]{"The amount of durability your item", "can repair when set an item."},
new String[] { "consumable" }); new String[]{"consumable"});
} }
@Override @Override
public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) { public boolean handleConsumableEffect(@NotNull InventoryClickEvent event, @NotNull PlayerData playerData, @NotNull Consumable consumable, @NotNull NBTItem target, Type targetType) {
int repairPower = (int) consumable.getNBTItem().getStat(ItemStats.REPAIR.getId()); int repairPower = (int) consumable.getNBTItem().getStat(ItemStats.REPAIR.getId());
if (repairPower <= 0) if (repairPower <= 0)
return false; return false;
// custom durability // custom durability
Player player = playerData.getPlayer(); Player player = playerData.getPlayer();
final String type = "MMOITEMS_REPAIR_TYPE"; final String type = "MMOITEMS_REPAIR_TYPE";
if((target.hasTag(type) || consumable.getNBTItem().hasTag(type)) && if ((target.hasTag(type) || consumable.getNBTItem().hasTag(type)) &&
!target.getString(type).equals(consumable.getNBTItem().getString(type))) { !target.getString(type).equals(consumable.getNBTItem().getString(type))) {
Message.UNABLE_TO_REPAIR.format(ChatColor.RED, "#item#", MMOUtils.getDisplayName(target.getItem())).send(player); Message.UNABLE_TO_REPAIR.format(ChatColor.RED, "#item#", MMOUtils.getDisplayName(target.getItem())).send(player);
player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f); player.getPlayer().playSound(player.getPlayer().getLocation(), Sound.ENTITY_VILLAGER_NO, 1, 1.5f);
return false; return false;
} }
if (target.hasTag("MMOITEMS_DURABILITY")) { if (target.hasTag("MMOITEMS_DURABILITY")) {
RepairItemEvent called = new RepairItemEvent(playerData, consumable.getMMOItem(), target, repairPower); RepairItemEvent called = new RepairItemEvent(playerData, consumable.getMMOItem(), target, repairPower);
Bukkit.getPluginManager().callEvent(called); Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled()) if (called.isCancelled())
return false; return false;
DurabilityItem durItem = new DurabilityItem(player, target); DurabilityItem durItem = new DurabilityItem(player, target);
if (durItem.getDurability() < durItem.getMaxDurability()) { if (durItem.getDurability() < durItem.getMaxDurability()) {
target.getItem().setItemMeta(durItem.addDurability(called.getRepaired()).toItem().getItemMeta()); target.getItem().setItemMeta(durItem.addDurability(called.getRepaired()).toItem().getItemMeta());
Message.REPAIRED_ITEM Message.REPAIRED_ITEM
.format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(target.getItem()), "#amount#", String.valueOf(called.getRepaired())) .format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(target.getItem()), "#amount#", String.valueOf(called.getRepaired()))
.send(player); .send(player);
CustomSoundListener.playConsumableSound(consumable.getItem(), player); CustomSoundListener.playConsumableSound(consumable.getItem(), player);
} }
return true; return true;
} }
// vanilla durability // vanilla durability
if (!target.getBoolean("Unbreakable") && target.getItem().hasItemMeta() && target.getItem().getItemMeta() instanceof Damageable return RepairUtils.repairPower(playerData, target, consumable, repairPower);
&& ((Damageable) target.getItem().getItemMeta()).getDamage() > 0) { }
RepairItemEvent called = new RepairItemEvent(playerData, consumable.getMMOItem(), target, repairPower);
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled())
return false;
ItemMeta meta = target.getItem().getItemMeta();
((Damageable) meta).setDamage(Math.max(0, ((Damageable) meta).getDamage() - called.getRepaired()));
target.getItem().setItemMeta(meta);
Message.REPAIRED_ITEM.format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(target.getItem()), "#amount#", "" + called.getRepaired())
.send(player);
CustomSoundListener.playConsumableSound(consumable.getItem(), player);
return true;
}
return false;
}
} }

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.RepairItemEvent; import net.Indyuce.mmoitems.api.event.item.RepairItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;
@ -12,14 +12,13 @@ import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.listener.CustomSoundListener; import net.Indyuce.mmoitems.listener.CustomSoundListener;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.DoubleStat;
import net.Indyuce.mmoitems.util.RepairUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -65,23 +64,6 @@ public class RepairPowerPercent extends DoubleStat implements ConsumableItemInte
} }
// vanilla durability // vanilla durability
if (!target.getBoolean("Unbreakable") && target.getItem().hasItemMeta() && target.getItem().getItemMeta() instanceof Damageable return RepairUtils.repairPower(playerData, target, consumable, repairPower);
&& ((Damageable) target.getItem().getItemMeta()).getDamage() > 0) {
RepairItemEvent called = new RepairItemEvent(playerData, consumable.getMMOItem(), target, repairPower);
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled())
return false;
ItemMeta meta = target.getItem().getItemMeta();
((Damageable) meta).setDamage(Math.max(0, ((Damageable) meta).getDamage() - called.getRepaired()));
target.getItem().setItemMeta(meta);
Message.REPAIRED_ITEM.format(ChatColor.YELLOW, "#item#", MMOUtils.getDisplayName(target.getItem()), "#amount#", "" + called.getRepaired())
.send(player);
CustomSoundListener.playConsumableSound(consumable.getItem(), player);
return true;
}
return false;
} }
} }

View File

@ -4,7 +4,7 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.DoubleStat;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.DoubleStat;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.MythicLib; import io.lumine.mythic.lib.MythicLib;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.type.DoubleStat; import net.Indyuce.mmoitems.stat.type.DoubleStat;

View File

@ -6,7 +6,6 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import net.Indyuce.mmoitems.stat.data.BooleanData;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -23,15 +22,12 @@ import org.bukkit.inventory.meta.BlockStateMeta;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.ShieldPatternData; 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 io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.BreakSoulboundEvent; import net.Indyuce.mmoitems.api.event.item.BreakSoulboundEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;

View File

@ -3,8 +3,7 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.ApplySoulboundEvent; import net.Indyuce.mmoitems.api.event.item.ApplySoulboundEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;

View File

@ -19,7 +19,7 @@ import com.google.gson.JsonSyntaxException;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.player.RPGPlayer;

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.ItemTag; import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.version.VersionMaterial; import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.NumericStatFormula;
import net.Indyuce.mmoitems.stat.data.DoubleData; import net.Indyuce.mmoitems.stat.data.DoubleData;

View File

@ -8,7 +8,7 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.api.util.AltChar; import io.lumine.mythic.lib.api.util.AltChar;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.UpgradeItemEvent; import net.Indyuce.mmoitems.api.event.item.UpgradeItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable; import net.Indyuce.mmoitems.api.interaction.Consumable;
@ -22,7 +22,6 @@ import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.gui.edition.EditionInventory; import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.gui.edition.UpgradingEdition; import net.Indyuce.mmoitems.gui.edition.UpgradingEdition;
import net.Indyuce.mmoitems.stat.data.UpgradeData; import net.Indyuce.mmoitems.stat.data.UpgradeData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData; import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction; import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;

View File

@ -9,7 +9,7 @@ import io.lumine.mythic.lib.skill.SkillMetadata;
import io.lumine.mythic.lib.skill.handler.SkillHandler; import io.lumine.mythic.lib.skill.handler.SkillHandler;
import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.player.PlayerData; import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.player.RPGPlayer; import net.Indyuce.mmoitems.api.player.RPGPlayer;
import net.Indyuce.mmoitems.api.util.message.Message; import net.Indyuce.mmoitems.api.util.message.Message;

View File

@ -3,7 +3,7 @@ package net.Indyuce.mmoitems.stat.data;
import com.google.gson.JsonElement; import com.google.gson.JsonElement;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.stat.GemUpgradeScaling; import net.Indyuce.mmoitems.stat.GemUpgradeScaling;
import net.Indyuce.mmoitems.stat.type.ItemStat; import net.Indyuce.mmoitems.stat.type.ItemStat;

View File

@ -1,6 +1,6 @@
package net.Indyuce.mmoitems.stat.data; package net.Indyuce.mmoitems.stat.data;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;

View File

@ -5,7 +5,7 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.skill.RegisteredSkill; import net.Indyuce.mmoitems.skill.RegisteredSkill;
import org.apache.commons.lang.Validate; import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;

View File

@ -4,7 +4,7 @@ import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder; import net.Indyuce.mmoitems.api.item.build.MMOItemBuilder;
import net.Indyuce.mmoitems.api.util.NumericStatFormula; import net.Indyuce.mmoitems.api.util.NumericStatFormula;
import net.Indyuce.mmoitems.stat.data.PotionEffectData; import net.Indyuce.mmoitems.stat.data.PotionEffectData;

View File

@ -13,7 +13,7 @@ import org.bukkit.event.inventory.InventoryAction;
import org.bukkit.event.inventory.InventoryClickEvent; import org.bukkit.event.inventory.InventoryClickEvent;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;

View File

@ -10,7 +10,7 @@ import io.lumine.mythic.lib.api.util.ui.PlusMinusPercent;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers; import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import io.lumine.mythic.lib.manager.StatManager; import io.lumine.mythic.lib.manager.StatManager;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.UpgradeTemplate; import net.Indyuce.mmoitems.api.UpgradeTemplate;
import net.Indyuce.mmoitems.api.edition.StatEdition; import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder; import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;

View File

@ -6,7 +6,7 @@ import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackCategory;
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider; import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
import net.Indyuce.mmoitems.ItemStats; import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems; import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils; import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem; import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems; import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
import net.Indyuce.mmoitems.stat.data.*; import net.Indyuce.mmoitems.stat.data.*;

View File

@ -1,4 +1,4 @@
package net.Indyuce.mmoitems; package net.Indyuce.mmoitems.util;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
@ -8,6 +8,7 @@ import io.lumine.mythic.lib.api.item.ItemTag;
import io.lumine.mythic.lib.api.item.NBTItem; import io.lumine.mythic.lib.api.item.NBTItem;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues; import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import io.lumine.mythic.lib.skill.trigger.TriggerType; import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type; import net.Indyuce.mmoitems.api.Type;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Base64;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
@ -33,6 +34,10 @@ import java.util.*;
@SuppressWarnings("unused") @SuppressWarnings("unused")
public class MMOUtils { public class MMOUtils {
public MMOUtils() {
throw new IllegalArgumentException("This class cannot be instantiated.");
}
/** /**
* @return The skull texture URL from a given player head * @return The skull texture URL from a given player head
*/ */

View File

@ -0,0 +1,34 @@
package net.Indyuce.mmoitems.util;
import net.Indyuce.mmoitems.MMOItems;
import org.bukkit.Bukkit;
import org.jetbrains.annotations.NotNull;
import java.util.function.Consumer;
import java.util.logging.Level;
/**
* mmoitems
*
* @author Roch Blondiaux
* @date 24/10/2022
*/
public class PluginUtils {
public PluginUtils() {
throw new IllegalStateException("Utility class");
}
public static void isDependencyPresent(@NotNull String name, @NotNull Consumer<Void> callback) {
if (Bukkit.getPluginManager().getPlugin(name) != null)
callback.accept(null);
}
public static void hookDependencyIfPresent(@NotNull String name, @NotNull Consumer<Void> callback) {
if (Bukkit.getPluginManager().getPlugin(name) == null)
return;
callback.accept(null);
MMOItems.plugin.getLogger().log(Level.INFO, "Hooked onto %s".formatted(name));
}
}

View File

@ -0,0 +1,51 @@
package net.Indyuce.mmoitems.util;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.api.event.item.RepairItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.listener.CustomSoundListener;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
/**
* mmoitems
*
* @author Roch Blondiaux
* @date 24/10/2022
*/
public class RepairUtils {
public RepairUtils() {
throw new IllegalStateException("Utility class");
}
public static boolean repairPower(@NotNull PlayerData playerData, @NotNull NBTItem target, @NotNull Consumable consumable, double repairPower) {
final Player player = playerData.getPlayer();
if (!target.getBoolean("Unbreakable") && target.getItem().hasItemMeta() && target.getItem().getItemMeta() instanceof Damageable
&& ((Damageable) target.getItem().getItemMeta()).getDamage() > 0) {
RepairItemEvent called = new RepairItemEvent(playerData, consumable.getMMOItem(), target, repairPower);
Bukkit.getPluginManager().callEvent(called);
if (called.isCancelled())
return false;
ItemMeta meta = target.getItem().getItemMeta();
((Damageable) meta).setDamage(Math.max(0, ((Damageable) meta).getDamage() - called.getRepaired()));
target.getItem().setItemMeta(meta);
Message.REPAIRED_ITEM.format(ChatColor.YELLOW,
"#item#",
MMOUtils.getDisplayName(target.getItem()),
"#amount#",
String.valueOf(called.getRepaired() == -1 ? called.getRepairedPercent() : called.getRepaired()))
.send(player);
CustomSoundListener.playConsumableSound(consumable.getItem(), player);
return true;
}
return false;
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
</module>

View File

@ -17,8 +17,26 @@
<maven.compiler.target>16</maven.compiler.target> <maven.compiler.target>16</maven.compiler.target>
</properties> </properties>
<build> <!-- Dependencies -->
<dependencies>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- MMOItems API -->
<dependency>
<groupId>net.Indyuce</groupId>
<artifactId>MMOItems-API</artifactId>
<version>${revision}</version>
<optional>true</optional>
</dependency>
</dependencies>
<!-- Build -->
<build>
<!-- Includes default files in the Bukkit module --> <!-- Includes default files in the Bukkit module -->
<resources> <resources>
<resource> <resource>
@ -28,7 +46,6 @@
</resources> </resources>
<plugins> <plugins>
<!-- Completely necessary for dev build deployment --> <!-- Completely necessary for dev build deployment -->
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
@ -92,28 +109,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
<dependencies>
<!-- Spigot API -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.18-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.Indyuce</groupId>
<artifactId>MMOItems-API</artifactId>
<version>${revision}</version>
<optional>true</optional>
</dependency>
</dependencies>
</project> </project>

Some files were not shown because too many files have changed in this diff Show More