mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
2.3.0
This commit is contained in:
@@ -473,7 +473,7 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
|
||||
|
||||
public abstract List<Pair<String, WeightOperation>> parseWeightOperation(List<String> ops, Function<String, Boolean> validator, Function<String, List<String>> groupProvider);
|
||||
|
||||
public abstract List<Pair<String, WeightOperation>> parseGroupWeightOperation(List<String> gops);
|
||||
public abstract List<Pair<String, WeightOperation>> parseGroupWeightOperation(List<String> gops, boolean forAvailable, Function<String, List<String>> groupProvider);
|
||||
|
||||
@Deprecated
|
||||
public Map<String, Node<ConfigParserFunction>> getDefaultFormatFunctions() {
|
||||
|
||||
@@ -27,14 +27,19 @@ public class AddWeightOperation implements WeightOperation {
|
||||
|
||||
private final MathValue<Player> arg;
|
||||
private final int sharedMembers;
|
||||
private final boolean forAvailable;
|
||||
|
||||
public AddWeightOperation(MathValue<Player> arg, int sharedMembers) {
|
||||
public AddWeightOperation(MathValue<Player> arg, int sharedMembers, boolean forAvailable) {
|
||||
this.arg = arg;
|
||||
this.sharedMembers = sharedMembers;
|
||||
this.forAvailable = forAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double apply(Context<Player> context, Double weight, Map<String, Double> weights) {
|
||||
if (this.forAvailable && weight <= 0) {
|
||||
return weight;
|
||||
}
|
||||
return weight + arg.evaluate(context) / sharedMembers;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,17 +34,22 @@ public class CustomWeightOperation implements WeightOperation {
|
||||
private final List<String> otherEntries;
|
||||
private final List<Pair<String, String[]>> otherGroups;
|
||||
private final int sharedMembers;
|
||||
private final boolean forAvailable;
|
||||
|
||||
public CustomWeightOperation(MathValue<Player> arg, boolean hasTotalWeight, List<String> otherEntries, List<Pair<String, String[]>> otherGroups, int sharedMembers) {
|
||||
public CustomWeightOperation(MathValue<Player> arg, boolean hasTotalWeight, List<String> otherEntries, List<Pair<String, String[]>> otherGroups, int sharedMembers, boolean forAvailable) {
|
||||
this.arg = arg;
|
||||
this.hasTotalWeight = hasTotalWeight;
|
||||
this.otherEntries = otherEntries;
|
||||
this.otherGroups = otherGroups;
|
||||
this.sharedMembers = sharedMembers;
|
||||
this.forAvailable = forAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double apply(Context<Player> context, Double weight, Map<String, Double> weights) {
|
||||
if (this.forAvailable && weight <= 0) {
|
||||
return weight;
|
||||
}
|
||||
context.arg(ContextKeys.WEIGHT, weight);
|
||||
if (hasTotalWeight) {
|
||||
context.arg(ContextKeys.TOTAL_WEIGHT, getValidTotalWeight(weights.values()));
|
||||
|
||||
@@ -26,13 +26,18 @@ import java.util.Map;
|
||||
public class DivideWeightOperation implements WeightOperation {
|
||||
|
||||
private final MathValue<Player> arg;
|
||||
private final boolean forAvailable;
|
||||
|
||||
public DivideWeightOperation(MathValue<Player> arg) {
|
||||
public DivideWeightOperation(MathValue<Player> arg, boolean forAvailable) {
|
||||
this.arg = arg;
|
||||
this.forAvailable = forAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double apply(Context<Player> context, Double weight, Map<String, Double> weights) {
|
||||
if (this.forAvailable && weight <= 0) {
|
||||
return weight;
|
||||
}
|
||||
return weight / arg.evaluate(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,18 @@ import java.util.Map;
|
||||
public class ModuloWeightOperation implements WeightOperation {
|
||||
|
||||
private final MathValue<Player> arg;
|
||||
private final boolean forAvailable;
|
||||
|
||||
public ModuloWeightOperation(MathValue<Player> arg) {
|
||||
public ModuloWeightOperation(MathValue<Player> arg, boolean forAvailable) {
|
||||
this.arg = arg;
|
||||
this.forAvailable = forAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double apply(Context<Player> context, Double weight, Map<String, Double> weights) {
|
||||
if (this.forAvailable && weight <= 0) {
|
||||
return weight;
|
||||
}
|
||||
return weight % arg.evaluate(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,13 +26,18 @@ import java.util.Map;
|
||||
public class MultiplyWeightOperation implements WeightOperation {
|
||||
|
||||
private final MathValue<Player> arg;
|
||||
private final boolean forAvailable;
|
||||
|
||||
public MultiplyWeightOperation(MathValue<Player> arg) {
|
||||
public MultiplyWeightOperation(MathValue<Player> arg, boolean forAvailable) {
|
||||
this.arg = arg;
|
||||
this.forAvailable = forAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double apply(Context<Player> context, Double weight, Map<String, Double> weights) {
|
||||
if (this.forAvailable && weight <= 0) {
|
||||
return weight;
|
||||
}
|
||||
return weight * arg.evaluate(context);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,19 @@ public class ReduceWeightOperation implements WeightOperation {
|
||||
|
||||
private final MathValue<Player> arg;
|
||||
private final int sharedMembers;
|
||||
private final boolean forAvailable;
|
||||
|
||||
public ReduceWeightOperation(MathValue<Player> arg, int sharedMembers) {
|
||||
public ReduceWeightOperation(MathValue<Player> arg, int sharedMembers, boolean forAvailable) {
|
||||
this.arg = arg;
|
||||
this.sharedMembers = sharedMembers;
|
||||
this.forAvailable = forAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double apply(Context<Player> context, Double weight, Map<String, Double> weights) {
|
||||
if (this.forAvailable && weight < 0) {
|
||||
return weight;
|
||||
}
|
||||
return weight - arg.evaluate(context) / sharedMembers;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user