mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
legacy format support
This commit is contained in:
@@ -26,6 +26,16 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface RequirementManager {
|
||||
|
||||
/**
|
||||
* Legacy format support
|
||||
* @param key key
|
||||
* @param requirements requirements
|
||||
* @param weight weight
|
||||
* @return success or not
|
||||
*/
|
||||
@Deprecated
|
||||
boolean putLegacyLootToMap(String key, Requirement[] requirements, double weight);
|
||||
|
||||
/**
|
||||
* Registers a custom requirement type with its corresponding factory.
|
||||
*
|
||||
|
||||
@@ -7,7 +7,7 @@ plugins {
|
||||
|
||||
allprojects {
|
||||
|
||||
version = "2.0.0"
|
||||
version = "2.0.1"
|
||||
|
||||
apply<JavaPlugin>()
|
||||
apply(plugin = "java")
|
||||
|
||||
@@ -219,7 +219,7 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
|
||||
"org.mongodb:mongodb-driver-core:4.11.1", mavenRepo,
|
||||
"org.mongodb:bson:4.11.1", mavenRepo,
|
||||
"org.xerial:sqlite-jdbc:3.43.2.2", mavenRepo,
|
||||
"dev.jorel:commandapi-bukkit-shade:9.2.0", mavenRepo,
|
||||
"dev.jorel:commandapi-bukkit-shade:9.3.0", mavenRepo,
|
||||
"xyz.xenondevs.invui:invui-core:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
"xyz.xenondevs.invui:inventory-access-r8:1.23", "https://repo.xenondevs.xyz/releases/",
|
||||
|
||||
@@ -241,8 +241,13 @@ public class LootManagerImpl implements LootManager {
|
||||
groupMembers.add(loot.getID());
|
||||
}
|
||||
}
|
||||
if (section.contains("requirements")) {
|
||||
|
||||
// legacy format support
|
||||
if (section.contains("requirements") && section.contains("weight")) {
|
||||
plugin.getRequirementManager().putLegacyLootToMap(
|
||||
loot.getID(),
|
||||
plugin.getRequirementManager().getRequirements(section.getConfigurationSection("requirements"), false),
|
||||
section.getDouble("weight", 0)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import net.momirealms.customfishing.api.mechanic.action.Action;
|
||||
import net.momirealms.customfishing.api.mechanic.competition.FishingCompetition;
|
||||
import net.momirealms.customfishing.api.mechanic.condition.Condition;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.Loot;
|
||||
import net.momirealms.customfishing.api.mechanic.loot.WeightModifier;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.Requirement;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementExpansion;
|
||||
import net.momirealms.customfishing.api.mechanic.requirement.RequirementFactory;
|
||||
@@ -85,6 +86,16 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
this.conditionalLootsMap.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean putLegacyLootToMap(String key, Requirement[] requirements, double weight) {
|
||||
if (conditionalLootsMap.containsKey("LEGACY_" + key)) {
|
||||
return false;
|
||||
} else {
|
||||
conditionalLootsMap.put("LEGACY_" + key, new ConditionalElement(requirements, List.of(Pair.of(key, (player, origin) -> weight + origin)), new HashMap<>()));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads requirement group configuration data from various configuration files.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user