diff options
| author | Krakenied <krakenied1@gmail.com> | 2025-06-08 18:58:19 +0200 |
|---|---|---|
| committer | Krakenied <46192742+Krakenied@users.noreply.github.com> | 2025-07-29 00:06:46 +0200 |
| commit | afecac14e341dec1e30f4a2639c8cc1337dbe86a (patch) | |
| tree | cf8d801d9adb233920af4be3b2ce86a8c6739cd5 | |
| parent | 1ed7e4187f4da08013e859cfe191fb5af8cee428 (diff) | |
Implement FancyNpcs support
7 files changed, 207 insertions, 2 deletions
diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index 9e95a0e7..7d9d6292 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -29,6 +29,8 @@ repositories { maven("https://repo.auxilor.io/repository/maven-public/") // EssentialsX maven("https://repo.essentialsx.net/releases/") + // FancyNpcs + maven("https://repo.fancyinnovations.com/releases") // MMOItems, MythicLib maven("https://nexus.phoenixdevt.fr/repository/maven-public/") // MythicMobs 4, MythicMobs 5 @@ -74,8 +76,8 @@ dependencies { // BedWars1058 compileOnlyPlugin("com.andrei1058.bedwars:bedwars-api:22.01") // BentoBox - compileOnly("world.bentobox:bentobox:2.5.4-SNAPSHOT") - compileOnly("world.bentobox:level:2.16.1-SNAPSHOT") + compileOnlyPlugin("world.bentobox:bentobox:2.5.4-SNAPSHOT") + compileOnlyPlugin("world.bentobox:level:2.16.1-SNAPSHOT") // Citizens compileOnlyPlugin("net.citizensnpcs:citizensapi:2.0.30-SNAPSHOT") // CoreProtect @@ -89,6 +91,8 @@ dependencies { compileOnlyPlugin("com.willfp:libreforge:4.21.1") // EssentialsX compileOnlyPlugin("net.essentialsx:EssentialsX:2.19.7") + // FancyNpcs + compileOnlyPlugin("de.oliver:FancyNpcs:2.5.1") // IridiumSkyblock TODO fix whenever repo is up //compileOnlyPlugin("com.github.Iridium-Development:IridiumSkyblock:master-SNAPSHOT") // ItemsAdder diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java index 21afa14f..a08fb4f0 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java @@ -120,6 +120,8 @@ import com.leonardobishop.quests.bukkit.tasktype.type.dependent.EcoMobsKillingTa import com.leonardobishop.quests.bukkit.tasktype.type.dependent.EssentialsBalanceTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.EssentialsMoneyEarnTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.FabledSkyBlockLevelTaskType; +import com.leonardobishop.quests.bukkit.tasktype.type.dependent.FancyNpcsDeliverTaskType; +import com.leonardobishop.quests.bukkit.tasktype.type.dependent.FancyNpcsInteractTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.IridiumSkyblockValueTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.MythicMobsKillingTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.NuVotifierVoteTaskType; @@ -500,6 +502,8 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests { taskTypeManager.registerTaskType(() -> new EssentialsBalanceTaskType(this), () -> CompatUtils.isPluginEnabled("Essentials")); taskTypeManager.registerTaskType(() -> new EssentialsMoneyEarnTaskType(this), () -> CompatUtils.isPluginEnabled("Essentials")); taskTypeManager.registerTaskType(() -> new FabledSkyBlockLevelTaskType(this), () -> CompatUtils.isPluginEnabled("FabledSkyBlock")); // not tested + taskTypeManager.registerTaskType(() -> new FancyNpcsDeliverTaskType(this), () -> CompatUtils.isPluginEnabled("FancyNpcs")); + taskTypeManager.registerTaskType(() -> new FancyNpcsInteractTaskType(this), () -> CompatUtils.isPluginEnabled("FancyNpcs")); taskTypeManager.registerTaskType(() -> new PinataPartyHitTaskType(this), () -> CompatUtils.isPluginEnabled("PinataParty")); taskTypeManager.registerTaskType(() -> new PlaceholderAPIEvaluateTaskType(this), () -> CompatUtils.isPluginEnabled("PlaceholderAPI")); taskTypeManager.registerTaskType(() -> new PlayerPointsEarnTaskType(this), () -> CompatUtils.isPluginEnabled("PlayerPoints")); diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/FancyNpcsDeliverTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/FancyNpcsDeliverTaskType.java new file mode 100644 index 00000000..e377642f --- /dev/null +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/FancyNpcsDeliverTaskType.java @@ -0,0 +1,41 @@ +package com.leonardobishop.quests.bukkit.tasktype.type.dependent; + +import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin; +import com.leonardobishop.quests.bukkit.util.TaskUtils; +import com.leonardobishop.quests.common.quest.Task; +import de.oliver.fancynpcs.api.Npc; +import de.oliver.fancynpcs.api.actions.ActionTrigger; +import de.oliver.fancynpcs.api.events.NpcInteractEvent; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import java.util.List; + +public final class FancyNpcsDeliverTaskType extends DeliverTaskType<String> { + + private final BukkitQuestsPlugin plugin; + + public FancyNpcsDeliverTaskType(BukkitQuestsPlugin plugin) { + super("fancynpcs_deliver", TaskUtils.TASK_ATTRIBUTION_STRING, "Deliver a set of items to a FancyNpcs NPC."); + this.plugin = plugin; + + super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "npc-id")); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onNpcInteract(NpcInteractEvent event) { + ActionTrigger trigger = event.getInteractionType(); + + if (trigger != ActionTrigger.RIGHT_CLICK) { + return; + } + + Npc npc = event.getNpc(); + checkInventory(event.getPlayer(), npc.getData().getId(), npc.getData().getDisplayName(), 1L, plugin); + } + + @Override + public List<String> getNPCId(Task task) { + return TaskUtils.getConfigStringList(task, "npc-id"); + } +} diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/FancyNpcsInteractTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/FancyNpcsInteractTaskType.java new file mode 100644 index 00000000..bb4fd378 --- /dev/null +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/FancyNpcsInteractTaskType.java @@ -0,0 +1,41 @@ +package com.leonardobishop.quests.bukkit.tasktype.type.dependent; + +import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin; +import com.leonardobishop.quests.bukkit.util.TaskUtils; +import com.leonardobishop.quests.common.quest.Task; +import de.oliver.fancynpcs.api.Npc; +import de.oliver.fancynpcs.api.actions.ActionTrigger; +import de.oliver.fancynpcs.api.events.NpcInteractEvent; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +import java.util.List; + +public final class FancyNpcsInteractTaskType extends InteractTaskType<String> { + + private final BukkitQuestsPlugin plugin; + + public FancyNpcsInteractTaskType(BukkitQuestsPlugin plugin) { + super("fancynpcs_interact", TaskUtils.TASK_ATTRIBUTION_STRING, "Interact with a FancyNpcs NPC to complete the quest."); + this.plugin = plugin; + + super.addConfigValidator(TaskUtils.useIntegerConfigValidator(this, "npc-id")); + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onNpcInteract(NpcInteractEvent event) { + ActionTrigger trigger = event.getInteractionType(); + + if (trigger != ActionTrigger.RIGHT_CLICK) { + return; + } + + Npc npc = event.getNpc(); + handle(event.getPlayer(), npc.getData().getId(), npc.getData().getDisplayName(), plugin); + } + + @Override + public List<String> getNPCId(Task task) { + return TaskUtils.getConfigStringList(task, "npc-id"); + } +} diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 33feddff..982ef575 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -18,6 +18,7 @@ softdepend: - EcoMobs - Essentials - FabledSkyBlock +- FancyNpcs - IridiumSkyblock - MythicMobs - Nexo diff --git a/docs/task-types/fancynpcs_deliver-(task-type).md b/docs/task-types/fancynpcs_deliver-(task-type).md new file mode 100644 index 00000000..7b391c08 --- /dev/null +++ b/docs/task-types/fancynpcs_deliver-(task-type).md @@ -0,0 +1,79 @@ +--- +title: fancynpcs_deliver +parent: External task types +grand_parent: Task types +--- + +# fancynpcs_deliver (task type) + +Not released yet (dev builds) +{: .label .label-green } + +Plugin 'FancyNpcs' required +{: .label } + +Deliver a set of items to a FancyNpcs NPC. + +## Options + +| Key | Description | Type | Required | Default | Notes | +|------------------------------|------------------------------------------------------------------|------------------------|----------|---------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `amount` | The number of items to deliver. | Integer | Yes | \- | \- | +| `item` | The specific item to deliver. | Material, or ItemStack | Yes | \- | Accepts standard [item definition](../configuration/defining-items). Please see [this list](https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html) (1.13+) or [this list](https://helpch.at/docs/1.12.2/org/bukkit/Material.html) (1.8-1.12) for material names. | +| `data` | The data code for the item. | Integer | No | 0 | This field is not used in Minecraft versions 1.13+, nor is it compatible with ItemStack definitions. | +| `exact-match` | Whether the item should exactly match what is defined. | Boolean | No | true | \- | +| `remove-items-when-complete` | Whether the items should be taken from the player when complete. | Boolean | No | false | If `allow-partial-completion` is true, then this will also be set to true. | +| `allow-partial-completion` | Whether any number of items counts towards the task progress. | Boolean | No | true | Setting to true will force `remove-items-when-complete` to true as well. If a player obtains any matching item, it will be immediately taken away from them and added towards the quest progress. | +| `npc-name` | The name of the NPC to deliver to. | String | No | \- | Mutually exclusive with `npc-id`. | +| `npc-id` | The id of the NPC to deliver to. | String | No | \- | Mutually exclusive with `npc-name`. | +| `worlds` | Worlds which should count towards the progress. | List of world names | No | \- | \- | + +## Examples + +Deliver 8 of `BEEF` to an NPC with ID "gerald": + +``` yaml +fancynpcsdeliver: + type: "fancynpcs_deliver" + npc-id: "gerald" # ID of NPC + item: BEEF # name of item (can be id or minecraft name) + amount: 8 # amount of item needed + remove-items-when-complete: false # (OPTIONAL) take the items away from the player on completion - default: false + allow-partial-completion: false # (OPTIONAL) allow partial deliveries - default: false + worlds: # (OPTIONAL) restrict to certain worlds + - "world" +``` + +Deliver 8 of a specific item to an NPC with ID "gerald": + +``` yaml +beef: + type: "fancynpcsplus_deliver" + npc-id: "gerald" # ID of NPC + item: # SPECIFIC item with name and lore + name: "&cSpecial Beef" + type: "BEEF" + lore: + - "&7This is a special type of beef" + amount: 8 # amount of item needed + remove-items-when-complete: false # (OPTIONAL) take the items away from the player on completion - default: false + accept-partial-completion: false # (OPTIONAL) allow partial deliveries - default: false + worlds: # (OPTIONAL) restrict to certain worlds + - "world" +``` + +Deliver 8 of [quest item](../configuration/defining-items#quest-items) +`special_beef` to an NPC with ID "gerald": + +``` yaml +beef: + type: "fancynpcs_deliver" + npc-id: "npc1" # ID of NPC + item: # USING quest-item + quest-item: "special_beef" + amount: 8 # amount of item needed + remove-items-when-complete: false # (OPTIONAL) take the items away from the player on completion - default: false + accept-partial-completion: false # (OPTIONAL) allow partial deliveries - default: false + worlds: # (OPTIONAL) restrict to certain worlds + - "world" +``` diff --git a/docs/task-types/fancynpcs_interact-(task-type).md b/docs/task-types/fancynpcs_interact-(task-type).md new file mode 100644 index 00000000..f0abcde7 --- /dev/null +++ b/docs/task-types/fancynpcs_interact-(task-type).md @@ -0,0 +1,35 @@ +--- +title: fancynpcs_interact +parent: External task types +grand_parent: Task types +--- + +# fancynpcs_interact (task type) + +Not released yet (dev builds) +{: .label .label-green } + +Plugin 'FancyNpcs' required +{: .label } + +Interact with a FancyNpcs NPC. + +## Options + +| Key | Description | Type | Required | Default | Notes | +|------------|-------------------------------------------------|---------------------|----------|---------|-------------------------------------| +| `npc-name` | The name of the NPC to interact with. | String | No | \- | Mutually exclusive with `npc-id`. | +| `npc-id` | The id of the NPC to interact with. | String | No | \- | Mutually exclusive with `npc-name`. | +| `worlds` | Worlds which should count towards the progress. | List of world names | No | \- | \- | + +## Examples + +Interact with an NPC with ID "gerald": + +``` yaml +fancynpcsinteract: + type: "fancynpcs_interact + npc-id: "gerald" # ID of NPC + worlds: # (OPTIONAL) restrict to certain worlds + - "world" +``` |
