mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-29 20:09:14 +00:00
Add BattlePass Plugin hook.
This commit is contained in:
@@ -30,6 +30,7 @@ import net.momirealms.customfishing.compatibility.entity.ItemsAdderEntityImpl;
|
||||
import net.momirealms.customfishing.compatibility.entity.MythicEntityImpl;
|
||||
import net.momirealms.customfishing.compatibility.item.*;
|
||||
import net.momirealms.customfishing.compatibility.level.*;
|
||||
import net.momirealms.customfishing.compatibility.quest.BattlePassHook;
|
||||
import net.momirealms.customfishing.compatibility.quest.BetonQuestHook;
|
||||
import net.momirealms.customfishing.compatibility.quest.ClueScrollsHook;
|
||||
import net.momirealms.customfishing.compatibility.quest.NotQuestHook;
|
||||
@@ -134,6 +135,11 @@ public class IntegrationManagerImpl implements IntegrationManager {
|
||||
if (plugin.isHookedPluginEnabled("Vault")) {
|
||||
VaultHook.initialize();
|
||||
}
|
||||
if (plugin.isHookedPluginEnabled("BattlePass")){
|
||||
BattlePassHook battlePassHook = new BattlePassHook();
|
||||
battlePassHook.register();
|
||||
hookMessage("BattlePass");
|
||||
}
|
||||
if (plugin.isHookedPluginEnabled("ClueScrolls")) {
|
||||
ClueScrollsHook clueScrollsHook = new ClueScrollsHook();
|
||||
clueScrollsHook.register();
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package net.momirealms.customfishing.compatibility.quest;
|
||||
|
||||
import io.github.battlepass.BattlePlugin;
|
||||
import io.github.battlepass.api.events.server.PluginReloadEvent;
|
||||
import net.advancedplugins.bp.impl.actions.ActionRegistry;
|
||||
import net.advancedplugins.bp.impl.actions.external.executor.ActionQuestExecutor;
|
||||
import net.momirealms.customfishing.api.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.event.FishingResultEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class BattlePassHook implements Listener {
|
||||
|
||||
public BattlePassHook() {
|
||||
Bukkit.getPluginManager().registerEvents(this, CustomFishingPlugin.get());
|
||||
}
|
||||
|
||||
public void register() {
|
||||
ActionRegistry actionRegistry = BattlePlugin.getPlugin().getActionRegistry();
|
||||
actionRegistry.hook("customfishing", BPFishingQuest::new);
|
||||
}
|
||||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onBattlePassReload(PluginReloadEvent event){
|
||||
register();
|
||||
}
|
||||
|
||||
|
||||
private static class BPFishingQuest extends ActionQuestExecutor {
|
||||
public BPFishingQuest(JavaPlugin plugin) {
|
||||
super(plugin, "customfishing");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onFish(FishingResultEvent event){
|
||||
if (event.isCancelled() || event.getResult() == FishingResultEvent.Result.FAILURE)
|
||||
return;
|
||||
Player player = event.getPlayer();
|
||||
|
||||
// Single Fish Quest
|
||||
if (event.getLoot().getID() != null)
|
||||
this.executionBuilder("fish")
|
||||
.player(player)
|
||||
.root(event.getLoot().getID())
|
||||
.progress(event.getAmount())
|
||||
.buildAndExecute();
|
||||
|
||||
// Group Fish Quest
|
||||
String[] lootGroup = event.getLoot().getLootGroup();
|
||||
if (event.getLoot() != null && lootGroup != null)
|
||||
for (String group : lootGroup) {
|
||||
this.executionBuilder("group")
|
||||
.player(player)
|
||||
.root(group)
|
||||
.progress(event.getAmount())
|
||||
.buildAndExecute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user