Skip to content

Commit

Permalink
MythicDungeons support and some wild ComandDispatcher integrations
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikSzabo committed Nov 23, 2024
1 parent b6df380 commit ea20b53
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 8 deletions.
6 changes: 5 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ plugins {
}

group = "gg.auroramc"
version = "1.3.6"
version = "1.3.7"

repositories {
flatDir {
dirs("libs")
}
mavenCentral()
mavenLocal()
maven("https://papermc.io/repo/repository/maven-public/")
Expand Down Expand Up @@ -56,6 +59,7 @@ dependencies {
compileOnly("io.th0rgal:oraxen:1.179.0")
compileOnly("com.github.brcdev-minecraft:shopgui-api:3.0.0")
compileOnly("io.lumine:MythicLib-dist:1.6.2-SNAPSHOT")
compileOnly(name = "MythicDungeons-2.0.0-SNAPSHOT", group = "net.playavalon", version = "2.0.0-SNAPSHOT")
compileOnly("de.oliver:FancyNpcs:2.2.2")
compileOnly("ink.ptms.adyeshach:all:2.0.0-snapshot-1")
compileOnly("com.bgsoftware:SuperiorSkyblockAPI:2024.3")
Expand Down
Binary file added libs/MythicDungeons-2.0.0-SNAPSHOT.jar
Binary file not shown.
14 changes: 14 additions & 0 deletions src/main/java/gg/auroramc/quests/AuroraQuests.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

import gg.auroramc.aurora.api.AuroraAPI;
import gg.auroramc.aurora.api.AuroraLogger;
import gg.auroramc.aurora.api.command.CommandDispatcher;
import gg.auroramc.quests.api.data.QuestData;
import gg.auroramc.quests.api.quest.QuestManager;
import gg.auroramc.quests.command.CommandManager;
import gg.auroramc.quests.config.ConfigManager;
import gg.auroramc.quests.hooks.HookManager;
import gg.auroramc.quests.listener.*;
import gg.auroramc.quests.menu.PoolMenu;
import gg.auroramc.quests.placeholder.QuestPlaceholderHandler;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import lombok.Getter;
Expand Down Expand Up @@ -80,6 +82,18 @@ public void onEnable() {
reloadUnlockTask();
});

CommandDispatcher.registerActionHandler("quest-pool", (player, input) -> {
var split = input.split("---");
var poolId = split[0].trim();
var pool = questManager.getQuestPool(poolId);
if (pool == null) return;
if (split.length > 1) {
new PoolMenu(player, pool, () -> CommandDispatcher.dispatch(player, split[1].trim())).open();
} else {
new PoolMenu(player, pool).open();
}
});

new Metrics(this, 23779);
}

Expand Down
6 changes: 4 additions & 2 deletions src/main/java/gg/auroramc/quests/api/quest/QuestManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import gg.auroramc.aurora.api.util.NamespacedId;
import gg.auroramc.quests.AuroraQuests;
import gg.auroramc.quests.api.event.QuestsLoadedEvent;
import gg.auroramc.quests.api.quest.task.DifficultyTaskEvaluator;
import gg.auroramc.quests.api.quest.task.LevelledTaskEvaluator;
import gg.auroramc.quests.hooks.HookManager;
import gg.auroramc.quests.hooks.worldguard.WorldGuardHook;
Expand Down Expand Up @@ -37,6 +38,7 @@ public QuestManager(AuroraQuests plugin) {

TaskManager.registerEvaluator(TaskType.ENCHANT, new LevelledTaskEvaluator());
TaskManager.registerEvaluator(TaskType.KILL_LEVELLED_MOB, new LevelledTaskEvaluator());
TaskManager.registerEvaluator(TaskType.COMPLETE_DUNGEON, new DifficultyTaskEvaluator());

try {
StdSchedulerFactory.getDefaultScheduler().start();
Expand Down Expand Up @@ -78,12 +80,12 @@ private boolean failsCheck(Player player) {
}

public void progress(Player player, String taskType, double amount, Map<String, Object> params) {
if(failsCheck(player)) return;
if (failsCheck(player)) return;
CompletableFuture.runAsync(() -> actuallyProgress(player, taskType, amount, params));
}

public void setProgress(Player player, String taskType, double amount, Map<String, Object> params) {
if(failsCheck(player)) return;
if (failsCheck(player)) return;
CompletableFuture.runAsync(() -> actuallySetProgress(player, taskType, amount, params));
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/gg/auroramc/quests/api/quest/TaskType.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ public class TaskType {
public static final String REACH_ISLAND_WORTH = "REACH_ISLAND_WORTH";
public static final String REACH_ISLAND_LEVEL = "REACH_ISLAND_LEVEL";
public static final String UPGRADE_ISLAND = "UPGRADE_ISLAND";
public static final String COMPLETE_DUNGEON = "COMPLETE_DUNGEON";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package gg.auroramc.quests.api.quest.task;

import gg.auroramc.quests.config.quest.TaskConfig;
import org.bukkit.entity.Player;

import java.util.Map;

public class DifficultyTaskEvaluator extends TypedTaskEvaluator {
@Override
public boolean evaluate(Player player, TaskConfig config, Map<String, Object> params) {
var res = super.evaluate(player, config, params);
if (!res) return false;

if (params.containsKey("difficulty") && params.get("difficulty") instanceof String difficulty) {
var concreteDifficulty = config.getArgs().getString("difficulty");
if (concreteDifficulty == null) {
return true;
}
return difficulty.equals(concreteDifficulty);
}

return true;
}
}
2 changes: 2 additions & 0 deletions src/main/java/gg/auroramc/quests/hooks/Hooks.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import gg.auroramc.quests.hooks.fancynpcs.FancyNPCsHook;
import gg.auroramc.quests.hooks.luckperms.LuckPermsHook;
import gg.auroramc.quests.hooks.mmolib.MMOLibHook;
import gg.auroramc.quests.hooks.mythicdungeons.DungeonsHook;
import gg.auroramc.quests.hooks.mythicmobs.MythicHook;
import gg.auroramc.quests.hooks.oraxen.OraxenHook;
import gg.auroramc.quests.hooks.shopguiplus.ShopGUIPlusHook;
Expand All @@ -26,6 +27,7 @@ public enum Hooks {
AURA_SKILLS(AuraSkillsHook.class, "AuraSkills"),
CUSTOM_FISHING(CustomFishingHook.class, "CustomFishing"),
MYTHIC_MOBS(MythicHook.class, "MythicMobs"),
MYTHIC_DUNGEONS(DungeonsHook.class, "MythicDungeons"),
WORLD_GUARD(WorldGuardHook.class, "WorldGuard"),
CITIZENS(CitizensHook.class, "Citizens"),
SHOPKEEPERS(ShopkeepersHook.class, "Shopkeepers"),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package gg.auroramc.quests.hooks.mythicdungeons;

import gg.auroramc.aurora.api.item.TypeId;
import gg.auroramc.quests.AuroraQuests;
import gg.auroramc.quests.api.quest.TaskType;
import gg.auroramc.quests.hooks.Hook;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import net.playavalon.mythicdungeons.api.events.dungeon.PlayerFinishDungeonEvent;

import java.util.Map;

public class DungeonsHook implements Hook, Listener {
private AuroraQuests plugin;

@Override
public void hook(AuroraQuests plugin) {
this.plugin = plugin;
}

@EventHandler
public void onDungeonComplete(PlayerFinishDungeonEvent event) {
var player = event.getPlayer();
var dungeon = event.getDungeon();
var instance = event.getInstance().asPlayInstance();

Map<String, Object> params = instance != null && instance.getDifficulty() != null ? Map.of(
"type", new TypeId("mythicdungeons", dungeon.getFolder().getName()),
"difficulty", instance.getDifficulty().getNamespace()
) : Map.of(
"type", new TypeId("mythicdungeons", dungeon.getFolder().getName())
);

plugin.getQuestManager().progress(player, TaskType.COMPLETE_DUNGEON, 1, params);
}
}
8 changes: 6 additions & 2 deletions src/main/java/gg/auroramc/quests/menu/LevelMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,22 @@
import gg.auroramc.quests.util.RomanNumber;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class LevelMenu {
private final Player player;
private final QuestPool pool;
private int page = 0;
private final Runnable backAction;

public LevelMenu(Player player, QuestPool pool) {
public LevelMenu(Player player, QuestPool pool, @Nullable Runnable backAction) {
this.player = player;
this.pool = pool;
this.backAction = Objects.requireNonNullElseGet(backAction, () -> () -> new PoolMenu(player, pool).open());
}

public void open() {
Expand All @@ -43,7 +47,7 @@ private AuroraMenu createMenu() {

if (cm.getHasBackButton()) {
menu.addItem(ItemBuilder.back(cmf.getItems().get("back").merge(cm.getItems().get("back"))).build(player), (e) -> {
new PoolMenu(player, pool).open();
backAction.run();
});
}

Expand Down
21 changes: 18 additions & 3 deletions src/main/java/gg/auroramc/quests/menu/PoolMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.Collection;
Expand All @@ -25,10 +26,16 @@ public class PoolMenu {
private final QuestPool pool;
private int page = 0;
private boolean isCompletedQuests = false;
private final Runnable backAction;

public PoolMenu(Player player, QuestPool pool) {
public PoolMenu(Player player, QuestPool pool, @Nullable Runnable backAction) {
this.player = player;
this.pool = pool;
this.backAction = backAction;
}

public PoolMenu(Player player, QuestPool pool) {
this(player, pool, null);
}

public void open() {
Expand Down Expand Up @@ -101,7 +108,11 @@ private AuroraMenu createMenu() {
var backConfig = cmf.getItems().get("back").merge(mc.getItems().get("back"));

menu.addItem(ItemBuilder.back(backConfig).build(player), (e) -> {
new MainMenu(player).open();
if (backAction != null) {
backAction.run();
} else {
new MainMenu(player).open();
}
});
}

Expand Down Expand Up @@ -200,7 +211,11 @@ private AuroraMenu createMenu() {
.build(player);

menu.addItem(item, (e) -> {
new LevelMenu(player, pool).open();
if (backAction != null) {
new LevelMenu(player, pool, () -> new PoolMenu(player, pool, backAction).open()).open();
} else {
new LevelMenu(player, pool, null).open();
}
});
}

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ softdepend:
- "FancyNpcs"
- "Adyeshach"
- "SuperiorSkyblock2"
- "MythicDungeons"

website: https://auroramc.gg

Expand Down

0 comments on commit ea20b53

Please sign in to comment.