diff options
| author | Krakenied <Krakenied1@gmail.com> | 2024-02-15 11:27:15 +0100 |
|---|---|---|
| committer | Leonardo Bishop <13875753+LMBishop@users.noreply.github.com> | 2024-02-18 12:19:16 +0000 |
| commit | 4cdb262d04e9a18e3d17e5ac3dea6b8b82158d45 (patch) | |
| tree | f92b656a5efe9896585b6c6ad6a653f5c9a241bb /bukkit/src | |
| parent | df3263bd6ca13a4840e7165453e280a33399859a (diff) | |
Add ServerNPC support
Diffstat (limited to 'bukkit/src')
3 files changed, 42 insertions, 0 deletions
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 14c2d5a5..f05c2454 100644 --- a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/BukkitQuestsPlugin.java @@ -104,6 +104,7 @@ import com.leonardobishop.quests.bukkit.tasktype.type.dependent.NuVotifierVoteTa import com.leonardobishop.quests.bukkit.tasktype.type.dependent.PlaceholderAPIEvaluateTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.PlayerPointsEarnTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.PyroFishingProFishingTaskType; +import com.leonardobishop.quests.bukkit.tasktype.type.dependent.ServerNPCDeliverTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.ShopGUIPlusBuyTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.ShopGUIPlusSellTaskType; import com.leonardobishop.quests.bukkit.tasktype.type.dependent.SuperiorSkyblockLevelType; @@ -442,6 +443,7 @@ public class BukkitQuestsPlugin extends JavaPlugin implements Quests { taskTypeManager.registerTaskType(() -> new PlaceholderAPIEvaluateTaskType(this), () -> CompatUtils.isPluginEnabled("PlaceholderAPI")); taskTypeManager.registerTaskType(() -> new PlayerPointsEarnTaskType(this), () -> CompatUtils.isPluginEnabled("PlayerPoints")); taskTypeManager.registerTaskType(() -> new PyroFishingProFishingTaskType(this), () -> CompatUtils.isPluginEnabled("PyroFishingPro") && CompatUtils.classExists("me.arsmagica.API.PyroFishCatchEvent")); + taskTypeManager.registerTaskType(() -> new ServerNPCDeliverTaskType(this), () -> CompatUtils.isPluginEnabled("ServerNPC")); taskTypeManager.registerTaskType(() -> new ShopGUIPlusBuyTaskType(this), () -> CompatUtils.isPluginEnabled("ShopGUIPlus")); // not tested taskTypeManager.registerTaskType(() -> new ShopGUIPlusSellTaskType(this), () -> CompatUtils.isPluginEnabled("ShopGUIPlus")); // not tested taskTypeManager.registerTaskType(() -> new SuperiorSkyblockLevelType(this), () -> CompatUtils.isPluginEnabled("SuperiorSkyblock2")); // not tested diff --git a/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/ServerNPCDeliverTaskType.java b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/ServerNPCDeliverTaskType.java new file mode 100644 index 00000000..ff02f407 --- /dev/null +++ b/bukkit/src/main/java/com/leonardobishop/quests/bukkit/tasktype/type/dependent/ServerNPCDeliverTaskType.java @@ -0,0 +1,39 @@ +package com.leonardobishop.quests.bukkit.tasktype.type.dependent; + +import com.isnakebuzz.npcapi.entities.SnakeHologram; +import com.isnakebuzz.npcapi.entities.SnakeNPC; +import com.isnakebuzz.npcapi.enums.ClickType; +import com.isnakebuzz.npcapi.events.NPCInteractEvent; +import com.leonardobishop.quests.bukkit.BukkitQuestsPlugin; +import com.leonardobishop.quests.bukkit.util.TaskUtils; +import com.leonardobishop.quests.common.quest.Task; +import org.bukkit.event.EventHandler; +import org.bukkit.event.EventPriority; + +public final class ServerNPCDeliverTaskType extends DeliverTaskType<String> { + + private final BukkitQuestsPlugin plugin; + + public ServerNPCDeliverTaskType(BukkitQuestsPlugin plugin) { + super("servernpc_deliver", TaskUtils.TASK_ATTRIBUTION_STRING, "Deliver a set of items to a ServerNPC NPC."); + this.plugin = plugin; + } + + @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) + public void onNPCInteract(NPCInteractEvent event) { + if (event.getClickType() != ClickType.RIGHT_CLICK) { + return; + } + + SnakeNPC npc = event.getSnakeNPC(); + SnakeHologram hologram = npc.getHologram(); + String name = String.join("\n", hologram.getLines()); + + checkInventory(event.getPlayer(), npc.getName(), name, 1L, plugin); + } + + @Override + public String getNPCId(Task task) { + return (String) task.getConfigValue("npc-id"); + } +} diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index fd816a1b..8a9eeab7 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -21,6 +21,7 @@ softdepend: - PlayerBlockTracker - PlayerPoints - PyroFishingPro +- ServerNPC - ShopGUIPlus - SuperiorSkyblock2 - uSkyBlock |
