Support for MM 5.0.1

This commit is contained in:
Indyuce 2022-03-12 14:06:16 +01:00
parent 2f5b4eb8cb
commit d9dfa21592
8 changed files with 284 additions and 219 deletions

View File

@ -193,8 +193,8 @@
<dependency>
<groupId>io.lumine</groupId>
<artifactId>MythicMobs-Dist</artifactId>
<version>5.0.0-SNAPSHOT</version>
<artifactId>Mythic-Dist</artifactId>
<version>5.0.1</version>
<scope>provided</scope>
</dependency>

View File

@ -1,9 +1,10 @@
package net.Indyuce.mmoitems.comp.mythicmobs;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import org.bukkit.Bukkit;
import org.bukkit.Color;
import org.bukkit.Particle;
@ -16,11 +17,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.ItemTier;
import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.api.item.NBTItem;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
public class LootsplosionListener implements Listener {
private static final Random random = new Random();

View File

@ -1,11 +1,10 @@
package net.Indyuce.mmoitems.comp.mythicmobs;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMechanicLoadEvent;
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent;
import io.lumine.xikage.mythicmobs.mobs.MythicMob;
import io.lumine.mythic.api.mobs.MythicMob;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.bukkit.events.MythicMechanicLoadEvent;
import io.lumine.mythic.bukkit.events.MythicReloadedEvent;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.item.mmoitem.MMOItem;
import net.Indyuce.mmoitems.api.player.PlayerData;
import net.Indyuce.mmoitems.comp.mythicmobs.mechanics.MMOItemsArrowVolleyMechanic;
import net.Indyuce.mmoitems.comp.mythicmobs.mechanics.MMOItemsOnShootAura;
@ -16,7 +15,10 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import java.util.*;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class MythicMobsCompatibility implements Listener {
@ -39,12 +41,13 @@ public class MythicMobsCompatibility implements Listener {
// Switch Mechanic ig
switch (event.getMechanicName().toLowerCase()) {
case "mmoitemsvolley":
event.register(new MMOItemsArrowVolleyMechanic(event.getContainer().getConfigLine(), event.getConfig()));
event.register(new MMOItemsArrowVolleyMechanic(event.getContainer().getManager(), event.getContainer().getConfigLine(), event.getConfig()));
break;
case "onmmoitemuse":
event.register(new MMOItemsOnShootAura(event.getContainer().getConfigLine(), event.getConfig()));
event.register(new MMOItemsOnShootAura(event.getContainer().getManager(), event.getContainer().getConfigLine(), event.getConfig()));
break;
default:
break;
default: break;
}
}
@ -61,15 +64,16 @@ public class MythicMobsCompatibility implements Listener {
// Reload the abilities of online players...
for (Player p : Bukkit.getOnlinePlayers()) {
PlayerData data = PlayerData.get(p);
data.updateInventory(); }
data.updateInventory();
}
}
private Set<String> getFactions() {
Set<String> allFactions = new HashSet<>();
// Collects all mythic mobs + edited vanilla mobs in mythic mobs.
List<MythicMob> mobs = new ArrayList<>(MythicMobs.inst().getMobManager().getVanillaTypes());
mobs.addAll(MythicMobs.inst().getMobManager().getMobTypes());
List<MythicMob> mobs = new ArrayList<>(MythicBukkit.inst().getMobManager().getVanillaTypes());
mobs.addAll(MythicBukkit.inst().getMobManager().getMobTypes());
// Adds their faction to the set if it is set.
for (MythicMob mob : mobs)

View File

@ -1,9 +1,9 @@
package net.Indyuce.mmoitems.comp.mythicmobs.crafting;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.core.items.MythicItem;
import io.lumine.mythic.lib.api.MMOLineConfig;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
import io.lumine.xikage.mythicmobs.items.MythicItem;
import net.Indyuce.mmoitems.api.crafting.ingredient.Ingredient;
import net.Indyuce.mmoitems.api.player.RPGPlayer;
import org.apache.commons.lang.Validate;
@ -28,7 +28,7 @@ public class MythicItemIngredient extends Ingredient<MythicItemPlayerIngredient>
super("mythicitem", config);
config.validate("item");
Optional<MythicItem> mmitem = MythicMobs.inst().getItemManager().getItem(config.getString("item"));
Optional<MythicItem> mmitem = MythicBukkit.inst().getItemManager().getItem(config.getString("item"));
Validate.isTrue(mmitem.isPresent(), "Could not find MM Item with ID '" + config.getString("item") + "'");
display = config.contains("display") ? config.getString("display") : mmitem.get().getDisplayName();

View File

@ -1,10 +1,10 @@
package net.Indyuce.mmoitems.comp.mythicmobs.crafting;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.skills.Skill;
import io.lumine.mythic.api.skills.Skill;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.lib.api.MMOLineConfig;
import net.Indyuce.mmoitems.api.crafting.trigger.Trigger;
import net.Indyuce.mmoitems.api.player.PlayerData;
import io.lumine.mythic.lib.api.MMOLineConfig;
import org.apache.commons.lang.Validate;
import org.bukkit.entity.Entity;
@ -13,7 +13,6 @@ import java.util.List;
import java.util.Optional;
public class MythicMobsSkillTrigger extends Trigger {
private final Skill skill;
public MythicMobsSkillTrigger(MMOLineConfig config) {
@ -21,16 +20,16 @@ public class MythicMobsSkillTrigger extends Trigger {
config.validate("id");
String id = config.getString("id");
Optional<Skill> opt = MythicMobs.inst().getSkillManager().getSkill(id);
Optional<Skill> opt = MythicBukkit.inst().getSkillManager().getSkill(id);
Validate.isTrue(opt.isPresent(), "Could not find MM skill " + id);
skill = opt.get();
}
@Override
public void whenCrafting(PlayerData data) {
if(!data.isOnline()) return;
if (!data.isOnline()) return;
List<Entity> targets = new ArrayList<>();
targets.add(data.getPlayer());
MythicMobs.inst().getAPIHelper().castSkill(data.getPlayer(), this.skill.getInternalName(), data.getPlayer(), data.getPlayer().getEyeLocation(), targets, null, 1);
MythicBukkit.inst().getAPIHelper().castSkill(data.getPlayer(), this.skill.getInternalName(), data.getPlayer(), data.getPlayer().getEyeLocation(), targets, null, 1);
}
}

View File

@ -1,16 +1,18 @@
package net.Indyuce.mmoitems.comp.mythicmobs.mechanics;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.adapters.AbstractLocation;
import io.lumine.mythic.api.adapters.SkillAdapter;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.skills.*;
import io.lumine.mythic.api.skills.placeholders.PlaceholderDouble;
import io.lumine.mythic.api.skills.placeholders.PlaceholderFloat;
import io.lumine.mythic.api.skills.placeholders.PlaceholderInt;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.core.skills.SkillExecutor;
import io.lumine.mythic.core.skills.SkillMechanic;
import io.lumine.mythic.lib.api.crafting.uimanager.ProvidedUIFilter;
import io.lumine.mythic.lib.api.crafting.uimanager.UIFilterManager;
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
import io.lumine.xikage.mythicmobs.adapters.AbstractLocation;
import io.lumine.xikage.mythicmobs.adapters.SkillAdapter;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
import io.lumine.xikage.mythicmobs.skills.*;
import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderDouble;
import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderFloat;
import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderInt;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.listener.ItemUse;
import org.bukkit.Bukkit;
@ -37,34 +39,38 @@ import java.util.ArrayList;
*/
public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITargetedEntitySkill, ITargetedLocationSkill {
@NotNull PlaceholderInt amount, spread, fireTicks, removeDelay;
@NotNull PlaceholderFloat velocity, scale;
@NotNull PlaceholderDouble xOffset, yOffset, zOffset, fOffset, sOffset;
@NotNull
PlaceholderInt amount, spread, fireTicks, removeDelay;
@NotNull
PlaceholderFloat velocity, scale;
@NotNull
PlaceholderDouble xOffset, yOffset, zOffset, fOffset, sOffset;
@Nullable ItemStack arrowItem;
@Nullable
ItemStack arrowItem;
boolean fullEvent;
boolean scalePerArrow;
boolean fromOrigin;
boolean allowPickup;
public MMOItemsArrowVolleyMechanic(String line, MythicLineConfig mlc) {
super(line, mlc);
public MMOItemsArrowVolleyMechanic(SkillExecutor manager, String line, MythicLineConfig mlc) {
super(manager, line, mlc);
threadSafetyLevel = ThreadSafetyLevel.SYNC_ONLY;
amount = mlc.getPlaceholderInteger(new String[] {"amount", "arrows", "a"}, 20);
spread = mlc.getPlaceholderInteger(new String[] {"spread", "s"}, 45);
fireTicks = mlc.getPlaceholderInteger(new String[] {"fireticks", "ft", "f"}, 0);
removeDelay = mlc.getPlaceholderInteger(new String[] {"removedelay", "rd", "r"}, 200);
velocity = mlc.getPlaceholderFloat(new String[] {"velocity", "v"}, 20);
scale = mlc.getPlaceholderFloat(new String[] {"statsscale", "ss"}, 1);
amount = mlc.getPlaceholderInteger(new String[]{"amount", "arrows", "a"}, 20);
spread = mlc.getPlaceholderInteger(new String[]{"spread", "s"}, 45);
fireTicks = mlc.getPlaceholderInteger(new String[]{"fireticks", "ft", "f"}, 0);
removeDelay = mlc.getPlaceholderInteger(new String[]{"removedelay", "rd", "r"}, 200);
velocity = mlc.getPlaceholderFloat(new String[]{"velocity", "v"}, 20);
scale = mlc.getPlaceholderFloat(new String[]{"statsscale", "ss"}, 1);
fullEvent = mlc.getBoolean(new String[] {"fullevent", "fe"}, false);
scalePerArrow = mlc.getBoolean(new String[] {"scaleperarrow", "spa"}, false);
fromOrigin = mlc.getBoolean(new String[] {"fromorigin", "fo"}, false);
allowPickup = mlc.getBoolean(new String[] {"allowpickup", "ap"}, false);
fullEvent = mlc.getBoolean(new String[]{"fullevent", "fe"}, false);
scalePerArrow = mlc.getBoolean(new String[]{"scaleperarrow", "spa"}, false);
fromOrigin = mlc.getBoolean(new String[]{"fromorigin", "fo"}, false);
allowPickup = mlc.getBoolean(new String[]{"allowpickup", "ap"}, false);
//region Get Arrow Item
String itemFilter = mlc.getString(new String[] {"arrowitem", "item", "ai"}, null);
String itemFilter = mlc.getString(new String[]{"arrowitem", "item", "ai"}, null);
//DBG//MMOItems.log("Found In Config " + itemFilter);
if (itemFilter != null) {
//DBG//FriendlyFeedbackProvider ffp = new FriendlyFeedbackProvider(FFPMMOItems.get());
@ -85,16 +91,16 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
//endregion
// Offsets
xOffset = mlc.getPlaceholderDouble(new String[] {"startxoffset", "sxo"}, 0);
yOffset = mlc.getPlaceholderDouble(new String[] {"startyoffset", "syo"}, 3);
zOffset = mlc.getPlaceholderDouble(new String[] {"startzoffset", "szo"}, 0);
fOffset = mlc.getPlaceholderDouble(new String[] {"startfoffset", "sfo"}, 0);
sOffset = mlc.getPlaceholderDouble(new String[] {"startsoffset", "sso"}, 0);
xOffset = mlc.getPlaceholderDouble(new String[]{"startxoffset", "sxo"}, 0);
yOffset = mlc.getPlaceholderDouble(new String[]{"startyoffset", "syo"}, 3);
zOffset = mlc.getPlaceholderDouble(new String[]{"startzoffset", "szo"}, 0);
fOffset = mlc.getPlaceholderDouble(new String[]{"startfoffset", "sfo"}, 0);
sOffset = mlc.getPlaceholderDouble(new String[]{"startsoffset", "sso"}, 0);
}
@Override
public boolean castAtLocation(SkillMetadata data, AbstractLocation target) {
public SkillResult castAtLocation(SkillMetadata data, AbstractLocation target) {
// Caster must be a player
if (data.getCaster().getEntity().getBukkitEntity() instanceof Player) {
@ -107,34 +113,38 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
// Run as normal mythicmobs arrow volley
SkillAdapter.get().executeVolley(data.getCaster(), target, amount.get(data), velocity.get(data) * 0.1F, spread.get(data), fireTicks.get(data), removeDelay.get(data));
}
return true;
return SkillResult.SUCCESS;
}
@Override
public boolean castAtEntity(SkillMetadata data, AbstractEntity target) {
public SkillResult castAtEntity(SkillMetadata data, AbstractEntity target) {
// Caster must be a player
if (data.getCaster().getEntity().getBukkitEntity() instanceof Player) {
// MMOItems Volley!
executeMIVolley(data.getCaster(), data, target.getLocation(), amount.get(data,target), velocity.get(data) * 0.1F, spread.get(data), fireTicks.get(data), removeDelay.get(data), scale);
executeMIVolley(data.getCaster(), data, target.getLocation(), amount.get(data, target), velocity.get(data) * 0.1F, spread.get(data), fireTicks.get(data), removeDelay.get(data), scale);
} else {
// Run as normal mythicmobs arrow volley
SkillAdapter.get().executeVolley(data.getCaster(), target.getLocation(), amount.get(data,target), velocity.get(data) * 0.1F, spread.get(data), fireTicks.get(data), removeDelay.get(data));
SkillAdapter.get().executeVolley(data.getCaster(), target.getLocation(), amount.get(data, target), velocity.get(data) * 0.1F, spread.get(data), fireTicks.get(data), removeDelay.get(data));
}
return true;
return SkillResult.SUCCESS;
}
public void executeMIVolley(@NotNull SkillCaster caster, @NotNull SkillMetadata data, @NotNull AbstractLocation t, int amount, float velocity, float spread, int fireTicks, int removeDelay, @NotNull PlaceholderFloat statsMultiplier) {
// Cancel infinite loops
if (syncEventBlock) { return; }
if (syncEventBlock) {
return;
}
// Skill caster MUST be a player
if (!(caster.getEntity().getBukkitEntity() instanceof Player)) { return; }
if (!(caster.getEntity().getBukkitEntity() instanceof Player)) {
return;
}
Player player = (Player) caster.getEntity().getBukkitEntity();
// Target yeah
@ -170,11 +180,14 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
for (int i = 0; i < amount; i++) {
// Spawn Arrow
Arrow a = player.getWorld().spawnArrow(spawn, v, velocity, (spread/10.0F));
Arrow a = player.getWorld().spawnArrow(spawn, v, velocity, (spread / 10.0F));
a.setVelocity(a.getVelocity());
if (allowPickup) { a.setPickupStatus(AbstractArrow.PickupStatus.ALLOWED); }
else { a.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED); }
if (allowPickup) {
a.setPickupStatus(AbstractArrow.PickupStatus.ALLOWED);
} else {
a.setPickupStatus(AbstractArrow.PickupStatus.DISALLOWED);
}
// Identify arrow as the player's
a.setShooter(player);
@ -182,25 +195,40 @@ public class MMOItemsArrowVolleyMechanic extends SkillMechanic implements ITarge
// Run Event
syncEventBlock = true;
EntityShootBowEvent shootBowEvent = new EntityShootBowEvent(player, bowItem, localArrowItem, a, EquipmentSlot.HAND, arrowForce, false);
if (fullEvent) { Bukkit.getPluginManager().callEvent(shootBowEvent); } else { use.handleCustomBows(shootBowEvent); }
if (fullEvent) {
Bukkit.getPluginManager().callEvent(shootBowEvent);
} else {
use.handleCustomBows(shootBowEvent);
}
syncEventBlock = false;
// Cancelled???
if (shootBowEvent.isCancelled()) { a.remove(); continue; }
if (shootBowEvent.isCancelled()) {
a.remove();
continue;
}
// Set on fire I guess
if(fireTicks > 0) { a.setFireTicks(fireTicks); }
if (fireTicks > 0) {
a.setFireTicks(fireTicks);
}
// Add to list
arrowList.add(a);
// Recalculate
if (scalePerArrow) { arrowForce = statsMultiplier.get(data); }
if (scalePerArrow) {
arrowForce = statsMultiplier.get(data);
}
}
// Remove after delay
Bukkit.getScheduler().scheduleSyncDelayedTask(MMOItems.plugin, () -> {
for (Arrow a : arrowList) { a.remove(); }arrowList.clear(); }, removeDelay);
for (Arrow a : arrowList) {
a.remove();
}
arrowList.clear();
}, removeDelay);
}
static boolean syncEventBlock;

View File

@ -1,14 +1,15 @@
package net.Indyuce.mmoitems.comp.mythicmobs.mechanics;
import io.lumine.xikage.mythicmobs.MythicMobs;
import io.lumine.xikage.mythicmobs.adapters.AbstractEntity;
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter;
import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
import io.lumine.xikage.mythicmobs.mobs.GenericCaster;
import io.lumine.xikage.mythicmobs.skills.*;
import io.lumine.xikage.mythicmobs.skills.auras.Aura;
import io.lumine.xikage.mythicmobs.skills.placeholders.parsers.PlaceholderString;
import io.lumine.xikage.mythicmobs.utils.Events;
import io.lumine.mythic.api.adapters.AbstractEntity;
import io.lumine.mythic.api.config.MythicLineConfig;
import io.lumine.mythic.api.mobs.GenericCaster;
import io.lumine.mythic.api.skills.*;
import io.lumine.mythic.api.skills.placeholders.PlaceholderString;
import io.lumine.mythic.bukkit.BukkitAdapter;
import io.lumine.mythic.bukkit.MythicBukkit;
import io.lumine.mythic.core.skills.SkillExecutor;
import io.lumine.mythic.core.skills.auras.Aura;
import io.lumine.mythic.utils.Events;
import net.Indyuce.mmoitems.MMOItems;
import net.Indyuce.mmoitems.api.event.item.SpecialWeaponAttackEvent;
import net.Indyuce.mmoitems.api.interaction.weapon.Gauntlet;
@ -24,22 +25,26 @@ import java.util.Optional;
/**
* Sure there is the 'onShoot' aura for bows, but what about
* musket and crossbow and lute and...?
*
* <p>
* This Aura will cover all of those.
*
* @author Gunging
*/
public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
@NotNull PlaceholderString skillName;
@NotNull String weaponTypes;
@Nullable Skill metaskill;
@NotNull
PlaceholderString skillName;
@NotNull
String weaponTypes;
@Nullable
Skill metaskill;
boolean cancelEvent;
boolean forceAsPower;
@NotNull final ArrayList<UseItemTypes> auraWeapons = new ArrayList<>();
@NotNull
final ArrayList<UseItemTypes> auraWeapons = new ArrayList<>();
public MMOItemsOnShootAura(String skill, MythicLineConfig mlc) {
super(skill, mlc);
public MMOItemsOnShootAura(SkillExecutor manager, String skill, MythicLineConfig mlc) {
super(manager, skill, mlc);
skillName = mlc.getPlaceholderString(new String[]{"skill", "s", "ondamagedskill", "ondamaged", "od", "onhitskill", "onhit", "oh", "meta", "m", "mechanics", "$", "()"}, "skill not found");
weaponTypes = mlc.getString(new String[]{"weapons", "weapon", "w"}, "MUSKET");
metaskill = GetSkill(skillName.get());
@ -47,7 +52,11 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
// Parse weapon types
ArrayList<String> weaponTypesUnparsed = new ArrayList<>();
if (weaponTypes.contains(",")) { weaponTypesUnparsed.addAll(Arrays.asList(weaponTypes.split(","))); } else { weaponTypesUnparsed.add(weaponTypes); }
if (weaponTypes.contains(",")) {
weaponTypesUnparsed.addAll(Arrays.asList(weaponTypes.split(",")));
} else {
weaponTypesUnparsed.add(weaponTypes);
}
for (String weapon : weaponTypesUnparsed) {
// Try to get
@ -59,7 +68,8 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
// Yes
auraWeapons.add(weap);
} catch (IllegalArgumentException ignored) {}
} catch (IllegalArgumentException ignored) {
}
}
// Attempt to fix meta skill
@ -78,16 +88,16 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
}
}
public boolean castAtEntity(SkillMetadata data, AbstractEntity target) {
public SkillResult castAtEntity(SkillMetadata data, AbstractEntity target) {
// Find caster
SkillCaster caster;
// Will be caster of the skill, as a mythicmob
if (MythicMobs.inst().getMobManager().isActiveMob(target)) {
if (MythicBukkit.inst().getMobManager().isActiveMob(target)) {
//SOM//OotilityCeption.Log("\u00a73 * \u00a77Target as ActiveMob");
// Just pull the mythicmob
caster = MythicMobs.inst().getMobManager().getMythicMobInstance(target);
caster = MythicBukkit.inst().getMobManager().getMythicMobInstance(target);
// If its a player or some other non-mythicmob
} else {
@ -98,10 +108,10 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
}
new MMOItemsOnShootAura.Tracker(caster, data, target);
return true;
return SkillResult.SUCCESS;
}
private class Tracker extends AuraTracker implements IParentSkill, Runnable {
private class Tracker extends Aura.AuraTracker implements IParentSkill, Runnable {
public Tracker(SkillCaster caster, SkillMetadata data, AbstractEntity entity) {
super(caster, entity, data);
this.start();
@ -113,14 +123,21 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
//SOM//OotilityCeption.Log("\u00a7cStep 3 \u00a77Subscribe Run: " + getName(event.getEntity()) + "\u00a77 vs " + getName(this.entity.get()) + "\u00a78 ~\u00a7e " + event.getEntity().getUniqueId().equals(this.entity.get().getUniqueId()));
// Player is the one who has the aura applied, right?
if (!event.getPlayer().getUniqueId().equals(this.entity.get().getUniqueId())) { return false; }
if (!event.getPlayer().getUniqueId().equals(this.entity.get().getUniqueId())) {
return false;
}
// All custom weapons fire it if none specified.
if (auraWeapons.size() == 0) { return true; }
if (auraWeapons.size() == 0) {
return true;
}
// Okay go through all weapon types, must match one
for (UseItemTypes weap : auraWeapons) {
if (weap.getInst().isInstance(event.getWeapon())) { return true; } }
if (weap.getInst().isInstance(event.getWeapon())) {
return true;
}
}
// None matched
return false;
@ -131,7 +148,9 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
SkillMetadata meta = this.skillMetadata.deepClone();
// Refresh
if (metaskill == null) { metaskill = GetSkill(skillName.get(meta, meta.getCaster().getEntity())); }
if (metaskill == null) {
metaskill = GetSkill(skillName.get(meta, meta.getCaster().getEntity()));
}
// Target obviously the projectile
AbstractEntity target = BukkitAdapter.adapt(event.getTarget());
@ -142,7 +161,9 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
this.consumeCharge();
if (cancelEvent) { event.setCancelled(true); }
if (cancelEvent) {
event.setCancelled(true);
}
}
}));
@ -150,22 +171,30 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
}
}
@Nullable public static Skill GetSkill(String skillName) {
@Nullable
public static Skill GetSkill(String skillName) {
if (SkillExists(skillName)) {
Optional<Skill> mSkillFk = MythicMobs.inst().getSkillManager().getSkill(skillName);
if (mSkillFk == null) { return null; }
if (mSkillFk.isPresent()) { return mSkillFk.get(); }
Optional<Skill> mSkillFk = MythicBukkit.inst().getSkillManager().getSkill(skillName);
if (mSkillFk == null) {
return null;
}
if (mSkillFk.isPresent()) {
return mSkillFk.get();
}
}
return null;
}
public static boolean SkillExists(String skillName) {
// If null no
if (skillName == null) { return false; }
if (skillName == null) {
return false;
}
Optional<Skill> mSkillFk = MythicMobs.inst().getSkillManager().getSkill(skillName);
Optional<Skill> mSkillFk = MythicBukkit.inst().getSkillManager().getSkill(skillName);
// Is there a skill of that name?
if (mSkillFk.isPresent()) {
@ -202,8 +231,14 @@ public class MMOItemsOnShootAura extends Aura implements ITargetedEntitySkill {
/**
* @return Class to use InstanceOf and identify a weapon.
*/
@NotNull public Class getInst() { return inst; }
@NotNull final Class inst;
@NotNull
public Class getInst() {
return inst;
}
@NotNull
final Class inst;
UseItemTypes(@NotNull Class inst) {
this.inst = inst;
}

View File

@ -1,12 +1,12 @@
package net.Indyuce.mmoitems.comp.mythicmobs.stat;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
import io.lumine.mythic.lib.version.VersionMaterial;
import net.Indyuce.mmoitems.stat.type.DoubleStat;
public class FactionDamage extends DoubleStat {
public FactionDamage(String faction) {
super("FACTION_DAMAGE_" + faction.toUpperCase(), VersionMaterial.RED_DYE.toMaterial(), faction + " Faction Damage", new String[] { "Deals additional damage to mobs", "from the " + faction + " faction in %." }, new String[] { "!block", "all" });
super("FACTION_DAMAGE_" + faction.toUpperCase(), VersionMaterial.RED_DYE.toMaterial(), faction + " Faction Damage", new String[]{"Deals additional damage to mobs", "from the " + faction + " faction in %."}, new String[]{"!block", "all"});
}
}