Skip to content

Commit

Permalink
Add ServerNPC support
Browse files Browse the repository at this point in the history
  • Loading branch information
Krakenied authored and LMBishop committed Feb 18, 2024
1 parent df3263b commit 4cdb262
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
Binary file added bukkit/libs/ServerNPC-1.16.1-b1.jar
Binary file not shown.
Expand Up @@ -104,6 +104,7 @@
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;
Expand Down Expand Up @@ -442,6 +443,7 @@ public void onEnable() {
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
Expand Down
@@ -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");
}
}
1 change: 1 addition & 0 deletions bukkit/src/main/resources/plugin.yml
Expand Up @@ -21,6 +21,7 @@ softdepend:
- PlayerBlockTracker
- PlayerPoints
- PyroFishingPro
- ServerNPC
- ShopGUIPlus
- SuperiorSkyblock2
- uSkyBlock
Expand Down

0 comments on commit 4cdb262

Please sign in to comment.