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

View File

@ -41,6 +41,7 @@ import net.Indyuce.mmoitems.gui.PluginInventory;
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeBrowserGUI;
import net.Indyuce.mmoitems.listener.CraftingListener;
import net.Indyuce.mmoitems.manager.*;
import net.Indyuce.mmoitems.util.PluginUtils;
import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
@ -105,17 +106,20 @@ public class MMOItems extends JavaPlugin {
*/
private boolean hasLoadedSuccessfully;
public MMOItems() { plugin = this; }
public MMOItems() {
plugin = this;
}
@Override
public void onLoad() {
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) try {
PluginUtils.isDependencyPresent("WorldEdit", u -> {
try {
new WorldEditSupport();
getLogger().log(Level.INFO, "Hooked onto WorldEdit");
} catch (Exception exception) {
getLogger().log(Level.WARNING, "Could not initialize support with WorldEdit 7: " + exception.getMessage());
getLogger().log(Level.WARNING, "Could not initialize support with WorldEdit 7: ", exception);
}
});
// Initialize default config files
saveDefaultConfig();
@ -125,21 +129,14 @@ public class MMOItems extends JavaPlugin {
typeManager.reload();
templateManager.preloadTemplates();
if (Bukkit.getPluginManager().getPlugin("MMOCore") != null) new MMOCoreMMOLoader();
if (Bukkit.getPluginManager().getPlugin("mcMMO") != null)
//statManager.register(McMMOHook.MCMMO_SUPER_TOOL);
statManager.register(McMMOHook.disableMcMMORepair);
if (Bukkit.getPluginManager().getPlugin("AdvancedEnchantments") != null) {
PluginUtils.isDependencyPresent("MMOCore", u -> new MMOCoreMMOLoader());
PluginUtils.isDependencyPresent("mcMMO", u -> statManager.register(McMMOHook.disableMcMMORepair));
PluginUtils.isDependencyPresent("AdvancedEnchantments", u -> {
statManager.register(AdvancedEnchantmentsHook.ADVANCED_ENCHANTMENTS);
statManager.register(AdvancedEnchantmentsHook.DISABLE_ADVANCED_ENCHANTMENTS);
}
if (Bukkit.getPluginManager().getPlugin("MythicEnchants") != null) enchantPlugins.add(new MythicEnchantsSupport());
if (Bukkit.getPluginManager().getPlugin("Heroes") != null)
statManager.register(HeroesHook.MAX_STAMINA);
});
PluginUtils.isDependencyPresent("MythicEnchants", u -> enchantPlugins.add(new MythicEnchantsSupport()));
PluginUtils.isDependencyPresent("Heroes", u -> statManager.register(HeroesHook.MAX_STAMINA));
}
@Override
@ -159,16 +156,12 @@ public class MMOItems extends JavaPlugin {
}
// registering here so the stats will load with the templates
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null) {
PluginUtils.hookDependencyIfPresent("MythicMobs", unused -> {
new MythicMobsCompatibility();
if (getConfig().getBoolean("lootsplosion.enabled")) Bukkit.getPluginManager().registerEvents(new LootsplosionListener(), this);
getLogger().log(Level.INFO, "Hooked onto MythicMobs");
}
if (Bukkit.getPluginManager().getPlugin("MMOInventory") != null) {
new MMOInventorySupport();
getLogger().log(Level.INFO, "Hooked onto MMOInventory");
}
if (getConfig().getBoolean("lootsplosion.enabled"))
Bukkit.getPluginManager().registerEvents(new LootsplosionListener(), this);
});
PluginUtils.hookDependencyIfPresent("MMOInventory", unused -> new MMOInventorySupport());
findRpgPlugin();
@ -176,6 +169,7 @@ public class MMOItems extends JavaPlugin {
* After tiers, sets and upgrade templates are loaded, MI template data
* can be fully loaded
*/
statManager.loadElements();
formatManager.reload();
tierManager = new TierManager();
setManager = new SetManager();
@ -185,9 +179,10 @@ public class MMOItems extends JavaPlugin {
dropTableManager = new DropTableManager();
worldGenManager = new WorldGenManager();
blockManager = new BlockManager();
MMOItems.plugin.getStats().reload(false);
statManager.reload(false);
if (Bukkit.getPluginManager().getPlugin("Vault") != null) vaultSupport = new VaultSupport();
PluginUtils.hookDependencyIfPresent("Vault", u -> vaultSupport = new VaultSupport());
getLogger().log(Level.INFO, "Loading crafting stations, please wait..");
layoutManager.reload();
@ -204,7 +199,7 @@ public class MMOItems extends JavaPlugin {
// Load MMOCore-Bukkit module
try {
Class.forName("net.Indyuce.mmoitems.MMOItemsBukkit").getConstructor(MMOItems.class).newInstance(this);
} catch(Throwable exception) {
} catch (Throwable exception) {
throw new RuntimeException("Cannot run an API build on Spigot!");
}
@ -218,33 +213,20 @@ public class MMOItems extends JavaPlugin {
PlayerData.get(player).getInventory().updateCheck();
}, 100, getConfig().getInt("inventory-update-delay"));
if (Bukkit.getPluginManager().getPlugin("mcMMO") != null) Bukkit.getPluginManager().registerEvents(new McMMONonRPGHook(), this);
PluginUtils.isDependencyPresent("mcMMO", unused -> Bukkit.getPluginManager().registerEvents(new McMMONonRPGHook(), this));
/*
* Registers Player Inventories. Each of these add locations of items to search for
* when doing inventory updates.
*/
getInventory().register(new DefaultPlayerInventory());
if (Bukkit.getPluginManager().getPlugin("RPGInventory") != null) {
getInventory().register(new RPGInventoryHook());
getLogger().log(Level.INFO, "Hooked onto RPGInventory");
}
if (MMOItems.plugin.getConfig().getBoolean("iterate-whole-inventory")) getInventory().register(new OrnamentPlayerInventory());
PluginUtils.hookDependencyIfPresent("RPGInventory", unused -> getInventory().register(new RPGInventoryHook()));
PluginUtils.hookDependencyIfPresent("CrazyEnchantments", unused -> getStats().register(new CrazyEnchantsStat()));
PluginUtils.hookDependencyIfPresent("AdvancedEnchantments", unused -> Bukkit.getPluginManager().registerEvents(new AdvancedEnchantmentsHook(), this));
PluginUtils.hookDependencyIfPresent("PlaceholderAPI", unused -> placeholderParser = new PlaceholderAPIParser());
if (MMOItems.plugin.getConfig().getBoolean("iterate-whole-inventory"))
getInventory().register(new OrnamentPlayerInventory());
if (Bukkit.getPluginManager().getPlugin("CrazyEnchantments") != null) {
getStats().register(new CrazyEnchantsStat());
getLogger().log(Level.INFO, "Hooked onto CrazyEnchantments");
}
if (Bukkit.getPluginManager().getPlugin("AdvancedEnchantments") != null) {
Bukkit.getPluginManager().registerEvents(new AdvancedEnchantmentsHook(), this);
getLogger().log(Level.INFO, "Hooked onto AdvancedEnchantments");
}
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
getLogger().log(Level.INFO, "Hooked onto PlaceholderAPI");
placeholderParser = new PlaceholderAPIParser();
}
if (Bukkit.getPluginManager().getPlugin("BossShopPro") != null) {
getLogger().log(Level.INFO, "Hooked onto BossShopPro");
@ -342,7 +324,7 @@ public class MMOItems extends JavaPlugin {
* Decide by which system will the RPG Requirements of the player will be checked.
* <p>
* For example, required level, is that vanilla XP levels, MMOCore levels, McMMO Leves or what?
*
* <p>
* This method is called on server startup and will try to read the preferred RPG
* provider in the main plugin config. If it can't be found, it will look for RPG
* plugins in the installed plugin list.
@ -564,7 +546,9 @@ public class MMOItems extends JavaPlugin {
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id, @Nullable PlayerData player) {
if (type == null || id == null) { return null; }
if (type == null || id == null) {
return null;
}
// Valid template?
MMOItemTemplate found = getTemplates().getTemplate(type, id);
@ -599,7 +583,9 @@ public class MMOItems extends JavaPlugin {
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id, int itemLevel, @Nullable ItemTier itemTier) {
if (type == null || id == null) { return null; }
if (type == null || id == null) {
return null;
}
// Valid template?
MMOItemTemplate found = getTemplates().getTemplate(type, id);
@ -612,7 +598,6 @@ public class MMOItems extends JavaPlugin {
/**
* @param itemLevel The desired item level
* @param itemTier The desired item tier, can be null
*
* @return Generates an item given an item template with a
* specific item level and item tier
*/
@ -635,7 +620,9 @@ public class MMOItems extends JavaPlugin {
* Will return <code>null</code> if such MMOItem does not exist.
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id) { return getMMOItem(type, id, 0, null); }
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id) {
return getMMOItem(type, id, 0, null);
}
/**
* @return Generates an item given an item template. The item level will be
@ -647,7 +634,9 @@ public class MMOItems extends JavaPlugin {
@Nullable
public ItemStack getItem(@Nullable String type, @Nullable String id) {
if (type == null || id == null) { return null; }
if (type == null || id == null) {
return null;
}
return getItem(getTypes().get(type), id);
}
@ -660,11 +649,15 @@ public class MMOItems extends JavaPlugin {
*/
@Nullable
public ItemStack getItem(@Nullable Type type, @Nullable String id) {
if (type == null || id == null) { return null; }
if (type == null || id == null) {
return null;
}
// Valid MMOItem?
MMOItem m = getMMOItem(type, id);
if (m == null) { return null; }
if (m == null) {
return null;
}
// Build if found
return m.newBuilder().build();
@ -780,13 +773,15 @@ public class MMOItems extends JavaPlugin {
/**
* JULES DO NOT DELETE THIS AGAIN I KNOW ITS UNUSED PRECISELY BECAUSE I ALWAYS COMMENT
* ALL ITS USAGES BEFORE PUSHING ANY UPDATES, I USE IT FOR SPAMMY DEVELOPER MESSAGES
*
* <p>
* Note that {@link #print(Level, String, String, String...)} is used for actual warnings
* or such that the users may see, so dont delete that one either.
*
* @author Gunging
*/
public static void log(@Nullable String message, @NotNull String... replaces) { print(null, message, null, replaces); }
public static void log(@Nullable String message, @NotNull String... replaces) {
print(null, message, null, replaces);
}
/**
* @return The server's console sender.

View File

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

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmoitems.api;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import net.Indyuce.mmoitems.stat.data.ParticleData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.apache.commons.lang.Validate;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.potion.PotionEffect;
@ -31,50 +31,55 @@ public class ItemSet {
this.loreTag = config.getStringList("lore-tag");
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++)
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
for (String perm : config.getConfigurationSection("bonuses." + j).getStringList("granted-permissions"))
for (String perm : bonusesSection.getStringList("granted-permissions"))
bonuses.addPermission(perm);
for (String key : config.getConfigurationSection("bonuses." + j).getKeys(false))
for (String key : bonusesSection.getKeys(false))
if (!key.equals("granted-permissions")) {
try {
String format = key.toUpperCase().replace("-", "_").replace(" ", "_");
// 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;
}
// potion effect
if (key.startsWith("potion-")) {
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),
config.getInt("bonuses." + j + "." + key) - 1, true, false));
config.getInt("%s.%s".formatted(bonusesKey, key)) - 1, true, false));
continue;
}
// particle effect
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;
}
// stat
ItemStat stat = MMOItems.plugin.getStats().get(format);
Validate.notNull(stat, "Could not find stat called '" + format + "'");
bonuses.addStat(stat, config.getDouble("bonuses." + j + "." + key));
ItemStat<?, ?> stat = MMOItems.plugin.getStats().get(format);
Validate.notNull(stat, "Could not find stat called '%s'".formatted(format));
bonuses.addStat(stat, config.getDouble("bonuses.%d.%s".formatted(j, key)));
} 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 {
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 Set<AbilityData> abilities = new HashSet<>();
private final Set<ParticleData> particles = new HashSet<>();
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);
}
@ -129,15 +134,15 @@ public class ItemSet {
permissions.add(permission);
}
public boolean hasStat(ItemStat stat) {
public boolean hasStat(ItemStat<?, ?> stat) {
return stats.containsKey(stat);
}
public double getStat(ItemStat stat) {
public double getStat(ItemStat<?, ?> stat) {
return stats.get(stat);
}
public Map<ItemStat, Double> getStats() {
public Map<ItemStat<?, ?>, Double> getStats() {
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.version.VersionSound;
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.player.PlayerData;
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 net.Indyuce.mmoitems.ItemStats;
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.crafting.ConfigMMOItem;
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.FriendlyFeedbackProvider;
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.crafting.ingredient.inventory.VanillaPlayerIngredient;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
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 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.CraftingStation;
import net.Indyuce.mmoitems.api.crafting.ingredient.CheckedIngredient;

View File

@ -13,20 +13,16 @@ public class RepairItemEvent extends PlayerDataEvent {
private final VolatileMMOItem consumable;
private final NBTItem target;
private int repaired;
private double repairedPercent;
private int repaired = -1;
private double repairedPercent = -1;
/**
* Called when a player repairs an item using a consumable
*
* @param playerData
* Player repairing the item
* @param consumable
* Consumable used to repair the item
* @param target
* Item being repaired
* @param repaired
* Amount of durability being repaired
* @param playerData Player repairing the item
* @param consumable Consumable used to repair the item
* @param target Item being repaired
* @param repaired Amount of durability being repaired
*/
public RepairItemEvent(PlayerData playerData, VolatileMMOItem consumable, NBTItem target, int repaired) {
super(playerData);
@ -56,7 +52,7 @@ public class RepairItemEvent extends PlayerDataEvent {
return repaired;
}
public double getRepairedPercent(){
public double getRepairedPercent() {
return repairedPercent;
}

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.api.interaction;
import io.lumine.mythic.lib.api.item.NBTItem;
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.event.item.ApplyGemStoneEvent;
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 net.Indyuce.mmoitems.ItemStats;
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.item.mmoitem.VolatileMMOItem;
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 net.Indyuce.mmoitems.ItemStats;
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.stat.LuteAttackEffectStat.LuteAttackEffect;
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.api.item.NBTItem;
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.player.PlayerMetadata;
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.stat.data.ProjectileParticlesData;
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.api.item.NBTItem;
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.player.PlayerMetadata;
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.stat.data.ProjectileParticlesData;
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.api.item.NBTItem;
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.player.PlayerMetadata;
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.stat.data.ProjectileParticlesData;
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.api.item.NBTItem;
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.player.PlayerMetadata;
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.stat.data.ProjectileParticlesData;
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.api.item.NBTItem;
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.player.PlayerMetadata;
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.stat.data.ProjectileParticlesData;
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.player.EquipmentSlot;
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.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Color;
import org.bukkit.Location;
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.player.EquipmentSlot;
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.player.PlayerMetadata;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Location;
import org.bukkit.Particle;
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.player.EquipmentSlot;
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.player.PlayerMetadata;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Location;
import org.bukkit.Particle;
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.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.bukkit.Location;
import org.bukkit.Particle;
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.player.EquipmentSlot;
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.player.PlayerMetadata;
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.entity.EntityType;
import org.bukkit.entity.ShulkerBullet;
@ -34,6 +33,6 @@ public class VoidSpirit implements StaffAttackHandler {
shulkerBullet.setVelocity(vec);
}
}.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;
import io.lumine.mythic.lib.MythicLib;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import org.apache.commons.lang.Validate;
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.api.item.ItemTag;
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.bukkit.ChatColor;
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.NBTItem;
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.condition.CheckedCondition;
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.NBTItem;
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.condition.CheckedCondition;
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.ModifierType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.player.inventory.EquippedItem;
import net.Indyuce.mmoitems.stat.type.AttackWeaponStat;
import net.Indyuce.mmoitems.stat.type.ItemStat;
@ -28,11 +27,11 @@ public class PlayerStats {
return playerData.getMMOPlayerData().getStatMap();
}
public double getStat(ItemStat stat) {
public double getStat(ItemStat<?, ?> stat) {
return getMap().getInstance(stat.getId()).getTotal();
}
public StatInstance getInstance(ItemStat stat) {
public StatInstance getInstance(ItemStat<?, ?> stat) {
return getMap().getInstance(stat.getId());
}
@ -50,8 +49,7 @@ public class PlayerStats {
}
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
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.version.VersionMaterial;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.manager.RecipeManager;
import org.bukkit.Material;
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 net.Indyuce.mmoitems.ItemStats;
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.item.mmoitem.MMOItem;
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.RPGPlayer;
import net.Indyuce.mmoitems.comp.mmocore.stat.ExtraAttribute;
import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Attribute;
import net.Indyuce.mmoitems.comp.mmocore.stat.Required_Profession;
import net.Indyuce.mmoitems.comp.mmocore.stat.RequiredAttribute;
import net.Indyuce.mmoitems.comp.mmocore.stat.RequiredProfession;
import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import org.bukkit.event.EventHandler;
@ -32,7 +32,7 @@ public class MMOCoreHook implements RPGHandler, Listener {
*/
public MMOCoreHook() {
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));
}
@ -43,8 +43,7 @@ public class MMOCoreHook implements RPGHandler, Listener {
.replace('-', '_').replace(' ', '_').toUpperCase(Locale.ROOT),
VersionMaterial.EXPERIENCE_BOTTLE.toMaterial(), profession.getName() + ' ' + "Additional Experience (MMOCore)"
, new String[]{"Additional MMOCore profession " + profession.getName() + " experience in %."}, new String[]{"!block", "all"}));
MMOItems.plugin.getStats().register(new Required_Profession(profession));
MMOItems.plugin.getStats().register(new RequiredProfession(profession));
}
}

View File

@ -12,11 +12,11 @@ import net.Indyuce.mmoitems.stat.type.ItemRestriction;
import org.bukkit.ChatColor;
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;
// 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"});
this.attribute = attribute;

View File

@ -12,11 +12,11 @@ import org.bukkit.ChatColor;
import org.bukkit.Material;
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;
// 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)",
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.api.item.NBTItem;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.ItemTier;
import org.bukkit.Bukkit;
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.util.LegacyComponent;
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.recipe.CheckedRecipe;
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.util.SmartGive;
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.CraftingStatus.CraftingQueue;
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.version.VersionMaterial;
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.edition.NewItemEdition;
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 net.Indyuce.mmoitems.ItemStats;
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.item.template.MMOItemTemplate;
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 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.util.NumericStatFormula;
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.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
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.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
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 net.Indyuce.mmoitems.ItemStats;
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.item.template.MMOItemTemplate;
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.version.VersionMaterial;
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.stat.type.InternalStat;
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.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
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 net.Indyuce.mmoitems.ItemStats;
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.util.MMOItemReforger;
import net.Indyuce.mmoitems.stat.RevisionID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.InventoryAction;
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.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.CustomSound;
import net.Indyuce.mmoitems.api.edition.StatEdition;
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.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.edition.StatEdition;
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.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.template.MMOItemTemplate;
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.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.gui.ItemBrowser;
import net.Indyuce.mmoitems.gui.PluginInventory;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.gui.edition.ItemEdition;
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.recipes.RecipeMakerGUI;
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.skill.trigger.TriggerType;
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.ReforgeOptions;
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 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.block.CustomBlock;
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.api.ConfigFile;
import net.Indyuce.mmoitems.api.ItemSet;
import org.bukkit.configuration.ConfigurationSection;
import java.util.Collection;
import java.util.HashMap;
@ -22,9 +23,12 @@ public class SetManager implements Reloadable {
ConfigFile config = new ConfigFile("item-sets");
for (String id : config.getConfig().getKeys(false))
try {
itemSets.put(id, new ItemSet(config.getConfig().getConfigurationSection(id)));
final ConfigurationSection section = config.getConfig().getConfigurationSection(id);
if (section == null)
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 '" + id + "': " + exception.getMessage());
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load item set '%s': %s".formatted(id, exception.getMessage()));
}
}

View File

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

View File

@ -14,7 +14,7 @@ import java.util.*;
import java.util.logging.Level;
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
@ -34,9 +34,9 @@ public class StatManager {
for (Field field : ItemStats.class.getFields())
try {
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) {
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());
}
}
@ -46,22 +46,26 @@ public class StatManager {
*/
@Deprecated
public void reload(boolean cleanFirst) {
// Clean fictive numeric stats before
if (cleanFirst)
for (Iterator<DoubleStat> ite = numeric.iterator(); ite.hasNext(); ) {
DoubleStat stat = ite.next();
if (stat instanceof FictiveNumericStat)
ite.remove();
}
numeric.removeIf(stat -> stat instanceof FictiveNumericStat);
// Register elemental stats
for (ElementStatType type : ElementStatType.values())
for (Element element : MythicLib.plugin.getElements().getAll())
numeric.add(new FictiveNumericStat(element, type));
loadElements();
}
public Collection<ItemStat> getAll() {
/**
* Register all MythicLib elements as stats
*/
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() {
return stats.values();
}
@ -103,8 +107,14 @@ public class StatManager {
return stats.containsKey(id);
}
public ItemStat get(String id) {
return stats.getOrDefault(id, null);
public ItemStat<?, ?> get(String id) {
ItemStat<?, ?> stat = stats.getOrDefault(id, null);
if (stat == null)
stat = numeric.stream()
.filter(doubleStat -> doubleStat.getId().equals(id))
.findFirst()
.orElse(null);
return stat;
}
/**
@ -117,7 +127,7 @@ public class StatManager {
*/
@Deprecated
@SuppressWarnings("unused")
public void register(String id, ItemStat stat) {
public void register(String id, ItemStat<?, ?> stat) {
register(stat);
}
@ -128,7 +138,7 @@ public class StatManager {
*
* @param stat The stat to register
*/
public void register(ItemStat stat) {
public void register(ItemStat<?, ?> stat) {
if (!stat.isEnabled())
return;
@ -146,7 +156,7 @@ public class StatManager {
if (stat instanceof PlayerConsumable)
playerConsumables.add((PlayerConsumable) stat);
/**
/*
* Cache stat for every type which may have this stat. Really important
* otherwise the stat will NOT be used anywhere in the plugin. This
* process is also done in the TypeManager when registering new types
@ -154,8 +164,10 @@ public class StatManager {
* take it into account
*/
if (MMOItems.plugin.getTypes() != null)
for (Type type : MMOItems.plugin.getTypes().getAll())
if (stat.isCompatible(type))
type.getAvailableStats().add(stat);
MMOItems.plugin.getTypes()
.getAll()
.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.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.util.StringValue;
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.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
public class Shulker_Missile extends SkillHandler<VectorSkillResult> implements Listener {
public Shulker_Missile() {
public class ShulkerMissile extends SkillHandler<VectorSkillResult> implements Listener {
public ShulkerMissile() {
super();
registerModifiers("damage", "effect-duration", "duration");
}
@NotNull
@Override
public VectorSkillResult getResult(SkillMetadata 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.skill.trigger.TriggerType;
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.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.api.util.NumericStatFormula;

View File

@ -5,28 +5,24 @@ import java.util.List;
import java.util.Optional;
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
import net.Indyuce.mmoitems.stat.data.StringData;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Particle;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Item;
import org.bukkit.event.inventory.InventoryClickEvent;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.JsonSyntaxException;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.ArrowParticlesEdition;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.ArrowParticlesData;
import net.Indyuce.mmoitems.stat.data.ParticleData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
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 net.Indyuce.mmoitems.ItemStats;
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.interaction.projectile.ArrowPotionEffectArrayItem;
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 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.Type;
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 net.Indyuce.mmoitems.ItemStats;
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.interaction.Consumable;
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.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.event.item.IdentifyItemEvent;
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 net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.api.ItemTier;
import net.Indyuce.mmoitems.util.MMOUtils;
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.item.mmoitem.LiveMMOItem;
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.ConsumableItemInteraction;
import net.Indyuce.mmoitems.util.Pair;
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.ItemStack;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
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.util.AltChar;
import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats;
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.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.CommandListEdition;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.CommandData;
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 org.apache.commons.lang.Validate;
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 net.Indyuce.mmoitems.ItemStats;
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.item.build.ItemStackBuilder;
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.stat.data.SoundData;
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.ItemStat;
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 net.Indyuce.mmoitems.ItemStats;
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.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
@ -71,10 +71,10 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
@Override
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
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());
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 amplifier = split.length > 2 ? new NumericStatFormula(split[2]) : new NumericStatFormula(1, 0, 0, 0);
@ -87,17 +87,13 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
@Override
public void whenDisplayed(List<String> lore, Optional<RandomPotionEffectListData> statData) {
if (statData.isPresent()) {
statData.ifPresentOrElse(randomPotionEffectListData -> {
lore.add(ChatColor.GRAY + "Current Value:");
RandomPotionEffectListData data = statData.get();
for (RandomPotionEffectData effect : data.getEffects())
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());
} else
lore.add(ChatColor.GRAY + "Current Value: " + ChatColor.RED + "None");
}, () -> 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.");
@ -111,17 +107,14 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
@Override
public void whenApplied(@NotNull ItemStackBuilder item, @NotNull PotionEffectListData data) {
// Process Lore
List<String> lore = new ArrayList<>();
String effectFormat = ItemStat.translate("effect");
data.getEffects().forEach(effect -> {
lore.add(effectFormat
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())));
});
.replace("{duration}", MythicLib.plugin.getMMOConfig().decimal.format(effect.getDuration()))));
item.getLore().insert("effects", lore);
// Add tags to item
@ -137,7 +130,6 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
// For every effect
for (PotionEffectData effect : data.getEffects()) {
// Convert to Json Object
JsonObject object = new JsonObject();
object.addProperty("Type", effect.getType().getName());
@ -156,7 +148,6 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
@Override
public void whenLoaded(@NotNull ReadMMOItem mmoitem) {
// Find relevant tag
ArrayList<ItemTag> relevantTags = new ArrayList<>();
if (mmoitem.getNBT().hasTag(getNBTPath()))
@ -166,7 +157,8 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
StatData data = getLoadedNBT(relevantTags);
// Valid? Append.
if (data != null) { mmoitem.setData(this, data); }
if (data != null)
mmoitem.setData(this, data);
}
@Nullable
@ -177,8 +169,8 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
ItemTag rTag = ItemTag.getTagAtPath(getNBTPath(), storedTags);
// Found?
if (rTag != null) {
if (rTag == null)
return null;
// Must be Json Array, attempt to parse.
try {
PotionEffectListData effects = new PotionEffectListData();
@ -205,19 +197,16 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
// Success
return effects;
} catch (JsonSyntaxException|IllegalStateException exception) {
} 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;
@ -226,11 +215,11 @@ public class Effects extends ItemStat<RandomPotionEffectListData, PotionEffectLi
PotionEffectListData pelData = (PotionEffectListData) mmo.getData(ItemStats.EFFECTS);
// Apply
for (PotionEffectData ped : pelData.getEffects())
if (ped != null) {
for (PotionEffectData ped : pelData.getEffects()) {
if (ped == null)
continue;
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.element.Element;
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.mmoitem.ReadMMOItem;
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 net.Indyuce.mmoitems.ItemStats;
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.item.build.ItemStackBuilder;
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.stat.data.EnchantListData;
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.UpgradeInfo;
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.version.VersionMaterial;
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.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;

View File

@ -1,15 +1,13 @@
package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.ItemTag;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemSet;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.StringData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
import net.Indyuce.mmoitems.stat.type.StringStat;
import io.lumine.mythic.lib.api.item.ItemTag;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -22,8 +20,8 @@ import java.util.ArrayList;
public class ItemSetStat extends StringStat implements GemStoneStat {
public ItemSetStat() {
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[] { "!gem_stone", "!consumable", "!material", "!block", "!miscellaneous", "all" });
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"});
}
@Override
@ -35,7 +33,7 @@ public class ItemSetStat extends StringStat implements GemStoneStat {
for (ItemSet set : MMOItems.plugin.getSets().getAll())
builder.append(ChatColor.GREEN).append(set.getId()).append(ChatColor.GRAY)
.append(" (").append(set.getName()).append(ChatColor.GRAY).append("), ");
if(builder.length() > 1)
if (builder.length() > 1)
builder.setLength(builder.length() - 2);
inv.getPlayer().sendMessage(builder.toString());
}
@ -48,7 +46,8 @@ public class ItemSetStat extends StringStat implements GemStoneStat {
ItemSet set = MMOItems.plugin.getSets().get(data.toString());
// Apply lore
if (set != null) { item.getLore().insert("set", set.getLoreTag()); }
if (set != null)
item.getLore().insert("set", set.getLoreTag());
// Add NBT
item.addItemTag(getAppliedNBT(data));
@ -57,9 +56,8 @@ public class ItemSetStat extends StringStat implements GemStoneStat {
@NotNull
@Override
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 '" + data.toString() + "'");
Validate.notNull(set, "Could not find item set with ID '%s'".formatted(data));
// Make Array
ArrayList<ItemTag> ret = new ArrayList<>();
@ -72,12 +70,15 @@ public class ItemSetStat extends StringStat implements GemStoneStat {
}
@Override
@NotNull public String getNBTPath() { return "MMOITEMS_ITEM_SET"; }
@NotNull
public String getNBTPath() {
return "MMOITEMS_ITEM_SET";
}
@Override
public void whenInput(@NotNull EditionInventory inv, @NotNull String message, Object... info) {
ItemSet set = MMOItems.plugin.getSets().get(message);
Validate.notNull(set, "Couldn't find the set named '" + message + "'.");
Validate.notNull(set, "Couldn't find the set named '%s'.".formatted(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 net.Indyuce.mmoitems.ItemStats;
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.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
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.md_5.bungee.api.ChatColor;
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.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
import net.Indyuce.mmoitems.util.MMOUtils;
import net.Indyuce.mmoitems.api.edition.StatEdition;
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
@ -31,7 +31,6 @@ import net.Indyuce.mmoitems.stat.data.PotionEffectData;
import net.Indyuce.mmoitems.stat.data.PotionEffectListData;
import net.Indyuce.mmoitems.stat.data.random.RandomPotionEffectData;
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.type.ItemStat;
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 net.Indyuce.mmoitems.ItemStats;
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.item.build.ItemStackBuilder;
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.version.VersionMaterial;
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.item.build.ItemStackBuilder;
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 net.Indyuce.mmoitems.ItemStats;
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.interaction.Consumable;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;

View File

@ -1,32 +1,30 @@
package net.Indyuce.mmoitems.stat;
import net.Indyuce.mmoitems.listener.CustomSoundListener;
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 io.lumine.mythic.lib.api.item.NBTItem;
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.event.item.RepairItemEvent;
import net.Indyuce.mmoitems.api.interaction.Consumable;
import net.Indyuce.mmoitems.api.interaction.util.DurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData;
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.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;
public class RepairPower extends DoubleStat implements ConsumableItemInteraction {
public RepairPower() {
super("REPAIR", Material.ANVIL, "Repair", new String[] { "The amount of durability your item", "can repair when set an item." },
new String[] { "consumable" });
super("REPAIR", Material.ANVIL, "Repair", new String[]{"The amount of durability your item", "can repair when set an item."},
new String[]{"consumable"});
}
@Override
@ -39,7 +37,7 @@ public class RepairPower extends DoubleStat implements ConsumableItemInteraction
Player player = playerData.getPlayer();
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))) {
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);
@ -64,23 +62,6 @@ public class RepairPower extends DoubleStat implements ConsumableItemInteraction
}
// vanilla durability
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#", "" + called.getRepaired())
.send(player);
CustomSoundListener.playConsumableSound(consumable.getItem(), player);
return true;
}
return false;
return RepairUtils.repairPower(playerData, target, consumable, repairPower);
}
}

View File

@ -2,7 +2,7 @@ package net.Indyuce.mmoitems.stat;
import io.lumine.mythic.lib.api.item.NBTItem;
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.event.item.RepairItemEvent;
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.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
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.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -65,23 +64,6 @@ public class RepairPowerPercent extends DoubleStat implements ConsumableItemInte
}
// vanilla durability
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#", "" + called.getRepaired())
.send(player);
CustomSoundListener.playConsumableSound(consumable.getItem(), player);
return true;
}
return false;
return RepairUtils.repairPower(playerData, target, consumable, repairPower);
}
}

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.version.VersionMaterial;
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.stat.data.DoubleData;
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 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.stat.data.DoubleData;
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 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.stat.data.DoubleData;
import net.Indyuce.mmoitems.stat.type.DoubleStat;

View File

@ -6,7 +6,6 @@ import java.util.Optional;
import java.util.Set;
import io.lumine.mythic.lib.api.item.ItemTag;
import net.Indyuce.mmoitems.stat.data.BooleanData;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import org.apache.commons.lang.Validate;
import org.bukkit.ChatColor;
@ -23,15 +22,12 @@ import org.bukkit.inventory.meta.BlockStateMeta;
import net.Indyuce.mmoitems.ItemStats;
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.item.build.ItemStackBuilder;
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
import net.Indyuce.mmoitems.stat.data.ShieldPatternData;
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
import net.Indyuce.mmoitems.stat.data.type.StatData;
import net.Indyuce.mmoitems.stat.type.StringStat;
import io.lumine.mythic.lib.api.util.AltChar;
import org.jetbrains.annotations.NotNull;
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.version.VersionMaterial;
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.event.item.BreakSoulboundEvent;
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.version.VersionMaterial;
import net.Indyuce.mmoitems.ItemStats;
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.event.item.ApplySoulboundEvent;
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.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.mmoitem.ReadMMOItem;
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.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.util.NumericStatFormula;
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 net.Indyuce.mmoitems.ItemStats;
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.event.item.UpgradeItemEvent;
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.UpgradingEdition;
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.type.ConsumableItemInteraction;
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.trigger.TriggerType;
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.RPGPlayer;
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.JsonObject;
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.stat.GemUpgradeScaling;
import net.Indyuce.mmoitems.stat.type.ItemStat;

View File

@ -1,6 +1,6 @@
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.PotionEffectType;

View File

@ -5,7 +5,7 @@ import java.util.Map;
import java.util.Set;
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 org.apache.commons.lang.Validate;
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.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.util.NumericStatFormula;
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 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.item.build.ItemStackBuilder;
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.manager.StatManager;
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.edition.StatEdition;
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 net.Indyuce.mmoitems.ItemStats;
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.util.message.FFPMMOItems;
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.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.SupportedNBTTagValues;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import org.apache.commons.codec.binary.Base64;
import org.bukkit.ChatColor;
@ -33,6 +34,10 @@ import java.util.*;
@SuppressWarnings("unused")
public class MMOUtils {
public MMOUtils() {
throw new IllegalArgumentException("This class cannot be instantiated.");
}
/**
* @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>
</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 -->
<resources>
<resource>
@ -28,7 +46,6 @@
</resources>
<plugins>
<!-- Completely necessary for dev build deployment -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -92,28 +109,6 @@
</execution>
</executions>
</plugin>
</plugins>
</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>

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