From 2ad24b06596f687a4ea5576e14ec7d411d184b8d Mon Sep 17 00:00:00 2001 From: Xiao-MoMi <70987828+Xiao-MoMi@users.noreply.github.com> Date: Mon, 9 Jan 2023 19:31:45 +0800 Subject: [PATCH] 1.2.17.1 --- build.gradle | 2 +- .../api/event/FishResultEvent.java | 9 ++- .../integration/quest/BattlePassCFQuest.java | 55 +++++++++++++++++++ .../integration/quest/BetonQuestHook.java | 21 +++++++ .../integration/quest/ClueScrollHook.java | 18 ++++++ .../customfishing/manager/FishingManager.java | 10 ++-- .../manager/IntegrationManager.java | 9 +++ 7 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 src/main/java/net/momirealms/customfishing/integration/quest/BattlePassCFQuest.java create mode 100644 src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestHook.java diff --git a/build.gradle b/build.gradle index 2c110359..837f0dcd 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group = 'net.momirealms' -version = '1.2.17' +version = '1.2.17.1' repositories { mavenCentral() diff --git a/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java b/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java index 29f1360e..531cb7a5 100644 --- a/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java +++ b/src/main/java/net/momirealms/customfishing/api/event/FishResultEvent.java @@ -32,14 +32,16 @@ public class FishResultEvent extends PlayerEvent implements Cancellable { private boolean isDouble; private final FishResult result; private final ItemStack loot; + private final String loot_id; private static final HandlerList handlerList = new HandlerList(); - public FishResultEvent(@NotNull Player who, FishResult result, boolean isDouble, ItemStack loot) { + public FishResultEvent(@NotNull Player who, FishResult result, boolean isDouble, @Nullable ItemStack loot, @Nullable String loot_id) { super(who); this.cancelled = false; this.result = result; this.isDouble = isDouble; this.loot = loot; + this.loot_id = loot_id; } @Override @@ -79,4 +81,9 @@ public class FishResultEvent extends PlayerEvent implements Cancellable { public void setDouble(boolean willDouble) { isDouble = willDouble; } + + @Nullable + public String getLoot_id() { + return loot_id; + } } diff --git a/src/main/java/net/momirealms/customfishing/integration/quest/BattlePassCFQuest.java b/src/main/java/net/momirealms/customfishing/integration/quest/BattlePassCFQuest.java new file mode 100644 index 00000000..5117bb95 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/quest/BattlePassCFQuest.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.quest; + +import io.github.battlepass.BattlePlugin; +import io.github.battlepass.objects.quests.variable.QuestResult; +import io.github.battlepass.quests.quests.external.executor.ExternalQuestExecutor; +import io.github.battlepass.registry.quest.QuestRegistry; +import net.momirealms.customfishing.CustomFishing; +import net.momirealms.customfishing.api.event.FishResultEvent; +import net.momirealms.customfishing.object.fishing.FishResult; +import org.bukkit.Bukkit; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class BattlePassCFQuest extends ExternalQuestExecutor implements Listener { + + public static void register() { + QuestRegistry questRegistry = BattlePlugin.getApi().getQuestRegistry(); + questRegistry.hook("customfishing", instance -> { + BattlePassCFQuest battlePassCFQuest = new BattlePassCFQuest(instance); + return battlePassCFQuest; + }); + } + + public BattlePassCFQuest(BattlePlugin battlePlugin) { + super(battlePlugin, "customfishing"); + } + + @EventHandler + public void onFishCaught(FishResultEvent event) { + if (event.isCancelled()) return; + Player player = event.getPlayer(); + if (event.getResult() == FishResult.CAUGHT_LOOT || event.getResult() == FishResult.CAUGHT_VANILLA || event.getResult() == FishResult.CAUGHT_MOB) { + this.execute("fish", player, (var1x) -> var1x.root(event.getLoot_id())); + } + } +} diff --git a/src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestHook.java b/src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestHook.java new file mode 100644 index 00000000..4a476485 --- /dev/null +++ b/src/main/java/net/momirealms/customfishing/integration/quest/BetonQuestHook.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package net.momirealms.customfishing.integration.quest; + +public class BetonQuestHook { +} diff --git a/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollHook.java b/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollHook.java index 446940db..933e1a5a 100644 --- a/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollHook.java +++ b/src/main/java/net/momirealms/customfishing/integration/quest/ClueScrollHook.java @@ -1,3 +1,20 @@ +/* + * Copyright (C) <2022> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package net.momirealms.customfishing.integration.quest; import com.electro2560.dev.cluescrolls.api.ClueScrollsAPI; @@ -22,6 +39,7 @@ public class ClueScrollHook implements Listener { @EventHandler public void onFish(FishResultEvent event) { + if (event.isCancelled()) return; if (event.getResult() == FishResult.CAUGHT_LOOT || event.getResult() == FishResult.CAUGHT_VANILLA) { fishClue.handle(event.getPlayer(), 1); commonClue.handle(event.getPlayer(), 1); diff --git a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java index 20680d76..a460264a 100644 --- a/src/main/java/net/momirealms/customfishing/manager/FishingManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/FishingManager.java @@ -498,7 +498,7 @@ public class FishingManager extends Function { private void dropCustomFishingLoot(Player player, Location location, DroppedItem droppedItem, boolean isDouble, double scoreMultiplier) { ItemStack drop = getCustomFishingLootItemStack(droppedItem, player); - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_LOOT, isDouble, drop); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_LOOT, isDouble, drop, droppedItem.getKey()); Bukkit.getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return; @@ -539,7 +539,7 @@ public class FishingManager extends Function { ItemStack itemStack = McMMOTreasure.getTreasure(player); if (itemStack == null) return false; - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_VANILLA, isDouble, itemStack); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_VANILLA, isDouble, itemStack, "mcmmo"); Bukkit.getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return true; @@ -582,7 +582,7 @@ public class FishingManager extends Function { } } - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_VANILLA, isDouble, itemStack); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_VANILLA, isDouble, itemStack, "vanilla"); Bukkit.getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return; @@ -605,7 +605,7 @@ public class FishingManager extends Function { MobInterface mobInterface = CustomFishing.plugin.getIntegrationManager().getMobInterface(); if (mobInterface == null) return; - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_MOB, false, null); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.CAUGHT_MOB, false, null, loot.getKey()); if (fishResultEvent.isCancelled()) { return; } @@ -695,7 +695,7 @@ public class FishingManager extends Function { private void fail(Player player, Loot loot, boolean isVanilla) { - FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.FAILURE, false, null); + FishResultEvent fishResultEvent = new FishResultEvent(player, FishResult.FAILURE, false, null, "null"); Bukkit.getServer().getPluginManager().callEvent(fishResultEvent); if (fishResultEvent.isCancelled()) { return; diff --git a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java index cb52cd13..d3f7c01f 100644 --- a/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java +++ b/src/main/java/net/momirealms/customfishing/manager/IntegrationManager.java @@ -27,6 +27,7 @@ import net.momirealms.customfishing.integration.block.VanillaBlockImpl; import net.momirealms.customfishing.integration.item.*; import net.momirealms.customfishing.integration.mob.MythicMobsMobImpl; import net.momirealms.customfishing.integration.papi.PlaceholderManager; +import net.momirealms.customfishing.integration.quest.BattlePassCFQuest; import net.momirealms.customfishing.integration.quest.ClueScrollHook; import net.momirealms.customfishing.integration.season.CustomCropsSeasonImpl; import net.momirealms.customfishing.integration.season.RealisticSeasonsImpl; @@ -216,6 +217,14 @@ public class IntegrationManager extends Function { Bukkit.getPluginManager().registerEvents(clueScrollHook, CustomFishing.plugin); hookMessage("ClueScrolls"); } + if (Bukkit.getPluginManager().isPluginEnabled("BetonQuest")) { + + hookMessage("BetonQuest"); + } + if (Bukkit.getPluginManager().isPluginEnabled("BattlePass")) { + BattlePassCFQuest.register(); + hookMessage("BattlePass"); + } } @Override