mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-28 00:55:29 +01:00
/mm reload now reloads MMOCore skills
This commit is contained in:
parent
733f3c5239
commit
2b406e0cf5
@ -10,9 +10,14 @@ import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
|||||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
import net.Indyuce.mmocore.api.player.attribute.PlayerAttributes;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop;
|
import net.Indyuce.mmocore.comp.mythicmobs.load.CurrencyItemDrop;
|
||||||
import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop;
|
import net.Indyuce.mmocore.comp.mythicmobs.load.GoldPouchDrop;
|
||||||
|
import net.Indyuce.mmocore.skill.Skill;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class MythicHook implements Listener {
|
public class MythicHook implements Listener {
|
||||||
public MythicHook() {
|
public MythicHook() {
|
||||||
registerPlaceholders();
|
registerPlaceholders();
|
||||||
@ -34,10 +39,23 @@ public class MythicHook implements Listener {
|
|||||||
event.register(new CurrencyItemDrop("NOTE", event.getConfig()));
|
event.register(new CurrencyItemDrop("NOTE", event.getConfig()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// When MythicMobs is reloaded, the placeholders are emptied. Add them again
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void b(MythicReloadedEvent event) {
|
public void b(MythicReloadedEvent event) {
|
||||||
|
|
||||||
|
// When MM is reloaded, reload placeholders because they are no longer registered
|
||||||
registerPlaceholders();
|
registerPlaceholders();
|
||||||
|
|
||||||
|
// Reload MMOCore skills as well
|
||||||
|
for (Skill skill : MMOCore.plugin.skillManager.getActive())
|
||||||
|
if (skill instanceof MythicSkill)
|
||||||
|
try {
|
||||||
|
String skillId = ((MythicSkill) skill).getSkill().getInternalName();
|
||||||
|
Optional<io.lumine.xikage.mythicmobs.skills.Skill> opt = MythicMobs.inst().getSkillManager().getSkill(skillId);
|
||||||
|
Validate.isTrue(opt.isPresent(), "Could not find skill with ID '" + skillId + "'");
|
||||||
|
((MythicSkill) skill).setSkill(opt.get());
|
||||||
|
} catch (RuntimeException exception) {
|
||||||
|
MMOCore.log(Level.WARNING, "Could not reload MM skill '" + skill.getId() + "': " + exception.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerPlaceholders() {
|
private void registerPlaceholders() {
|
||||||
|
@ -4,8 +4,8 @@ import io.lumine.mythic.lib.api.player.EquipmentSlot;
|
|||||||
import io.lumine.mythic.lib.api.stat.modifier.ModifierSource;
|
import io.lumine.mythic.lib.api.stat.modifier.ModifierSource;
|
||||||
import io.lumine.mythic.lib.api.util.EnumUtils;
|
import io.lumine.mythic.lib.api.util.EnumUtils;
|
||||||
import io.lumine.mythic.lib.player.cooldown.CooldownInfo;
|
import io.lumine.mythic.lib.player.cooldown.CooldownInfo;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
|
||||||
import io.lumine.mythic.lib.skill.trigger.PassiveSkill;
|
import io.lumine.mythic.lib.skill.trigger.PassiveSkill;
|
||||||
|
import io.lumine.mythic.lib.skill.trigger.TriggerMetadata;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
import io.lumine.mythic.lib.skill.trigger.TriggerType;
|
||||||
import io.lumine.mythic.lib.skill.trigger.TriggeredSkill;
|
import io.lumine.mythic.lib.skill.trigger.TriggeredSkill;
|
||||||
import io.lumine.xikage.mythicmobs.MythicMobs;
|
import io.lumine.xikage.mythicmobs.MythicMobs;
|
||||||
@ -32,6 +32,7 @@ import org.apache.commons.lang.Validate;
|
|||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -40,10 +41,12 @@ import java.util.Optional;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
public class MythicSkill extends Skill implements TriggeredSkill {
|
public class MythicSkill extends Skill implements TriggeredSkill {
|
||||||
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<>();
|
||||||
private final PassiveSkill mythicLibSkill;
|
private final PassiveSkill mythicLibSkill;
|
||||||
|
|
||||||
|
// Not final so that it can be changed when MM is reloaded
|
||||||
|
private io.lumine.xikage.mythicmobs.skills.Skill skill;
|
||||||
|
|
||||||
public MythicSkill(String id, FileConfiguration config) {
|
public MythicSkill(String id, FileConfiguration config) {
|
||||||
super(id);
|
super(id);
|
||||||
|
|
||||||
@ -93,6 +96,19 @@ public class MythicSkill extends Skill implements TriggeredSkill {
|
|||||||
return skill;
|
return skill;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used when reloading MMOCore. Something convenient to do is to
|
||||||
|
* reload the MMOCore skills that are linked to a MM skill whenever
|
||||||
|
* MM is reloaded, so that changes to the skill are taken into account
|
||||||
|
* in MMOCore skills.
|
||||||
|
*
|
||||||
|
* @param skill Newest version of skill
|
||||||
|
*/
|
||||||
|
public void setSkill(@NotNull io.lumine.xikage.mythicmobs.skills.Skill skill) {
|
||||||
|
Validate.notNull(skill);
|
||||||
|
this.skill = skill;
|
||||||
|
}
|
||||||
|
|
||||||
public PassiveSkill toMythicLib() {
|
public PassiveSkill toMythicLib() {
|
||||||
return mythicLibSkill;
|
return mythicLibSkill;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user