9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-06 15:51:50 +00:00
This commit is contained in:
XiaoMoMi
2024-07-16 01:27:45 +08:00
parent df1b425186
commit d8735d06e9
11 changed files with 57 additions and 16 deletions

View File

@@ -54,7 +54,8 @@ public final class CompetitionGoal {
public static final CompetitionGoal MIN_SIZE = new CompetitionGoal(
"min_size", true,
((rankingProvider, player, score) -> {
if (-rankingProvider.getPlayerScore(player) > score) {
double previousScore = -rankingProvider.getPlayerScore(player);
if (previousScore == 0 || previousScore > score) {
rankingProvider.setData(player, -score);
}
}),

View File

@@ -369,7 +369,9 @@ public abstract class ConfigManager implements ConfigLoader, Reloadable {
@Override
public YamlDocument loadData(File file, char routeSeparator) {
try (InputStream inputStream = new FileInputStream(file)) {
return YamlDocument.create(inputStream, GeneralSettings.builder().setRouteSeparator(routeSeparator).build());
return YamlDocument.create(inputStream, GeneralSettings.builder()
.setRouteSeparator(routeSeparator)
.build());
} catch (IOException e) {
plugin.getPluginLogger().severe("Failed to load config " + file, e);
throw new RuntimeException(e);

View File

@@ -231,4 +231,24 @@ public class EffectImpl implements Effect {
.properties(this.properties);
}
@Override
public String toString() {
return "Effect{" +
"properties=" + properties +
", multipleLootChance=" + multipleLootChance +
", sizeAdder=" + sizeAdder +
", sizeMultiplier=" + sizeMultiplier +
", scoreAdder=" + scoreAdder +
", scoreMultiplier=" + scoreMultiplier +
", gameTimeAdder=" + gameTimeAdder +
", gameTimeMultiplier=" + gameTimeMultiplier +
", waitTimeAdder=" + waitTimeAdder +
", waitTimeMultiplier=" + waitTimeMultiplier +
", difficultyAdder=" + difficultyAdder +
", difficultyMultiplier=" + difficultyMultiplier +
", weightOperations=" + weightOperations +
", weightOperationsIgnored=" + weightOperationsIgnored +
'}';
}
}

View File

@@ -163,6 +163,7 @@ public class CustomFishingHook {
// to update some properties
mechanic.preStart();
Effect tempEffect = effect.copy();
for (EffectModifier modifier : gears.effectModifiers()) {
for (TriConsumer<Effect, Context<Player>, Integer> consumer : modifier.modifiers()) {
consumer.accept(tempEffect, context, 1);
@@ -175,7 +176,7 @@ public class CustomFishingHook {
context.arg(ContextKeys.OTHER_Z, hook.getLocation().getBlockZ());
// get the next loot
Loot loot = plugin.getLootManager().getNextLoot(effect, context);
Loot loot = plugin.getLootManager().getNextLoot(tempEffect, context);
if (loot != null) {
this.nextLoot = loot;
@@ -517,7 +518,7 @@ public class CustomFishingHook {
competition.refreshData(context.getHolder(), score);
} else if (competition.getGoal() == CompetitionGoal.MAX_SIZE || competition.getGoal() == CompetitionGoal.MIN_SIZE) {
Float size = context.arg(ContextKeys.SIZE);
if (size != null) {
if (size != null && size > 0) {
competition.refreshData(context.getHolder(), size);
}
} else if (competition.getGoal() == CompetitionGoal.TOTAL_SCORE) {

View File

@@ -24,6 +24,7 @@ import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Optional;
@@ -41,6 +42,13 @@ public interface LootManager extends Reloadable {
*/
boolean registerLoot(@NotNull Loot loot);
/**
* Get all the registered loots
*
* @return registered loots
*/
Collection<Loot> getRegisteredLoots();
/**
* Retrieves the members of a loot group identified by the given key.
*