Fixed compatibility issue with MMOCore stats

This commit is contained in:
Indyuce 2019-10-21 19:42:37 +02:00
parent d7d027450c
commit 78ecf2346e
2 changed files with 13 additions and 14 deletions

View File

@ -67,7 +67,6 @@ public class PlayerData {
* inventory
*/
private ItemStack helmet = null, chestplate = null, leggings = null, boots = null, hand = null, offhand = null;
private Map<PotionEffectType, PotionEffect> permanentEffects = new HashMap<>();
private List<MMOItem> playerInventory = new ArrayList<>();
private CraftingStatus craftingStatus = new CraftingStatus();
@ -79,6 +78,7 @@ public class PlayerData {
/*
* specific stat calculation
*/
private Map<PotionEffectType, PotionEffect> permanentEffects = new HashMap<>();
private Set<ParticleRunnable> itemParticles = new HashSet<>();
private ParticleRunnable overridingItemParticles = null;
private Set<AbilityData> itemAbilities = new HashSet<>();
@ -103,16 +103,12 @@ public class PlayerData {
craftingStatus.load(this, config.getConfigurationSection("crafting-queue"));
}
private void save(FileConfiguration config) {
config.createSection("crafting-queue");
craftingStatus.save(config.getConfigurationSection("crafting-queue"));
}
public void save() {
cancelRunnables();
ConfigFile config = new ConfigFile("/userdata", getUniqueId().toString());
save(config.getConfig());
config.getConfig().createSection("crafting-queue");
craftingStatus.save(config.getConfig().getConfigurationSection("crafting-queue"));
config.save();
/*
@ -149,7 +145,8 @@ public class PlayerData {
public void checkForInventoryUpdate() {
PlayerInventory inv = player.getInventory();
if (!equals(helmet, inv.getHelmet()) || !equals(chestplate, inv.getChestplate()) || !equals(leggings, inv.getLeggings()) || !equals(boots, inv.getBoots()) || !equals(hand, inv.getItemInMainHand()) || !equals(offhand, inv.getItemInOffHand()))
if (!equals(helmet, inv.getHelmet()) || !equals(chestplate, inv.getChestplate()) || !equals(leggings, inv.getLeggings()) || !equals(boots, inv.getBoots())
|| !equals(hand, inv.getItemInMainHand()) || !equals(offhand, inv.getItemInOffHand()))
updateInventory();
}
@ -174,7 +171,8 @@ public class PlayerData {
public boolean areHandsFull() {
NBTItem main = MMOItems.plugin.getNMS().getNBTItem(player.getInventory().getItemInMainHand());
NBTItem off = MMOItems.plugin.getNMS().getNBTItem(player.getInventory().getItemInOffHand());
return (main.getBoolean("MMOITEMS_TWO_HANDED") && (off.getItem() != null && off.getItem().getType() != Material.AIR)) || (off.getBoolean("MMOITEMS_TWO_HANDED") && (main.getItem() != null && main.getItem().getType() != Material.AIR));
return (main.getBoolean("MMOITEMS_TWO_HANDED") && (off.getItem() != null && off.getItem().getType() != Material.AIR))
|| (off.getBoolean("MMOITEMS_TWO_HANDED") && (main.getItem() != null && main.getItem().getType() != Material.AIR));
}
public void updateInventory() {
@ -433,7 +431,8 @@ public class PlayerData {
*/
public void applyCooldown(CooldownType type, double value) {
String mitigation;
long extra = (long) (1000 * (type.isMitigation() ? getMitigationCooldown(mitigation = type.name().toLowerCase()) * (1 - Math.min(getMaxMitigationCooldownReduction(mitigation), value) / 100) : value));
long extra = (long) (1000
* (type.isMitigation() ? getMitigationCooldown(mitigation = type.name().toLowerCase()) * (1 - Math.min(getMaxMitigationCooldownReduction(mitigation), value) / 100) : value));
extraCooldowns.put(type, System.currentTimeMillis() + extra);
}

View File

@ -28,9 +28,9 @@ import net.Indyuce.mmoitems.version.VersionMaterial;
public class MMOCoreHook implements RPGHandler, Listener, DamageHandler {
private final ItemStat manaRegen = new DoubleStat(VersionMaterial.LAPIS_LAZULI.toItem(), "Mana Regeneration", new String[] { "Increases mana regen." }, "mana-regen");
private final ItemStat manaRegen = new DoubleStat(VersionMaterial.LAPIS_LAZULI.toItem(), "Mana Regeneration", new String[] { "Increases mana regen." }, "mana-regeneration");
private final ItemStat maxStamina = new DoubleStat(VersionMaterial.LIGHT_BLUE_DYE.toItem(), "Max Stamina", new String[] { "Adds stamina to your max stamina bar." }, "max-stamina");
private final ItemStat staminaRegen = new DoubleStat(VersionMaterial.LIGHT_BLUE_DYE.toItem(), "Stamina Regeneration", new String[] { "Increases stamina regen." }, "stamina-regen");
private final ItemStat staminaRegen = new DoubleStat(VersionMaterial.LIGHT_BLUE_DYE.toItem(), "Stamina Regeneration", new String[] { "Increases stamina regen." }, "stamina-regeneration");
private final ItemStat cooldownReduction = new DoubleStat(new ItemStack(Material.BOOK), "Skill Cooldown Reduction", new String[] { "Reduces cooldowns of MMOCore skills (%)." }, "skill-cooldown-reduction");
private final ItemStat additionalExperience = new DoubleStat(new ItemStack(Material.EXPERIENCE_BOTTLE), "Additional Experience", new String[] { "Additional MMOCore main class experience in %." }, "additional-experience");
@ -50,7 +50,7 @@ public class MMOCoreHook implements RPGHandler, Listener, DamageHandler {
MMOItems.plugin.getStats().register("MANA_REGENERATION", manaRegen);
MMOItems.plugin.getStats().register("MAX_STAMINA", maxStamina);
MMOItems.plugin.getStats().register("STAMINA_REGENERATION", staminaRegen);
MMOItems.plugin.getStats().register("COOLDOWN_REDUCTION", cooldownReduction);
MMOItems.plugin.getStats().register("SKILL_COOLDOWN_REDUCTION", cooldownReduction);
MMOItems.plugin.getStats().register("ADDITIONAL_EXPERIENCE", additionalExperience);
/*