forked from Upstream/mmocore
!improved mm skill compatibility
This commit is contained in:
parent
d4071f532e
commit
8b85248918
@ -20,7 +20,7 @@ import net.Indyuce.mmocore.comp.flags.DefaultFlags;
|
|||||||
import net.Indyuce.mmocore.comp.flags.FlagPlugin;
|
import net.Indyuce.mmocore.comp.flags.FlagPlugin;
|
||||||
import net.Indyuce.mmocore.comp.flags.ResidenceFlags;
|
import net.Indyuce.mmocore.comp.flags.ResidenceFlags;
|
||||||
import net.Indyuce.mmocore.comp.flags.WorldGuardFlags;
|
import net.Indyuce.mmocore.comp.flags.WorldGuardFlags;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.MythicMobsDrops;
|
import net.Indyuce.mmocore.comp.mythicmobs.MythicHook;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.MythicMobsMMOLoader;
|
import net.Indyuce.mmocore.comp.mythicmobs.MythicMobsMMOLoader;
|
||||||
import net.Indyuce.mmocore.comp.placeholder.DefaultParser;
|
import net.Indyuce.mmocore.comp.placeholder.DefaultParser;
|
||||||
import net.Indyuce.mmocore.comp.placeholder.PlaceholderAPIParser;
|
import net.Indyuce.mmocore.comp.placeholder.PlaceholderAPIParser;
|
||||||
@ -167,7 +167,7 @@ public class MMOCore extends LuminePlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null) {
|
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null) {
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(new MythicMobsDrops(), this);
|
Bukkit.getServer().getPluginManager().registerEvents(new MythicHook(), this);
|
||||||
MMOCore.plugin.getLogger().log(Level.INFO, "Hooked onto MythicMobs");
|
MMOCore.plugin.getLogger().log(Level.INFO, "Hooked onto MythicMobs");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -279,12 +279,17 @@ public class PlayerClass extends PostLoadObject {
|
|||||||
return getSkill(skill.getId());
|
return getSkill(skill.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* reduces map checkups when skills are being checked on events that are
|
* Reduces map checkups when skills are being checked on events that are
|
||||||
* commonly called like EntityDamageEvent or regen events.
|
* commonly called like EntityDamageEvent or regen events.
|
||||||
|
* <p>
|
||||||
|
* Examples:
|
||||||
|
* - {@link net.Indyuce.mmocore.skill.list.Neptune_Gift}
|
||||||
|
* - {@link net.Indyuce.mmocore.skill.list.Fire_Berserker}
|
||||||
*/
|
*/
|
||||||
public Optional<SkillInfo> findSkill(Skill skill) {
|
public Optional<SkillInfo> findSkill(Skill skill) {
|
||||||
return skills.containsKey(skill.getId()) ? Optional.of(skills.get(skill.getId())) : Optional.empty();
|
SkillInfo found = skills.get(skill.getId());
|
||||||
|
return found == null ? Optional.empty() : Optional.of(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkillInfo getSkill(String id) {
|
public SkillInfo getSkill(String id) {
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package net.Indyuce.mmocore.comp.mythicmobs;
|
||||||
|
|
||||||
|
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||||
|
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicDropLoadEvent;
|
||||||
|
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent;
|
||||||
|
import io.lumine.xikage.mythicmobs.skills.SkillMetadata;
|
||||||
|
import io.lumine.xikage.mythicmobs.skills.placeholders.Placeholder;
|
||||||
|
import io.lumine.xikage.mythicmobs.skills.variables.Variable;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop;
|
||||||
|
import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
public class MythicHook implements Listener {
|
||||||
|
public MythicHook() {
|
||||||
|
registerPlaceholders();
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void a(MythicDropLoadEvent event) {
|
||||||
|
|
||||||
|
// random gold pouches
|
||||||
|
if (event.getDropName().equalsIgnoreCase("gold_pouch") || event.getDropName().equalsIgnoreCase("goldpouch"))
|
||||||
|
event.register(new GoldPouchDrop(event.getConfig()));
|
||||||
|
|
||||||
|
// gold coins
|
||||||
|
if (event.getDropName().equalsIgnoreCase("gold_coin") || event.getDropName().equalsIgnoreCase("coin"))
|
||||||
|
event.register(new CurrencyItemDrop("GOLD_COIN", event.getConfig()));
|
||||||
|
|
||||||
|
// notes
|
||||||
|
if (event.getDropName().equalsIgnoreCase("note") || event.getDropName().equalsIgnoreCase("banknote") || event.getDropName().equalsIgnoreCase("bank_note"))
|
||||||
|
event.register(new CurrencyItemDrop("NOTE", event.getConfig()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// When MythicMobs is reloaded, the placeholders are emptied. Add them again
|
||||||
|
@EventHandler
|
||||||
|
public void b(MythicReloadedEvent event) {
|
||||||
|
registerPlaceholders();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerPlaceholders() {
|
||||||
|
|
||||||
|
MythicMobs.inst().getPlaceholderManager().register("modifier", Placeholder.meta((metadata, arg) -> {
|
||||||
|
if (!(metadata instanceof SkillMetadata))
|
||||||
|
throw new RuntimeException("Cannot use this placeholder outside of skill");
|
||||||
|
|
||||||
|
Variable var = ((SkillMetadata) metadata).getVariables().get("MMOCoreSkill");
|
||||||
|
net.Indyuce.mmocore.skill.metadata.SkillMetadata cast = (net.Indyuce.mmocore.skill.metadata.SkillMetadata) var.get();
|
||||||
|
return String.valueOf(cast.getModifier(arg));
|
||||||
|
}));
|
||||||
|
|
||||||
|
MythicMobs.inst().getPlaceholderManager().register("modifier.int", Placeholder.meta((metadata, arg) -> {
|
||||||
|
if (!(metadata instanceof SkillMetadata))
|
||||||
|
throw new RuntimeException("Cannot use this placeholder outside of skill");
|
||||||
|
|
||||||
|
Variable var = ((SkillMetadata) metadata).getVariables().get("MMOCoreSkill");
|
||||||
|
net.Indyuce.mmocore.skill.metadata.SkillMetadata cast = (net.Indyuce.mmocore.skill.metadata.SkillMetadata) var.get();
|
||||||
|
return String.valueOf((int) cast.getModifier(arg));
|
||||||
|
}));
|
||||||
|
|
||||||
|
MythicMobs.inst().getPlaceholderManager().register("mana", Placeholder.meta((metadata, arg) -> String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getMana())));
|
||||||
|
MythicMobs.inst().getPlaceholderManager().register("stamina", Placeholder.meta((metadata, arg) -> String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStamina())));
|
||||||
|
}
|
||||||
|
}
|
@ -1,49 +0,0 @@
|
|||||||
package net.Indyuce.mmocore.comp.mythicmobs;
|
|
||||||
|
|
||||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
|
||||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicDropLoadEvent;
|
|
||||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicReloadedEvent;
|
|
||||||
import io.lumine.xikage.mythicmobs.skills.placeholders.Placeholder;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop;
|
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
|
|
||||||
public class MythicMobsDrops implements Listener {
|
|
||||||
public MythicMobsDrops() {
|
|
||||||
registerPlaceholders();
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void a(MythicDropLoadEvent event) {
|
|
||||||
|
|
||||||
// random gold pouches
|
|
||||||
if (event.getDropName().equalsIgnoreCase("gold_pouch") || event.getDropName().equalsIgnoreCase("goldpouch"))
|
|
||||||
event.register(new GoldPouchDrop(event.getConfig()));
|
|
||||||
|
|
||||||
// gold coins
|
|
||||||
if (event.getDropName().equalsIgnoreCase("gold_coin") || event.getDropName().equalsIgnoreCase("coin"))
|
|
||||||
event.register(new CurrencyItemDrop("GOLD_COIN", event.getConfig()));
|
|
||||||
|
|
||||||
// notes
|
|
||||||
if (event.getDropName().equalsIgnoreCase("note") || event.getDropName().equalsIgnoreCase("banknote") || event.getDropName().equalsIgnoreCase("bank_note"))
|
|
||||||
event.register(new CurrencyItemDrop("NOTE", event.getConfig()));
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* when MythicMobs is reloaded, the placeholders are emptied. Add them again
|
|
||||||
*/
|
|
||||||
@EventHandler
|
|
||||||
public void b(MythicReloadedEvent event) {
|
|
||||||
registerPlaceholders();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerPlaceholders() {
|
|
||||||
// TODO
|
|
||||||
/*MythicMobs.inst().getPlaceholderManager().register("mmocore.skill", Placeholder.meta((metadata, arg) -> String.valueOf(PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getSkillData().getCachedModifier(arg))));
|
|
||||||
MythicMobs.inst().getPlaceholderManager().register("mmocore.skill.int", Placeholder.meta((metadata, arg) -> String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getSkillData().getCachedModifier(arg))));*/
|
|
||||||
MythicMobs.inst().getPlaceholderManager().register("mmocore.mana", Placeholder.meta((metadata, arg) -> String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getMana())));
|
|
||||||
MythicMobs.inst().getPlaceholderManager().register("mmocore.stamina", Placeholder.meta((metadata, arg) -> String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStamina())));
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,7 +3,6 @@ package net.Indyuce.mmocore.comp.mythicmobs;
|
|||||||
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.experience.Profession;
|
|
||||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||||
@ -12,7 +11,7 @@ import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionExperienceSourc
|
|||||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionObjective;
|
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionObjective;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobExperienceSource;
|
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobExperienceSource;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobObjective;
|
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobObjective;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.load.MythicMobSkillTrigger;
|
import net.Indyuce.mmocore.comp.mythicmobs.load.MythicSkillTrigger;
|
||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||||
|
|
||||||
public class MythicMobsMMOLoader extends MMOLoader {
|
public class MythicMobsMMOLoader extends MMOLoader {
|
||||||
@ -21,7 +20,7 @@ public class MythicMobsMMOLoader extends MMOLoader {
|
|||||||
public Trigger loadTrigger(MMOLineConfig config) {
|
public Trigger loadTrigger(MMOLineConfig config) {
|
||||||
|
|
||||||
if (config.getKey().equalsIgnoreCase("mmskill") || config.getKey().equalsIgnoreCase("mythicmobskill"))
|
if (config.getKey().equalsIgnoreCase("mmskill") || config.getKey().equalsIgnoreCase("mythicmobskill"))
|
||||||
return new MythicMobSkillTrigger(config);
|
return new MythicSkillTrigger(config);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Optional;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
|
|
||||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
|
||||||
import io.lumine.xikage.mythicmobs.skills.Skill;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
|
||||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
|
||||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
|
||||||
|
|
||||||
public class MythicMobSkillTrigger extends Trigger {
|
|
||||||
private final Skill skill;
|
|
||||||
|
|
||||||
public MythicMobSkillTrigger(MMOLineConfig config) {
|
|
||||||
super(config);
|
|
||||||
|
|
||||||
config.validate("id");
|
|
||||||
String id = config.getString("id");
|
|
||||||
Optional<io.lumine.xikage.mythicmobs.skills.Skill> opt = MythicMobs.inst().getSkillManager().getSkill(id);
|
|
||||||
Validate.isTrue(opt.isPresent(), "Could not find MM skill " + id);
|
|
||||||
skill = opt.get();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply(PlayerData player) {
|
|
||||||
if(!player.isOnline()) return;
|
|
||||||
List<Entity> targets = new ArrayList<>();
|
|
||||||
targets.add(player.getPlayer());
|
|
||||||
MythicMobs.inst().getAPIHelper().castSkill(player.getPlayer(), this.skill.getInternalName(), player.getPlayer(), player.getPlayer().getEyeLocation(), targets, null, 1);
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,42 @@
|
|||||||
|
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||||
|
|
||||||
|
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||||
|
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||||
|
import io.lumine.xikage.mythicmobs.adapters.AbstractPlayer;
|
||||||
|
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.mmocore.api.player.PlayerData;
|
||||||
|
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
public class MythicSkillTrigger extends Trigger {
|
||||||
|
private final Skill skill;
|
||||||
|
|
||||||
|
public MythicSkillTrigger(MMOLineConfig config) {
|
||||||
|
super(config);
|
||||||
|
|
||||||
|
config.validate("id");
|
||||||
|
String id = config.getString("id");
|
||||||
|
Optional<io.lumine.xikage.mythicmobs.skills.Skill> opt = MythicMobs.inst().getSkillManager().getSkill(id);
|
||||||
|
Validate.isTrue(opt.isPresent(), "Could not find MM skill " + id);
|
||||||
|
skill = opt.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void apply(PlayerData player) {
|
||||||
|
if (!player.isOnline()) return;
|
||||||
|
|
||||||
|
AbstractPlayer trigger = BukkitAdapter.adapt(player.getPlayer());
|
||||||
|
SkillCaster caster = new GenericCaster(trigger);
|
||||||
|
SkillMetadata skillMeta = new SkillMetadata(SkillTrigger.API, caster, trigger, BukkitAdapter.adapt(player.getPlayer().getLocation()), new HashSet<>(), null, 1);
|
||||||
|
if (skill.usable(skillMeta, SkillTrigger.API))
|
||||||
|
skill.execute(skillMeta);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package net.Indyuce.mmocore.comp.mythicmobs.skill;
|
||||||
|
|
||||||
|
import io.lumine.xikage.mythicmobs.skills.variables.Variable;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used by MMOCore to cache skill modifiers inside a variable.
|
||||||
|
* The modifiers are cached in a variable with the skill scope.
|
||||||
|
*
|
||||||
|
* @deprecated Now using an {@link io.lumine.xikage.mythicmobs.skills.variables.types.AbstractVariable}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
|
public class MapVariable extends Variable {
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
private final Map<String, Double> map = new HashMap<>();
|
||||||
|
|
||||||
|
public Map<String, Double> getValue() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "VAR_Map(" + map + ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean shouldSave() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object get() {
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object o) {
|
||||||
|
if (this == o) return true;
|
||||||
|
if (o == null || getClass() != o.getClass()) return false;
|
||||||
|
MapVariable that = (MapVariable) o;
|
||||||
|
return map.equals(that.map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return Objects.hash(map);
|
||||||
|
}
|
||||||
|
}
|
@ -27,11 +27,11 @@ import java.util.Map;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class MythicMobSkill extends Skill {
|
public class MythicSkill extends Skill {
|
||||||
private final io.lumine.xikage.mythicmobs.skills.Skill skill;
|
private final io.lumine.xikage.mythicmobs.skills.Skill skill;
|
||||||
private final Map<CheatType, Integer> antiCheat = new HashMap<>();
|
private final Map<CheatType, Integer> antiCheat = new HashMap<>();
|
||||||
|
|
||||||
public MythicMobSkill(String id, FileConfiguration config) {
|
public MythicSkill(String id, FileConfiguration config) {
|
||||||
super(id);
|
super(id);
|
||||||
|
|
||||||
String mmId = config.getString("mythicmobs-skill-id");
|
String mmId = config.getString("mythicmobs-skill-id");
|
||||||
@ -85,6 +85,7 @@ public class MythicMobSkill extends Skill {
|
|||||||
if (!cast.isSuccessful() || isPassive())
|
if (!cast.isSuccessful() || isPassive())
|
||||||
return cast;
|
return cast;
|
||||||
|
|
||||||
|
// Gather MythicMobs skill info
|
||||||
HashSet<AbstractEntity> targetEntities = new HashSet<>();
|
HashSet<AbstractEntity> targetEntities = new HashSet<>();
|
||||||
HashSet<AbstractLocation> targetLocations = new HashSet<>();
|
HashSet<AbstractLocation> targetLocations = new HashSet<>();
|
||||||
|
|
||||||
@ -96,9 +97,11 @@ public class MythicMobSkill extends Skill {
|
|||||||
if (MMOCore.plugin.hasAntiCheat())
|
if (MMOCore.plugin.hasAntiCheat())
|
||||||
MMOCore.plugin.antiCheatSupport.disableAntiCheat(caster.getPlayer(), antiCheat);
|
MMOCore.plugin.antiCheatSupport.disableAntiCheat(caster.getPlayer(), antiCheat);
|
||||||
|
|
||||||
/*
|
// Place cast skill info in a variable
|
||||||
* Yo is that me or the second argument is f***ing useless
|
skillMeta.getVariables().putObject("MMOCoreSkill", cast);
|
||||||
*/
|
skillMeta.getVariables().putObject("MMOStatMap", caster.getStats());
|
||||||
|
|
||||||
|
// Yo is that me or the second argument is f***ing useless
|
||||||
if (this.skill.usable(skillMeta, SkillTrigger.CAST))
|
if (this.skill.usable(skillMeta, SkillTrigger.CAST))
|
||||||
this.skill.execute(skillMeta);
|
this.skill.execute(skillMeta);
|
||||||
else
|
else
|
@ -16,13 +16,13 @@ import org.bukkit.event.Listener;
|
|||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
public abstract class PassiveMythicMobSkillHandler implements Listener {
|
public abstract class PassiveMythicSkillHandler implements Listener {
|
||||||
protected final MythicMobSkill skill;
|
protected final MythicSkill skill;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Core class for all passive types
|
* Core class for all passive types
|
||||||
*/
|
*/
|
||||||
protected PassiveMythicMobSkillHandler(MythicMobSkill skill) {
|
protected PassiveMythicSkillHandler(MythicSkill skill) {
|
||||||
this.skill = skill;
|
this.skill = skill;
|
||||||
}
|
}
|
||||||
|
|
@ -11,7 +11,7 @@ public enum PassiveSkillType {
|
|||||||
PLAYER_LOGIN,
|
PLAYER_LOGIN,
|
||||||
SHOOT_BOW;
|
SHOOT_BOW;
|
||||||
|
|
||||||
public PassiveMythicMobSkillHandler getHandler(MythicMobSkill skill) {
|
public PassiveMythicSkillHandler getHandler(MythicSkill skill) {
|
||||||
if (this == PLAYER_ATTACK)
|
if (this == PLAYER_ATTACK)
|
||||||
return new PlayerAttackSkillHandler(skill);
|
return new PlayerAttackSkillHandler(skill);
|
||||||
if (this == PLAYER_DAMAGE)
|
if (this == PLAYER_DAMAGE)
|
||||||
|
@ -2,19 +2,19 @@ package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
|
|||||||
|
|
||||||
import io.lumine.mythic.lib.api.event.EntityKillEntityEvent;
|
import io.lumine.mythic.lib.api.event.EntityKillEntityEvent;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicMobSkillHandler;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
|
|
||||||
public class EntityDeathSkillHandler extends PassiveMythicMobSkillHandler {
|
public class EntityDeathSkillHandler extends PassiveMythicSkillHandler {
|
||||||
/**
|
/**
|
||||||
* Used to handle passive skills which trigger when a player kills
|
* Used to handle passive skills which trigger when a player kills
|
||||||
* another entity
|
* another entity
|
||||||
*/
|
*/
|
||||||
public EntityDeathSkillHandler(MythicMobSkill skill) {
|
public EntityDeathSkillHandler(MythicSkill skill) {
|
||||||
super(skill);
|
super(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,16 +3,16 @@ package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
|
|||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicMobSkillHandler;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
|
||||||
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
|
import io.lumine.mythic.lib.api.event.PlayerAttackEvent;
|
||||||
|
|
||||||
public class PlayerAttackSkillHandler extends PassiveMythicMobSkillHandler {
|
public class PlayerAttackSkillHandler extends PassiveMythicSkillHandler {
|
||||||
/**
|
/**
|
||||||
* Used to handle passive skills which trigger when a player attacks another
|
* Used to handle passive skills which trigger when a player attacks another
|
||||||
* entity
|
* entity
|
||||||
*/
|
*/
|
||||||
public PlayerAttackSkillHandler(MythicMobSkill skill) {
|
public PlayerAttackSkillHandler(MythicSkill skill) {
|
||||||
super(skill);
|
super(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,19 +2,19 @@ package net.Indyuce.mmocore.comp.mythicmobs.skill.handlers;
|
|||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicMobSkillHandler;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
public class PlayerDamageByEntitySkillHandler extends PassiveMythicMobSkillHandler {
|
public class PlayerDamageByEntitySkillHandler extends PassiveMythicSkillHandler {
|
||||||
/**
|
/**
|
||||||
* Used to handle passive skills which trigger when a player takes damage
|
* Used to handle passive skills which trigger when a player takes damage
|
||||||
* from another entity
|
* from another entity
|
||||||
*/
|
*/
|
||||||
public PlayerDamageByEntitySkillHandler(MythicMobSkill skill) {
|
public PlayerDamageByEntitySkillHandler(MythicSkill skill) {
|
||||||
super(skill);
|
super(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicMobSkillHandler;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
|
||||||
|
|
||||||
public class PlayerDamageSkillHandler extends PassiveMythicMobSkillHandler {
|
public class PlayerDamageSkillHandler extends PassiveMythicSkillHandler {
|
||||||
/**
|
/**
|
||||||
* Used to handle passive skills which trigger when a player takes damage
|
* Used to handle passive skills which trigger when a player takes damage
|
||||||
*/
|
*/
|
||||||
public PlayerDamageSkillHandler(MythicMobSkill skill) {
|
public PlayerDamageSkillHandler(MythicSkill skill) {
|
||||||
super(skill);
|
super(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicMobSkillHandler;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
|
||||||
|
|
||||||
public class PlayerDeathSkillHandler extends PassiveMythicMobSkillHandler {
|
public class PlayerDeathSkillHandler extends PassiveMythicSkillHandler {
|
||||||
/**
|
/**
|
||||||
* Used to handle passive skills which trigger when a player dies
|
* Used to handle passive skills which trigger when a player dies
|
||||||
*/
|
*/
|
||||||
public PlayerDeathSkillHandler(MythicMobSkill skill) {
|
public PlayerDeathSkillHandler(MythicSkill skill) {
|
||||||
super(skill);
|
super(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,16 +5,16 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
|||||||
|
|
||||||
import io.lumine.mythic.utils.Schedulers;
|
import io.lumine.mythic.utils.Schedulers;
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicMobSkillHandler;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
|
||||||
|
|
||||||
public class PlayerLoginSkillHandler extends PassiveMythicMobSkillHandler {
|
public class PlayerLoginSkillHandler extends PassiveMythicSkillHandler {
|
||||||
/**
|
/**
|
||||||
* Used when a player logins
|
* Used when a player logins
|
||||||
*
|
*
|
||||||
* @param skill
|
* @param skill
|
||||||
*/
|
*/
|
||||||
public PlayerLoginSkillHandler(MythicMobSkill skill) {
|
public PlayerLoginSkillHandler(MythicSkill skill) {
|
||||||
super(skill);
|
super(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||||
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicMobSkillHandler;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.PassiveMythicSkillHandler;
|
||||||
|
|
||||||
public class ShootBowSkillHandler extends PassiveMythicMobSkillHandler {
|
public class ShootBowSkillHandler extends PassiveMythicSkillHandler {
|
||||||
/**
|
/**
|
||||||
* Used to handle passive skills which trigger when a player shoots a bow
|
* Used to handle passive skills which trigger when a player shoots a bow
|
||||||
*/
|
*/
|
||||||
public ShootBowSkillHandler(MythicMobSkill skill) {
|
public ShootBowSkillHandler(MythicSkill skill) {
|
||||||
super(skill);
|
super(skill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ import net.Indyuce.mmocore.MMOCore;
|
|||||||
import net.Indyuce.mmocore.api.ConfigFile;
|
import net.Indyuce.mmocore.api.ConfigFile;
|
||||||
import net.Indyuce.mmocore.skill.Skill;
|
import net.Indyuce.mmocore.skill.Skill;
|
||||||
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
import net.Indyuce.mmocore.api.util.math.formula.LinearValue;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicSkill;
|
||||||
|
|
||||||
public class SkillManager {
|
public class SkillManager {
|
||||||
private final Map<String, Skill> skills = new LinkedHashMap<>();
|
private final Map<String, Skill> skills = new LinkedHashMap<>();
|
||||||
@ -59,7 +59,7 @@ public class SkillManager {
|
|||||||
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null)
|
if (Bukkit.getPluginManager().getPlugin("MythicMobs") != null)
|
||||||
for (File file : mythicMobs.listFiles()) {
|
for (File file : mythicMobs.listFiles()) {
|
||||||
try {
|
try {
|
||||||
register(new MythicMobSkill(file.getName().substring(0, file.getName().length() - 4).toUpperCase(),
|
register(new MythicSkill(file.getName().substring(0, file.getName().length() - 4).toUpperCase(),
|
||||||
YamlConfiguration.loadConfiguration(file)));
|
YamlConfiguration.loadConfiguration(file)));
|
||||||
} catch (Exception exception) {
|
} catch (Exception exception) {
|
||||||
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load skill from " + file.getName() + ": " + exception.getMessage());
|
MMOCore.plugin.getLogger().log(Level.WARNING, "Could not load skill from " + file.getName() + ": " + exception.getMessage());
|
||||||
@ -67,7 +67,7 @@ public class SkillManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (Skill skill : getAll())
|
for (Skill skill : getAll())
|
||||||
if (!(skill instanceof MythicMobSkill)) {
|
if (!(skill instanceof MythicSkill)) {
|
||||||
File file = new File(MMOCore.plugin.getDataFolder() + "/skills", skill.getLowerCaseId() + ".yml");
|
File file = new File(MMOCore.plugin.getDataFolder() + "/skills", skill.getLowerCaseId() + ".yml");
|
||||||
ConfigFile config = new ConfigFile("/skills", skill.getLowerCaseId());
|
ConfigFile config = new ConfigFile("/skills", skill.getLowerCaseId());
|
||||||
|
|
||||||
|
@ -3,11 +3,8 @@ package net.Indyuce.mmocore.skill;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.lumine.mythic.utils.cooldown.CooldownMap;
|
|
||||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.skill.Skill.SkillInfo;
|
import net.Indyuce.mmocore.skill.Skill.SkillInfo;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.skill.MythicMobSkill;
|
|
||||||
import net.Indyuce.mmocore.skill.metadata.SkillMetadata;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Note: any method which return longs returns milliseconds.
|
* Note: any method which return longs returns milliseconds.
|
||||||
|
Loading…
Reference in New Issue
Block a user