mirror of
https://gitlab.com/phoenix-dvpmt/mmoitems.git
synced 2025-03-13 13:30:06 +01:00
Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/net/Indyuce/mmoitems/stat/type/AttributeStat.java
This commit is contained in:
commit
c91be73d98
6
pom.xml
6
pom.xml
@ -43,8 +43,8 @@
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<source>9</source>
|
||||
<target>9</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
@ -141,7 +141,7 @@
|
||||
<dependency>
|
||||
<groupId>io.lumine</groupId>
|
||||
<artifactId>MythicLib-dist</artifactId>
|
||||
<version>1.3-R11</version>
|
||||
<version>1.3</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -1,13 +1,11 @@
|
||||
package net.Indyuce.mmoitems;
|
||||
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
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.version.SpigotPlugin;
|
||||
import io.lumine.mythic.utils.plugin.LuminePlugin;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.ItemTier;
|
||||
import net.Indyuce.mmoitems.api.SoulboundInfo;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
@ -19,22 +17,13 @@ import net.Indyuce.mmoitems.api.util.MMOItemReforger;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
|
||||
import net.Indyuce.mmoitems.command.MMOItemsCommandTreeRoot;
|
||||
import net.Indyuce.mmoitems.comp.MMOItemsMetrics;
|
||||
import net.Indyuce.mmoitems.comp.MMOItemsRewardTypes;
|
||||
import net.Indyuce.mmoitems.comp.McMMONonRPGHook;
|
||||
import net.Indyuce.mmoitems.comp.PhatLootsHook;
|
||||
import net.Indyuce.mmoitems.comp.RealDualWieldHook;
|
||||
import net.Indyuce.mmoitems.comp.WorldEditSupport;
|
||||
import net.Indyuce.mmoitems.comp.*;
|
||||
import net.Indyuce.mmoitems.comp.eco.VaultSupport;
|
||||
import net.Indyuce.mmoitems.comp.enchants.CrazyEnchantsStat;
|
||||
import net.Indyuce.mmoitems.comp.enchants.EnchantPlugin;
|
||||
import net.Indyuce.mmoitems.comp.enchants.MythicEnchantsSupport;
|
||||
import net.Indyuce.mmoitems.comp.enchants.advanced_enchants.AdvancedEnchantmentsHook;
|
||||
import net.Indyuce.mmoitems.comp.inventory.DefaultPlayerInventory;
|
||||
import net.Indyuce.mmoitems.comp.inventory.OrnamentPlayerInventory;
|
||||
import net.Indyuce.mmoitems.comp.inventory.PlayerInventory;
|
||||
import net.Indyuce.mmoitems.comp.inventory.PlayerInventoryHandler;
|
||||
import net.Indyuce.mmoitems.comp.inventory.RPGInventoryHook;
|
||||
import net.Indyuce.mmoitems.comp.inventory.*;
|
||||
import net.Indyuce.mmoitems.comp.itemglow.ItemGlowListener;
|
||||
import net.Indyuce.mmoitems.comp.itemglow.NoGlowListener;
|
||||
import net.Indyuce.mmoitems.comp.mmocore.MMOCoreMMOLoader;
|
||||
@ -51,16 +40,7 @@ import net.Indyuce.mmoitems.comp.rpg.RPGHandler;
|
||||
import net.Indyuce.mmoitems.gui.PluginInventory;
|
||||
import net.Indyuce.mmoitems.gui.edition.recipe.RecipeBrowserGUI;
|
||||
import net.Indyuce.mmoitems.gui.listener.GuiListener;
|
||||
import net.Indyuce.mmoitems.listener.CraftingListener;
|
||||
import net.Indyuce.mmoitems.listener.CustomBlockListener;
|
||||
import net.Indyuce.mmoitems.listener.CustomSoundListener;
|
||||
import net.Indyuce.mmoitems.listener.DisableInteractions;
|
||||
import net.Indyuce.mmoitems.listener.DurabilityListener;
|
||||
import net.Indyuce.mmoitems.listener.ElementListener;
|
||||
import net.Indyuce.mmoitems.listener.EquipListener;
|
||||
import net.Indyuce.mmoitems.listener.ItemListener;
|
||||
import net.Indyuce.mmoitems.listener.ItemUse;
|
||||
import net.Indyuce.mmoitems.listener.PlayerListener;
|
||||
import net.Indyuce.mmoitems.listener.*;
|
||||
import net.Indyuce.mmoitems.manager.*;
|
||||
import net.Indyuce.mmoitems.skill.Shulker_Missile;
|
||||
import org.apache.commons.lang.Validate;
|
||||
@ -77,6 +57,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@ -116,7 +97,7 @@ public class MMOItems extends LuminePlugin {
|
||||
private VaultSupport vaultSupport;
|
||||
private RPGHandler rpgPlugin;
|
||||
|
||||
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 1;
|
||||
private static final int MYTHICLIB_COMPATIBILITY_INDEX = 3;
|
||||
|
||||
public MMOItems() {
|
||||
plugin = this;
|
||||
@ -128,7 +109,7 @@ public class MMOItems extends LuminePlugin {
|
||||
// Check if the ML build matches
|
||||
if (MYTHICLIB_COMPATIBILITY_INDEX != MythicLib.MMOITEMS_COMPATIBILITY_INDEX) {
|
||||
getLogger().log(Level.WARNING, "Your versions of MythicLib and MMOItems do not match. Make sure you are using the latest builds of both plugins");
|
||||
disable();
|
||||
setEnabled(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -139,10 +120,12 @@ public class MMOItems extends LuminePlugin {
|
||||
getLogger().log(Level.WARNING, "Could not initialize support with WorldEdit 7: " + exception.getMessage());
|
||||
}
|
||||
|
||||
// Initialize default config files
|
||||
saveDefaultConfig();
|
||||
configManager = new ConfigManager();
|
||||
|
||||
/*
|
||||
* stat manager must be initialized before MMOCore compatibility
|
||||
/**
|
||||
* Stat manager must be initialized before MMOCore compatibility
|
||||
* initializes so that MMOCore can register its stats
|
||||
*/
|
||||
statManager = new StatManager();
|
||||
@ -173,7 +156,6 @@ public class MMOItems extends LuminePlugin {
|
||||
|
||||
RecipeBrowserGUI.registerNativeRecipes();
|
||||
skillManager.initialize(false);
|
||||
configManager = new ConfigManager();
|
||||
|
||||
final int configVersion = getConfig().contains("config-version", true) ? getConfig().getInt("config-version") : -1;
|
||||
final int defConfigVersion = getConfig().getDefaults().getInt("config-version");
|
||||
@ -309,7 +291,7 @@ public class MMOItems extends LuminePlugin {
|
||||
getLogger().log(Level.INFO, "Hooked onto Denizen");
|
||||
}*/
|
||||
|
||||
// compatibility with /reload
|
||||
// Compatibility with /reload
|
||||
Bukkit.getScheduler().runTask(this, () -> Bukkit.getOnlinePlayers().forEach(PlayerData::load));
|
||||
|
||||
boolean book = getConfig().getBoolean("recipes.use-recipe-book");
|
||||
@ -326,35 +308,30 @@ public class MMOItems extends LuminePlugin {
|
||||
recipeManager.load(book, amounts);
|
||||
if (amounts) Bukkit.getPluginManager().registerEvents(new CraftingListener(), this);
|
||||
|
||||
// amount and bukkit recipes
|
||||
// Amount and bukkit recipes
|
||||
getLogger().log(Level.INFO, "Loading recipes, please wait...");
|
||||
recipeManager.loadRecipes();
|
||||
|
||||
// main command
|
||||
// Main command
|
||||
MMOItemsCommandTreeRoot mmoitemsCommand = new MMOItemsCommandTreeRoot();
|
||||
getCommand("mmoitems").setExecutor(mmoitemsCommand);
|
||||
getCommand("mmoitems").setTabCompleter(mmoitemsCommand);
|
||||
|
||||
// update item command DISABLED
|
||||
//getCommand("updateitem").setExecutor(new UpdateItemCommand());
|
||||
//getCommand("updateitem").setTabCompleter(new UpdateItemCompletion());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disable() {
|
||||
|
||||
// save player data
|
||||
// Support for early plugin disabling
|
||||
if (!isEnabled())
|
||||
return;
|
||||
|
||||
// Save player data
|
||||
PlayerData.getLoaded().forEach(PlayerData::save);
|
||||
|
||||
// save item updater data
|
||||
ConfigFile updater = new ConfigFile("/dynamic", "updater");
|
||||
updater.getConfig().getKeys(false).forEach(key -> updater.getConfig().set(key, null));
|
||||
updater.save();
|
||||
|
||||
// drop abandonned soulbound items
|
||||
// Drop abandonned soulbound items
|
||||
SoulboundInfo.getAbandonnedInfo().forEach(SoulboundInfo::dropItems);
|
||||
|
||||
// close inventories
|
||||
// Close inventories
|
||||
for (Player player : Bukkit.getOnlinePlayers())
|
||||
if (player.getOpenInventory() != null && player.getOpenInventory().getTopInventory().getHolder() instanceof PluginInventory)
|
||||
player.closeInventory();
|
||||
@ -401,6 +378,30 @@ public class MMOItems extends LuminePlugin {
|
||||
if (handler instanceof Listener && isEnabled()) Bukkit.getPluginManager().registerEvents((Listener) handler, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param potentialPlugin Some plugin that the user wants compatibility with
|
||||
* @return If it worked
|
||||
*/
|
||||
public boolean setRPG(RPGHandler.PluginEnum potentialPlugin) {
|
||||
|
||||
// Check if the plugin is installed
|
||||
if (Bukkit.getPluginManager().getPlugin(potentialPlugin.getName()) == null) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not initialize RPG plugin compatibility with " + potentialPlugin.getName() + ": plugin is not installed");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
setRPG(potentialPlugin.load());
|
||||
return true;
|
||||
|
||||
// Some loading issue
|
||||
} catch (InvocationTargetException | NoSuchMethodException | InstantiationException | IllegalAccessException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not initialize RPG plugin compatibility with " + potentialPlugin.getName() + ":");
|
||||
exception.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public PluginUpdateManager getUpdates() {
|
||||
return pluginUpdateManager;
|
||||
}
|
||||
@ -558,57 +559,32 @@ public class MMOItems extends LuminePlugin {
|
||||
|
||||
/**
|
||||
* Decide by which system will the RPG Requirements of the player will be checked.
|
||||
* <p></p>
|
||||
* <p>
|
||||
* For example, required level, is that vanilla XP levels, MMOCore levels, McMMO Leves or what?
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
public void findRpgPlugin() {
|
||||
if (rpgPlugin != null) return;
|
||||
|
||||
String preferred = plugin.getConfig().getString("preferred-rpg-provider", null);
|
||||
if (preferred != null) {
|
||||
|
||||
if (preferred != null)
|
||||
try {
|
||||
RPGHandler.PluginEnum preferredRPG = RPGHandler.PluginEnum.valueOf(preferred.toUpperCase());
|
||||
// Found the plugin?
|
||||
if (Bukkit.getPluginManager().getPlugin(preferredRPG.getName()) != null) {
|
||||
|
||||
// Load that one
|
||||
setRPG(preferredRPG.load());
|
||||
|
||||
// Mention it
|
||||
print(null, "Using $s{0}$b as RPGPlayer provider", "RPG Provider", preferredRPG.getName());
|
||||
if (setRPG(RPGHandler.PluginEnum.valueOf(preferred.toUpperCase())))
|
||||
return;
|
||||
} else
|
||||
|
||||
print(null, "Preferred RPGPlayer provider $r{0}$b is not installed!", "RPG Provider", preferred);
|
||||
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
|
||||
// Log error
|
||||
FriendlyFeedbackProvider ffp = new FriendlyFeedbackProvider(FFPMMOItems.get());
|
||||
ffp.activatePrefix(true, "RPG Provider");
|
||||
ffp.log(FriendlyFeedbackCategory.ERROR, "Invalid RPG Provider '$u{0}$b' --- These are the supported ones:", preferred);
|
||||
for (RPGHandler.PluginEnum pgrep : RPGHandler.PluginEnum.values()) {
|
||||
ffp.log(FriendlyFeedbackCategory.ERROR, " $r+ $b{0}", pgrep.getName());
|
||||
}
|
||||
ffp.sendTo(FriendlyFeedbackCategory.ERROR, getConsole());
|
||||
} catch (IllegalArgumentException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "'" + preferred.toUpperCase() + "' is not a valid RPG plugin:");
|
||||
for (RPGHandler.PluginEnum pgrep : RPGHandler.PluginEnum.values())
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "- " + pgrep.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// For each supported plugin
|
||||
for (RPGHandler.PluginEnum pluginEnum : RPGHandler.PluginEnum.values()) {
|
||||
|
||||
// Found the plugin?
|
||||
if (Bukkit.getPluginManager().getPlugin(pluginEnum.getName()) != null) {
|
||||
|
||||
// Load that one
|
||||
setRPG(pluginEnum.load());
|
||||
|
||||
// Mention it
|
||||
print(null, "Using $s{0}$b as RPGPlayer provider", "RPG Provider", pluginEnum.getName());
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Look through installed plugins
|
||||
for (RPGHandler.PluginEnum pluginEnum : RPGHandler.PluginEnum.values())
|
||||
if (Bukkit.getPluginManager().getPlugin(pluginEnum.getName()) != null)
|
||||
if (setRPG(pluginEnum))
|
||||
return;
|
||||
|
||||
// Just use the default
|
||||
setRPG(new DefaultHook());
|
||||
@ -815,22 +791,6 @@ public class MMOItems extends LuminePlugin {
|
||||
}
|
||||
//endregion
|
||||
|
||||
/**
|
||||
* Logs something into the console with a cool [MMOItems] prefix :)
|
||||
* <p></p>
|
||||
* Parses color codes. <b>Mostly for DEV testing</b>. these may removed any release.
|
||||
*
|
||||
* @author Gunging
|
||||
*/
|
||||
public static void log(@Nullable String message) {
|
||||
if (message == null) {
|
||||
message = "< null >";
|
||||
}
|
||||
//String prefix = "\u00a78[" + ChatColor.YELLOW + "MMOItems\u00a78] \u00a77";
|
||||
String prefix = "";
|
||||
plugin.getServer().getConsoleSender().sendMessage(prefix + message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Easily log something using the FriendlyFeedbackProvider, nice!
|
||||
* <p></p>
|
||||
|
@ -4,6 +4,7 @@ import io.lumine.mythic.lib.damage.AttackMetadata;
|
||||
import io.lumine.mythic.lib.skill.SkillMetadata;
|
||||
import io.lumine.mythic.lib.skill.custom.variable.VariableList;
|
||||
import io.lumine.mythic.lib.skill.custom.variable.VariableScope;
|
||||
import io.lumine.mythic.lib.skill.handler.SkillHandler;
|
||||
import net.Indyuce.mmoitems.ability.metadata.BackwardsCompatibleAbilityMetadata;
|
||||
import net.Indyuce.mmoitems.skill.RegisteredSkill;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
@ -18,19 +19,17 @@ public class BackwardsCompatibleAbility extends Ability<BackwardsCompatibleAbili
|
||||
super(registeredSkill.getHandler().getId(), registeredSkill.getName());
|
||||
|
||||
this.registeredSkill = registeredSkill;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public BackwardsCompatibleAbilityMetadata canBeCast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
|
||||
SkillMetadata skillMeta = new SkillMetadata(ability, attack, new VariableList(VariableScope.SKILL), attack, attack.getPlayer().getLocation(), null, target);
|
||||
SkillMetadata skillMeta = new SkillMetadata(ability, attack, new VariableList(VariableScope.SKILL), attack, attack.getPlayer().getLocation(), null, target, null);
|
||||
return new BackwardsCompatibleAbilityMetadata(skillMeta, registeredSkill.getHandler().getResult(skillMeta), ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void whenCast(AttackMetadata attack, BackwardsCompatibleAbilityMetadata ability) {
|
||||
registeredSkill.getHandler().whenCast(ability.getResult(), ability.getMetadata());
|
||||
((SkillHandler) registeredSkill.getHandler()).whenCast(ability.getResult(), ability.getMetadata());
|
||||
}
|
||||
}
|
||||
|
@ -1,14 +1,12 @@
|
||||
package net.Indyuce.mmoitems.ability;
|
||||
|
||||
import io.lumine.mythic.lib.damage.AttackMetadata;
|
||||
import net.Indyuce.mmoitems.ability.list.vector.Firebolt;
|
||||
import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
|
||||
/**
|
||||
* Ability that requires a direction to be cast. For
|
||||
* instance, a projectile like {@link Firebolt}
|
||||
* Ability that requires a direction to be cast
|
||||
*
|
||||
* @deprecated Abilities were moved over to MythicLib.
|
||||
* Abilities are being replaced by {@link io.lumine.mythic.lib.skill.handler.SkillHandler}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package net.Indyuce.mmoitems.ability.metadata;
|
||||
|
||||
import net.Indyuce.mmoitems.ability.AbilityMetadata;
|
||||
import net.Indyuce.mmoitems.ability.list.location.Minor_Explosion;
|
||||
import net.Indyuce.mmoitems.stat.data.AbilityData;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@ -9,8 +8,7 @@ import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Ability that requires a target location, for
|
||||
* instance {@link Minor_Explosion}
|
||||
* Ability that requires a target location
|
||||
*
|
||||
* @deprecated Abilities were moved over to MythicLib.
|
||||
* AbilityMetadata from MMOItems are now {@link io.lumine.mythic.lib.skill.result.SkillResult}
|
||||
|
@ -20,18 +20,18 @@ import java.util.List;
|
||||
@SuppressWarnings("unused")
|
||||
public class Type {
|
||||
|
||||
// slashing
|
||||
// Slashing
|
||||
public static final Type SWORD = new Type(TypeSet.SLASHING, "SWORD", true, EquipmentSlot.MAIN_HAND);
|
||||
|
||||
// piercing
|
||||
// Piercing
|
||||
public static final Type DAGGER = new Type(TypeSet.PIERCING, "DAGGER", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type SPEAR = new Type(TypeSet.PIERCING, "SPEAR", true, EquipmentSlot.MAIN_HAND);
|
||||
|
||||
// blunt
|
||||
// Blunt
|
||||
public static final Type HAMMER = new Type(TypeSet.BLUNT, "HAMMER", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type GAUNTLET = new Type(TypeSet.BLUNT, "GAUNTLET", true, EquipmentSlot.MAIN_HAND);
|
||||
|
||||
// range
|
||||
// Range
|
||||
public static final Type WHIP = new Type(TypeSet.RANGE, "WHIP", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type STAFF = new Type(TypeSet.RANGE, "STAFF", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type BOW = new Type(TypeSet.RANGE, "BOW", true, EquipmentSlot.BOTH_HANDS);
|
||||
@ -39,14 +39,14 @@ public class Type {
|
||||
public static final Type MUSKET = new Type(TypeSet.RANGE, "MUSKET", true, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type LUTE = new Type(TypeSet.RANGE, "LUTE", true, EquipmentSlot.MAIN_HAND);
|
||||
|
||||
// offhand
|
||||
// Offhand
|
||||
public static final Type CATALYST = new Type(TypeSet.OFFHAND, "CATALYST", false, EquipmentSlot.BOTH_HANDS);
|
||||
public static final Type OFF_CATALYST = new Type(TypeSet.OFFHAND, "OFF_CATALYST", false, EquipmentSlot.OFF_HAND);
|
||||
|
||||
// any
|
||||
// Any
|
||||
public static final Type ORNAMENT = new Type(TypeSet.EXTRA, "ORNAMENT", false, EquipmentSlot.ANY);
|
||||
|
||||
// extra
|
||||
// Extra
|
||||
public static final Type ARMOR = new Type(TypeSet.EXTRA, "ARMOR", false, EquipmentSlot.ARMOR, true);
|
||||
public static final Type TOOL = new Type(TypeSet.EXTRA, "TOOL", false, EquipmentSlot.MAIN_HAND);
|
||||
public static final Type CONSUMABLE = new Type(TypeSet.EXTRA, "CONSUMABLE", false, EquipmentSlot.MAIN_HAND);
|
||||
@ -96,8 +96,8 @@ public class Type {
|
||||
|
||||
private UnidentifiedItem unidentifiedTemplate;
|
||||
|
||||
/*
|
||||
* list of stats which can be applied onto an item which has this type. This
|
||||
/**
|
||||
* List of stats which can be applied onto an item which has this type. This
|
||||
* improves performance when generating an item by a significant amount.
|
||||
*/
|
||||
private final List<ItemStat> available = new ArrayList<>();
|
||||
@ -118,7 +118,7 @@ public class Type {
|
||||
//TYP//MMOItems.log("\u00a78TYPE \u00a75HARDCODED\u00a77 > Lore\u00a7b " + loreFormat);
|
||||
}
|
||||
|
||||
public Type(@NotNull TypeManager manager,@NotNull ConfigurationSection config) {
|
||||
public Type(@NotNull TypeManager manager, @NotNull ConfigurationSection config) {
|
||||
id = config.getName().toUpperCase().replace("-", "_").replace(" ", "_");
|
||||
|
||||
parent = manager.get(config.getString("parent", "").toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.Indyuce.mmoitems.api;
|
||||
|
||||
import io.lumine.mythic.lib.api.stat.modifier.ModifierSource;
|
||||
import io.lumine.mythic.lib.comp.target.InteractionType;
|
||||
import io.lumine.mythic.lib.damage.AttackMetadata;
|
||||
import io.lumine.mythic.lib.player.modifier.ModifierSource;
|
||||
import io.lumine.mythic.lib.version.VersionSound;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.MMOUtils;
|
||||
|
@ -5,7 +5,6 @@ import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.api.droptable.item.BlockDropItem;
|
||||
import net.Indyuce.mmoitems.api.droptable.item.DropItem;
|
||||
import net.Indyuce.mmoitems.api.droptable.item.MMOItemDropItem;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
|
||||
import net.Indyuce.mmoitems.api.player.PlayerData;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -16,11 +15,11 @@ import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class DropTable {
|
||||
private static final Random random = new Random();
|
||||
|
||||
private final List<String> subtablesList = new ArrayList<>();
|
||||
private final Map<String, Subtable> subtables = new HashMap<>();
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
public DropTable(ConfigurationSection config) {
|
||||
Validate.notNull(config, "Could not read the drop table config");
|
||||
for (String key : config.getKeys(false))
|
||||
@ -33,11 +32,8 @@ public class DropTable {
|
||||
// Include parsed subtable
|
||||
subtables.put(key, new Subtable(config.getConfigurationSection(key)));
|
||||
|
||||
// Ew
|
||||
} catch (IllegalArgumentException exception) {
|
||||
|
||||
// Print that error message
|
||||
MMOItems.print(null, "Could not read subtable '$r{0}$b' from drop table '$e{1}$b';&f {2}", key, config.getName(), exception.getMessage());
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not read subtable '" + key + "' from drop table '" + config.getName() + "': " + exception.getMessage());
|
||||
}
|
||||
|
||||
Validate.notEmpty(subtablesList, "Your droptable must contain at least one subtable");
|
||||
@ -74,8 +70,8 @@ public class DropTable {
|
||||
public static class Subtable {
|
||||
private final List<DropItem> items = new ArrayList<>();
|
||||
|
||||
/*
|
||||
* options to prevent players from abusing drop tables.
|
||||
/**
|
||||
* Options to prevent players from abusing drop tables.
|
||||
*/
|
||||
private final boolean disableSilkTouch;
|
||||
|
||||
|
@ -2,18 +2,11 @@ package net.Indyuce.mmoitems.api.item.build;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.util.ui.FriendlyFeedbackProvider;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
|
||||
import io.lumine.mythic.lib.api.math.EvaluatedFormula;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* There are three types of lore placeholders.
|
||||
@ -132,8 +125,6 @@ public class LoreBuilder {
|
||||
* have been inserted in the lore. It cleans all unused static placeholders
|
||||
* as well as lore bars. The dynamic placeholders still remain however.
|
||||
*/
|
||||
DecimalFormat df = new DecimalFormat("#.####");
|
||||
|
||||
public List<String> build() {
|
||||
|
||||
/*
|
||||
@ -157,18 +148,17 @@ public class LoreBuilder {
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Allows math to be done within the stats.yml file
|
||||
*
|
||||
* */
|
||||
int index = 0;
|
||||
* Allows math to be done within the stats.yml file
|
||||
*/
|
||||
int index = -1;
|
||||
for (String string : lore) {
|
||||
if (string.contains("MATH%")) {
|
||||
String result = String.valueOf(df.format(eval(StringUtils.substringBetween(string, "%", "%"))));
|
||||
lore.set(index, string.replaceAll("MATH\\%[^%]*\\%", result));
|
||||
}
|
||||
index++;
|
||||
String match = StringUtils.substringBetween(string, "%", "%");
|
||||
if (match == null)
|
||||
continue;
|
||||
|
||||
String result = MythicLib.plugin.getMMOConfig().decimals.format(new EvaluatedFormula(match).evaluate());
|
||||
lore.set(index, string.replaceAll("MATH\\%[^%]*\\%", result));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -207,91 +197,4 @@ public class LoreBuilder {
|
||||
private boolean isBar(String str) {
|
||||
return str.startsWith("{bar}") || str.startsWith("{sbar}");
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
* Math methods
|
||||
*
|
||||
* */
|
||||
|
||||
public static double eval(final String str) {
|
||||
return new Object() {
|
||||
int pos = -1, ch;
|
||||
|
||||
void nextChar() {
|
||||
ch = (++pos < str.length()) ? str.charAt(pos) : -1;
|
||||
}
|
||||
|
||||
boolean eat(int charToEat) {
|
||||
while (ch == ' ') nextChar();
|
||||
if (ch == charToEat) {
|
||||
nextChar();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
double parse() {
|
||||
nextChar();
|
||||
double x = parseExpression();
|
||||
if (pos < str.length()) throw new RuntimeException("Unexpected: " + (char) ch);
|
||||
return x;
|
||||
}
|
||||
|
||||
// Grammar:
|
||||
// expression = term | expression `+` term | expression `-` term
|
||||
// term = factor | term `*` factor | term `/` factor
|
||||
// factor = `+` factor | `-` factor | `(` expression `)`
|
||||
// | number | functionName factor | factor `^` factor
|
||||
|
||||
double parseExpression() {
|
||||
double x = parseTerm();
|
||||
for (; ; ) {
|
||||
if (eat('+')) x += parseTerm(); // addition
|
||||
else if (eat('-')) x -= parseTerm(); // subtraction
|
||||
else return x;
|
||||
}
|
||||
}
|
||||
|
||||
double parseTerm() {
|
||||
double x = parseFactor();
|
||||
for (; ; ) {
|
||||
if (eat('*')) x *= parseFactor(); // multiplication
|
||||
else if (eat('/')) x /= parseFactor(); // division
|
||||
else return x;
|
||||
}
|
||||
}
|
||||
|
||||
double parseFactor() {
|
||||
if (eat('+')) return parseFactor(); // unary plus
|
||||
if (eat('-')) return -parseFactor(); // unary minus
|
||||
|
||||
double x;
|
||||
int startPos = this.pos;
|
||||
if (eat('(')) { // parentheses
|
||||
x = parseExpression();
|
||||
eat(')');
|
||||
} else if ((ch >= '0' && ch <= '9') || ch == '.') { // numbers
|
||||
while ((ch >= '0' && ch <= '9') || ch == '.') nextChar();
|
||||
x = Double.parseDouble(str.substring(startPos, this.pos));
|
||||
} else if (ch >= 'a' && ch <= 'z') { // functions
|
||||
while (ch >= 'a' && ch <= 'z') nextChar();
|
||||
String func = str.substring(startPos, this.pos);
|
||||
x = parseFactor();
|
||||
if (func.equals("sqrt")) x = Math.sqrt(x);
|
||||
else if (func.equals("sin")) x = Math.sin(Math.toRadians(x));
|
||||
else if (func.equals("cos")) x = Math.cos(Math.toRadians(x));
|
||||
else if (func.equals("tan")) x = Math.tan(Math.toRadians(x));
|
||||
else throw new RuntimeException("Unknown function: " + func);
|
||||
} else {
|
||||
throw new RuntimeException("Unexpected: " + (char) ch);
|
||||
}
|
||||
|
||||
if (eat('^')) x = Math.pow(x, parseFactor()); // exponentiation
|
||||
|
||||
return x;
|
||||
}
|
||||
}.parse();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,10 +4,10 @@ import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.api.player.MMOPlayerData;
|
||||
import io.lumine.mythic.lib.api.stat.modifier.ModifierSource;
|
||||
import io.lumine.mythic.lib.damage.AttackMetadata;
|
||||
import io.lumine.mythic.lib.player.PlayerMetadata;
|
||||
import io.lumine.mythic.lib.skill.trigger.PassiveSkill;
|
||||
import io.lumine.mythic.lib.player.modifier.ModifierSource;
|
||||
import io.lumine.mythic.lib.player.skill.PassiveSkill;
|
||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
@ -167,7 +167,7 @@ public class PlayerData {
|
||||
inventory.getEquipped().clear();
|
||||
permanentEffects.clear();
|
||||
cancelRunnables();
|
||||
mmoData.unregisterSkillTriggers("MMOItemsItem");
|
||||
mmoData.getPassiveSkillMap().removeModifiers("MMOItemsItem");
|
||||
itemParticles.clear();
|
||||
overridingItemParticles = null;
|
||||
if (MMOItems.plugin.hasPermissions()) {
|
||||
@ -239,7 +239,7 @@ public class PlayerData {
|
||||
if (equipped.getSlot() != EquipmentSlot.OFF_HAND || !MMOItems.plugin.getConfig().getBoolean("disable-abilities-in-offhand"))
|
||||
for (AbilityData abilityData : ((AbilityListData) item.getData(ItemStats.ABILITIES)).getAbilities()) {
|
||||
ModifierSource modSource = equipped.getItem().getType() == null ? ModifierSource.OTHER : equipped.getItem().getType().getItemSet().getModifierSource();
|
||||
mmoData.registerSkillTrigger(new PassiveSkill("MMOItemsItem", abilityData.getTriggerType(), abilityData, equipped.getSlot(), modSource));
|
||||
mmoData.getPassiveSkillMap().addModifier(new PassiveSkill("MMOItemsItem", abilityData.getTriggerType(), abilityData, equipped.getSlot(), modSource));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -280,7 +280,7 @@ public class PlayerData {
|
||||
|
||||
if (hasSetBonuses()) {
|
||||
for (AbilityData ability : setBonuses.getAbilities())
|
||||
mmoData.registerSkillTrigger(new PassiveSkill("MMOItemsItem", ability.getTriggerType(), ability));
|
||||
mmoData.getPassiveSkillMap().addModifier(new PassiveSkill("MMOItemsItem", ability.getTriggerType(), ability));
|
||||
for (ParticleData particle : setBonuses.getParticles())
|
||||
itemParticles.add(particle.start(this));
|
||||
for (PotionEffect effect : setBonuses.getPotionEffects())
|
||||
|
@ -3,10 +3,10 @@ package net.Indyuce.mmoitems.api.player;
|
||||
import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
||||
import io.lumine.mythic.lib.api.stat.StatInstance;
|
||||
import io.lumine.mythic.lib.api.stat.StatMap;
|
||||
import io.lumine.mythic.lib.api.stat.modifier.ModifierSource;
|
||||
import io.lumine.mythic.lib.api.stat.modifier.ModifierType;
|
||||
import io.lumine.mythic.lib.api.stat.modifier.StatModifier;
|
||||
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.EquippedPlayerItem;
|
||||
@ -61,8 +61,7 @@ public class PlayerStats {
|
||||
|
||||
// Add set bonuses
|
||||
if (playerData.hasSetBonuses() && playerData.getSetBonuses().hasStat(stat))
|
||||
packet.addModifier("MMOItemSetBonus",
|
||||
new StatModifier(playerData.getSetBonuses().getStat(stat), ModifierType.FLAT, EquipmentSlot.OTHER, ModifierSource.OTHER));
|
||||
packet.addModifier(new StatModifier("MMOItemSetBonus", stat.getId(), playerData.getSetBonuses().getStat(stat), ModifierType.FLAT, EquipmentSlot.OTHER, ModifierSource.OTHER));
|
||||
|
||||
// The index of the mmoitem stat modifier being added
|
||||
int index = 0;
|
||||
@ -79,7 +78,7 @@ public class PlayerStats {
|
||||
if (item.getSlot() == EquipmentSlot.MAIN_HAND && stat instanceof AttributeStat)
|
||||
value -= ((AttributeStat) stat).getOffset(playerData);
|
||||
|
||||
packet.addModifier("MMOItem-" + index++, new StatModifier(value, ModifierType.FLAT, item.getSlot(), source));
|
||||
packet.addModifier(new StatModifier("MMOItem-" + index++, stat.getId(), value, ModifierType.FLAT, item.getSlot(), source));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
package net.Indyuce.mmoitems.api.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
public class StatFormat extends DecimalFormat {
|
||||
private static final long serialVersionUID = -2880611307522719877L;
|
||||
|
||||
public StatFormat(String format) {
|
||||
super("0." + format);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package net.Indyuce.mmoitems.command.mmoitems;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.util.MMOItemReforger;
|
||||
@ -15,10 +16,12 @@ public class ReloadCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
addChild(new SubReloadCommandTreeNode("recipes", this, this::reloadRecipes));
|
||||
addChild(new SubReloadCommandTreeNode("stations", this, this::reloadStations));
|
||||
addChild(new SubReloadCommandTreeNode("skills", this, this::reloadSkills));
|
||||
addChild(new SubReloadCommandTreeNode("all", this, (sender) -> {
|
||||
reloadMain(sender);
|
||||
reloadRecipes(sender);
|
||||
reloadStations(sender);
|
||||
reloadSkills(sender);
|
||||
}));
|
||||
}
|
||||
|
||||
@ -28,9 +31,9 @@ public class ReloadCommandTreeNode extends CommandTreeNode {
|
||||
return CommandResult.SUCCESS;
|
||||
}
|
||||
|
||||
public static class SubReloadCommandTreeNode extends CommandTreeNode {
|
||||
public class SubReloadCommandTreeNode extends CommandTreeNode {
|
||||
private final Consumer<CommandSender> action;
|
||||
|
||||
|
||||
public SubReloadCommandTreeNode(String sub, CommandTreeNode parent, Consumer<CommandSender> action) {
|
||||
super(parent, sub);
|
||||
this.action = action;
|
||||
@ -43,6 +46,12 @@ public class ReloadCommandTreeNode extends CommandTreeNode {
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadSkills(CommandSender sender) {
|
||||
MythicLib.plugin.getSkills().initialize(true);
|
||||
MMOItems.plugin.getSkills().initialize(true);
|
||||
sender.sendMessage(MMOItems.plugin.getPrefix() + "Successfully reloaded " + MMOItems.plugin.getSkills().getAll().size() + " skills.");
|
||||
}
|
||||
|
||||
public void reloadMain(CommandSender sender) {
|
||||
MMOItems.plugin.getEquipListener().reload();
|
||||
MMOItems.plugin.getLanguage().reload();
|
||||
|
@ -26,7 +26,7 @@ public class CheckStatCommandTreeNode extends CommandTreeNode {
|
||||
|
||||
ItemStat stat = MMOItems.plugin.getStats().get(args[2].toUpperCase().replace("-", "_"));
|
||||
if (stat == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find the stat called " + args[1].toUpperCase().replace("-", "_") + ".");
|
||||
sender.sendMessage(ChatColor.RED + "Couldn't find the stat called " + args[2].toUpperCase().replace("-", "_") + ".");
|
||||
return CommandResult.FAILURE;
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,11 @@ public class MMOCoreHook implements RPGHandler, Listener {
|
||||
|
||||
/**
|
||||
* Called when MMOItems enables
|
||||
* <p>
|
||||
* These stats are only updated on a server reload because that
|
||||
* class has to be instanciated again for the registered stats to update
|
||||
*/
|
||||
public MMOCoreHook() {
|
||||
/*
|
||||
* only works when the server is reloaded. needs /reload when changing
|
||||
* attributes or professions to refresh MMOItems stats
|
||||
*/
|
||||
for (PlayerAttribute attribute : MMOCore.plugin.attributeManager.getAll())
|
||||
MMOItems.plugin.getStats().register(new Required_Attribute(attribute));
|
||||
for (Profession profession : MMOCore.plugin.professionManager.getAll())
|
||||
@ -105,12 +104,12 @@ public class MMOCoreHook implements RPGHandler, Listener {
|
||||
|
||||
@Override
|
||||
public void giveMana(double value) {
|
||||
data.giveMana(value, PlayerResourceUpdateEvent.UpdateReason.REGENERATION);
|
||||
data.giveMana(value, PlayerResourceUpdateEvent.UpdateReason.OTHER);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void giveStamina(double value) {
|
||||
data.giveStamina(value, PlayerResourceUpdateEvent.UpdateReason.REGENERATION);
|
||||
data.giveStamina(value, PlayerResourceUpdateEvent.UpdateReason.OTHER);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
package net.Indyuce.mmoitems.comp.rpg;
|
||||
|
||||
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.MMOCoreHook;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public interface RPGHandler {
|
||||
|
||||
@ -52,14 +50,8 @@ public interface RPGHandler {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public RPGHandler load() {
|
||||
try {
|
||||
return pluginClass.getDeclaredConstructor().newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException | NoSuchMethodException | InvocationTargetException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING,
|
||||
"Could not initialize RPG plugin compatibility with " + name + ": " + exception.getMessage());
|
||||
return new DefaultHook();
|
||||
}
|
||||
public RPGHandler load() throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
|
||||
return pluginClass.getDeclaredConstructor().newInstance();
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
|
@ -94,7 +94,7 @@ public class DisableInteractions implements Listener {
|
||||
|
||||
NBTItem item = NBTItem.get(event.getItem());
|
||||
if (item.getBoolean("MMOITEMS_DISABLE_INTERACTION") || item.hasTag("MMOITEMS_UNIDENTIFIED_ITEM"))
|
||||
event.setUseItemInHand(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,6 @@ public class ConfigManager implements Reloadable {
|
||||
|
||||
mkdir("layouts");
|
||||
mkdir("item");
|
||||
mkdir("dynamic");
|
||||
mkdir("language");
|
||||
mkdir("language/lore-formats");
|
||||
mkdir("modifiers");
|
||||
|
@ -4,6 +4,7 @@ import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.ConfigFile;
|
||||
import net.Indyuce.mmoitems.api.PluginUpdate;
|
||||
import net.Indyuce.mmoitems.api.Type;
|
||||
import net.Indyuce.mmoitems.skill.RegisteredSkill;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
@ -12,12 +13,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class PluginUpdateManager {
|
||||
@ -227,6 +223,28 @@ public class PluginUpdateManager {
|
||||
config.save();
|
||||
}
|
||||
}));
|
||||
|
||||
|
||||
register(new PluginUpdate(6, new String[]{"MMOItems 6.7 introduced individual config files for skills. This update reads your previous language folder and applies it to the new individual config files.", "This can also be used to apply an old plugin translation"}, sender -> {
|
||||
FileConfiguration abilities = new ConfigFile("/language", "abilities").getConfig();
|
||||
|
||||
for (RegisteredSkill skill : MMOItems.plugin.getSkills().getAll()) {
|
||||
ConfigFile configFile = new ConfigFile("/skill", skill.getHandler().getLowerCaseId());
|
||||
FileConfiguration config = configFile.getConfig();
|
||||
|
||||
// Apply old name
|
||||
config.set("name", Objects.requireNonNullElse(abilities.getString("ability." + skill.getHandler().getLowerCaseId()), skill.getName()));
|
||||
|
||||
// Apply old modifier name
|
||||
for (String mod : skill.getHandler().getModifiers())
|
||||
config.set("modifier." + mod + ".name", Objects.requireNonNullElse(abilities.getString("modifier." + mod), skill.getModifierName(mod)));
|
||||
|
||||
configFile.save();
|
||||
}
|
||||
|
||||
sender.sendMessage("Config updates successfully applied, reloading skills..");
|
||||
MMOItems.plugin.getSkills().initialize(true);
|
||||
}));
|
||||
}
|
||||
|
||||
public void register(PluginUpdate update) {
|
||||
|
@ -81,8 +81,11 @@ public class SkillManager {
|
||||
config.save();
|
||||
}
|
||||
|
||||
RegisteredSkill skill = new RegisteredSkill(handler, config.getConfig());
|
||||
this.skills.put(handler.getId(), skill);
|
||||
try {
|
||||
this.skills.put(handler.getId(), new RegisteredSkill(handler, config.getConfig()));
|
||||
} catch (RuntimeException exception) {
|
||||
MMOItems.plugin.getLogger().log(Level.WARNING, "Could not load skill '" + handler.getId() + "': " + exception.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ public class StatManager {
|
||||
private final Set<ConsumableItemInteraction> consumableActions = new HashSet<>();
|
||||
private final Set<PlayerConsumable> playerConsumables = new HashSet<>();
|
||||
|
||||
/*
|
||||
* load default stats using java reflection, get all public static final
|
||||
/**
|
||||
* Load default stats using java reflection, get all public static final
|
||||
* fields in the ItemStat and register them as stat instances
|
||||
*/
|
||||
public StatManager() {
|
||||
|
@ -25,7 +25,7 @@ public class TypeManager implements Reloadable {
|
||||
Type.STAFF, Type.SWORD, Type.TOOL, Type.WHIP);
|
||||
|
||||
/*
|
||||
* register all other types. important: check if the map already
|
||||
* Register all other types. Important: check if the map already
|
||||
* contains the id, this way the DEFAULT types are not registered twice,
|
||||
* and only custom types are registered with a parent.
|
||||
*/
|
||||
|
@ -45,7 +45,7 @@ public class RegisteredSkill {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public SkillHandler getHandler() {
|
||||
public SkillHandler<?> getHandler() {
|
||||
return handler;
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,8 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class Armor extends AttributeStat {
|
||||
public Armor() {
|
||||
|
@ -1,11 +1,6 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
||||
|
@ -1,19 +1,14 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import net.Indyuce.mmoitems.stat.type.GemStoneStat;
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@ -23,9 +18,6 @@ import java.util.ArrayList;
|
||||
public class CustomModelData extends DoubleStat implements GemStoneStat {
|
||||
public CustomModelData() {
|
||||
super("CUSTOM_MODEL_DATA", Material.PAINTING, "Custom Model Data", new String[] { "Your 1.14+ model data." }, new String[] { "!block", "all" });
|
||||
|
||||
if (MythicLib.plugin.getVersion().isBelowOrEqual(1, 13))
|
||||
disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,10 +10,8 @@ import net.Indyuce.mmoitems.api.Element;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.gui.edition.ElementsEdition;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.ElementListData;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomElementListData;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
|
@ -4,7 +4,6 @@ import io.lumine.mythic.lib.api.item.SupportedNBTTagValues;
|
||||
import net.Indyuce.mmoitems.MMOItems;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
|
@ -3,12 +3,7 @@ package net.Indyuce.mmoitems.stat;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
|
||||
public class KnockbackResistance extends AttributeStat {
|
||||
public KnockbackResistance() {
|
||||
|
@ -3,12 +3,7 @@ package net.Indyuce.mmoitems.stat;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
|
||||
public class MaxHealth extends AttributeStat {
|
||||
public MaxHealth() {
|
||||
|
@ -3,12 +3,7 @@ package net.Indyuce.mmoitems.stat;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.attribute.Attribute;
|
||||
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.AttributeStat;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
|
||||
public class MovementSpeed extends AttributeStat {
|
||||
public MovementSpeed() {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package net.Indyuce.mmoitems.stat;
|
||||
|
||||
import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
@ -57,8 +57,8 @@ public class PickaxePower extends DoubleStat {
|
||||
if (techMinimum != 0 || techMaximum != 0) {
|
||||
|
||||
String builtRange;
|
||||
if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) { builtRange = new StatFormat("##").format(techMinimum); }
|
||||
else { builtRange = new StatFormat("##").format(techMinimum) + "-" + new StatFormat("##").format(techMaximum); }
|
||||
if (SilentNumbers.round(techMinimum, 2) == SilentNumbers.round(techMaximum, 2)) { builtRange = MythicLib.plugin.getMMOConfig().decimals.format(techMinimum); }
|
||||
else { builtRange = MythicLib.plugin.getMMOConfig().decimals.format(techMinimum) + "-" + MythicLib.plugin.getMMOConfig().decimals.format(techMaximum); }
|
||||
|
||||
// Just display normally
|
||||
item.getLore().insert("pickaxe-power", formatNumericStat(techMinimum, "#", builtRange));
|
||||
|
@ -3,7 +3,6 @@ package net.Indyuce.mmoitems.stat;
|
||||
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.api.util.ui.PlusMinusPercent;
|
||||
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
|
||||
import io.lumine.mythic.lib.version.VersionMaterial;
|
||||
import net.Indyuce.mmoitems.ItemStats;
|
||||
@ -11,14 +10,12 @@ import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.item.mmoitem.ReadMMOItem;
|
||||
import net.Indyuce.mmoitems.api.player.RPGPlayer;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.api.util.message.Message;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.RequiredLevelData;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomRequiredLevelData;
|
||||
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.DoubleStat;
|
||||
import net.Indyuce.mmoitems.stat.type.ItemRestriction;
|
||||
import org.apache.commons.lang.Validate;
|
||||
|
@ -1,15 +1,11 @@
|
||||
package net.Indyuce.mmoitems.stat.block;
|
||||
|
||||
import io.lumine.mythic.lib.api.util.ui.SilentNumbers;
|
||||
import net.Indyuce.mmoitems.api.item.build.ItemStackBuilder;
|
||||
import net.Indyuce.mmoitems.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
import net.Indyuce.mmoitems.stat.data.random.RandomStatData;
|
||||
import net.Indyuce.mmoitems.stat.data.type.StatData;
|
||||
import net.Indyuce.mmoitems.stat.type.DoubleStat;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import org.apache.commons.lang.Validate;
|
||||
import org.bukkit.Material;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
@ -15,7 +15,6 @@ 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.api.util.NumericStatFormula;
|
||||
import net.Indyuce.mmoitems.api.util.StatFormat;
|
||||
import net.Indyuce.mmoitems.api.util.message.FFPMMOItems;
|
||||
import net.Indyuce.mmoitems.gui.edition.EditionInventory;
|
||||
import net.Indyuce.mmoitems.stat.data.DoubleData;
|
||||
@ -108,26 +107,13 @@ public class DoubleStat extends ItemStat implements Upgradable, Previewable {
|
||||
// Calculate Difference
|
||||
upgradeShift = value - uData.getValue(); } }
|
||||
|
||||
// Display if not ZERO
|
||||
// Display in lore
|
||||
if (value != 0 || upgradeShift != 0) {
|
||||
|
||||
// Get path and modify
|
||||
String pathFormat = MMOItems.plugin.getLanguage().getStatFormat(getPath());
|
||||
|
||||
// Displaying upgrades?
|
||||
if (upgradeShift != 0) {
|
||||
|
||||
item.getLore().insert(getPath(), formatPath(MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter(), value * multiplyWhenDisplaying())
|
||||
|
||||
// Add upgrade format
|
||||
+ MythicLib.plugin.parseColors(UpgradeTemplate.getUpgradeChangeSuffix(plus(upgradeShift * multiplyWhenDisplaying()) + (new StatFormat("##").format(upgradeShift * multiplyWhenDisplaying())), !isGood(upgradeShift * multiplyWhenDisplaying()))));
|
||||
|
||||
} else {
|
||||
|
||||
// Just display normally
|
||||
item.getLore().insert(getPath(), formatPath(MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter(), value * multiplyWhenDisplaying()));
|
||||
|
||||
} }
|
||||
String loreInsert = formatPath(MMOItems.plugin.getLanguage().getStatFormat(getPath()), moreIsBetter(), value * multiplyWhenDisplaying());
|
||||
if (upgradeShift != 0)
|
||||
loreInsert += MythicLib.plugin.parseColors(UpgradeTemplate.getUpgradeChangeSuffix(plus(upgradeShift * multiplyWhenDisplaying()) + (MythicLib.plugin.getMMOConfig().decimals.format(upgradeShift * multiplyWhenDisplaying())), !isGood(upgradeShift * multiplyWhenDisplaying())));
|
||||
item.getLore().insert(getPath(), loreInsert);
|
||||
}
|
||||
|
||||
/*
|
||||
* Add NBT Data if it is not equal to ZERO, in which case it will just get removed.
|
||||
@ -144,10 +130,10 @@ public class DoubleStat extends ItemStat implements Upgradable, Previewable {
|
||||
return format
|
||||
|
||||
// Replace conditional pluses with +value
|
||||
.replace("<plus>#",getColorPrefix(value < 0 && moreIsBetter) + (value > 0 ? "+" : "") + new StatFormat("##").format(value))
|
||||
.replace("<plus>#",getColorPrefix(value < 0 && moreIsBetter) + (value > 0 ? "+" : "") + MythicLib.plugin.getMMOConfig().decimals.format(value))
|
||||
|
||||
// Replace loose pounds with the value
|
||||
.replace("#",getColorPrefix(value < 0 && moreIsBetter) + new StatFormat("##").format(value))
|
||||
.replace("#",getColorPrefix(value < 0 && moreIsBetter) + MythicLib.plugin.getMMOConfig().decimals.format(value))
|
||||
|
||||
// Replace loose <plus>es
|
||||
.replace("<plus>", (value > 0 ? "+" : ""));
|
||||
@ -163,9 +149,9 @@ public class DoubleStat extends ItemStat implements Upgradable, Previewable {
|
||||
|
||||
// Replace loose pounds with the value
|
||||
.replace("#", getColorPrefix(min < 0 && moreIsBetter) +
|
||||
(min > 0 ? "+" : "") + new StatFormat("##").format(min)
|
||||
(min > 0 ? "+" : "") + MythicLib.plugin.getMMOConfig().decimals.format(min)
|
||||
+ MMOItems.plugin.getConfig().getString("stats-displaying.range-dash", "⎓") + getColorPrefix(max < 0 && moreIsBetter) +
|
||||
(min < 0 && max > 0 ? "+" : "") + new StatFormat("##").format(max)); }
|
||||
(min < 0 && max > 0 ? "+" : "") + MythicLib.plugin.getMMOConfig().decimals.format(max)); }
|
||||
|
||||
@Override
|
||||
public void whenPreviewed(@NotNull ItemStackBuilder item, @NotNull StatData currentData, @NotNull RandomStatData templateData) throws IllegalArgumentException {
|
||||
|
Loading…
Reference in New Issue
Block a user