entities = MMOUtils.getNearbyChunkEntities(loc);
- for (int j = 0; j < 3; j++) {
- loc.add(vec);
- if (loc.getBlock().getType().isSolid())
- cancel();
-
- /*
- * has a different particle effect since SNOW_DIG is not the
- * same as in legacy minecraft, the particle effect is now a
- * cross that rotates
- */
- for (double r = 0; r < .4; r += .1)
- for (double a = 0; a < Math.PI * 2; a += Math.PI / 2) {
- Vector vec = MMOUtils.rotateFunc(new Vector(r * Math.cos(a + (double) ti / 10), r * Math.sin(a + (double) ti / 10), 0),
- loc);
- loc.add(vec);
- loc.getWorld().spawnParticle(Particle.REDSTONE, loc, 1, new Particle.DustOptions(Color.WHITE, .7f));
- loc.add(vec.multiply(-1));
- }
-
- for (Entity entity : entities)
- if (MMOUtils.canTarget(attack.getPlayer(), loc, entity)) {
- loc.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, loc, 0);
- loc.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc, 48, 0, 0, 0, .2);
- loc.getWorld().playSound(loc, Sound.ENTITY_GENERIC_EXPLODE, 2, 1);
- new AttackMetadata(new DamageMetadata(ability.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), attack.getStats()).damage((LivingEntity) entity);
- ((LivingEntity) entity).addPotionEffect(new PotionEffect(PotionEffectType.SLOW,
- (int) (ability.getModifier("duration") * 20), (int) ability.getModifier("amplifier")));
- cancel();
- return;
- }
- }
- }
- }.runTaskTimer(MMOItems.plugin, 0, 1);
- }
-}
diff --git a/src/main/java/net/Indyuce/mmoitems/ability/list/vector/TNT_Throw.java b/src/main/java/net/Indyuce/mmoitems/ability/list/vector/TNT_Throw.java
deleted file mode 100644
index d92d6194..00000000
--- a/src/main/java/net/Indyuce/mmoitems/ability/list/vector/TNT_Throw.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package net.Indyuce.mmoitems.ability.list.vector;
-
-import io.lumine.mythic.lib.api.util.TemporaryListener;
-import net.Indyuce.mmoitems.MMOUtils;
-import net.Indyuce.mmoitems.ability.VectorAbility;
-import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
-import io.lumine.mythic.lib.damage.AttackMetadata;
-import org.bukkit.Particle;
-import org.bukkit.Sound;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.TNTPrimed;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.EventPriority;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.util.Vector;
-
-public class TNT_Throw extends VectorAbility {
- public TNT_Throw() {
- super();
-
- addModifier("cooldown", 10);
- addModifier("force", 1);
- addModifier("mana", 0);
- addModifier("stamina", 0);
- }
-
- @Override
- public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
- Vector vec = ability.getTarget().multiply(2 * ability.getModifier("force"));
- TNTPrimed tnt = (TNTPrimed) attack.getPlayer().getWorld().spawnEntity(attack.getPlayer().getLocation().add(0, 1, 0), EntityType.PRIMED_TNT);
- tnt.setFuseTicks(80);
- tnt.setVelocity(vec);
- new CancelTeamDamage(attack.getPlayer(), tnt);
- attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_SNOWBALL_THROW, 1, 0);
- attack.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, attack.getPlayer().getLocation().add(0, 1, 0), 12, 0, 0, 0, .1);
- }
-
- /**
- * Used to cancel team damage and other things
- */
- public static class CancelTeamDamage extends TemporaryListener {
- private final Player player;
- private final TNTPrimed tnt;
-
- public CancelTeamDamage(Player player, TNTPrimed tnt) {
- super(EntityDamageByEntityEvent.getHandlerList());
-
- this.player = player;
- this.tnt = tnt;
-
- close(100);
- }
-
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void a(EntityDamageByEntityEvent event) {
- if (event.getDamager().equals(tnt) && !MMOUtils.canTarget(player, event.getEntity()))
- event.setCancelled(true);
- }
-
- @Override
- public void whenClosed() {
- // Nothing
- }
- }
-}
diff --git a/src/main/java/net/Indyuce/mmoitems/ability/list/vector/Thrust.java b/src/main/java/net/Indyuce/mmoitems/ability/list/vector/Thrust.java
deleted file mode 100644
index e6c15721..00000000
--- a/src/main/java/net/Indyuce/mmoitems/ability/list/vector/Thrust.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package net.Indyuce.mmoitems.ability.list.vector;
-
-import io.lumine.mythic.lib.damage.AttackMetadata;
-import io.lumine.mythic.lib.damage.DamageMetadata;
-import io.lumine.mythic.lib.damage.DamageType;
-import net.Indyuce.mmoitems.MMOUtils;
-import net.Indyuce.mmoitems.ability.VectorAbility;
-import net.Indyuce.mmoitems.ability.metadata.VectorAbilityMetadata;
-import io.lumine.mythic.lib.damage.AttackMetadata;
-import org.bukkit.Location;
-import org.bukkit.Particle;
-import org.bukkit.Sound;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.potion.PotionEffect;
-import org.bukkit.potion.PotionEffectType;
-import org.bukkit.util.Vector;
-
-public class Thrust extends VectorAbility {
- public Thrust() {
- super();
-
- addModifier("cooldown", 10);
- addModifier("damage", 6);
- addModifier("mana", 0);
- addModifier("stamina", 0);
- }
-
- @Override
- public void whenCast(AttackMetadata attack, VectorAbilityMetadata ability) {
- double damage = ability.getModifier("damage");
-
- attack.getPlayer().getWorld().playSound(attack.getPlayer().getLocation(), Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR, 1, 0);
- attack.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 2, 3));
-
- Location loc = attack.getPlayer().getEyeLocation().clone();
- Vector vec = ability.getTarget().multiply(.5);
- for (double j = 0; j < 7; j += .5) {
- loc.add(vec);
- for (Entity entity : MMOUtils.getNearbyChunkEntities(loc))
- if (MMOUtils.canTarget(attack.getPlayer(), loc, entity))
- new AttackMetadata(new DamageMetadata(damage, DamageType.SKILL, DamageType.PHYSICAL), attack.getStats()).damage((LivingEntity) entity);
- loc.getWorld().spawnParticle(Particle.SMOKE_LARGE, loc, 0);
- }
- }
-}
diff --git a/src/main/java/net/Indyuce/mmoitems/api/Element.java b/src/main/java/net/Indyuce/mmoitems/api/Element.java
index 631994c3..8d677a25 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/Element.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/Element.java
@@ -80,7 +80,7 @@ public enum Element {
target.getWorld().playSound(target.getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_LARGE_BLAST.toSound(), 2, 0);
for (Entity entity : target.getNearbyEntities(3, 2, 3))
if (MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION))
- MythicLib.plugin.getDamage().damage(new ItemAttackMetadata(new DamageMetadata(attack.getDamage().getDamage() * damage / 100, DamageType.WEAPON), attack.getStats()), (LivingEntity) entity);
+ MythicLib.plugin.getDamage().damage(new ItemAttackMetadata(new DamageMetadata(attack.getDamage().getDamage() * damage / 100, DamageType.WEAPON), attack), (LivingEntity) entity);
attack.getDamage().add(absolute);
for (double k = 0; k < Math.PI * 2; k += Math.PI / 16)
diff --git a/src/main/java/net/Indyuce/mmoitems/api/ItemAttackMetadata.java b/src/main/java/net/Indyuce/mmoitems/api/ItemAttackMetadata.java
index d492d039..c11fb0be 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/ItemAttackMetadata.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/ItemAttackMetadata.java
@@ -6,6 +6,7 @@ import io.lumine.mythic.lib.api.stat.StatMap;
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.api.player.PlayerData;
import org.bukkit.entity.LivingEntity;
@@ -18,12 +19,12 @@ import org.bukkit.entity.LivingEntity;
*/
@Deprecated
public class ItemAttackMetadata extends AttackMetadata {
- public ItemAttackMetadata(DamageMetadata damage, StatMap.CachedStatMap damager) {
+ public ItemAttackMetadata(DamageMetadata damage, PlayerMetadata damager) {
super(damage, damager);
}
public ItemAttackMetadata(AttackMetadata attackMeta) {
- super(attackMeta.getDamage(), attackMeta.getStats());
+ super(attackMeta.getDamage(), attackMeta);
}
public PlayerData getPlayerData() {
@@ -31,7 +32,7 @@ public class ItemAttackMetadata extends AttackMetadata {
}
public ItemAttackMetadata clone() {
- return new ItemAttackMetadata(getDamage().clone(), getStats());
+ return new ItemAttackMetadata(getDamage().clone(), this);
}
/**
diff --git a/src/main/java/net/Indyuce/mmoitems/api/MMOItemsAPI.java b/src/main/java/net/Indyuce/mmoitems/api/MMOItemsAPI.java
index 229ee228..a6b12ba1 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/MMOItemsAPI.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/MMOItemsAPI.java
@@ -1,10 +1,10 @@
package net.Indyuce.mmoitems.api;
-import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.damage.AttackMetadata;
-import io.lumine.mythic.lib.damage.DamageMetadata;
+import io.lumine.mythic.lib.player.PlayerMetadata;
+import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.ability.Ability;
@@ -16,6 +16,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.Map;
import java.util.Objects;
@@ -24,7 +25,7 @@ public class MMOItemsAPI {
private final JavaPlugin plugin;
/**
- * @param plugin Plugin
+ * @param plugin Plugin using the API
*/
public MMOItemsAPI(JavaPlugin plugin) {
this.plugin = plugin;
@@ -47,9 +48,33 @@ public class MMOItemsAPI {
}
/**
- * @return Ability with the specified identifier like FIREBOLT
+ * Registers an ability in MMOItems. This must be called before MMOItems enables,
+ * therefore either using a loadbefore of MMOItems and while the plugin enables,
+ * or using a dependency and usign #onLoad().
+ *
+ * This method does NOT register listeners.
+ *
+ * Throws an IAE if anything goes wrong.
+ *
+ * @param skill Skill to register
*/
- public RegisteredSkill getAbilityById(String id) {
+ public void registerSkill(RegisteredSkill skill) {
+ MMOItems.plugin.getSkills().registerSkill(skill);
+ }
+
+ /**
+ * @return Ability with the specified identifier like 'FIREBOLT'
+ * @deprecated Use {@link #getSkillById(String)}
+ */
+ @Deprecated
+ public Ability getAbilityById(String id) {
+ return MMOItems.plugin.getAbilities().getAbility(id);
+ }
+
+ /**
+ * @return Skill with the specified identifier like 'FIREBOLT'
+ */
+ public RegisteredSkill getSkillById(String id) {
return Objects.requireNonNull(MMOItems.plugin.getSkills().getSkill(id), "Could not find skill with ID '" + id + "'");
}
@@ -65,32 +90,34 @@ public class MMOItemsAPI {
* Forces a player to cast an ability
*
* @param player Player casting the ability
- * @param abilityName Ability name. The ability is found using {@link #getAbilityById(String)}
+ * @param abilityName Skill name. Skill is found using {@link #getAbilityById(String)}
* @param modifiers Ability modifiers
* @param target The ability target (null if no target)
*/
- public AttackMetadata castAbility(Player player, String abilityName, Map modifiers, @NotNull LivingEntity target) {
- AttackMetadata attackMeta = new AttackMetadata(new DamageMetadata(), MMOPlayerData.get(player).getStatMap().cache(EquipmentSlot.MAIN_HAND));
- return castAbility(player, abilityName, modifiers, target, attackMeta);
+ @Deprecated
+ @Nullable
+ public AttackMetadata castAbility(Player player, String abilityName, Map modifiers, @Nullable LivingEntity target) {
+ return castAbility(player, abilityName, modifiers, target, null);
}
/**
* Forces a player to cast an ability
*
- * @param player Player casting the ability
- * @param abilityName Ability name. The ability is found using {@link #getAbilityById(String)}
- * @param modifiers Ability modifiers
- * @param target The ability target (null if no target)
- * @param attackMeta If the trigger type is ATTACK, the corresponding AttackMetadata is provided. This allows
- * MMOItems to increase the damage of the current attack or even add new damage packets.
- * This parameter is useless for trigger types like RIGHT_CLICK or SNEAK which aren't
- * based on entity attacks; in that case the attackMeta will have an empty DamageMetadata
+ * @param player Player casting the ability
+ * @param skillName Ability name. The ability is found using {@link #getSkillById(String)}
+ * @param modifiers Ability modifiers
+ * @param target The ability target (null if no target)
+ * @param attackMeta If the trigger type is ATTACK, the corresponding AttackMetadata is provided. This allows
+ * MMOItems to increase the damage of the current attack or even add new damage packets.
+ * This parameter is useless for trigger types like RIGHT_CLICK or SNEAK which aren't
+ * based on entity attacks; in that case the attackMeta will have an empty DamageMetadata
*/
@Deprecated
- public AttackMetadata castAbility(Player player, String abilityName, Map modifiers, @NotNull LivingEntity target, AttackMetadata attackMeta) {
+ @Nullable
+ public AttackMetadata castAbility(Player player, String skillName, Map modifiers, @Nullable LivingEntity target, @Nullable AttackMetadata attackMeta) {
// Setup ability
- AbilityData abilityData = new AbilityData(getAbilityById(abilityName), TriggerType.RIGHT_CLICK);
+ AbilityData abilityData = new AbilityData(getSkillById(skillName), TriggerType.API);
modifiers.forEach((key, value) -> abilityData.setModifier(key, value));
// Cast ability
@@ -106,11 +133,35 @@ public class MMOItemsAPI {
* @param attackMeta If the trigger type is ATTACK, the corresponding AttackMetadata is provided. This allows
* MMOItems to increase the damage of the current attack or even add new damage packets.
* This parameter is useless for trigger types like RIGHT_CLICK or SNEAK which aren't
- * based on entity attacks; in that case the attackMeta will have an empty DamageMetadata
+ * based on entity attacks; in that case no attack metadata is provided.
*/
+ @Nullable
@Deprecated
- public AttackMetadata castAbility(PlayerData playerData, AbilityData ability, @NotNull LivingEntity target, AttackMetadata attackMeta) {
+ public AttackMetadata castAbility(PlayerData playerData, AbilityData ability, @Nullable LivingEntity target, @Nullable AttackMetadata attackMeta) {
playerData.cast(attackMeta, target, ability);
return attackMeta;
}
+
+ /**
+ * Forces a player to cast a skill on a specific target, with
+ * custom modifiers and an attack bound to the cast skill.
+ *
+ * @param player Player casting the ability
+ * @param skill Ability being cast. Can be found using {@link #getSkillById(String)}
+ * @param modifiers Ability modifiers. Can be empty; if one of the skill
+ * modifiers is not found in that map, MMOItems will take
+ * its default value.
+ * @param target The ability target (null if no target)
+ * @param attackMeta If the trigger type is ATTACK, the corresponding AttackMetadata is provided. This allows
+ * MMOItems to increase the damage of the current attack or even add new damage packets.
+ * This parameter is useless for trigger types like RIGHT_CLICK or SNEAK which aren't
+ * based on entity attacks; in that case no attack metadata is provided.
+ */
+ public void castSkill(Player player, RegisteredSkill skill, @NotNull Map modifiers, @Nullable LivingEntity target, @Nullable AttackMetadata attackMeta) {
+ AbilityData castable = new AbilityData(skill, TriggerType.API);
+ modifiers.forEach((mod, value) -> castable.setModifier(mod, value));
+
+ PlayerMetadata caster = MMOPlayerData.get(player).getStatMap().cache(EquipmentSlot.MAIN_HAND);
+ castable.cast(new TriggerMetadata(caster, attackMeta, target));
+ }
}
diff --git a/src/main/java/net/Indyuce/mmoitems/api/TypeSet.java b/src/main/java/net/Indyuce/mmoitems/api/TypeSet.java
index fcf440dd..57bff646 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/TypeSet.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/TypeSet.java
@@ -42,7 +42,7 @@ public enum TypeSet {
&& attack.getPlayer().getEyeLocation().getDirection()
.angle(entity.getLocation().subtract(attack.getPlayer().getLocation()).toVector()) < Math.PI / 3
&& MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
- ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack.getStats());
+ ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack);
subAttack.getDamage().multiply(.4);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);
}
@@ -71,7 +71,7 @@ public enum TypeSet {
&& attack.getPlayer().getEyeLocation().getDirection()
.angle(entity.getLocation().toVector().subtract(attack.getPlayer().getLocation().toVector())) < Math.PI / 18
&& MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
- ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack.getStats());
+ ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack);
subAttack.getDamage().multiply(.4);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);
}
@@ -91,13 +91,13 @@ public enum TypeSet {
damager.applyCooldown(CooldownType.SPECIAL_ATTACK, MMOItems.plugin.getConfig().getDouble("item-ability.blunt.aoe.cooldown"));
target.getWorld().playSound(target.getLocation(), Sound.BLOCK_ANVIL_LAND, 0.6f, pitchRange);
target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
- double bluntPower = attack.getStats().getStat("BLUNT_POWER");
+ double bluntPower = attack.getStat("BLUNT_POWER");
if (bluntPower > 0) {
- double bluntRating = weapon.getValue(attack.getStats().getStat("BLUNT_RATING"),
+ double bluntRating = weapon.getValue(attack.getStat("BLUNT_RATING"),
MMOItems.plugin.getConfig().getDouble("default.blunt-rating")) / 100;
for (Entity entity : target.getNearbyEntities(bluntPower, bluntPower, bluntPower))
if (MMOUtils.canTarget(attack.getPlayer(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target)) {
- ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack.getStats());
+ ItemAttackMetadata subAttack = new ItemAttackMetadata(attack.getDamage().clone(), attack);
subAttack.getDamage().multiply(bluntRating);
subAttack.applyEffectsAndDamage(weapon.getNBTItem(), (LivingEntity) entity);
}
diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/util/UntargetedDurabilityItem.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/util/UntargetedDurabilityItem.java
index d86894ce..fac89e37 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/interaction/util/UntargetedDurabilityItem.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/util/UntargetedDurabilityItem.java
@@ -1,7 +1,7 @@
package net.Indyuce.mmoitems.api.interaction.util;
+import io.lumine.mythic.lib.api.player.EquipmentSlot;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.EquipmentSlot;
import io.lumine.mythic.lib.api.item.NBTItem;
diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/Weapon.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/Weapon.java
index 8a56c803..ae6186a1 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/Weapon.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/Weapon.java
@@ -51,6 +51,7 @@ public class Weapon extends UseItem {
* @param attackSpeed The weapon attack speed
* @param cooldown The weapon cooldown type. When set to null, no
* cooldown will be applied. This is made to handle
+ * custom weapons
* @return If requirements were met ie the attack was cast successfully
*/
public boolean applyWeaponCosts(double attackSpeed, @Nullable CooldownType cooldown) {
diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Crossbow.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Crossbow.java
index 1d8516bd..7ddf8c44 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Crossbow.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Crossbow.java
@@ -1,7 +1,8 @@
package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.stat.StatMap;
+import io.lumine.mythic.lib.api.player.EquipmentSlot;
+import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
@@ -11,7 +12,6 @@ import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
public class Crossbow extends UntargetedWeapon {
@@ -26,7 +26,7 @@ public class Crossbow extends UntargetedWeapon {
if (getPlayer().getGameMode() != GameMode.CREATIVE && !getPlayer().getInventory().containsAtLeast(new ItemStack(Material.ARROW), 1))
return;
- StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
+ PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;
diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Lute.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Lute.java
index 28afe26f..98dc9c10 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Lute.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Lute.java
@@ -3,15 +3,15 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import com.google.gson.JsonObject;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.stat.StatMap;
+import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.DamageMetadata;
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.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
-import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
@@ -23,7 +23,6 @@ import org.bukkit.Particle;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
@@ -36,8 +35,7 @@ public class Lute extends UntargetedWeapon {
@Override
public void untargetedAttack(EquipmentSlot slot) {
-
- StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
+ PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
double attackSpeed = 1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed"));
if (!applyWeaponCosts(attackSpeed, CooldownType.ATTACK))
return;
diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Musket.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Musket.java
index fe0bcd24..6dd842bf 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Musket.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Musket.java
@@ -3,14 +3,14 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMORayTraceResult;
import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.stat.StatMap;
+import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType;
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.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
-import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
@@ -18,7 +18,6 @@ import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
public class Musket extends UntargetedWeapon {
@@ -28,7 +27,7 @@ public class Musket extends UntargetedWeapon {
@Override
public void untargetedAttack(EquipmentSlot slot) {
- StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
+ PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Staff.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Staff.java
index 95e7af0f..630a43c4 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Staff.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Staff.java
@@ -3,15 +3,15 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMORayTraceResult;
import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.stat.StatMap;
+import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.DamageMetadata;
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.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
-import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
@@ -22,7 +22,6 @@ import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
public class Staff extends UntargetedWeapon {
@@ -33,7 +32,7 @@ public class Staff extends UntargetedWeapon {
@Override
public void untargetedAttack(EquipmentSlot slot) {
- StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
+ PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;
diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeapon.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeapon.java
index f2f7e141..2527b7c9 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeapon.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeapon.java
@@ -1,8 +1,8 @@
package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
+import io.lumine.mythic.lib.api.player.EquipmentSlot;
import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
-import org.bukkit.inventory.EquipmentSlot;
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import io.lumine.mythic.lib.api.item.NBTItem;
diff --git a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Whip.java b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Whip.java
index 6efb90a8..51ba9437 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Whip.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Whip.java
@@ -3,22 +3,21 @@ package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.MMORayTraceResult;
import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.stat.StatMap;
+import io.lumine.mythic.lib.api.player.EquipmentSlot;
import io.lumine.mythic.lib.comp.target.InteractionType;
import io.lumine.mythic.lib.damage.DamageMetadata;
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.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.MMOUtils;
-import io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.entity.Player;
-import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.util.Vector;
public class Whip extends UntargetedWeapon {
@@ -29,7 +28,7 @@ public class Whip extends UntargetedWeapon {
@Override
public void untargetedAttack(EquipmentSlot slot) {
- StatMap.CachedStatMap stats = getPlayerData().getStats().newTemporary(io.lumine.mythic.lib.api.player.EquipmentSlot.fromBukkit(slot));
+ PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
if (!applyWeaponCosts(1 / getValue(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed")),
CooldownType.ATTACK))
return;
diff --git a/src/main/java/net/Indyuce/mmoitems/api/player/PlayerData.java b/src/main/java/net/Indyuce/mmoitems/api/player/PlayerData.java
index fe4dddab..f9bfa4c4 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/player/PlayerData.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/player/PlayerData.java
@@ -6,6 +6,7 @@ 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.skill.trigger.TriggerMetadata;
import net.Indyuce.mmoitems.ItemStats;
@@ -34,6 +35,7 @@ import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitRunnable;
import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
import java.util.*;
@@ -360,8 +362,9 @@ public class PlayerData {
* @deprecated
*/
@Deprecated
- public void cast(AttackMetadata attack, LivingEntity target, AbilityData ability) {
- ability.cast(new TriggerMetadata(attack, target));
+ public void cast(@Nullable AttackMetadata attack, @Nullable LivingEntity target, @NotNull AbilityData ability) {
+ PlayerMetadata caster = getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND);
+ ability.cast(new TriggerMetadata(caster, attack, target));
}
public boolean isOnCooldown(CooldownType type) {
diff --git a/src/main/java/net/Indyuce/mmoitems/api/player/PlayerStats.java b/src/main/java/net/Indyuce/mmoitems/api/player/PlayerStats.java
index 68619c80..011018be 100644
--- a/src/main/java/net/Indyuce/mmoitems/api/player/PlayerStats.java
+++ b/src/main/java/net/Indyuce/mmoitems/api/player/PlayerStats.java
@@ -6,6 +6,7 @@ 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 net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.player.inventory.EquippedPlayerItem;
@@ -44,7 +45,7 @@ public class PlayerStats {
* source will NOT be taken into account for stat calculation
* @return
*/
- public StatMap.CachedStatMap newTemporary(EquipmentSlot castSlot) {
+ public PlayerMetadata newTemporary(EquipmentSlot castSlot) {
return playerData.getMMOPlayerData().getStatMap().cache(castSlot);
}
diff --git a/src/main/java/net/Indyuce/mmoitems/command/mmoitems/AbilityCommandTreeNode.java b/src/main/java/net/Indyuce/mmoitems/command/mmoitems/AbilityCommandTreeNode.java
index 2ce9cc7c..a24504a9 100644
--- a/src/main/java/net/Indyuce/mmoitems/command/mmoitems/AbilityCommandTreeNode.java
+++ b/src/main/java/net/Indyuce/mmoitems/command/mmoitems/AbilityCommandTreeNode.java
@@ -1,14 +1,13 @@
package net.Indyuce.mmoitems.command.mmoitems;
import io.lumine.mythic.lib.api.player.EquipmentSlot;
+import io.lumine.mythic.lib.api.player.MMOPlayerData;
import io.lumine.mythic.lib.commands.mmolib.api.CommandTreeNode;
import io.lumine.mythic.lib.commands.mmolib.api.Parameter;
-import io.lumine.mythic.lib.damage.AttackMetadata;
-import io.lumine.mythic.lib.damage.DamageMetadata;
+import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
-import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.skill.RegisteredSkill;
import net.Indyuce.mmoitems.stat.data.AbilityData;
import org.bukkit.Bukkit;
@@ -61,7 +60,7 @@ public class AbilityCommandTreeNode extends CommandTreeNode {
}
// modifiers
- AbilityData ability = new AbilityData(MMOItems.plugin.getSkills().getSkill(key), TriggerType.RIGHT_CLICK);
+ AbilityData ability = new AbilityData(MMOItems.plugin.getSkills().getSkill(key), TriggerType.API);
for (int j = 3; j < args.length - 1; j += 2) {
String name = args[j];
String value = args[j + 1];
@@ -74,9 +73,8 @@ public class AbilityCommandTreeNode extends CommandTreeNode {
}
}
- PlayerData data = PlayerData.get(target);
- AttackMetadata attackMeta = new AttackMetadata(new DamageMetadata(), data.getMMOPlayerData().getStatMap().cache(EquipmentSlot.MAIN_HAND));
- ability.cast(new TriggerMetadata(attackMeta, null));
+ PlayerMetadata caster = MMOPlayerData.get(target).getStatMap().cache(EquipmentSlot.MAIN_HAND);
+ ability.cast(new TriggerMetadata(caster, null, null));
return CommandResult.SUCCESS;
}
}
diff --git a/src/main/java/net/Indyuce/mmoitems/comp/RealDualWieldHook.java b/src/main/java/net/Indyuce/mmoitems/comp/RealDualWieldHook.java
index 9dacace7..9e3c3453 100644
--- a/src/main/java/net/Indyuce/mmoitems/comp/RealDualWieldHook.java
+++ b/src/main/java/net/Indyuce/mmoitems/comp/RealDualWieldHook.java
@@ -8,6 +8,7 @@ import io.lumine.mythic.lib.api.stat.StatMap;
import io.lumine.mythic.lib.damage.DamageMetadata;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.damage.AttackMetadata;
+import io.lumine.mythic.lib.player.PlayerMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.TypeSet;
@@ -71,7 +72,7 @@ public class RealDualWieldHook implements Listener {
}
private ItemAttackMetadata getAttack(PlayerData playerData, PlayerDamageEntityWithOffhandEvent event) {
- StatMap.CachedStatMap cachedStatMap = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.OFF_HAND);
+ PlayerMetadata cachedStatMap = playerData.getMMOPlayerData().getStatMap().cache(EquipmentSlot.OFF_HAND);
return new ItemAttackMetadata(new DamageMetadata(event.getDamage(), DamageType.WEAPON, DamageType.PHYSICAL), cachedStatMap);
}
}
diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/MythicMobsCompatibility.java b/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/MythicMobsCompatibility.java
index 8fed1ca3..b2a992b4 100644
--- a/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/MythicMobsCompatibility.java
+++ b/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/MythicMobsCompatibility.java
@@ -4,16 +4,13 @@ import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent;
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
import net.Indyuce.mmoitems.MMOItems;
-import net.Indyuce.mmoitems.comp.mythicmobs.skill.MythicMobsAbility;
import net.Indyuce.mmoitems.comp.mythicmobs.stat.FactionDamage;
-import org.apache.commons.lang.Validate;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.*;
-import java.util.logging.Level;
public class MythicMobsCompatibility implements Listener {
@@ -37,7 +34,7 @@ public class MythicMobsCompatibility implements Listener {
public void a(MythicReloadedEvent event) {
// Update skills
- MMOItems.plugin.getSkills().reload();
+ MMOItems.plugin.getSkills().initialize(true);
}
private Set getFactions() {
diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/skill/MythicMobsAbility.java b/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/skill/MythicMobsAbility.java
deleted file mode 100644
index 926e38fb..00000000
--- a/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/skill/MythicMobsAbility.java
+++ /dev/null
@@ -1,77 +0,0 @@
-package net.Indyuce.mmoitems.comp.mythicmobs.skill;
-
-import io.lumine.mythic.lib.damage.AttackMetadata;
-import io.lumine.xikage.mythicmobs.MythicMobs;
-import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
-import io.lumine.xikage.mythicmobs.adapters.AbstractLocation;
-import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
-import io.lumine.xikage.mythicmobs.mobs.GenericCaster;
-import io.lumine.xikage.mythicmobs.skills.Skill;
-import io.lumine.xikage.mythicmobs.skills.SkillCaster;
-import io.lumine.xikage.mythicmobs.skills.SkillMetadata;
-import io.lumine.xikage.mythicmobs.skills.SkillTrigger;
-import net.Indyuce.mmoitems.ability.Ability;
-import net.Indyuce.mmoitems.stat.data.AbilityData;
-import org.apache.commons.lang.Validate;
-import org.bukkit.configuration.file.FileConfiguration;
-import org.bukkit.entity.LivingEntity;
-
-import java.util.HashSet;
-import java.util.Optional;
-
-public class MythicMobsAbility extends Ability {
- private Skill skill;
-
- public MythicMobsAbility(String id, FileConfiguration config) {
- super(id, config.getString("name"));
-
- String skillName = config.getString("mythicmobs-skill-id");
- Validate.notNull(skillName, "Could not find MM skill name");
-
- Optional opt = MythicMobs.inst().getSkillManager().getSkill(skillName);
- Validate.isTrue(opt.isPresent(), "Could not find MM skill with name '" + skillName + "'");
- skill = opt.get();
-
- addModifier("cooldown", 10);
- addModifier("mana", 0);
- addModifier("stamina", 0);
-
- for (String mod : config.getKeys(false))
- if (!mod.equals("name") && !mod.equals("mythicmobs-skill-id") && !mod.equals("self-only"))
- addModifier(mod.toLowerCase().replace("_", "-").replace(" ", "-"), config.getInt(mod));
- }
-
- public String getInternalName() {
- return skill.getInternalName();
- }
-
- public void setSkill(Skill skill) {
- this.skill = skill;
- }
-
- @Override
- public void whenCast(AttackMetadata attackMeta, MythicMobsAbilityMetadata ability) {
- skill.execute(ability.getSkillMetadata());
- }
-
- @Override
- public MythicMobsAbilityMetadata canBeCast(AttackMetadata attackMeta, LivingEntity target, AbilityData data) {
-
- // TODO what's the difference between trigger and caster.
- AbstractEntity trigger = BukkitAdapter.adapt(attackMeta.getPlayer());
- SkillCaster caster = new GenericCaster(trigger);
-
- HashSet targetEntities = new HashSet<>();
- HashSet targetLocations = new HashSet<>();
-
- targetEntities.add(BukkitAdapter.adapt(target));
-
- SkillMetadata skillMeta = new SkillMetadata(SkillTrigger.CAST, caster, trigger, BukkitAdapter.adapt(attackMeta.getPlayer().getEyeLocation()), targetEntities, targetLocations, 1);
-
- // Stats are cached inside a variable
- skillMeta.getVariables().putObject("MMOStatMap", attackMeta.getStats());
- skillMeta.getVariables().putObject("MMOSkill", data);
-
- return new MythicMobsAbilityMetadata(data, skill, skillMeta);
- }
-}
diff --git a/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/skill/MythicMobsAbilityMetadata.java b/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/skill/MythicMobsAbilityMetadata.java
deleted file mode 100644
index f5f054ff..00000000
--- a/src/main/java/net/Indyuce/mmoitems/comp/mythicmobs/skill/MythicMobsAbilityMetadata.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package net.Indyuce.mmoitems.comp.mythicmobs.skill;
-
-import io.lumine.xikage.mythicmobs.skills.Skill;
-import io.lumine.xikage.mythicmobs.skills.SkillMetadata;
-import io.lumine.xikage.mythicmobs.skills.SkillTrigger;
-import net.Indyuce.mmoitems.ability.AbilityMetadata;
-import net.Indyuce.mmoitems.stat.data.AbilityData;
-
-public class MythicMobsAbilityMetadata extends AbilityMetadata {
- private final Skill skill;
- private final SkillMetadata skillMeta;
-
- public MythicMobsAbilityMetadata(AbilityData ability, Skill skill, SkillMetadata skillMeta) {
- super(ability);
-
- this.skill = skill;
- this.skillMeta = skillMeta;
- }
-
- public SkillMetadata getSkillMetadata() {
- return skillMeta;
- }
-
- @Override
- public boolean isSuccessful() {
- return skill.usable(skillMeta, SkillTrigger.CAST);
- }
-}
\ No newline at end of file
diff --git a/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java b/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java
index a08b3594..469689f8 100644
--- a/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java
+++ b/src/main/java/net/Indyuce/mmoitems/listener/ItemUse.java
@@ -98,7 +98,7 @@ public class ItemUse implements Listener {
UntargetedWeapon weapon = (UntargetedWeapon) useItem;
if ((event.getAction().name().contains("RIGHT_CLICK") && weapon.getWeaponType() == WeaponType.RIGHT_CLICK)
|| (event.getAction().name().contains("LEFT_CLICK") && weapon.getWeaponType() == WeaponType.LEFT_CLICK))
- weapon.untargetedAttack(event.getHand());
+ weapon.untargetedAttack(EquipmentSlot.fromBukkit(event.getHand()));
}
}
diff --git a/src/main/java/net/Indyuce/mmoitems/manager/AbilityManager.java b/src/main/java/net/Indyuce/mmoitems/manager/AbilityManager.java
index 6f4ef215..f92b2775 100644
--- a/src/main/java/net/Indyuce/mmoitems/manager/AbilityManager.java
+++ b/src/main/java/net/Indyuce/mmoitems/manager/AbilityManager.java
@@ -50,7 +50,6 @@ public class AbilityManager {
* @param ability Ability to register
*/
public void registerAbility(Ability ability) {
- MythicLib.plugin.getSkills().registerSkillHandler(ability);
MMOItems.plugin.getSkills().registerSkill(new RegisteredSkill(ability));
}
}
diff --git a/src/main/java/net/Indyuce/mmoitems/manager/EntityManager.java b/src/main/java/net/Indyuce/mmoitems/manager/EntityManager.java
index be740568..36af9a6c 100644
--- a/src/main/java/net/Indyuce/mmoitems/manager/EntityManager.java
+++ b/src/main/java/net/Indyuce/mmoitems/manager/EntityManager.java
@@ -1,11 +1,10 @@
package net.Indyuce.mmoitems.manager;
import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.stat.StatMap;
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 io.lumine.mythic.lib.damage.AttackMetadata;
import net.Indyuce.mmoitems.api.ItemAttackMetadata;
import net.Indyuce.mmoitems.api.interaction.projectile.ArrowParticles;
import net.Indyuce.mmoitems.api.interaction.projectile.EntityData;
@@ -37,8 +36,8 @@ public class EntityManager implements Listener {
private final WeakHashMap projectiles = new WeakHashMap<>();
- public void registerCustomProjectile(NBTItem sourceItem, StatMap.CachedStatMap stats, Entity entity, boolean customWeapon) {
- registerCustomProjectile(sourceItem, stats, entity, customWeapon, 1);
+ public void registerCustomProjectile(NBTItem sourceItem, PlayerMetadata attacker, Entity entity, boolean customWeapon) {
+ registerCustomProjectile(sourceItem, attacker, entity, customWeapon, 1);
}
/**
@@ -47,13 +46,13 @@ public class EntityManager implements Listener {
* Default bow/trident damage is set to 7 just like vanilla Minecraft.
*
* @param sourceItem Item used to shoot the projectile
- * @param stats Cached stats of the player shooting the projectile
+ * @param attacker Cached stats of the player shooting the projectile
* @param entity The custom entity
* @param customWeapon Is the source weapon is a custom item
* @param damageMultiplicator The damage coefficient. For bows, this is basically the pull force.
* For tridents or anything else this is always set to 1
*/
- public void registerCustomProjectile(NBTItem sourceItem, StatMap.CachedStatMap stats, Entity entity, boolean customWeapon, double damageMultiplicator) {
+ public void registerCustomProjectile(NBTItem sourceItem, PlayerMetadata attacker, Entity entity, boolean customWeapon, double damageMultiplicator) {
/*
* For bows, MC default value is 7. When using custom bows, the attack
@@ -64,11 +63,11 @@ public class EntityManager implements Listener {
* Damage coefficient is how much you pull the bow. It's something between 0
* and 1 for bows, and it's always 1 for tridents or crossbows.
*/
- double damage = stats.getStat("ATTACK_DAMAGE");
+ double damage = attacker.getStat("ATTACK_DAMAGE");
damage = (customWeapon ? damage : 5 + damage) * damageMultiplicator;
- ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(damage, DamageType.WEAPON, DamageType.PHYSICAL, DamageType.PROJECTILE), stats);
- stats.setStat("ATTACK_DAMAGE", damage);
+ ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(damage, DamageType.WEAPON, DamageType.PHYSICAL, DamageType.PROJECTILE), attacker);
+ attacker.setStat("ATTACK_DAMAGE", damage);
/*
* Load arrow particles if the entity is an arrow and if the item has
diff --git a/src/main/java/net/Indyuce/mmoitems/manager/SkillManager.java b/src/main/java/net/Indyuce/mmoitems/manager/SkillManager.java
index eadba331..a1d2c4bf 100644
--- a/src/main/java/net/Indyuce/mmoitems/manager/SkillManager.java
+++ b/src/main/java/net/Indyuce/mmoitems/manager/SkillManager.java
@@ -48,7 +48,10 @@ public class SkillManager {
return skills.values();
}
- public void reload() {
+ public void initialize(boolean clearBefore) {
+
+ if (clearBefore)
+ skills.clear();
// Check for default files
File skillFolder = new File(MMOItems.plugin.getDataFolder() + "/skill");
diff --git a/src/main/java/net/Indyuce/mmoitems/skill/Shulker_Missile.java b/src/main/java/net/Indyuce/mmoitems/skill/Shulker_Missile.java
index be0f18a1..90702351 100644
--- a/src/main/java/net/Indyuce/mmoitems/skill/Shulker_Missile.java
+++ b/src/main/java/net/Indyuce/mmoitems/skill/Shulker_Missile.java
@@ -62,7 +62,7 @@ public class Shulker_Missile extends SkillHandler implements
EntityType.SHULKER_BULLET);
shulkerBullet.setShooter(caster);
- ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(skillMeta.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), skillMeta.getStats());
+ ItemAttackMetadata attackMeta = new ItemAttackMetadata(new DamageMetadata(skillMeta.getModifier("damage"), DamageType.SKILL, DamageType.MAGIC, DamageType.PROJECTILE), skillMeta.getCaster());
MMOItems.plugin.getEntities().registerCustomEntity(shulkerBullet, new ShulkerMissileEntityData(attackMeta, skillMeta.getModifier("effect-duration")));
new BukkitRunnable() {
diff --git a/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java b/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java
index 8efdf1d7..d8a73001 100644
--- a/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java
+++ b/src/main/java/net/Indyuce/mmoitems/stat/data/AbilityData.java
@@ -83,12 +83,12 @@ public class AbilityData extends Skill {
@Override
public boolean getResult(SkillMetadata meta) {
- PlayerData playerData = PlayerData.get(meta.getCaster().getUniqueId());
+ PlayerData playerData = PlayerData.get(meta.getCaster().getData().getUniqueId());
RPGPlayer rpgPlayer = playerData.getRPG();
Player player = meta.getCaster().getPlayer();
// Check for cooldown
- if (meta.getCaster().getCooldownMap().isOnCooldown(this)) {
+ if (meta.getCaster().getData().getCooldownMap().isOnCooldown(this)) {
CooldownInfo info = playerData.getMMOPlayerData().getCooldownMap().getInfo(this);
if (!triggerType.isSilent()) {
StringBuilder progressBar = new StringBuilder(ChatColor.YELLOW + "");
@@ -125,7 +125,7 @@ public class AbilityData extends Skill {
@Override
public void whenCast(SkillMetadata meta) {
- PlayerData playerData = PlayerData.get(meta.getCaster().getUniqueId());
+ PlayerData playerData = PlayerData.get(meta.getCaster().getData().getUniqueId());
RPGPlayer rpgPlayer = playerData.getRPG();
// Apply mana cost
@@ -137,9 +137,9 @@ public class AbilityData extends Skill {
rpgPlayer.giveStamina(-meta.getModifier("stamina"));
// Apply cooldown
- double cooldown = meta.getModifier("cooldown") * (1 - Math.min(.8, meta.getStats().getStat("COOLDOWN_REDUCTION") / 100));
+ double cooldown = meta.getModifier("cooldown") * (1 - Math.min(.8, meta.getCaster().getStat("COOLDOWN_REDUCTION") / 100));
if (cooldown > 0)
- meta.getCaster().getCooldownMap().applyCooldown(this, cooldown);
+ meta.getCaster().getData().getCooldownMap().applyCooldown(this, cooldown);
}
@Override