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/ClueScrolls-4.8.7-api.jar"))
compileOnly(files("libs/notquests-5.17.1.jar"))
compileOnly("org.betonquest:betonquest:2.1.2")
compileOnly("org.betonquest:betonquest:2.1.3")
// item
compileOnly(files("libs/zaphkiel-2.0.24.jar"))
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 org.betonquest.betonquest.BetonQuest;
import org.betonquest.betonquest.Instruction;
import org.betonquest.betonquest.VariableNumber;
import org.betonquest.betonquest.api.CountingObjective;
import org.betonquest.betonquest.api.config.quest.QuestPackage;
import org.betonquest.betonquest.api.profiles.OnlineProfile;
import org.betonquest.betonquest.api.profiles.Profile;
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.location.CompoundLocation;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.event.EventHandler;
@@ -43,23 +44,13 @@ public class BetonQuestQuest {
public static void register() {
BetonQuest ins1 = BetonQuest.getInstance();
if (ins1 != null) {
ins1.registerObjectives("customfishing_loot", IDObjective.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);
}
ins1.registerObjectives("customfishing_loot", IDObjective.class);
ins1.registerObjectives("customfishing_group", GroupObjective.class);
}
public static class IDObjective extends CountingObjective implements Listener {
private final CompoundLocation playerLocation;
private final VariableLocation playerLocation;
private final VariableNumber rangeVar;
private final HashSet<String> loot_ids;
@@ -67,14 +58,13 @@ public class BetonQuestQuest {
super(instruction, "loot_to_fish");
loot_ids = new HashSet<>();
Collections.addAll(loot_ids, instruction.getArray());
targetAmount = instruction.getVarNum();
preCheckAmountNotLessThanOne(targetAmount);
targetAmount = instruction.getVarNum(VariableNumber.NOT_LESS_THAN_ONE_CHECKER);
final QuestPackage pack = instruction.getPackage();
final String loc = instruction.getOptional("playerLocation");
final String range = instruction.getOptional("range");
if (loc != null && range != null) {
playerLocation = new CompoundLocation(pack, loc);
rangeVar = new VariableNumber(pack, range);
playerLocation = new VariableLocation(BetonQuest.getInstance().getVariableProcessor(), pack, loc);
rangeVar = new VariableNumber(BetonQuest.getInstance().getVariableProcessor(), pack, range);
} else {
playerLocation = null;
rangeVar = null;
@@ -105,12 +95,17 @@ public class BetonQuestQuest {
final Location targetLocation;
try {
targetLocation = playerLocation.getLocation(profile);
targetLocation = playerLocation.getValue(profile);
} catch (final org.betonquest.betonquest.exceptions.QuestRuntimeException e) {
e.printStackTrace();
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();
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 {
private final CompoundLocation playerLocation;
private final VariableLocation playerLocation;
private final VariableNumber rangeVar;
private final HashSet<String> loot_groups;
@@ -136,14 +131,13 @@ public class BetonQuestQuest {
super(instruction, "group_to_fish");
loot_groups = new HashSet<>();
Collections.addAll(loot_groups, instruction.getArray());
targetAmount = instruction.getVarNum();
preCheckAmountNotLessThanOne(targetAmount);
targetAmount = instruction.getVarNum(VariableNumber.NOT_LESS_THAN_ONE_CHECKER);
final QuestPackage pack = instruction.getPackage();
final String loc = instruction.getOptional("playerLocation");
final String range = instruction.getOptional("range");
if (loc != null && range != null) {
playerLocation = new CompoundLocation(pack, loc);
rangeVar = new VariableNumber(pack, range);
playerLocation = new VariableLocation(BetonQuest.getInstance().getVariableProcessor(), pack, loc);
rangeVar = new VariableNumber(BetonQuest.getInstance().getVariableProcessor(), pack, range);
} else {
playerLocation = null;
rangeVar = null;
@@ -179,12 +173,17 @@ public class BetonQuestQuest {
final Location targetLocation;
try {
targetLocation = playerLocation.getLocation(profile);
targetLocation = playerLocation.getValue(profile);
} catch (final org.betonquest.betonquest.exceptions.QuestRuntimeException e) {
e.printStackTrace();
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();
return !playerLoc.getWorld().equals(targetLocation.getWorld()) || targetLocation.distanceSquared(playerLoc) > range * range;
}

View File

@@ -17,7 +17,7 @@
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.mechanic.misc.season.Season;
import org.bukkit.World;
@@ -25,21 +25,18 @@ import org.jetbrains.annotations.NotNull;
public class AdvancedSeasonsProvider implements SeasonProvider {
private final AdvancedSeasonsAPI api;
public AdvancedSeasonsProvider() {
this.api = new AdvancedSeasonsAPI();
}
@NotNull
@Override
public Season getSeason(@NotNull World world) {
return switch (api.getSeason(world)) {
case "SPRING" -> Season.SPRING;
case "WINTER" -> Season.WINTER;
case "SUMMER" -> Season.SUMMER;
case "FALL" -> Season.AUTUMN;
default -> Season.DISABLE;
net.advancedplugins.seasons.enums.Season season = Core.getSeasonHandler().getSeason(world);
if (season == null) {
return Season.DISABLE;
}
return switch (season.getType()) {
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) {
this.plugin = plugin;
this.load();
try {
this.load();
} catch (Exception e) {
plugin.getPluginLogger().warn("Failed to load integrations", e);
}
}
@Override
@@ -125,7 +129,7 @@ public class BukkitIntegrationManager implements IntegrationManager {
}
if (isHooked("RealisticSeasons")) {
registerSeasonProvider(new RealisticSeasonsProvider());
} else if (isHooked("AdvancedSeasons")) {
} else if (isHooked("AdvancedSeasons", "1.4", "1.5", "1.6")) {
registerSeasonProvider(new AdvancedSeasonsProvider());
} else if (isHooked("CustomCrops", "3.4", "3.5", "3.6")) {
registerSeasonProvider(new CustomCropsSeasonProvider());

View File

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