mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2026-01-04 15:41:35 +00:00
global effects
This commit is contained in:
@@ -206,7 +206,7 @@ public class CustomFishingPluginImpl extends CustomFishingPlugin {
|
||||
"https://maven.aliyun.com/repository/public/" : "https://repo.maven.apache.org/maven2/";
|
||||
LibraryLoader.loadDependencies(
|
||||
"org.apache.commons:commons-pool2:2.12.0", mavenRepo,
|
||||
"redis.clients:jedis:5.0.2", mavenRepo,
|
||||
"redis.clients:jedis:5.1.0", mavenRepo,
|
||||
"dev.dejvokep:boosted-yaml:1.3.1", mavenRepo,
|
||||
"com.zaxxer:HikariCP:5.0.1", mavenRepo,
|
||||
"net.objecthunter:exp4j:0.4.8", mavenRepo,
|
||||
|
||||
@@ -115,7 +115,7 @@ public class ActionManagerImpl implements ActionManager {
|
||||
// Method to load global event actions from the plugin's configuration file.
|
||||
private void loadGlobalEventActions() {
|
||||
YamlConfiguration config = plugin.getConfig("config.yml");
|
||||
GlobalSettings.load(config.getConfigurationSection("mechanics.global-events"));
|
||||
GlobalSettings.loadEvents(config.getConfigurationSection("mechanics.global-events"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,6 +21,7 @@ import net.momirealms.customfishing.api.CustomFishingPlugin;
|
||||
import net.momirealms.customfishing.api.common.Key;
|
||||
import net.momirealms.customfishing.api.common.Pair;
|
||||
import net.momirealms.customfishing.api.manager.EffectManager;
|
||||
import net.momirealms.customfishing.api.mechanic.GlobalSettings;
|
||||
import net.momirealms.customfishing.api.mechanic.effect.EffectCarrier;
|
||||
import net.momirealms.customfishing.api.mechanic.effect.EffectModifier;
|
||||
import net.momirealms.customfishing.api.mechanic.effect.FishingEffect;
|
||||
@@ -101,13 +102,18 @@ public class EffectManagerImpl implements EffectManager {
|
||||
return effectMap.get(Key.of(namespace, id));
|
||||
}
|
||||
|
||||
public void load() {
|
||||
this.loadFiles();
|
||||
this.loadGlobalEffects();
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads EffectCarrier configurations from YAML files in different content folders.
|
||||
* EffectCarrier configurations are organized by type (rod, bait, enchant, util, totem, hook) in separate folders.
|
||||
* Each YAML file within these folders is processed to populate the effectMap.
|
||||
*/
|
||||
@SuppressWarnings("DuplicatedCode")
|
||||
public void load() {
|
||||
private void loadFiles() {
|
||||
Deque<File> fileDeque = new ArrayDeque<>();
|
||||
for (String type : List.of("rod", "bait", "enchant", "util", "totem", "hook")) {
|
||||
File typeFolder = new File(plugin.getDataFolder() + File.separator + "contents" + File.separator + type);
|
||||
@@ -234,6 +240,12 @@ public class EffectManagerImpl implements EffectManager {
|
||||
return modifiers.toArray(new EffectModifier[0]);
|
||||
}
|
||||
|
||||
private void loadGlobalEffects() {
|
||||
YamlConfiguration config = plugin.getConfig("config.yml");
|
||||
ConfigurationSection section = config.getConfigurationSection("mechanics.global-effects");
|
||||
GlobalSettings.setEffects(getEffectModifiers(section));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a ConfigurationSection to create an EffectModifier based on the specified type and configuration.
|
||||
*
|
||||
|
||||
@@ -297,8 +297,8 @@ public class HookCheckTimerTask implements Runnable {
|
||||
double initialTime = ThreadLocalRandom.current().nextInt(CFConfig.waterMaxTime - CFConfig.waterMinTime + 1) + CFConfig.waterMinTime;
|
||||
fishHook.setWaitTime(Math.max(1, (int) (initialTime * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
|
||||
} else {
|
||||
fishHook.setMaxWaitTime(Math.max(2, (int) (fishHook.getMaxWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
|
||||
fishHook.setMinWaitTime(Math.max(1, (int) (fishHook.getMinWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
|
||||
fishHook.setMaxWaitTime(Math.max(2, (int) (fishHook.getMaxWaitTime() * initialEffect.getWaitTimeMultiplier() + initialEffect.getWaitTime())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,7 +175,6 @@ public class LootManagerImpl implements LootManager {
|
||||
@Override
|
||||
public Map<String, Double> getPossibleLootKeysWithWeight(Effect initialEffect, Condition condition) {
|
||||
Map<String, Double> lootWithWeight = ((RequirementManagerImpl) plugin.getRequirementManager()).getLootWithWeight(condition);
|
||||
|
||||
Player player = condition.getPlayer();
|
||||
for (Pair<String, WeightModifier> pair : initialEffect.getWeightModifier()) {
|
||||
Double previous = lootWithWeight.get(pair.left());
|
||||
|
||||
@@ -198,6 +198,7 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
this.registerHookRequirement();
|
||||
this.registerCompetitionRequirement();
|
||||
this.registerListRequirement();
|
||||
this.registerEnvironmentRequirement();
|
||||
}
|
||||
|
||||
public HashMap<String, Double> getLootWithWeight(Condition condition) {
|
||||
@@ -1018,6 +1019,27 @@ public class RequirementManagerImpl implements RequirementManager {
|
||||
});
|
||||
}
|
||||
|
||||
private void registerEnvironmentRequirement() {
|
||||
registerRequirement("environment", (args, actions, advanced) -> {
|
||||
List<String> environments = ConfigUtils.stringListArgs(args);
|
||||
return condition -> {
|
||||
var name = condition.getLocation().getWorld().getEnvironment().name().toLowerCase(Locale.ENGLISH);
|
||||
if (environments.contains(name)) return true;
|
||||
if (advanced) triggerActions(actions, condition);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
registerRequirement("!environment", (args, actions, advanced) -> {
|
||||
List<String> environments = ConfigUtils.stringListArgs(args);
|
||||
return condition -> {
|
||||
var name = condition.getLocation().getWorld().getEnvironment().name().toLowerCase(Locale.ENGLISH);
|
||||
if (!environments.contains(name)) return true;
|
||||
if (advanced) triggerActions(actions, condition);
|
||||
return false;
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
private void registerHookRequirement() {
|
||||
registerRequirement("hook", (args, actions, advanced) -> {
|
||||
List<String> hooks = ConfigUtils.stringListArgs(args);
|
||||
|
||||
@@ -40,7 +40,7 @@ import java.util.Objects;
|
||||
public class CFConfig {
|
||||
|
||||
// config version
|
||||
public static String configVersion = "29";
|
||||
public static String configVersion = "30";
|
||||
// Debug mode
|
||||
public static boolean debug;
|
||||
// language
|
||||
@@ -114,6 +114,7 @@ public class CFConfig {
|
||||
.setVersioning(new BasicVersioning("config-version"))
|
||||
.addIgnoredRoute(configVersion, "mechanics.mechanic-requirements", '.')
|
||||
.addIgnoredRoute(configVersion, "mechanics.global-events", '.')
|
||||
.addIgnoredRoute(configVersion, "mechanics.global-effects", '.')
|
||||
.addIgnoredRoute(configVersion, "other-settings.placeholder-register", '.')
|
||||
.build()
|
||||
);
|
||||
@@ -165,7 +166,6 @@ public class CFConfig {
|
||||
|
||||
durabilityLore = config.getStringList("other-settings.custom-durability-format").stream().map(it -> "<!i>" + it).toList();
|
||||
|
||||
|
||||
OffsetUtils.loadConfig(config.getConfigurationSection("other-settings.offset-characters"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Developer: @Xiao-MoMi
|
||||
# Wiki: https://mo-mi.gitbook.io/xiaomomi-plugins/
|
||||
config-version: '29'
|
||||
config-version: '30'
|
||||
|
||||
# Debug
|
||||
debug: false
|
||||
@@ -26,6 +26,20 @@ mechanics:
|
||||
value:
|
||||
- blacklist_world
|
||||
|
||||
# Configures global effects. This is useful if you want to give all the players certain effects based on certain conditions
|
||||
global-effects:
|
||||
effect_1:
|
||||
type: conditional
|
||||
conditions:
|
||||
competition:
|
||||
ongoing: true
|
||||
id:
|
||||
- weekend_competition
|
||||
effects:
|
||||
effect_1:
|
||||
type: wait-time-multiplier
|
||||
value: 0.85
|
||||
|
||||
# Configures global events for hook/bait/rod/loot
|
||||
# which would help you reduce duplicated lines
|
||||
global-events:
|
||||
|
||||
@@ -36,7 +36,7 @@ simple_bait:
|
||||
- ''
|
||||
custom-model-data: 50001
|
||||
effects:
|
||||
difficulty:
|
||||
effect_1:
|
||||
type: difficulty
|
||||
value: -10
|
||||
|
||||
@@ -59,10 +59,10 @@ magnetic_bait:
|
||||
- ''
|
||||
custom-model-data: 50002
|
||||
effects:
|
||||
hooktime:
|
||||
effect_1:
|
||||
type: wait-time-multiplier
|
||||
value: 0.9
|
||||
gametime:
|
||||
effect_2:
|
||||
type: game-time
|
||||
value: 2
|
||||
|
||||
@@ -84,12 +84,12 @@ wild_bait:
|
||||
- ''
|
||||
custom-model-data: 50003
|
||||
effects:
|
||||
difficulty:
|
||||
effect_1:
|
||||
type: difficulty
|
||||
value: +20
|
||||
size:
|
||||
effect_2:
|
||||
type: size-multiplier
|
||||
value: 1.5
|
||||
gametime:
|
||||
effect_3:
|
||||
type: game-time
|
||||
value: -2
|
||||
@@ -9,7 +9,7 @@
|
||||
minecraft:luck_of_the_sea:1:
|
||||
requirements: {}
|
||||
effects:
|
||||
group:
|
||||
effect_1:
|
||||
type: group-mod
|
||||
value:
|
||||
- silver_star:+2
|
||||
@@ -17,7 +17,7 @@ minecraft:luck_of_the_sea:1:
|
||||
minecraft:luck_of_the_sea:2:
|
||||
requirements: {}
|
||||
effects:
|
||||
group:
|
||||
effect_1:
|
||||
type: group-mod
|
||||
value:
|
||||
- silver_star:+4
|
||||
@@ -25,7 +25,7 @@ minecraft:luck_of_the_sea:2:
|
||||
minecraft:luck_of_the_sea:3:
|
||||
requirements: {}
|
||||
effects:
|
||||
group:
|
||||
effect_1:
|
||||
type: group-mod
|
||||
value:
|
||||
- silver_star:+6
|
||||
|
||||
@@ -26,7 +26,7 @@ delicate_hook:
|
||||
- '<#7FFFAA>Equipped hook:'
|
||||
- '<gray> - Delicate hook: <white>{dur}</white> times left'
|
||||
effects:
|
||||
group:
|
||||
effect_1:
|
||||
type: group-mod
|
||||
value:
|
||||
- silver_star:+1
|
||||
|
||||
@@ -9,7 +9,7 @@ FISHING_ROD:
|
||||
tag: false
|
||||
material: fishing_rod
|
||||
effects:
|
||||
time_effect:
|
||||
effect_1:
|
||||
type: wait-time-multiplier
|
||||
value: 1.5
|
||||
|
||||
@@ -31,10 +31,10 @@ beginner_rod:
|
||||
custom-model-data: 50001
|
||||
max-durability: 64
|
||||
effects:
|
||||
time_effect:
|
||||
effect_1:
|
||||
type: wait-time-multiplier
|
||||
value: 1.8
|
||||
difficulty:
|
||||
effect_2:
|
||||
type: difficulty
|
||||
value: -8
|
||||
|
||||
@@ -54,7 +54,7 @@ silver_rod:
|
||||
custom-model-data: 50002
|
||||
max-durability: 96
|
||||
effects:
|
||||
group:
|
||||
effect_1:
|
||||
type: group-mod
|
||||
value:
|
||||
- silver_star:+8
|
||||
@@ -75,7 +75,7 @@ golden_rod:
|
||||
custom-model-data: 50003
|
||||
max-durability: 80
|
||||
effects:
|
||||
group:
|
||||
effect_1:
|
||||
type: group-mod
|
||||
value:
|
||||
- golden_star:+3
|
||||
@@ -98,7 +98,7 @@ star_rod:
|
||||
custom-model-data: 50004
|
||||
max-durability: 128
|
||||
effects:
|
||||
time_effect:
|
||||
effect_1:
|
||||
type: game-time
|
||||
value: 15
|
||||
|
||||
@@ -122,7 +122,7 @@ bone_rod:
|
||||
custom-model-data: 50005
|
||||
max-durability: 32
|
||||
effects:
|
||||
lava:
|
||||
effect_1:
|
||||
type: lava-fishing
|
||||
|
||||
magical_rod:
|
||||
@@ -152,7 +152,7 @@ magical_rod:
|
||||
type: level
|
||||
value: 10
|
||||
not-met-actions:
|
||||
action_message:
|
||||
action_1:
|
||||
type: message
|
||||
value:
|
||||
- 'You don''t have enough levels to control the rod.'
|
||||
@@ -171,11 +171,11 @@ magical_rod:
|
||||
type: level
|
||||
value: -10
|
||||
effects:
|
||||
weight_effect:
|
||||
effect_1:
|
||||
type: group-mod-ignore-conditions
|
||||
value:
|
||||
- enchantments:+10
|
||||
time_effect:
|
||||
effect_2:
|
||||
type: wait-time-multiplier
|
||||
value: 3
|
||||
|
||||
@@ -199,13 +199,13 @@ master_rod:
|
||||
custom-model-data: 50007
|
||||
max-durability: 128
|
||||
effects:
|
||||
time_effect:
|
||||
effect_1:
|
||||
type: wait-time-multiplier
|
||||
value: 0.95
|
||||
difficulty:
|
||||
effect_2:
|
||||
type: difficulty
|
||||
value: +10
|
||||
group:
|
||||
effect_3:
|
||||
type: group-mod
|
||||
value:
|
||||
- silver_star:+5
|
||||
|
||||
@@ -13,7 +13,7 @@ double_loot_totem:
|
||||
1:
|
||||
- 'AIR||GRASS||SNOW ANVIL AIR||GRASS||SNOW'
|
||||
effects:
|
||||
double_loot:
|
||||
effect_1:
|
||||
type: multiple-loot
|
||||
value: 1.0
|
||||
requirements:
|
||||
@@ -242,7 +242,7 @@ golden_star_totem:
|
||||
period: 5
|
||||
delay: 0
|
||||
effects:
|
||||
golden_weight_increase:
|
||||
effect_1:
|
||||
type: group-mod
|
||||
value:
|
||||
- golden_star:+15
|
||||
|
||||
@@ -6,8 +6,8 @@ global-group:
|
||||
loots_in_water:
|
||||
conditions:
|
||||
lava-fishing: false
|
||||
world:
|
||||
- world
|
||||
environment:
|
||||
- normal
|
||||
'!rod':
|
||||
- magical_rod
|
||||
list:
|
||||
@@ -115,8 +115,8 @@ global-group:
|
||||
- 'sturgeon_fish:+9'
|
||||
- 'sturgeon_fish_silver_star:+3'
|
||||
- 'sturgeon_fish_golden_star:+1'
|
||||
# Skeletons might appear if player holds the skeleton_rod and fish at night
|
||||
curse_rod:
|
||||
# Skeletons might appear if player holds the bone_rod and fish at night
|
||||
skeleton_group:
|
||||
conditions:
|
||||
rod:
|
||||
- bone_rod
|
||||
@@ -129,10 +129,10 @@ global-group:
|
||||
lava-fishing: true
|
||||
list: []
|
||||
sub-groups:
|
||||
overworld_loots:
|
||||
world_loots:
|
||||
conditions:
|
||||
world:
|
||||
- world
|
||||
environment:
|
||||
- normal
|
||||
list:
|
||||
- 'cobblestone:+50'
|
||||
- 'stone:+30'
|
||||
@@ -141,8 +141,8 @@ global-group:
|
||||
- 'flint:+6'
|
||||
nether_loots:
|
||||
conditions:
|
||||
world:
|
||||
- world_nether
|
||||
environment:
|
||||
- nether
|
||||
list:
|
||||
- 'netherrack:+20'
|
||||
- 'nether_brick:+12'
|
||||
@@ -154,11 +154,9 @@ global-group:
|
||||
- 'salmon_void_fish_silver_star:+3'
|
||||
- 'salmon_void_fish_golden_star:+1'
|
||||
sub-groups:
|
||||
curse_rod:
|
||||
skeleton_group:
|
||||
conditions:
|
||||
rod:
|
||||
- bone_rod
|
||||
time:
|
||||
- 14000~22000
|
||||
list:
|
||||
- 'wither_skeleton:+30'
|
||||
Reference in New Issue
Block a user