mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2024-11-23 00:05:52 +01:00
MM 5.0.1 support
This commit is contained in:
parent
196b977676
commit
d4813f5cfa
4
pom.xml
4
pom.xml
@ -146,8 +146,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>
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
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 io.lumine.mythic.bukkit.MythicBukkit;
|
||||
import io.lumine.mythic.bukkit.events.MythicDropLoadEvent;
|
||||
import io.lumine.mythic.bukkit.events.MythicReloadedEvent;
|
||||
import io.lumine.mythic.core.skills.placeholders.Placeholder;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.attribute.PlayerAttribute;
|
||||
@ -50,18 +50,18 @@ public class MythicHook implements Listener {
|
||||
private void registerPlaceholders() {
|
||||
|
||||
// Resource
|
||||
MythicMobs.inst().getPlaceholderManager().register("mana", Placeholder.meta((metadata, arg) -> {
|
||||
MythicBukkit.inst().getPlaceholderManager().register("mana", Placeholder.meta((metadata, arg) -> {
|
||||
return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getMana());
|
||||
}));
|
||||
MythicMobs.inst().getPlaceholderManager().register("stamina", Placeholder.meta((metadata, arg) -> {
|
||||
MythicBukkit.inst().getPlaceholderManager().register("stamina", Placeholder.meta((metadata, arg) -> {
|
||||
return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStamina());
|
||||
}));
|
||||
MythicMobs.inst().getPlaceholderManager().register("stellium", Placeholder.meta((metadata, arg) -> {
|
||||
MythicBukkit.inst().getPlaceholderManager().register("stellium", Placeholder.meta((metadata, arg) -> {
|
||||
return String.valueOf((int) PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getStellium());
|
||||
}));
|
||||
|
||||
// Attributes
|
||||
MythicMobs.inst().getPlaceholderManager().register("attribute", Placeholder.meta((metadata, arg) -> {
|
||||
MythicBukkit.inst().getPlaceholderManager().register("attribute", Placeholder.meta((metadata, arg) -> {
|
||||
PlayerAttributes attributes = PlayerData.get(metadata.getCaster().getEntity().getUniqueId()).getAttributes();
|
||||
PlayerAttribute attribute = MMOCore.plugin.attributeManager.get(arg);
|
||||
return String.valueOf(attributes.getAttribute(attribute));
|
||||
|
@ -1,49 +1,44 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs;
|
||||
|
||||
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.load.MMOLoader;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import net.Indyuce.mmocore.api.quest.trigger.Trigger;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionExperienceSource;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicFactionObjective;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobExperienceSource;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.KillMythicMobObjective;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.MythicSkillTrigger;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.comp.mythicmobs.load.*;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.ExperienceSource;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
|
||||
public class MythicMobsMMOLoader extends MMOLoader {
|
||||
|
||||
@Override
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
@Override
|
||||
public Trigger loadTrigger(MMOLineConfig config) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("mmskill") || config.getKey().equalsIgnoreCase("mythicmobskill"))
|
||||
return new MythicSkillTrigger(config);
|
||||
if (config.getKey().equalsIgnoreCase("mmskill") || config.getKey().equalsIgnoreCase("mythicmobskill"))
|
||||
return new MythicSkillTrigger(config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
|
||||
@Override
|
||||
public Objective loadObjective(MMOLineConfig config, ConfigurationSection section) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("killmythicmob"))
|
||||
return new KillMythicMobObjective(section, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
|
||||
return new KillMythicFactionObjective(section, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicmob"))
|
||||
return new KillMythicMobObjective(section, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
|
||||
return new KillMythicFactionObjective(section, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
@Override
|
||||
public ExperienceSource<?> loadExperienceSource(MMOLineConfig config, ExperienceDispenser dispenser) {
|
||||
|
||||
if (config.getKey().equalsIgnoreCase("killmythicmob"))
|
||||
return new KillMythicMobExperienceSource(dispenser, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
|
||||
return new KillMythicFactionExperienceSource(dispenser, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicmob"))
|
||||
return new KillMythicMobExperienceSource(dispenser, config);
|
||||
if (config.getKey().equalsIgnoreCase("killmythicfaction"))
|
||||
return new KillMythicFactionExperienceSource(dispenser, config);
|
||||
|
||||
return null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -1,40 +1,40 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import io.lumine.mythic.api.config.MythicLineConfig;
|
||||
import io.lumine.mythic.api.drops.DropMetadata;
|
||||
import io.lumine.mythic.api.drops.IMultiDrop;
|
||||
import io.lumine.mythic.bukkit.adapters.BukkitItemStack;
|
||||
import io.lumine.mythic.core.drops.Drop;
|
||||
import io.lumine.mythic.core.drops.LootBag;
|
||||
import io.lumine.mythic.core.drops.droppables.ItemDrop;
|
||||
import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitItemStack;
|
||||
import io.lumine.xikage.mythicmobs.drops.Drop;
|
||||
import io.lumine.xikage.mythicmobs.drops.DropMetadata;
|
||||
import io.lumine.xikage.mythicmobs.drops.IMultiDrop;
|
||||
import io.lumine.xikage.mythicmobs.drops.LootBag;
|
||||
import io.lumine.xikage.mythicmobs.drops.droppables.ItemDrop;
|
||||
import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
|
||||
import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
|
||||
|
||||
public class CurrencyItemDrop extends Drop implements IMultiDrop {
|
||||
private final String key;
|
||||
private final int minw;
|
||||
private final int maxw;
|
||||
private final String key;
|
||||
private final int minw;
|
||||
private final int maxw;
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final Random random = new Random();
|
||||
|
||||
public CurrencyItemDrop(String key, MythicLineConfig config) {
|
||||
super(config.getLine(), config);
|
||||
|
||||
this.key = key;
|
||||
minw = config.getInteger("minw", 1);
|
||||
maxw = config.getInteger("maxw", 1);
|
||||
}
|
||||
public CurrencyItemDrop(String key, MythicLineConfig config) {
|
||||
super(config.getLine(), config);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public LootBag get(DropMetadata metadata) {
|
||||
LootBag loot = new LootBag(metadata);
|
||||
loot.add(new ItemDrop(this.getLine(), (MythicLineConfig) this.getConfig(), new BukkitItemStack(new CurrencyItemBuilder(key, random(minw, maxw)).build())));
|
||||
return loot;
|
||||
}
|
||||
this.key = key;
|
||||
minw = config.getInteger("minw", 1);
|
||||
maxw = config.getInteger("maxw", 1);
|
||||
}
|
||||
|
||||
private int random(int a, int b) {
|
||||
return random.nextInt(b - a + 1) + a;
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public LootBag get(DropMetadata metadata) {
|
||||
LootBag loot = new LootBag(metadata);
|
||||
loot.add(new ItemDrop(this.getLine(), this.getConfig(), new BukkitItemStack(new CurrencyItemBuilder(key, random(minw, maxw)).build())));
|
||||
return loot;
|
||||
}
|
||||
|
||||
private int random(int a, int b) {
|
||||
return random.nextInt(b - a + 1) + a;
|
||||
}
|
||||
}
|
||||
|
@ -1,71 +1,70 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import io.lumine.mythic.api.config.MythicLineConfig;
|
||||
import io.lumine.mythic.api.drops.DropMetadata;
|
||||
import io.lumine.mythic.api.drops.IMultiDrop;
|
||||
import io.lumine.mythic.bukkit.adapters.BukkitItemStack;
|
||||
import io.lumine.mythic.core.drops.Drop;
|
||||
import io.lumine.mythic.core.drops.LootBag;
|
||||
import io.lumine.mythic.core.drops.droppables.ItemDrop;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
|
||||
import net.Indyuce.mmocore.util.item.SimpleItemBuilder;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitItemStack;
|
||||
import io.lumine.xikage.mythicmobs.drops.Drop;
|
||||
import io.lumine.xikage.mythicmobs.drops.DropMetadata;
|
||||
import io.lumine.xikage.mythicmobs.drops.IMultiDrop;
|
||||
import io.lumine.xikage.mythicmobs.drops.LootBag;
|
||||
import io.lumine.xikage.mythicmobs.drops.droppables.ItemDrop;
|
||||
import io.lumine.xikage.mythicmobs.io.MythicLineConfig;
|
||||
import net.Indyuce.mmocore.api.util.MMOCoreUtils;
|
||||
import net.Indyuce.mmocore.util.item.CurrencyItemBuilder;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import java.util.Random;
|
||||
|
||||
public class GoldPouchDrop extends Drop implements IMultiDrop {
|
||||
private final int min;
|
||||
private final int max;
|
||||
private final int min;
|
||||
private final int max;
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final Random random = new Random();
|
||||
|
||||
public GoldPouchDrop(MythicLineConfig config) {
|
||||
super(config.getLine(), config);
|
||||
public GoldPouchDrop(MythicLineConfig config) {
|
||||
super(config.getLine(), config);
|
||||
|
||||
min = config.getInteger("min", 1);
|
||||
max = config.getInteger("max", 10);
|
||||
}
|
||||
min = config.getInteger("min", 1);
|
||||
max = config.getInteger("max", 10);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public LootBag get(DropMetadata metadata) {
|
||||
LootBag loot = new LootBag(metadata);
|
||||
NBTItem nbt = NBTItem.get(new SimpleItemBuilder("MOB_GOLD_POUCH").build());
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public LootBag get(DropMetadata metadata) {
|
||||
LootBag loot = new LootBag(metadata);
|
||||
NBTItem nbt = NBTItem.get(new SimpleItemBuilder("MOB_GOLD_POUCH").build());
|
||||
|
||||
ItemStack[] content = new ItemStack[18];
|
||||
int money = random.nextInt(max - min + 1) + min;
|
||||
ItemStack[] content = new ItemStack[18];
|
||||
int money = random.nextInt(max - min + 1) + min;
|
||||
|
||||
for (int j = 0; j < 7 && money > 0; j++) {
|
||||
int a = j == 6 ? money : Math.max(1, (int) ((.12 + random.nextDouble() * .4) * (double) money));
|
||||
money -= a;
|
||||
for (int j = 0; j < 7 && money > 0; j++) {
|
||||
int a = j == 6 ? money : Math.max(1, (int) ((.12 + random.nextDouble() * .4) * (double) money));
|
||||
money -= a;
|
||||
|
||||
if (a < 30 && random.nextDouble() < .3) {
|
||||
content[getAvailableSlot(content)] = setAmount(new CurrencyItemBuilder("GOLD_COIN", 1).build(), a);
|
||||
continue;
|
||||
}
|
||||
if (a < 30 && random.nextDouble() < .3) {
|
||||
content[getAvailableSlot(content)] = setAmount(new CurrencyItemBuilder("GOLD_COIN", 1).build(), a);
|
||||
continue;
|
||||
}
|
||||
|
||||
content[getAvailableSlot(content)] = new CurrencyItemBuilder("NOTE", a).build();
|
||||
}
|
||||
content[getAvailableSlot(content)] = new CurrencyItemBuilder("NOTE", a).build();
|
||||
}
|
||||
|
||||
nbt.addTag(new ItemTag("RpgPouchSize", 18), new ItemTag("RpgPouchMob", true), new ItemTag("RpgPouchInventory", MMOCoreUtils.toBase64(content)));
|
||||
loot.add(new ItemDrop(this.getLine(), (MythicLineConfig) this.getConfig(), new BukkitItemStack(nbt.toItem())));
|
||||
return loot;
|
||||
}
|
||||
nbt.addTag(new ItemTag("RpgPouchSize", 18), new ItemTag("RpgPouchMob", true), new ItemTag("RpgPouchInventory", MMOCoreUtils.toBase64(content)));
|
||||
loot.add(new ItemDrop(this.getLine(), this.getConfig(), new BukkitItemStack(nbt.toItem())));
|
||||
return loot;
|
||||
}
|
||||
|
||||
private ItemStack setAmount(ItemStack item, int amount) {
|
||||
item.setAmount(amount);
|
||||
return item;
|
||||
}
|
||||
private ItemStack setAmount(ItemStack item, int amount) {
|
||||
item.setAmount(amount);
|
||||
return item;
|
||||
}
|
||||
|
||||
private int getAvailableSlot(ItemStack[] content) {
|
||||
int slot;
|
||||
while (content[slot = random.nextInt(content.length)] != null)
|
||||
if(content[slot].getType() == Material.AIR) break;
|
||||
return slot;
|
||||
}
|
||||
private int getAvailableSlot(ItemStack[] content) {
|
||||
int slot;
|
||||
while (content[slot = random.nextInt(content.length)] != null)
|
||||
if (content[slot].getType() == Material.AIR) break;
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -1,57 +1,56 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
|
||||
import net.Indyuce.mmocore.api.quest.QuestProgress;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
|
||||
import net.Indyuce.mmocore.api.quest.QuestProgress;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
|
||||
public class KillMythicFactionObjective extends Objective {
|
||||
private final String factionName;
|
||||
private final int required;
|
||||
private final String factionName;
|
||||
private final int required;
|
||||
|
||||
public KillMythicFactionObjective(ConfigurationSection section, MMOLineConfig config) {
|
||||
super(section);
|
||||
public KillMythicFactionObjective(ConfigurationSection section, MMOLineConfig config) {
|
||||
super(section);
|
||||
|
||||
config.validate("amount", "name");
|
||||
config.validate("amount", "name");
|
||||
|
||||
factionName = config.getString("name");
|
||||
required = config.getInt("amount");
|
||||
}
|
||||
factionName = config.getString("name");
|
||||
required = config.getInt("amount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectiveProgress newProgress(QuestProgress questProgress) {
|
||||
return new KillFactionProgress(questProgress, this);
|
||||
}
|
||||
@Override
|
||||
public ObjectiveProgress newProgress(QuestProgress questProgress) {
|
||||
return new KillFactionProgress(questProgress, this);
|
||||
}
|
||||
|
||||
public class KillFactionProgress extends ObjectiveProgress implements Listener {
|
||||
private int count;
|
||||
public class KillFactionProgress extends ObjectiveProgress implements Listener {
|
||||
private int count;
|
||||
|
||||
public KillFactionProgress(QuestProgress questProgress, Objective objective) {
|
||||
super(questProgress, objective);
|
||||
}
|
||||
public KillFactionProgress(QuestProgress questProgress, Objective objective) {
|
||||
super(questProgress, objective);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(MythicMobDeathEvent event) {
|
||||
if(!getQuestProgress().getPlayer().isOnline()) return;
|
||||
if (event.getKiller() instanceof Player
|
||||
&& event.getKiller().equals(getQuestProgress().getPlayer().getPlayer())
|
||||
&& event.getMob().hasFaction() && event.getMob().getFaction().equals(factionName)) {
|
||||
count++;
|
||||
getQuestProgress().getPlayer().getQuestData().updateBossBar();
|
||||
if (count >= required)
|
||||
getQuestProgress().completeObjective();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void a(MythicMobDeathEvent event) {
|
||||
if (!getQuestProgress().getPlayer().isOnline()) return;
|
||||
if (event.getKiller() instanceof Player
|
||||
&& event.getKiller().equals(getQuestProgress().getPlayer().getPlayer())
|
||||
&& event.getMob().hasFaction() && event.getMob().getFaction().equals(factionName)) {
|
||||
count++;
|
||||
getQuestProgress().getPlayer().getQuestData().updateBossBar();
|
||||
if (count >= required)
|
||||
getQuestProgress().completeObjective();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatLore(String lore) {
|
||||
return lore.replace("{left}", "" + (required - count));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String formatLore(String lore) {
|
||||
return lore.replace("{left}", "" + (required - count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.experience.provider.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.dispenser.ExperienceDispenser;
|
||||
import net.Indyuce.mmocore.experience.source.type.SpecificExperienceSource;
|
||||
import net.Indyuce.mmocore.manager.profession.ExperienceSourceManager;
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -1,55 +1,54 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import io.lumine.mythic.bukkit.events.MythicMobDeathEvent;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
|
||||
import net.Indyuce.mmocore.api.quest.QuestProgress;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
import io.lumine.xikage.mythicmobs.api.bukkit.events.MythicMobDeathEvent;
|
||||
import net.Indyuce.mmocore.api.quest.ObjectiveProgress;
|
||||
import net.Indyuce.mmocore.api.quest.QuestProgress;
|
||||
import net.Indyuce.mmocore.api.quest.objective.Objective;
|
||||
import io.lumine.mythic.lib.api.MMOLineConfig;
|
||||
|
||||
public class KillMythicMobObjective extends Objective {
|
||||
private final String internalName;
|
||||
private final int required;
|
||||
private final String internalName;
|
||||
private final int required;
|
||||
|
||||
public KillMythicMobObjective(ConfigurationSection section, MMOLineConfig config) {
|
||||
super(section);
|
||||
public KillMythicMobObjective(ConfigurationSection section, MMOLineConfig config) {
|
||||
super(section);
|
||||
|
||||
config.validate("amount", "name");
|
||||
config.validate("amount", "name");
|
||||
|
||||
internalName = config.getString("name");
|
||||
required = config.getInt("amount");
|
||||
}
|
||||
internalName = config.getString("name");
|
||||
required = config.getInt("amount");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectiveProgress newProgress(QuestProgress questProgress) {
|
||||
return new KillMobProgress(questProgress, this);
|
||||
}
|
||||
@Override
|
||||
public ObjectiveProgress newProgress(QuestProgress questProgress) {
|
||||
return new KillMobProgress(questProgress, this);
|
||||
}
|
||||
|
||||
public class KillMobProgress extends ObjectiveProgress implements Listener {
|
||||
private int count;
|
||||
public class KillMobProgress extends ObjectiveProgress implements Listener {
|
||||
private int count;
|
||||
|
||||
public KillMobProgress(QuestProgress questProgress, Objective objective) {
|
||||
super(questProgress, objective);
|
||||
}
|
||||
public KillMobProgress(QuestProgress questProgress, Objective objective) {
|
||||
super(questProgress, objective);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void a(MythicMobDeathEvent event) {
|
||||
if(!getQuestProgress().getPlayer().isOnline()) return;
|
||||
if (event.getKiller() instanceof Player && event.getKiller().equals(getQuestProgress().getPlayer().getPlayer()) && event.getMob().getType().getInternalName().equals(internalName)) {
|
||||
count++;
|
||||
getQuestProgress().getPlayer().getQuestData().updateBossBar();
|
||||
if (count >= required)
|
||||
getQuestProgress().completeObjective();
|
||||
}
|
||||
}
|
||||
@EventHandler
|
||||
public void a(MythicMobDeathEvent event) {
|
||||
if (!getQuestProgress().getPlayer().isOnline()) return;
|
||||
if (event.getKiller() instanceof Player && event.getKiller().equals(getQuestProgress().getPlayer().getPlayer()) && event.getMob().getType().getInternalName().equals(internalName)) {
|
||||
count++;
|
||||
getQuestProgress().getPlayer().getQuestData().updateBossBar();
|
||||
if (count >= required)
|
||||
getQuestProgress().completeObjective();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String formatLore(String lore) {
|
||||
return lore.replace("{left}", "" + (required - count));
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String formatLore(String lore) {
|
||||
return lore.replace("{left}", "" + (required - count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,20 @@
|
||||
package net.Indyuce.mmocore.comp.mythicmobs.load;
|
||||
|
||||
import io.lumine.mythic.api.adapters.AbstractPlayer;
|
||||
import io.lumine.mythic.api.mobs.GenericCaster;
|
||||
import io.lumine.mythic.api.skills.Skill;
|
||||
import io.lumine.mythic.api.skills.SkillCaster;
|
||||
import io.lumine.mythic.api.skills.SkillMetadata;
|
||||
import io.lumine.mythic.api.skills.SkillTrigger;
|
||||
import io.lumine.mythic.bukkit.BukkitAdapter;
|
||||
import io.lumine.mythic.bukkit.MythicBukkit;
|
||||
import io.lumine.mythic.core.skills.SkillMetadataImpl;
|
||||
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.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.Optional;
|
||||
|
||||
@ -24,7 +26,7 @@ public class MythicSkillTrigger extends Trigger {
|
||||
|
||||
config.validate("id");
|
||||
String id = config.getString("id");
|
||||
Optional<io.lumine.xikage.mythicmobs.skills.Skill> opt = MythicMobs.inst().getSkillManager().getSkill(id);
|
||||
Optional<io.lumine.mythic.api.skills.Skill> opt = MythicBukkit.inst().getSkillManager().getSkill(id);
|
||||
Validate.isTrue(opt.isPresent(), "Could not find MM skill " + id);
|
||||
skill = opt.get();
|
||||
}
|
||||
@ -35,8 +37,8 @@ public class MythicSkillTrigger extends Trigger {
|
||||
|
||||
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))
|
||||
SkillMetadata skillMeta = new SkillMetadataImpl(new SkillTrigger("API", new ArrayList<>()), caster, trigger, BukkitAdapter.adapt(player.getPlayer().getLocation()), new HashSet<>(), null, 1);
|
||||
if (skill.isUsable(skillMeta))
|
||||
skill.execute(skillMeta);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user