9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +00:00

Fix compatibility with latest BQ, AS

This commit is contained in:
XiaoMoMi
2024-08-08 03:03:42 +08:00
parent 44b7384efd
commit 228fc9a163
6 changed files with 45 additions and 45 deletions

View File

@@ -44,7 +44,7 @@ dependencies {
compileOnly(files("libs/BattlePass-4.0.6-api.jar")) compileOnly(files("libs/BattlePass-4.0.6-api.jar"))
compileOnly(files("libs/ClueScrolls-4.8.7-api.jar")) compileOnly(files("libs/ClueScrolls-4.8.7-api.jar"))
compileOnly(files("libs/notquests-5.17.1.jar")) compileOnly(files("libs/notquests-5.17.1.jar"))
compileOnly("org.betonquest:betonquest:2.1.2") compileOnly("org.betonquest:betonquest:2.1.3")
// item // item
compileOnly(files("libs/zaphkiel-2.0.24.jar")) compileOnly(files("libs/zaphkiel-2.0.24.jar"))
compileOnly("com.github.LoneDev6:API-ItemsAdder:3.6.1") compileOnly("com.github.LoneDev6:API-ItemsAdder:3.6.1")

View File

@@ -21,14 +21,15 @@ import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.event.FishingResultEvent; import net.momirealms.customfishing.api.event.FishingResultEvent;
import org.betonquest.betonquest.BetonQuest; import org.betonquest.betonquest.BetonQuest;
import org.betonquest.betonquest.Instruction; import org.betonquest.betonquest.Instruction;
import org.betonquest.betonquest.VariableNumber;
import org.betonquest.betonquest.api.CountingObjective; import org.betonquest.betonquest.api.CountingObjective;
import org.betonquest.betonquest.api.config.quest.QuestPackage; import org.betonquest.betonquest.api.config.quest.QuestPackage;
import org.betonquest.betonquest.api.profiles.OnlineProfile; import org.betonquest.betonquest.api.profiles.OnlineProfile;
import org.betonquest.betonquest.api.profiles.Profile; import org.betonquest.betonquest.api.profiles.Profile;
import org.betonquest.betonquest.exceptions.InstructionParseException; import org.betonquest.betonquest.exceptions.InstructionParseException;
import org.betonquest.betonquest.exceptions.QuestRuntimeException;
import org.betonquest.betonquest.instruction.variable.VariableNumber;
import org.betonquest.betonquest.instruction.variable.location.VariableLocation;
import org.betonquest.betonquest.utils.PlayerConverter; import org.betonquest.betonquest.utils.PlayerConverter;
import org.betonquest.betonquest.utils.location.CompoundLocation;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@@ -43,23 +44,13 @@ public class BetonQuestQuest {
public static void register() { public static void register() {
BetonQuest ins1 = BetonQuest.getInstance(); BetonQuest ins1 = BetonQuest.getInstance();
if (ins1 != null) { ins1.registerObjectives("customfishing_loot", IDObjective.class);
ins1.registerObjectives("customfishing_loot", IDObjective.class); ins1.registerObjectives("customfishing_group", GroupObjective.class);
ins1.registerObjectives("customfishing_group", GroupObjective.class);
} else {
Bukkit.getScheduler().runTaskLater(BukkitCustomFishingPlugin.getInstance().getBoostrap(), () -> {
BetonQuest ins2 = BetonQuest.getInstance();
if (ins2 != null) {
ins2.registerObjectives("customfishing_loot", IDObjective.class);
ins2.registerObjectives("customfishing_group", GroupObjective.class);
}
}, 1);
}
} }
public static class IDObjective extends CountingObjective implements Listener { public static class IDObjective extends CountingObjective implements Listener {
private final CompoundLocation playerLocation; private final VariableLocation playerLocation;
private final VariableNumber rangeVar; private final VariableNumber rangeVar;
private final HashSet<String> loot_ids; private final HashSet<String> loot_ids;
@@ -67,14 +58,13 @@ public class BetonQuestQuest {
super(instruction, "loot_to_fish"); super(instruction, "loot_to_fish");
loot_ids = new HashSet<>(); loot_ids = new HashSet<>();
Collections.addAll(loot_ids, instruction.getArray()); Collections.addAll(loot_ids, instruction.getArray());
targetAmount = instruction.getVarNum(); targetAmount = instruction.getVarNum(VariableNumber.NOT_LESS_THAN_ONE_CHECKER);
preCheckAmountNotLessThanOne(targetAmount);
final QuestPackage pack = instruction.getPackage(); final QuestPackage pack = instruction.getPackage();
final String loc = instruction.getOptional("playerLocation"); final String loc = instruction.getOptional("playerLocation");
final String range = instruction.getOptional("range"); final String range = instruction.getOptional("range");
if (loc != null && range != null) { if (loc != null && range != null) {
playerLocation = new CompoundLocation(pack, loc); playerLocation = new VariableLocation(BetonQuest.getInstance().getVariableProcessor(), pack, loc);
rangeVar = new VariableNumber(pack, range); rangeVar = new VariableNumber(BetonQuest.getInstance().getVariableProcessor(), pack, range);
} else { } else {
playerLocation = null; playerLocation = null;
rangeVar = null; rangeVar = null;
@@ -105,12 +95,17 @@ public class BetonQuestQuest {
final Location targetLocation; final Location targetLocation;
try { try {
targetLocation = playerLocation.getLocation(profile); targetLocation = playerLocation.getValue(profile);
} catch (final org.betonquest.betonquest.exceptions.QuestRuntimeException e) { } catch (final org.betonquest.betonquest.exceptions.QuestRuntimeException e) {
e.printStackTrace(); e.printStackTrace();
return true; return true;
} }
final int range = rangeVar.getInt(profile); int range;
try {
range = rangeVar.getValue(profile).intValue();
} catch (QuestRuntimeException e) {
throw new RuntimeException(e);
}
final Location playerLoc = event.getPlayer().getLocation(); final Location playerLoc = event.getPlayer().getLocation();
return !playerLoc.getWorld().equals(targetLocation.getWorld()) || targetLocation.distanceSquared(playerLoc) > range * range; return !playerLoc.getWorld().equals(targetLocation.getWorld()) || targetLocation.distanceSquared(playerLoc) > range * range;
} }
@@ -128,7 +123,7 @@ public class BetonQuestQuest {
public static class GroupObjective extends CountingObjective implements Listener { public static class GroupObjective extends CountingObjective implements Listener {
private final CompoundLocation playerLocation; private final VariableLocation playerLocation;
private final VariableNumber rangeVar; private final VariableNumber rangeVar;
private final HashSet<String> loot_groups; private final HashSet<String> loot_groups;
@@ -136,14 +131,13 @@ public class BetonQuestQuest {
super(instruction, "group_to_fish"); super(instruction, "group_to_fish");
loot_groups = new HashSet<>(); loot_groups = new HashSet<>();
Collections.addAll(loot_groups, instruction.getArray()); Collections.addAll(loot_groups, instruction.getArray());
targetAmount = instruction.getVarNum(); targetAmount = instruction.getVarNum(VariableNumber.NOT_LESS_THAN_ONE_CHECKER);
preCheckAmountNotLessThanOne(targetAmount);
final QuestPackage pack = instruction.getPackage(); final QuestPackage pack = instruction.getPackage();
final String loc = instruction.getOptional("playerLocation"); final String loc = instruction.getOptional("playerLocation");
final String range = instruction.getOptional("range"); final String range = instruction.getOptional("range");
if (loc != null && range != null) { if (loc != null && range != null) {
playerLocation = new CompoundLocation(pack, loc); playerLocation = new VariableLocation(BetonQuest.getInstance().getVariableProcessor(), pack, loc);
rangeVar = new VariableNumber(pack, range); rangeVar = new VariableNumber(BetonQuest.getInstance().getVariableProcessor(), pack, range);
} else { } else {
playerLocation = null; playerLocation = null;
rangeVar = null; rangeVar = null;
@@ -179,12 +173,17 @@ public class BetonQuestQuest {
final Location targetLocation; final Location targetLocation;
try { try {
targetLocation = playerLocation.getLocation(profile); targetLocation = playerLocation.getValue(profile);
} catch (final org.betonquest.betonquest.exceptions.QuestRuntimeException e) { } catch (final org.betonquest.betonquest.exceptions.QuestRuntimeException e) {
e.printStackTrace(); e.printStackTrace();
return true; return true;
} }
final int range = rangeVar.getInt(profile); int range;
try {
range = rangeVar.getValue(profile).intValue();
} catch (QuestRuntimeException e) {
throw new RuntimeException(e);
}
final Location playerLoc = event.getPlayer().getLocation(); final Location playerLoc = event.getPlayer().getLocation();
return !playerLoc.getWorld().equals(targetLocation.getWorld()) || targetLocation.distanceSquared(playerLoc) > range * range; return !playerLoc.getWorld().equals(targetLocation.getWorld()) || targetLocation.distanceSquared(playerLoc) > range * range;
} }

View File

@@ -17,7 +17,7 @@
package net.momirealms.customfishing.bukkit.integration.season; package net.momirealms.customfishing.bukkit.integration.season;
import net.advancedplugins.seasons.api.AdvancedSeasonsAPI; import net.advancedplugins.seasons.Core;
import net.momirealms.customfishing.api.integration.SeasonProvider; import net.momirealms.customfishing.api.integration.SeasonProvider;
import net.momirealms.customfishing.api.mechanic.misc.season.Season; import net.momirealms.customfishing.api.mechanic.misc.season.Season;
import org.bukkit.World; import org.bukkit.World;
@@ -25,21 +25,18 @@ import org.jetbrains.annotations.NotNull;
public class AdvancedSeasonsProvider implements SeasonProvider { public class AdvancedSeasonsProvider implements SeasonProvider {
private final AdvancedSeasonsAPI api;
public AdvancedSeasonsProvider() {
this.api = new AdvancedSeasonsAPI();
}
@NotNull @NotNull
@Override @Override
public Season getSeason(@NotNull World world) { public Season getSeason(@NotNull World world) {
return switch (api.getSeason(world)) { net.advancedplugins.seasons.enums.Season season = Core.getSeasonHandler().getSeason(world);
case "SPRING" -> Season.SPRING; if (season == null) {
case "WINTER" -> Season.WINTER; return Season.DISABLE;
case "SUMMER" -> Season.SUMMER; }
case "FALL" -> Season.AUTUMN; return switch (season.getType()) {
default -> Season.DISABLE; case SPRING -> Season.SPRING;
case WINTER -> Season.WINTER;
case SUMMER -> Season.SUMMER;
case FALL -> Season.AUTUMN;
}; };
} }

View File

@@ -60,7 +60,11 @@ public class BukkitIntegrationManager implements IntegrationManager {
public BukkitIntegrationManager(BukkitCustomFishingPlugin plugin) { public BukkitIntegrationManager(BukkitCustomFishingPlugin plugin) {
this.plugin = plugin; this.plugin = plugin;
this.load(); try {
this.load();
} catch (Exception e) {
plugin.getPluginLogger().warn("Failed to load integrations", e);
}
} }
@Override @Override
@@ -125,7 +129,7 @@ public class BukkitIntegrationManager implements IntegrationManager {
} }
if (isHooked("RealisticSeasons")) { if (isHooked("RealisticSeasons")) {
registerSeasonProvider(new RealisticSeasonsProvider()); registerSeasonProvider(new RealisticSeasonsProvider());
} else if (isHooked("AdvancedSeasons")) { } else if (isHooked("AdvancedSeasons", "1.4", "1.5", "1.6")) {
registerSeasonProvider(new AdvancedSeasonsProvider()); registerSeasonProvider(new AdvancedSeasonsProvider());
} else if (isHooked("CustomCrops", "3.4", "3.5", "3.6")) { } else if (isHooked("CustomCrops", "3.4", "3.5", "3.6")) {
registerSeasonProvider(new CustomCropsSeasonProvider()); registerSeasonProvider(new CustomCropsSeasonProvider());

View File

@@ -1,6 +1,6 @@
# Project settings # Project settings
# Rule: [major update].[feature update].[bug fix] # Rule: [major update].[feature update].[bug fix]
project_version=2.2.15 project_version=2.2.16
config_version=35 config_version=35
project_group=net.momirealms project_group=net.momirealms