9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-04 15:41:35 +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

@@ -65,7 +65,7 @@ public class ActionBarSender {
@SuppressWarnings("DuplicatedCode")
private void updatePrivatePlaceholders() {
double score = competition.getRanking().getPlayerScore(player.getName());
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, String.format("%.2f", competition.getGoal().isReversed() ? -score : score));
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, score == 0 ? TranslationManager.miniMessageTranslation(MessageConstants.COMPETITION_NO_SCORE.build().key()) : String.format("%.2f", competition.getGoal().isReversed() ? -score : score));
this.privateContext.arg(ContextKeys.SCORE, competition.getGoal().isReversed() ? -score : score);
int rank = competition.getRanking().getPlayerRank(player.getName());
this.privateContext.arg(ContextKeys.RANK, rank != -1 ? String.valueOf(rank) : TranslationManager.miniMessageTranslation(MessageConstants.COMPETITION_NO_RANK.build().key()));

View File

@@ -75,7 +75,7 @@ public class BossBarSender {
@SuppressWarnings("DuplicatedCode")
private void updatePrivatePlaceholders() {
double score = competition.getRanking().getPlayerScore(player.getName());
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, String.format("%.2f", competition.getGoal().isReversed() ? -score : score));
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, score == 0 ? TranslationManager.miniMessageTranslation(MessageConstants.COMPETITION_NO_SCORE.build().key()) : String.format("%.2f", competition.getGoal().isReversed() ? -score : score));
this.privateContext.arg(ContextKeys.SCORE, competition.getGoal().isReversed() ? -score : score);
int rank = competition.getRanking().getPlayerRank(player.getName());
this.privateContext.arg(ContextKeys.RANK, rank != -1 ? String.valueOf(rank) : TranslationManager.miniMessageTranslation(MessageConstants.COMPETITION_NO_RANK.build().key()));

View File

@@ -106,6 +106,11 @@ public class BukkitLootManager implements LootManager {
return true;
}
@Override
public Collection<Loot> getRegisteredLoots() {
return lootMap.values();
}
private void addGroupMember(String group, String member) {
List<String> members = groupMembersMap.get(group);
if (members == null) {
@@ -155,13 +160,16 @@ public class BukkitLootManager implements LootManager {
}
for (Pair<String, BiFunction<Context<Player>, Double, Double>> pair : effect.weightOperations()) {
double previous = lootWeightMap.getOrDefault(pair.left(), 0d);
if (previous > 0)
if (previous > 0) {
lootWeightMap.put(pair.left(), pair.right().apply(context, previous));
}
}
for (Pair<String, BiFunction<Context<Player>, Double, Double>> pair : effect.weightOperationsIgnored()) {
double previous = lootWeightMap.getOrDefault(pair.left(), 0d);
lootWeightMap.put(pair.left(), pair.right().apply(context, previous));
}
plugin.debug(lootWeightMap);
String lootID = WeightUtils.getRandom(lootWeightMap);
return Optional.ofNullable(lootID)
.map(id -> getLoot(lootID).orElseThrow(() -> new RuntimeException("Could not find loot " + lootID)))

View File

@@ -916,6 +916,7 @@ red_snapper_fish:
base: 10
bonus: 2.3
red_snapper_fish_silver_star:
amount: 7~9
show-in-fishfinder: false
material: cod
display: