diff --git a/MMOItems-API/pom.xml b/MMOItems-API/pom.xml
index fee419a4..778f4010 100644
--- a/MMOItems-API/pom.xml
+++ b/MMOItems-API/pom.xml
@@ -5,7 +5,7 @@
getInventory().register()
. This method
- * will clear all other PlayerInventories for now, as to keep
- * backwards compatibility.
+ * search equipment within, you must add your inventory to the
+ * handler with getInventory().register()
. This method
+ * will clear all other PlayerInventories for now, as to keep
+ * backwards compatibility.
*/
@Deprecated
public void setPlayerInventory(PlayerInventory value) {
@@ -490,7 +492,7 @@ public class MMOItems extends JavaPlugin {
return templateManager;
}
- public LoreFormatManager getLore(){
+ public LoreFormatManager getLore() {
return loreManager;
}
@@ -527,9 +529,9 @@ public class MMOItems extends JavaPlugin {
/**
* @return Generates an item given an item template. The item level will
- * scale according to the player RPG level if the template has the
- * 'level-item' option. The item will pick a random tier if the
- * template has the 'tiered' option
+ * scale according to the player RPG level if the template has the
+ * 'level-item' option. The item will pick a random tier if the
+ * template has the 'tiered' option
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id, @Nullable PlayerData player) {
@@ -547,9 +549,9 @@ public class MMOItems extends JavaPlugin {
/**
* @return Generates an item given an item template. The item level will
- * scale according to the player RPG level if the template has the
- * 'level-item' option. The item will pick a random tier if the
- * template has the 'tiered' option
+ * scale according to the player RPG level if the template has the
+ * 'level-item' option. The item will pick a random tier if the
+ * template has the 'tiered' option
*/
@Nullable
public ItemStack getItem(@Nullable Type type, @Nullable String id, @NotNull PlayerData player) {
@@ -566,7 +568,7 @@ public class MMOItems extends JavaPlugin {
* @param itemLevel The desired item level
* @param itemTier The desired item tier, can be null
* @return Generates an item given an item template with a
- * specific item level and item tier
+ * specific item level and item tier
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id, int itemLevel, @Nullable ItemTier itemTier) {
@@ -586,7 +588,7 @@ public class MMOItems extends JavaPlugin {
* @param itemLevel The desired item level
* @param itemTier The desired item tier, can be null
* @return Generates an item given an item template with a
- * specific item level and item tier
+ * specific item level and item tier
*/
@Nullable
public ItemStack getItem(@Nullable Type type, @Nullable String id, int itemLevel, @Nullable ItemTier itemTier) {
@@ -601,10 +603,10 @@ public class MMOItems extends JavaPlugin {
/**
* @return Generates an item given an item template. The item level will be
- * 0 and the item will have no item tier unless one is specified in
- * the base item data.
- *
null
if such MMOItem does not exist.
+ * 0 and the item will have no item tier unless one is specified in
+ * the base item data.
+ *
+ * Will return null
if such MMOItem does not exist.
*/
@Nullable
public MMOItem getMMOItem(@Nullable Type type, @Nullable String id) {
@@ -613,10 +615,10 @@ public class MMOItems extends JavaPlugin {
/**
* @return Generates an item given an item template. The item level will be
- * 0 and the item will have no item tier unless one is specified in
- * the base item data.
- *
- * Will return null
if such MMOItem does not exist.
+ * 0 and the item will have no item tier unless one is specified in
+ * the base item data.
+ *
+ * Will return null
if such MMOItem does not exist.
*/
@Nullable
@@ -629,10 +631,10 @@ public class MMOItems extends JavaPlugin {
/**
* @return Generates an item given an item template. The item level will be
- * 0 and the item will have no item tier unless one is specified in
- * the base item data.
- *
- * Will return null
if such MMOItem does not exist.
+ * 0 and the item will have no item tier unless one is specified in
+ * the base item data.
+ *
+ * Will return null
if such MMOItem does not exist.
*/
@Nullable
public ItemStack getItem(@Nullable Type type, @Nullable String id) {
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java
index dea5a911..a43fa714 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/Type.java
@@ -3,12 +3,17 @@ package net.Indyuce.mmoitems.api;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods;
import io.lumine.mythic.lib.api.item.NBTItem;
+import io.lumine.mythic.lib.player.cooldown.CooldownObject;
import io.lumine.mythic.lib.player.modifier.ModifierSource;
+import io.lumine.mythic.lib.skill.SimpleSkill;
+import io.lumine.mythic.lib.skill.Skill;
+import io.lumine.mythic.lib.skill.trigger.TriggerType;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.util.identify.UnidentifiedItem;
import net.Indyuce.mmoitems.manager.TypeManager;
import net.Indyuce.mmoitems.stat.type.ItemStat;
import org.apache.commons.lang.Validate;
+import org.apache.maven.model.ConfigurationContainer;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
@@ -20,47 +25,46 @@ import java.util.List;
import java.util.Objects;
@SuppressWarnings("unused")
-public class Type {
+public class Type implements CooldownObject {
// Slashing
- public static final Type SWORD = new Type(TypeSet.SLASHING, "SWORD", true, ModifierSource.MELEE_WEAPON);
+ public static final Type SWORD = new Type("SWORD", true, ModifierSource.MELEE_WEAPON);
// Piercing
- public static final Type DAGGER = new Type(TypeSet.PIERCING, "DAGGER", true, ModifierSource.MELEE_WEAPON);
- public static final Type SPEAR = new Type(TypeSet.PIERCING, "SPEAR", true, ModifierSource.MELEE_WEAPON);
+ public static final Type DAGGER = new Type("DAGGER", true, ModifierSource.MELEE_WEAPON);
+ public static final Type SPEAR = new Type("SPEAR", true, ModifierSource.MELEE_WEAPON);
// Blunt
- public static final Type HAMMER = new Type(TypeSet.BLUNT, "HAMMER", true, ModifierSource.MELEE_WEAPON);
- public static final Type GAUNTLET = new Type(TypeSet.BLUNT, "GAUNTLET", true, ModifierSource.MELEE_WEAPON);
+ public static final Type HAMMER = new Type("HAMMER", true, ModifierSource.MELEE_WEAPON);
+ public static final Type GAUNTLET = new Type("GAUNTLET", true, ModifierSource.MELEE_WEAPON);
// Range
- public static final Type WHIP = new Type(TypeSet.RANGE, "WHIP", true, ModifierSource.RANGED_WEAPON);
- public static final Type STAFF = new Type(TypeSet.RANGE, "STAFF", true, ModifierSource.RANGED_WEAPON);
- public static final Type BOW = new Type(TypeSet.RANGE, "BOW", true, ModifierSource.RANGED_WEAPON);
- public static final Type CROSSBOW = new Type(TypeSet.RANGE, "CROSSBOW", false, ModifierSource.RANGED_WEAPON);
- public static final Type MUSKET = new Type(TypeSet.RANGE, "MUSKET", true, ModifierSource.RANGED_WEAPON);
- public static final Type LUTE = new Type(TypeSet.RANGE, "LUTE", true, ModifierSource.RANGED_WEAPON);
+ public static final Type WHIP = new Type("WHIP", true, ModifierSource.RANGED_WEAPON);
+ public static final Type STAFF = new Type("STAFF", true, ModifierSource.RANGED_WEAPON);
+ public static final Type BOW = new Type("BOW", true, ModifierSource.RANGED_WEAPON);
+ public static final Type CROSSBOW = new Type("CROSSBOW", false, ModifierSource.RANGED_WEAPON);
+ public static final Type MUSKET = new Type("MUSKET", true, ModifierSource.RANGED_WEAPON);
+ public static final Type LUTE = new Type("LUTE", true, ModifierSource.RANGED_WEAPON);
// Hand Accessories
- public static final Type CATALYST = new Type(TypeSet.CATALYST, "CATALYST", false, ModifierSource.HAND_ITEM);
- public static final Type OFF_CATALYST = new Type(TypeSet.CATALYST, "OFF_CATALYST", false, ModifierSource.OFFHAND_ITEM);
- public static final Type MAIN_CATALYST = new Type(TypeSet.CATALYST, "MAIN_CATALYST", false, ModifierSource.MAINHAND_ITEM);
+ public static final Type CATALYST = new Type("CATALYST", false, ModifierSource.HAND_ITEM);
+ public static final Type OFF_CATALYST = new Type("OFF_CATALYST", false, ModifierSource.OFFHAND_ITEM);
+ public static final Type MAIN_CATALYST = new Type("MAIN_CATALYST", false, ModifierSource.MAINHAND_ITEM);
// Any
- public static final Type ORNAMENT = new Type(TypeSet.EXTRA, "ORNAMENT", false, ModifierSource.VOID);
+ public static final Type ORNAMENT = new Type("ORNAMENT", false, ModifierSource.VOID);
// Extra
- public static final Type ARMOR = new Type(TypeSet.EXTRA, "ARMOR", false, ModifierSource.ARMOR);
- public static final Type TOOL = new Type(TypeSet.EXTRA, "TOOL", false, ModifierSource.MELEE_WEAPON);
- public static final Type CONSUMABLE = new Type(TypeSet.EXTRA, "CONSUMABLE", false, ModifierSource.MAINHAND_ITEM);
- public static final Type MISCELLANEOUS = new Type(TypeSet.EXTRA, "MISCELLANEOUS", false, ModifierSource.MAINHAND_ITEM);
- public static final Type GEM_STONE = new Type(TypeSet.EXTRA, "GEM_STONE", false, ModifierSource.VOID);
- public static final Type SKIN = new Type(TypeSet.EXTRA, "SKIN", false, ModifierSource.VOID);
- public static final Type ACCESSORY = new Type(TypeSet.EXTRA, "ACCESSORY", false, ModifierSource.ACCESSORY);
- public static final Type BLOCK = new Type(TypeSet.EXTRA, "BLOCK", false, ModifierSource.VOID);
+ public static final Type ARMOR = new Type("ARMOR", false, ModifierSource.ARMOR);
+ public static final Type TOOL = new Type("TOOL", false, ModifierSource.MELEE_WEAPON);
+ public static final Type CONSUMABLE = new Type("CONSUMABLE", false, ModifierSource.MAINHAND_ITEM);
+ public static final Type MISCELLANEOUS = new Type("MISCELLANEOUS", false, ModifierSource.MAINHAND_ITEM);
+ public static final Type GEM_STONE = new Type("GEM_STONE", false, ModifierSource.VOID);
+ public static final Type SKIN = new Type("SKIN", false, ModifierSource.VOID);
+ public static final Type ACCESSORY = new Type("ACCESSORY", false, ModifierSource.ACCESSORY);
+ public static final Type BLOCK = new Type("BLOCK", false, ModifierSource.VOID);
private final String id;
- private final TypeSet set;
private final ModifierSource modifierSource;
private final boolean weapon;
@@ -69,6 +73,9 @@ public class Type {
@Nullable
private String loreFormat;
+ @NotNull
+ private String attackCooldownKey;
+
/**
* Used to display the item in the item explorer and in the item recipes
* list in the advanced workbench. can also be edited using the config
@@ -77,13 +84,19 @@ public class Type {
private ItemStack item;
/**
- * Any type can have a subtype which basically dictates what the item type
- * does.
+ * The parent item type determines:
+ * - the item options compatible with this new item type
+ * - if this item type is a weapon or not
+ * - the lore format
*/
private Type parent;
private UnidentifiedItem unidentifiedTemplate;
+ private Skill onLeftClick, onRightClick, onAttack, onEntityInteract;
+
+ private boolean meleeAttacks;
+
/**
* 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.
@@ -92,11 +105,10 @@ public class Type {
@Deprecated
public Type(TypeSet set, String id, boolean weapon, ModifierSource modSource, boolean fourGUIMode) {
- this(set, id, weapon, modSource);
+ this(id, weapon, modSource);
}
- public Type(TypeSet set, String id, boolean weapon, ModifierSource modSource) {
- this.set = set;
+ public Type(String id, boolean weapon, ModifierSource modSource) {
this.id = id.toUpperCase().replace("-", "_").replace(" ", "_");
this.modifierSource = modSource;
this.weapon = weapon;
@@ -108,7 +120,6 @@ public class Type {
parent = manager.get(config.getString("parent", "").toUpperCase().replace("-", "_").replace(" ", "_"));
- set = (parent != null ? parent.set : TypeSet.EXTRA);
weapon = (parent != null && parent.weapon);
modifierSource = (parent != null ? parent.modifierSource : ModifierSource.OTHER);
this.loreFormat = config.getString("LoreFormat", (parent != null ? parent.loreFormat : null));
@@ -123,7 +134,18 @@ public class Type {
(unidentifiedTemplate = new UnidentifiedItem(this)).update(config.getConfigurationSection("unident-item"));
// Getting overridden?
- loreFormat = config.getString("LoreFormat", (parent != null ? parent.loreFormat : loreFormat));
+ loreFormat = config.getString("LoreFormat", parent != null ? parent.loreFormat : null);
+
+ attackCooldownKey = config.getString("attack-cooldown-key", "default");
+
+ meleeAttacks = !config.getBoolean("cancel-melee-attacks");
+ }
+
+ public void postload(ConfigurationSection config) {
+ onLeftClick = config.contains("on-left-click") ? new SimpleSkill(TriggerType.CAST, MythicLib.plugin.getSkills().loadSkillHandler(config.get("on-left-click"))) : null;
+ onRightClick = config.contains("on-right-click") ? new SimpleSkill(MythicLib.plugin.getSkills().loadSkillHandler(config.get("on-right-click"))) : null;
+ onAttack = config.contains("on-attack") ? new SimpleSkill(MythicLib.plugin.getSkills().loadSkillHandler(config.get("on-attack"))) : null;
+ onEntityInteract = config.contains("on-entity-interact") ? new SimpleSkill(MythicLib.plugin.getSkills().loadSkillHandler(config.get("on-entity-interact"))) : null;
}
/**
@@ -144,18 +166,19 @@ public class Type {
return id;
}
- public TypeSet getItemSet() {
- return set;
- }
-
public boolean isWeapon() {
return weapon;
}
+ public boolean hasMeleeAttacks() {
+ return meleeAttacks;
+ }
+
public String getName() {
return name;
}
+ @NotNull
public ModifierSource getModifierSource() {
return modifierSource;
}
@@ -164,6 +187,31 @@ public class Type {
return item.clone();
}
+ @Nullable
+ public Skill onLeftClick() {
+ return onLeftClick;
+ }
+
+ @Override
+ public String getCooldownPath() {
+ return "mmoitems_weapons:" + attackCooldownKey;
+ }
+
+ @Nullable
+ public Skill onRightClick() {
+ return onRightClick;
+ }
+
+ @Nullable
+ public Skill onAttack() {
+ return onAttack;
+ }
+
+ @Nullable
+ public Skill onEntityInteract() {
+ return onEntityInteract;
+ }
+
/**
* @deprecated Use {@link #getSupertype()}
*/
@@ -213,11 +261,6 @@ public class Type {
return getSupertype().equals(type);
}
- @Deprecated
- public boolean corresponds(TypeSet set) {
- return getSupertype().getItemSet() == set;
- }
-
/**
* @return The collection of all stats which can be applied onto this
* specific item type. This list is cached when types are being
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/TypeSet.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/TypeSet.java
index 58edaf96..bd91557b 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/TypeSet.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/TypeSet.java
@@ -1,35 +1,23 @@
package net.Indyuce.mmoitems.api;
import io.lumine.mythic.lib.UtilityMethods;
-import io.lumine.mythic.lib.comp.interaction.InteractionType;
import io.lumine.mythic.lib.damage.AttackMetadata;
-import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
-import io.lumine.mythic.lib.version.VersionSound;
-import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import net.Indyuce.mmoitems.api.player.PlayerData;
-import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
-import net.Indyuce.mmoitems.util.MMOUtils;
-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.jetbrains.annotations.NotNull;
-import java.util.Random;
-
+@Deprecated
public enum TypeSet {
/**
* Slashing weapons deal damage in a cone behind the player's initial
* target, which makes it a deadly AoE weapon for warriors
*/
+ @Deprecated
SLASHING((attack, attacker, attackerData, target, weapon) -> {
- if (!MMOItems.plugin.getConfig().getBoolean("item-ability.slashing.enabled")
+ /*if (!MMOItems.plugin.getConfig().getBoolean("item-ability.slashing.enabled")
|| attackerData.isOnCooldown(CooldownType.SET_TYPE_ATTACK))
return;
@@ -46,7 +34,7 @@ public enum TypeSet {
&& attacker.getPlayer().getEyeLocation().getDirection()
.angle(entity.getLocation().subtract(attacker.getPlayer().getLocation()).toVector()) < Math.PI / 3
&& UtilityMethods.canTarget(attacker.getPlayer(), entity, InteractionType.OFFENSE_ACTION) && !entity.equals(target))
- attacker.attack((LivingEntity) entity, attack.getDamage().getDamage() * .4, DamageType.WEAPON, DamageType.PHYSICAL);
+ attacker.attack((LivingEntity) entity, attack.getDamage().getDamage() * .4, DamageType.WEAPON, DamageType.PHYSICAL);*/
}),
/**
@@ -55,8 +43,9 @@ public enum TypeSet {
* increased which makes it a perfect 'double or nothing' weapon for
* assassins
*/
+ @Deprecated
PIERCING((attack, attacker, attackerData, target, weapon) -> {
- if (!MMOItems.plugin.getConfig().getBoolean("item-ability.piercing.enabled")
+ /* if (!MMOItems.plugin.getConfig().getBoolean("item-ability.piercing.enabled")
|| attackerData.isOnCooldown(CooldownType.SET_TYPE_ATTACK))
return;
@@ -73,15 +62,16 @@ public enum TypeSet {
&& attacker.getPlayer().getEyeLocation().getDirection()
.angle(entity.getLocation().toVector().subtract(attacker.getPlayer().getLocation().toVector())) < Math.PI / 12
&& UtilityMethods.canTarget(attacker.getPlayer(), entity, InteractionType.OFFENSE_ACTION))
- attacker.attack((LivingEntity) entity, attack.getDamage().getDamage() * .6, DamageType.WEAPON, DamageType.PHYSICAL);
+ attacker.attack((LivingEntity) entity, attack.getDamage().getDamage() * .6, DamageType.WEAPON, DamageType.PHYSICAL);*/
}),
/**
* Blunt weapons are like 1.9 sweep attacks. They damage
* all enemies nearby and apply a slight knockback
*/
+ @Deprecated
BLUNT((attack, attacker, attackerData, target, weapon) -> {
- final Random random = new Random();
+ /* final Random random = new Random();
float pitchRange = 0.7f + random.nextFloat() * (0.9f - 0.7f);
final double bluntPower;
@@ -113,7 +103,7 @@ public enum TypeSet {
Location loc = target.getLocation();
loc.setYaw((float) (loc.getYaw() + 2 * (random.nextDouble() - .5) * 90));
loc.setPitch((float) (loc.getPitch() + 2 * (random.nextDouble() - .5) * 30));
- }
+ }*/
}),
/**
@@ -121,17 +111,20 @@ public enum TypeSet {
* the middle of the battle-field, these weapons allow him to take some
* distance and still deal some good damage
*/
+ @Deprecated
RANGE,
/**
* Hand/Mainhand/Offhand catalysts
*/
+ @Deprecated
CATALYST,
/**
* Any other item type, like armor, consumables, etc. They all have their
* very specific passive depending on their item type
*/
+ @Deprecated
EXTRA;
private final SetAttackHandler attackHandler;
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/event/item/UntargetedWeaponUseEvent.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/event/item/UntargetedWeaponUseEvent.java
index c892a074..26189535 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/event/item/UntargetedWeaponUseEvent.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/event/item/UntargetedWeaponUseEvent.java
@@ -1,14 +1,14 @@
package net.Indyuce.mmoitems.api.event.item;
import net.Indyuce.mmoitems.api.event.PlayerDataEvent;
-import net.Indyuce.mmoitems.api.interaction.weapon.untargeted.UntargetedWeapon;
+import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
import net.Indyuce.mmoitems.api.player.PlayerData;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;
public class UntargetedWeaponUseEvent extends PlayerDataEvent implements Cancellable {
- private final UntargetedWeapon weapon;
+ private final Weapon weapon;
private boolean cancelled;
@@ -20,7 +20,7 @@ public class UntargetedWeaponUseEvent extends PlayerDataEvent implements Cancell
* @param who Player attacking
* @param weapon Weapon being used
*/
- public UntargetedWeaponUseEvent(@NotNull PlayerData who, @NotNull UntargetedWeapon weapon) {
+ public UntargetedWeaponUseEvent(@NotNull PlayerData who, @NotNull Weapon weapon) {
super(who);
this.weapon = weapon;
@@ -30,7 +30,7 @@ public class UntargetedWeaponUseEvent extends PlayerDataEvent implements Cancell
* @return The weapon used by the player that fired this event
*/
@NotNull
- public UntargetedWeapon getWeapon() {
+ public Weapon getWeapon() {
return weapon;
}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/Consumable.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/Consumable.java
index d4e0d7ca..7fc3945f 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/Consumable.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/Consumable.java
@@ -11,6 +11,7 @@ import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.ConsumableConsumedEvent;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
import net.Indyuce.mmoitems.api.item.util.LoreUpdate;
+import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.stat.type.ConsumableItemInteraction;
import net.Indyuce.mmoitems.stat.type.PlayerConsumable;
import org.bukkit.Bukkit;
@@ -22,10 +23,16 @@ import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;
public class Consumable extends UseItem {
+
+ @Deprecated
public Consumable(Player player, NBTItem item) {
super(player, item);
}
+ public Consumable(PlayerData player, NBTItem item) {
+ super(player, item);
+ }
+
@Override
public boolean checkItemRequirements() {
return MythicLib.plugin.getFlags().isFlagAllowed(player, CustomFlag.MI_CONSUMABLES) && playerData.getRPG().canUse(getNBTItem(), true);
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/GemStone.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/GemStone.java
index e890069c..caead8d0 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/GemStone.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/GemStone.java
@@ -6,6 +6,7 @@ import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.event.item.ApplyGemStoneEvent;
import net.Indyuce.mmoitems.api.item.mmoitem.LiveMMOItem;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
+import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.Enchants;
import net.Indyuce.mmoitems.stat.GemUpgradeScaling;
@@ -28,11 +29,15 @@ import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public class GemStone extends UseItem {
-
+ @Deprecated
public GemStone(Player player, NBTItem item) {
super(player, item);
}
+ public GemStone(PlayerData player, NBTItem item) {
+ super(player, item);
+ }
+
@NotNull
public ApplyResult applyOntoItem(@NotNull NBTItem target, @NotNull Type targetType) {
@@ -60,7 +65,7 @@ public class GemStone extends UseItem {
// Checks if the gem supports the item type, or the item set, or a weapon
String appliableTypes = getNBTItem().getString(ItemStats.ITEM_TYPE_RESTRICTION.getNBTPath());
if (!appliableTypes.equals("") && (!targetType.isWeapon() || !appliableTypes.contains("WEAPON"))
- && !appliableTypes.contains(targetType.getItemSet().name()) && !appliableTypes.contains(targetType.getId()))
+ && !appliableTypes.contains(targetType.getId()))
return new ApplyResult(ResultType.NONE);
// Check for success rate
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/ItemSkin.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/ItemSkin.java
index 41994b0f..4abf9a9f 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/ItemSkin.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/ItemSkin.java
@@ -7,6 +7,7 @@ import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.api.item.mmoitem.VolatileMMOItem;
+import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.data.SkullTextureData;
import net.Indyuce.mmoitems.stat.data.StringListData;
@@ -19,16 +20,20 @@ import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.LeatherArmorMeta;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import java.lang.reflect.Field;
import java.util.List;
public class ItemSkin extends UseItem {
+ @Deprecated
public ItemSkin(Player player, NBTItem item) {
super(player, item);
}
+ public ItemSkin(PlayerData player, NBTItem item) {
+ super(player, item);
+ }
+
public ApplyResult applyOntoItem(NBTItem target, Type targetType) {
if (targetType == Type.SKIN)
return new ApplyResult(ResultType.NONE);
@@ -42,9 +47,9 @@ public class ItemSkin extends UseItem {
//SKIN//MMOItems.log("\u00a78SKIN \u00a7eCPT\u00a77 Applying onto " + MMOUtils.getDisplayName(target.getItem()));
// Types compatibility check
- if (getMMOItem().hasData(ItemStats.COMPATIBLE_TYPES)) {
+ if (mmoitem.hasData(ItemStats.COMPATIBLE_TYPES)) {
//SKIN//MMOItems.log("\u00a78SKIN \u00a7eCPT\u00a77 Testing that TYPE is compatible: ");
- final List
+ * Other weapon costs are inherent to the item type and are
+ * fully configurable inside of the types config file.
*
- * @param attackDelay The weapon attack period/delay
- * @param cooldown The weapon cooldown type. When set to null, no
- * cooldown will be applied. This is made to handle
- * custom weapons
+ * @see {@link #checkWeaponCosts(boolean)}
*/
- public void applyWeaponCosts(double attackDelay, @Nullable CooldownType cooldown) {
+ public void applyWeaponCosts(@Nullable Double attackDelay) {
- double manaCost = getNBTItem().getStat("MANA_COST");
+ final double manaCost = getNBTItem().getStat("MANA_COST");
if (manaCost > 0) playerData.getRPG().giveMana(-manaCost);
- double staminaCost = getNBTItem().getStat("STAMINA_COST");
+ final double staminaCost = getNBTItem().getStat("STAMINA_COST");
if (staminaCost > 0) playerData.getRPG().giveStamina(-staminaCost);
- if (cooldown != null) getPlayerData().applyCooldown(cooldown, attackDelay);
+ if (attackDelay != null)
+ getPlayerData().getMMOPlayerData().getCooldownMap().applyCooldown(mmoitem.getType(), attackDelay);
}
/**
@@ -103,20 +120,103 @@ public class Weapon extends UseItem {
public boolean handleTargetedAttack(AttackMetadata attackMeta, @NotNull PlayerMetadata attacker, LivingEntity target) {
// Handle weapon mana and stamina costs ONLY
- if (!checkAndApplyWeaponCosts())
- return false;
+ if (!checkAndApplyWeaponCosts()) return false;
- // Handle item set attack effects
- if (getMMOItem().getType().getItemSet().hasAttackEffect() && !getNBTItem().getBoolean("MMOITEMS_DISABLE_ATTACK_PASSIVE"))
- getMMOItem().getType().getItemSet().applyAttackEffect(attackMeta, attacker, playerData, target, this);
+ // Handle on-hit attack effects
+ final Skill onHitScript = mmoitem.getType().onAttack();
+ if (onHitScript != null && !getNBTItem().getBoolean("MMOITEMS_DISABLE_ATTACK_PASSIVE"))
+ onHitScript.cast(new TriggerMetadata(attacker, TriggerType.API, target, attackMeta));
return true;
}
+ /**
+ * Called when the player interacts with the item. This method is used to
+ * apply durability and cast the weapon attack
+ *
+ * @param rightClick Is the click a right click? If false, it's a left click.
+ * @param actionHand Slot being interacted with
+ * @return Null if there are no attack detected
+ * @implNote Since MI 6.7.3 this method handles custom durability, cooldown
+ * checks and player stat snapshots.
+ */
+ @Nullable
+ public WeaponAttackResult handleUntargetedAttack(boolean rightClick, @NotNull EquipmentSlot actionHand) {
+ if (this instanceof LegacyWeapon) return legacyHandleUntargetedAttack(rightClick, actionHand);
+
+ // Check for item type attack effect
+ final Type itemType = mmoitem.getType();
+ final Skill attackEffect = rightClick ? itemType.onRightClick() : itemType.onLeftClick();
+ if (attackEffect == null) return WeaponAttackResult.NO_ATTACK;
+
+ // Check for attack effect conditions
+ final SkillHandler handler = attackEffect.getHandler();
+ final SkillMetadata meta = new TriggerMetadata(getPlayerData().getMMOPlayerData(), TriggerType.API).toSkillMetadata(attackEffect);
+ final SkillResult result = handler.getResult(meta);
+ if (!result.isSuccessful(meta)) return WeaponAttackResult.NO_ATTACK;
+
+ // Check for durability
+ UntargetedDurabilityItem durItem = new UntargetedDurabilityItem(getPlayer(), getNBTItem(), actionHand);
+ if (durItem.isBroken()) return WeaponAttackResult.DURABILITY;
+
+ // Apply weapon instantaneous costs
+ PlayerMetadata stats = getPlayerData().getStats().newTemporary(actionHand);
+ if (!checkWeaponCosts(true)) return WeaponAttackResult.WEAPON_COSTS;
+
+ // Check for Bukkit event
+ UntargetedWeaponUseEvent called = new UntargetedWeaponUseEvent(playerData, this);
+ Bukkit.getPluginManager().callEvent(called);
+ if (called.isCancelled()) return WeaponAttackResult.BUKKIT_EVENT;
+
+ // Attack is ready to be performed.
+ // Apply weapon costs
+ final double attackDelay = 1 / requireNonZero(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed"));
+ applyWeaponCosts(attackDelay);
+
+ // Apply weapon attack effect
+ handler.whenCast(result, meta);
+
+ // Apply durability loss
+ if (durItem.isValid()) durItem.decreaseDurability(1).inventoryUpdate();
+ return WeaponAttackResult.SUCCESS;
+ }
+
+ @Deprecated
+ private WeaponAttackResult legacyHandleUntargetedAttack(boolean rightClick, @NotNull EquipmentSlot actionHand) {
+
+ // Check for attack effect conditions
+ if (((LegacyWeapon) this).canAttack(rightClick, actionHand)) return WeaponAttackResult.NO_ATTACK;
+
+ // Check for durability
+ UntargetedDurabilityItem durItem = new UntargetedDurabilityItem(getPlayer(), getNBTItem(), actionHand);
+ if (durItem.isBroken()) return WeaponAttackResult.DURABILITY;
+
+ // Apply weapon instantaneous costs
+ PlayerMetadata stats = getPlayerData().getStats().newTemporary(actionHand);
+ if (!checkWeaponCosts(true)) return WeaponAttackResult.WEAPON_COSTS;
+
+ // Check for Bukkit event
+ UntargetedWeaponUseEvent called = new UntargetedWeaponUseEvent(playerData, this);
+ Bukkit.getPluginManager().callEvent(called);
+ if (called.isCancelled()) return WeaponAttackResult.BUKKIT_EVENT;
+
+ // Attack is ready to be performed.
+ // Apply weapon costs
+ final double attackDelay = 1 / requireNonZero(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed"));
+ applyWeaponCosts(attackDelay);
+
+ // Apply weapon attack effect
+ final PlayerMetadata caster = playerData.getMMOPlayerData().getStatMap().cache(actionHand);
+ ((LegacyWeapon) this).applyAttackEffect(caster, actionHand);
+
+ // Apply durability loss
+ if (durItem.isValid()) durItem.decreaseDurability(1).inventoryUpdate();
+ return WeaponAttackResult.SUCCESS;
+ }
+
protected Location getGround(Location loc) {
for (int j = 0; j < 20; j++) {
- if (loc.getBlock().getType().isSolid())
- return loc;
+ if (loc.getBlock().getType().isSolid()) return loc;
loc.add(0, -1, 0);
}
return loc;
@@ -125,7 +225,7 @@ public class Weapon extends UseItem {
/**
* @return First argument, or second if zero or lower
*/
- public double requireNonZero(double number, double elseNumber) {
+ protected double requireNonZero(double number, double elseNumber) {
return number <= 0 ? elseNumber : number;
}
}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Crossbow.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Crossbow.java
index 67cd08a2..249fa33a 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Crossbow.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Crossbow.java
@@ -7,6 +7,8 @@ import io.lumine.mythic.lib.skill.trigger.TriggerType;
import io.lumine.mythic.lib.util.CustomProjectile;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.CustomSound;
+import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
+import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.listener.CustomSoundListener;
import org.bukkit.GameMode;
import org.bukkit.Material;
@@ -15,15 +17,23 @@ import org.bukkit.entity.Arrow;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
-public class Crossbow extends UntargetedWeapon {
+@Deprecated
+public class Crossbow extends Weapon implements LegacyWeapon {
private boolean consumesArrow;
+ @Deprecated
public Crossbow(Player player, NBTItem item) {
- super(player, item, UntargetedWeaponType.RIGHT_CLICK);
+ super(player, item);
+ }
+
+ public Crossbow(PlayerData player, NBTItem item) {
+ super(player, item);
}
@Override
- public boolean canAttack(EquipmentSlot slot) {
+ public boolean canAttack(boolean rightClick, EquipmentSlot slot) {
+ if (!rightClick) return false;
+
consumesArrow = !getNBTItem().getBoolean("MMOITEMS_DISABLE_ARROW_CONSUMPTION");
return player.getGameMode() == GameMode.CREATIVE || !consumesArrow || getPlayer().getInventory().containsAtLeast(new ItemStack(Material.ARROW), 1);
}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/LegacyWeapon.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/LegacyWeapon.java
new file mode 100644
index 00000000..d541819f
--- /dev/null
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/LegacyWeapon.java
@@ -0,0 +1,17 @@
+package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
+
+import io.lumine.mythic.lib.api.player.EquipmentSlot;
+import io.lumine.mythic.lib.player.PlayerMetadata;
+
+/**
+ * These weapon types need to be adapted to
+ */
+@Deprecated
+public interface LegacyWeapon {
+
+ @Deprecated
+ boolean canAttack(boolean rightClick, EquipmentSlot slot);
+
+ @Deprecated
+ void applyAttackEffect(PlayerMetadata stats, EquipmentSlot slot);
+}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Lute.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Lute.java
index dccaf816..5d6f756d 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Lute.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Lute.java
@@ -8,6 +8,8 @@ import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.version.VersionSound;
import net.Indyuce.mmoitems.MMOItems;
+import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
+import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.api.util.SoundReader;
import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect;
import net.Indyuce.mmoitems.stat.data.ProjectileParticlesData;
@@ -23,14 +25,20 @@ import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.List;
-public class Lute extends UntargetedWeapon {
+@Deprecated
+public class Lute extends Weapon implements LegacyWeapon {
+ @Deprecated
public Lute(Player player, NBTItem item) {
- super(player, item, UntargetedWeaponType.RIGHT_CLICK);
+ super(player, item);
+ }
+
+ public Lute(PlayerData player, NBTItem item) {
+ super(player, item);
}
@Override
- public boolean canAttack(EquipmentSlot slot) {
- return true;
+ public boolean canAttack(boolean rightClick, EquipmentSlot slot) {
+ return rightClick;
}
@Override
@@ -40,8 +48,7 @@ public class Lute extends UntargetedWeapon {
final Vector weight = new Vector(0, -.003 * stats.getStat("NOTE_WEIGHT"), 0);
final @Nullable LuteAttackEffect effect = LuteAttackEffect.get(getNBTItem());
- @Deprecated
- final SoundReader sound = new SoundReader(getNBTItem().getString("MMOITEMS_LUTE_ATTACK_SOUND"), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound());
+ @Deprecated final SoundReader sound = new SoundReader(getNBTItem().getString("MMOITEMS_LUTE_ATTACK_SOUND"), VersionSound.BLOCK_NOTE_BLOCK_BELL.toSound());
final @NotNull ProjectileParticlesData projParticle = getNBTItem().hasTag("MMOITEMS_PROJECTILE_PARTICLES") ?
new ProjectileParticlesData(getNBTItem().getString("MMOITEMS_PROJECTILE_PARTICLES")) : ProjectileParticlesData.DEFAULT;
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Musket.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Musket.java
index e1eb6a59..3503a757 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Musket.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Musket.java
@@ -7,21 +7,28 @@ import io.lumine.mythic.lib.comp.interaction.InteractionType;
import io.lumine.mythic.lib.damage.DamageType;
import io.lumine.mythic.lib.player.PlayerMetadata;
import io.lumine.mythic.lib.util.RayTrace;
-import net.Indyuce.mmoitems.ItemStats;
import net.Indyuce.mmoitems.MMOItems;
+import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
+import net.Indyuce.mmoitems.api.player.PlayerData;
import org.bukkit.Color;
import org.bukkit.Location;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
-public class Musket extends UntargetedWeapon {
+@Deprecated
+public class Musket extends Weapon implements LegacyWeapon {
+ @Deprecated
public Musket(Player player, NBTItem item) {
- super(player, item, UntargetedWeaponType.RIGHT_CLICK);
+ super(player, item);
+ }
+
+ public Musket(PlayerData player, NBTItem item) {
+ super(player, item);
}
@Override
- public boolean canAttack(EquipmentSlot slot) {
- return true;
+ public boolean canAttack(boolean rightClick, EquipmentSlot slot) {
+ return rightClick;
}
@Override
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Staff.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Staff.java
deleted file mode 100644
index 876c4cdf..00000000
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Staff.java
+++ /dev/null
@@ -1,72 +0,0 @@
-package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
-
-import io.lumine.mythic.lib.UtilityMethods;
-import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.player.EquipmentSlot;
-import io.lumine.mythic.lib.comp.interaction.InteractionType;
-import io.lumine.mythic.lib.damage.DamageType;
-import io.lumine.mythic.lib.player.PlayerMetadata;
-import io.lumine.mythic.lib.util.RayTrace;
-import io.lumine.mythic.lib.version.VersionSound;
-import net.Indyuce.mmoitems.ItemStats;
-import net.Indyuce.mmoitems.MMOItems;
-import net.Indyuce.mmoitems.api.player.PlayerData.CooldownType;
-import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
-import org.bukkit.EntityEffect;
-import org.bukkit.Particle;
-import org.bukkit.Sound;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Player;
-import org.bukkit.util.Vector;
-
-public class Staff extends UntargetedWeapon {
- public Staff(Player player, NBTItem item) {
- super(player, item, UntargetedWeaponType.LEFT_CLICK);
- }
-
- @Override
- public boolean canAttack(EquipmentSlot slot) {
- return true;
- }
-
- @Override
- public void applyAttackEffect(PlayerMetadata stats, EquipmentSlot slot) {
-
- double attackDamage = requireNonZero(stats.getStat("ATTACK_DAMAGE"), 1);
- double range = requireNonZero(stats.getStat("RANGE"), MMOItems.plugin.getConfig().getDouble("default.range"));
-
- StaffSpirit spirit = StaffSpirit.get(getNBTItem());
- if (spirit != null) {
- spirit.getAttack().handle(stats, attackDamage, getNBTItem(), slot, range);
- return;
- }
-
- RayTrace trace = new RayTrace(stats.getPlayer(), slot, range, entity -> UtilityMethods.canTarget(stats.getPlayer(), entity, InteractionType.OFFENSE_ACTION));
- if (trace.hasHit())
- stats.attack(trace.getHit(), attackDamage, DamageType.WEAPON, DamageType.MAGIC, DamageType.PROJECTILE);
- trace.draw(.5, tick -> tick.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, tick, 0, .1, .1, .1, 0));
- getPlayer().getWorld().playSound(getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_TWINKLE.toSound(), 2, 2);
-
- }
-
- public void specialAttack(LivingEntity target) {
- if (!MMOItems.plugin.getConfig().getBoolean("item-ability.staff.enabled"))
- return;
-
- if (!checkWeaponCosts(CooldownType.SPECIAL_ATTACK))
- return;
-
- applyWeaponCosts(MMOItems.plugin.getConfig().getDouble("item-ability.staff.cooldown"), CooldownType.SPECIAL_ATTACK);
- double power = MMOItems.plugin.getConfig().getDouble("item-ability.staff.power");
-
- try {
- Vector vec = target.getLocation().toVector().subtract(getPlayer().getLocation().toVector()).setY(0).normalize().multiply(1.75 * power).setY(.65 * power);
- target.getWorld().spawnParticle(Particle.EXPLOSION_LARGE, target.getLocation().add(0, 1, 0), 0);
- target.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, target.getLocation().add(0, 1, 0), 16, 0, 0, 0, .1);
- target.setVelocity(vec);
- target.playEffect(EntityEffect.HURT);
- target.getWorld().playSound(target.getLocation(), Sound.BLOCK_ANVIL_LAND, 1, 2);
- } catch (IllegalArgumentException ignored) {
- }
- }
-}
\ No newline at end of file
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeapon.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeapon.java
deleted file mode 100644
index 36bd3ca1..00000000
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeapon.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
-
-import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.player.EquipmentSlot;
-import io.lumine.mythic.lib.player.PlayerMetadata;
-import net.Indyuce.mmoitems.MMOItems;
-import net.Indyuce.mmoitems.api.event.item.UntargetedWeaponUseEvent;
-import net.Indyuce.mmoitems.api.interaction.util.UntargetedDurabilityItem;
-import net.Indyuce.mmoitems.api.interaction.weapon.Weapon;
-import net.Indyuce.mmoitems.api.player.PlayerData;
-import org.bukkit.Bukkit;
-import org.bukkit.entity.Player;
-
-public abstract class UntargetedWeapon extends Weapon {
- protected final UntargetedWeaponType weaponType;
-
- public UntargetedWeapon(Player player, NBTItem item, UntargetedWeaponType weaponType) {
- super(player, item);
-
- this.weaponType = weaponType;
- }
-
- /**
- * Called when the player interacts with the item. This method is used to
- * apply durability and cast the weapon attack
- *
- * @param slot Slot being interacted with
- * @implNote Since MI 6.7.3 this method handles custom durability, cooldown
- * checks and player stat snapshots.
- */
- public void handleTargetFreeAttack(EquipmentSlot slot) {
- if (!canAttack(slot))
- return;
-
- // Check for durability
- UntargetedDurabilityItem durItem = new UntargetedDurabilityItem(getPlayer(), getNBTItem(), slot);
- if (durItem.isBroken())
- return;
-
- // Apply weapon mana/stamina costs and cooldown
- PlayerMetadata stats = getPlayerData().getStats().newTemporary(slot);
- if (!checkWeaponCosts(PlayerData.CooldownType.BASIC_ATTACK))
- return;
-
- // Check for Bukkit event
- UntargetedWeaponUseEvent called = new UntargetedWeaponUseEvent(playerData, this);
- Bukkit.getPluginManager().callEvent(called);
- if (called.isCancelled())
- return;
-
- // Apply weapon costs
- double attackDelay = 1 / requireNonZero(stats.getStat("ATTACK_SPEED"), MMOItems.plugin.getConfig().getDouble("default.attack-speed"));
- applyWeaponCosts(attackDelay, PlayerData.CooldownType.BASIC_ATTACK);
-
- // Specific weapon attack effect
- applyAttackEffect(stats, slot);
-
- // Apply durability loss
- if (durItem.isValid())
- durItem.decreaseDurability(1).inventoryUpdate();
- }
-
- /**
- * Used for instance by the Crossbow item type to apply
- * ammo requirements. This is the first ever condition checked
- * when trying to perform an untargeted attack
- *
- * @param slot Slot used to attack
- * @return Extra attack condition, specific to the untargeted weapon type
- */
- public abstract boolean canAttack(EquipmentSlot slot);
-
- public abstract void applyAttackEffect(PlayerMetadata stats, EquipmentSlot slot);
-
- public UntargetedWeaponType getWeaponType() {
- return weaponType;
- }
-}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeaponType.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeaponType.java
deleted file mode 100644
index 651d0d37..00000000
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/UntargetedWeaponType.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
-
-import org.bukkit.event.block.Action;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * Used to determine if the item must be left or right clicked in order to
- * cast a basic attack. Whips, staffs are left click weapons whereas muskets
- * are right click weapons
- *
- * @author cympe
- */
-public enum UntargetedWeaponType {
- RIGHT_CLICK,
- LEFT_CLICK;
-
- public boolean corresponds(@NotNull Action action) {
- return this == RIGHT_CLICK ?
- action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK :
- action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK;
- }
-}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Whip.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Whip.java
deleted file mode 100644
index 6badb296..00000000
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/Whip.java
+++ /dev/null
@@ -1,38 +0,0 @@
-package net.Indyuce.mmoitems.api.interaction.weapon.untargeted;
-
-import io.lumine.mythic.lib.UtilityMethods;
-import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.player.EquipmentSlot;
-import io.lumine.mythic.lib.comp.interaction.InteractionType;
-import io.lumine.mythic.lib.damage.DamageType;
-import io.lumine.mythic.lib.player.PlayerMetadata;
-import io.lumine.mythic.lib.util.RayTrace;
-import io.lumine.mythic.lib.version.VersionSound;
-import net.Indyuce.mmoitems.ItemStats;
-import net.Indyuce.mmoitems.MMOItems;
-import org.bukkit.Particle;
-import org.bukkit.entity.Player;
-
-public class Whip extends UntargetedWeapon {
- public Whip(Player player, NBTItem item) {
- super(player, item, UntargetedWeaponType.LEFT_CLICK);
- }
-
- @Override
- public boolean canAttack(EquipmentSlot slot) {
- return true;
- }
-
- @Override
- public void applyAttackEffect(PlayerMetadata stats, EquipmentSlot slot) {
-
- double attackDamage = requireNonZero(stats.getStat("ATTACK_DAMAGE"), 7);
- double range = requireNonZero(getNBTItem().getStat(ItemStats.RANGE.getId()), MMOItems.plugin.getConfig().getDouble("default.range"));
-
- RayTrace trace = new RayTrace(getPlayer(), slot, range, entity -> UtilityMethods.canTarget(stats.getPlayer(), entity, InteractionType.OFFENSE_ACTION));
- if (trace.hasHit())
- stats.attack(trace.getHit(), attackDamage, DamageType.WEAPON, DamageType.PROJECTILE, DamageType.PHYSICAL);
- trace.draw(.5, tick -> tick.getWorld().spawnParticle(Particle.CRIT, tick, 0, .1, .1, .1, 0));
- getPlayer().getWorld().playSound(getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 1, 2);
- }
-}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/BruteLuteAttack.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/BruteLuteAttack.java
index 2f2e969f..2f957674 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/BruteLuteAttack.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/BruteLuteAttack.java
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
+@Deprecated
public class BruteLuteAttack implements LuteAttackHandler {
@Override
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/CircularLuteAttack.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/CircularLuteAttack.java
index 2a3aa4cd..bab9288a 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/CircularLuteAttack.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/CircularLuteAttack.java
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
+@Deprecated
public class CircularLuteAttack implements LuteAttackHandler {
@Override
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/LuteAttackHandler.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/LuteAttackHandler.java
index 5d84ce00..61fd2dcb 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/LuteAttackHandler.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/LuteAttackHandler.java
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.Random;
+@Deprecated
public interface LuteAttackHandler {
static final Random RANDOM = new Random();
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SimpleLuteAttack.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SimpleLuteAttack.java
index cf4e80f2..33432942 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SimpleLuteAttack.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SimpleLuteAttack.java
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
+@Deprecated
public class SimpleLuteAttack implements LuteAttackHandler {
@Override
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SlashLuteAttack.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SlashLuteAttack.java
index 30961ccb..a9cf0441 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SlashLuteAttack.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/SlashLuteAttack.java
@@ -16,6 +16,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.jetbrains.annotations.NotNull;
+@Deprecated
public class SlashLuteAttack implements LuteAttackHandler {
@Override
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/WaveLuteAttack.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/WaveLuteAttack.java
index c14862c1..61968a96 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/WaveLuteAttack.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/lute/WaveLuteAttack.java
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
import java.util.List;
+@Deprecated
public class WaveLuteAttack implements LuteAttackHandler {
@Override
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/staff/LightningSpirit.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/staff/LightningSpirit.java
deleted file mode 100644
index 3aa546b5..00000000
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/staff/LightningSpirit.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.staff;
-
-import io.lumine.mythic.lib.UtilityMethods;
-import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.player.EquipmentSlot;
-import io.lumine.mythic.lib.comp.interaction.InteractionType;
-import io.lumine.mythic.lib.damage.DamageType;
-import io.lumine.mythic.lib.player.PlayerMetadata;
-import io.lumine.mythic.lib.util.RayTrace;
-import io.lumine.mythic.lib.version.VersionSound;
-import org.bukkit.Particle;
-
-public class LightningSpirit implements StaffAttackHandler {
-
- @Override
- public void handle(PlayerMetadata caster, double damage, NBTItem nbt, EquipmentSlot slot, double range) {
- caster.getPlayer().getWorld().playSound(caster.getPlayer().getLocation(), VersionSound.ENTITY_FIREWORK_ROCKET_BLAST.toSound(), 2, 2);
-
- RayTrace trace = new RayTrace(caster.getPlayer(), slot, range, entity -> UtilityMethods.canTarget(caster.getPlayer(), entity, InteractionType.OFFENSE_ACTION));
-
- if (trace.hasHit())
- caster.attack(trace.getHit(), damage, DamageType.WEAPON, DamageType.MAGIC, DamageType.PROJECTILE);
- trace.draw(.5, loc1 -> loc1.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, loc1, 0));
- }
-}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/staff/ManaSpirit.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/staff/ManaSpirit.java
deleted file mode 100644
index 57873c67..00000000
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/api/interaction/weapon/untargeted/staff/ManaSpirit.java
+++ /dev/null
@@ -1,62 +0,0 @@
-package net.Indyuce.mmoitems.api.interaction.weapon.untargeted.staff;
-
-import io.lumine.mythic.lib.UtilityMethods;
-import io.lumine.mythic.lib.api.item.NBTItem;
-import io.lumine.mythic.lib.api.player.EquipmentSlot;
-import io.lumine.mythic.lib.comp.interaction.InteractionType;
-import io.lumine.mythic.lib.damage.DamageType;
-import io.lumine.mythic.lib.player.PlayerMetadata;
-import net.Indyuce.mmoitems.MMOItems;
-import net.Indyuce.mmoitems.util.MMOUtils;
-import org.bukkit.Color;
-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.scheduler.BukkitRunnable;
-import org.bukkit.util.Vector;
-
-import java.util.List;
-
-public class ManaSpirit implements StaffAttackHandler {
-
- @Override
- public void handle(PlayerMetadata caster, double damage, NBTItem nbt, EquipmentSlot slot, double range) {
- new BukkitRunnable() {
- final Vector vec = caster.getPlayer().getEyeLocation().getDirection().multiply(.4);
- final Location loc = caster.getPlayer().getEyeLocation();
- int ti = 0;
- final double r = .2;
-
- public void run() {
- if (ti++ > range)
- cancel();
-
- if (ti % 2 == 0)
- loc.getWorld().playSound(loc, Sound.BLOCK_SNOW_BREAK, 2, 2);
- List
- * Fixing commit 4aec1433
+ * This handler registers arrows from custom MMOItems bows
+ *
+ * @see {@link EntityManager#onHitEffects(PlayerAttackEvent)}
*/
@EventHandler
public void handleCustomBows(EntityShootBowEvent event) {
- if (!(event.getProjectile() instanceof AbstractArrow) || !(event.getEntity() instanceof Player))
- return;
+ if (!(event.getProjectile() instanceof AbstractArrow) || !(event.getEntity() instanceof Player)) return;
final NBTItem item = NBTItem.get(event.getBow());
final Type type = Type.get(item.getType());
@@ -284,8 +249,7 @@ public class ItemUse implements Listener {
// Apply arrow velocity
final double arrowVelocity = projData.getShooter().getStat("ARROW_VELOCITY");
- if (arrowVelocity > 0)
- arrow.setVelocity(arrow.getVelocity().multiply(arrowVelocity));
+ if (arrowVelocity > 0) arrow.setVelocity(arrow.getVelocity().multiply(arrowVelocity));
}
}
@@ -296,8 +260,7 @@ public class ItemUse implements Listener {
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void handleVanillaEatenConsumables(PlayerItemConsumeEvent event) {
NBTItem item = MythicLib.plugin.getVersion().getWrapper().getNBTItem(event.getItem());
- if (!item.hasType())
- return;
+ if (!item.hasType()) return;
Player player = event.getPlayer();
UseItem useItem = UseItem.getItem(player, item, item.getType());
@@ -310,9 +273,7 @@ public class ItemUse implements Listener {
if (useItem.getPlayerData().getMMOPlayerData().getCooldownMap().isOnCooldown(useItem.getMMOItem())) {
final double cd = useItem.getPlayerData().getMMOPlayerData().getCooldownMap().getCooldown(useItem.getMMOItem());
- Message.ITEM_ON_COOLDOWN
- .format(ChatColor.RED, "#left#", MythicLib.plugin.getMMOConfig().decimal.format(cd), "#s#", cd >= 2 ? "s" : "")
- .send(player);
+ Message.ITEM_ON_COOLDOWN.format(ChatColor.RED, "#left#", MythicLib.plugin.getMMOConfig().decimal.format(cd), "#s#", cd >= 2 ? "s" : "").send(player);
event.setCancelled(true);
return;
}
@@ -326,8 +287,7 @@ public class ItemUse implements Listener {
}
// Item is not consumed but its effects are applied anyways
- if (result == Consumable.ConsumableConsumeResult.NOT_CONSUME)
- event.setCancelled(true);
+ if (result == Consumable.ConsumableConsumeResult.NOT_CONSUME) event.setCancelled(true);
useItem.getPlayerData().getMMOPlayerData().getCooldownMap().applyCooldown(useItem.getMMOItem(), useItem.getNBTItem().getStat("ITEM_COOLDOWN"));
useItem.executeCommands();
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/ConfigManager.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/ConfigManager.java
index a0c4f872..be614881 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/ConfigManager.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/ConfigManager.java
@@ -11,7 +11,7 @@ import net.Indyuce.mmoitems.api.util.NumericStatFormula;
import net.Indyuce.mmoitems.api.util.message.Message;
import net.Indyuce.mmoitems.stat.GemUpgradeScaling;
import net.Indyuce.mmoitems.stat.LuteAttackEffectStat.LuteAttackEffect;
-import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
+//import net.Indyuce.mmoitems.stat.StaffSpiritStat.StaffSpirit;
import net.Indyuce.mmoitems.util.LanguageFile;
import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
@@ -138,9 +138,9 @@ public class ConfigManager implements Reloadable {
// Staff spirits
final LanguageFile attackEffects = new LanguageFile("attack-effects");
- for (StaffSpirit sp : StaffSpirit.values())
+ /* for (StaffSpirit sp : StaffSpirit.values())
sp.setName(attackEffects.computeTranslation("staff-spirit." + sp.name().toLowerCase().replace("_", "-"),
- () -> UtilityMethods.caseOnWords(sp.name().toLowerCase().replace("_", " "))));
+ () -> UtilityMethods.caseOnWords(sp.name().toLowerCase().replace("_", " "))));*/
// Lute attack effects
for (LuteAttackEffect eff : LuteAttackEffect.values())
@@ -262,11 +262,11 @@ public class ConfigManager implements Reloadable {
public String getLuteAttackEffectName(LuteAttackEffect effect) {
return effect.getName();
}
-
+/*
@Deprecated
public String getStaffSpiritName(StaffSpirit spirit) {
return spirit.getName();
- }
+ }*/
/**
* @deprecated See {@link net.Indyuce.mmoitems.api.item.util.LoreUpdate}
diff --git a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java
index b2cbbec6..65610423 100644
--- a/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java
+++ b/MMOItems-API/src/main/java/net/Indyuce/mmoitems/manager/TypeManager.java
@@ -5,6 +5,8 @@ import net.Indyuce.mmoitems.api.ConfigFile;
import net.Indyuce.mmoitems.api.Type;
import net.Indyuce.mmoitems.manager.ConfigManager.DefaultFile;
import org.apache.commons.lang.Validate;
+import org.bukkit.configuration.ConfigurationSection;
+import org.bukkit.configuration.file.FileConfiguration;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -13,100 +15,117 @@ import java.lang.reflect.Modifier;
import java.util.*;
import java.util.logging.Level;
-public class TypeManager implements Reloadable {
- private final Map