9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-28 11:29:15 +00:00

checkpoint - 20

This commit is contained in:
XiaoMoMi
2024-07-02 02:41:55 +08:00
parent 214292ad5a
commit 71de6ea626
16 changed files with 359 additions and 52 deletions

View File

@@ -2,6 +2,11 @@ package net.momirealms.customfishing.bukkit.config;
import dev.dejvokep.boostedyaml.YamlDocument;
import dev.dejvokep.boostedyaml.block.implementation.Section;
import dev.dejvokep.boostedyaml.dvs.versioning.BasicVersioning;
import dev.dejvokep.boostedyaml.settings.dumper.DumperSettings;
import dev.dejvokep.boostedyaml.settings.general.GeneralSettings;
import dev.dejvokep.boostedyaml.settings.loader.LoaderSettings;
import dev.dejvokep.boostedyaml.settings.updater.UpdaterSettings;
import net.momirealms.customfishing.api.BukkitCustomFishingPlugin;
import net.momirealms.customfishing.api.mechanic.action.Action;
import net.momirealms.customfishing.api.mechanic.action.ActionTrigger;
@@ -26,6 +31,7 @@ import net.momirealms.customfishing.api.mechanic.totem.block.property.TotemBlock
import net.momirealms.customfishing.api.mechanic.totem.block.type.TypeCondition;
import net.momirealms.customfishing.bukkit.totem.particle.DustParticleSetting;
import net.momirealms.customfishing.bukkit.totem.particle.ParticleSetting;
import net.momirealms.customfishing.common.dependency.DependencyProperties;
import net.momirealms.customfishing.common.helper.AdventureHelper;
import net.momirealms.customfishing.common.util.ListUtils;
import net.momirealms.customfishing.common.util.Pair;
@@ -40,6 +46,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventPriority;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.function.BiFunction;
@@ -65,7 +72,34 @@ public class BukkitConfigManager extends ConfigManager {
@Override
public void load() {
MAIN_CONFIG = loadConfig("config.yml");
String configVersion = DependencyProperties.getDependencyVersion("config");
try {
MAIN_CONFIG = YamlDocument.create(
resolveConfig("config.yml").toFile(),
plugin.getResourceStream("config.yml"),
GeneralSettings.builder()
.setRouteSeparator('.')
.setUseDefaults(false)
.build(),
LoaderSettings
.builder()
.setAutoUpdate(true)
.build(),
DumperSettings.DEFAULT,
UpdaterSettings
.builder()
.setVersioning(new BasicVersioning("config-version"))
.addIgnoredRoute(configVersion, "mechanics.mechanic-requirements", '.')
.addIgnoredRoute(configVersion, "mechanics.global-events", '.')
.addIgnoredRoute(configVersion, "mechanics.global-effects", '.')
.addIgnoredRoute(configVersion, "mechanics.fishing-bag.collect-actions", '.')
.addIgnoredRoute(configVersion, "mechanics.fishing-bag.full-actions", '.')
.addIgnoredRoute(configVersion, "other-settings.placeholder-register", '.')
.build()
);
} catch (IOException e) {
throw new RuntimeException(e);
}
this.loadSettings();
this.loadConfigs();
}
@@ -122,6 +156,15 @@ public class BukkitConfigManager extends ConfigManager {
}
}
}
globalEffects = new ArrayList<>();
Section globalEffectSection = config.getSection("mechanics.global-effects");
if (globalEffectSection != null)
for (Map.Entry<String, Object> entry : globalEffectSection.getStringRouteMappedValues(false).entrySet()) {
if (entry.getValue() instanceof Section innerSection) {
globalEffects.add(parseEffect(innerSection));
}
}
}
private void loadConfigs() {

View File

@@ -7,7 +7,6 @@ import net.momirealms.customfishing.api.mechanic.context.Context;
import net.momirealms.customfishing.api.mechanic.fishing.CustomFishingHook;
import net.momirealms.customfishing.api.mechanic.fishing.FishingGears;
import net.momirealms.customfishing.api.mechanic.fishing.FishingManager;
import net.momirealms.customfishing.api.mechanic.fishing.hook.VanillaMechanic;
import net.momirealms.customfishing.api.mechanic.requirement.RequirementManager;
import net.momirealms.customfishing.bukkit.util.EventUtils;
import net.momirealms.customfishing.common.helper.VersionHelper;

View File

@@ -24,8 +24,10 @@ import net.momirealms.customfishing.bukkit.entity.BukkitEntityManager;
import net.momirealms.customfishing.bukkit.integration.block.ItemsAdderBlockProvider;
import net.momirealms.customfishing.bukkit.integration.block.OraxenBlockProvider;
import net.momirealms.customfishing.bukkit.integration.enchant.AdvancedEnchantmentsProvider;
import net.momirealms.customfishing.bukkit.integration.enchant.VanillaEnchantmentsProvider;
import net.momirealms.customfishing.bukkit.integration.entity.ItemsAdderEntityProvider;
import net.momirealms.customfishing.bukkit.integration.entity.MythicEntityProvider;
import net.momirealms.customfishing.bukkit.integration.entity.VanillaEntityProvider;
import net.momirealms.customfishing.bukkit.integration.item.*;
import net.momirealms.customfishing.bukkit.integration.level.*;
import net.momirealms.customfishing.bukkit.integration.quest.BattlePassQuest;
@@ -67,6 +69,7 @@ public class BukkitIntegrationManager implements IntegrationManager {
@Override
public void load() {
registerEnchantmentProvider(new VanillaEnchantmentsProvider());
if (isHooked("ItemsAdder")) {
registerItemProvider(new ItemsAdderItemProvider());
registerBlockProvider(new ItemsAdderBlockProvider());

View File

@@ -24,7 +24,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
@@ -171,7 +170,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
private void registerCompetitionRequirement() {
registerRequirement("competition", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
boolean onCompetition = section.getBoolean("ongoing", true);
List<String> ids = ListUtils.toList(section.get("id"));
return context -> {
@@ -863,7 +862,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
private void registerPAPIRequirement() {
registerRequirement("<", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
return context -> {
@@ -877,7 +876,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("<=", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
return context -> {
@@ -891,7 +890,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("!=", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
return context -> {
@@ -905,7 +904,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("==", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
return context -> {
@@ -919,7 +918,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement(">=", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
return context -> {
@@ -933,7 +932,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement(">", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
MathValue<Player> v1 = MathValue.auto(section.get("value1"));
MathValue<Player> v2 = MathValue.auto(section.get("value2"));
return context -> {
@@ -947,7 +946,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("regex", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("papi", ""));
String v2 = section.getString("regex", "");
return context -> {
@@ -961,7 +960,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("startsWith", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
return context -> {
@@ -975,7 +974,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("!startsWith", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
return context -> {
@@ -989,7 +988,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("endsWith", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
return context -> {
@@ -1003,7 +1002,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("!endsWith", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
return context -> {
@@ -1017,7 +1016,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("contains", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
return context -> {
@@ -1031,7 +1030,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("!contains", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
return context -> {
@@ -1045,7 +1044,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("in-list", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> papi = TextValue.auto(section.getString("papi", ""));
List<String> values = ListUtils.toList(section.get("values"));
return context -> {
@@ -1059,7 +1058,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("!in-list", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> papi = TextValue.auto(section.getString("papi", ""));
List<String> values = ListUtils.toList(section.get("values"));
return context -> {
@@ -1073,7 +1072,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("equals", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
return context -> {
@@ -1087,7 +1086,7 @@ public class BukkitRequirementManager implements RequirementManager<Player> {
}
});
registerRequirement("!equals", (args, actions, advanced) -> {
if (args instanceof ConfigurationSection section) {
if (args instanceof Section section) {
TextValue<Player> v1 = TextValue.auto(section.getString("value1", ""));
TextValue<Player> v2 = TextValue.auto(section.getString("value2", ""));
return context -> {

View File

@@ -30,21 +30,42 @@ minecraft:luck_of_the_sea:3:
value:
- silver_star:+6
- golden_star:+3
#minecraft:lure:1:
# requirements: {}
# effects:
# effect_1:
# type: wait-time
# value: -50
#minecraft:lure:2:
# requirements: {}
# effects:
# effect_1:
# type: wait-time
# value: -100
#minecraft:lure:3:
# requirements: {}
# effects:
# effect_1:
# type: wait-time
# value: -150
minecraft:lure:1:
requirements: {}
effects:
effect_1:
type: conditional
conditions:
"||":
in-lava: true
in-void: true
effects:
effect_1:
type: wait-time
value: -80
minecraft:lure:2:
requirements: {}
effects:
effect_1:
type: conditional
conditions:
"||":
in-lava: true
in-void: true
effects:
effect_1:
type: wait-time
value: -160
minecraft:lure:3:
requirements: {}
effects:
effect_1:
type: conditional
conditions:
"||":
in-lava: true
in-void: true
effects:
effect_1:
type: wait-time
value: -240

View File

@@ -5,7 +5,7 @@ global-group:
sub-groups:
loots_in_water:
conditions:
lava-fishing: false
in-water: true
environment:
- normal
'!rod':
@@ -126,7 +126,7 @@ global-group:
- 'skeleton:+30'
loots_in_lava:
conditions:
lava-fishing: true
in-lava: true
list: []
sub-groups:
world_loots: