Skip to content

Commit d8735d0

Browse files
committed
2.2.21
1 parent df1b425 commit d8735d0

11 files changed

Lines changed: 57 additions & 16 deletions

File tree

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Custom-Fishing
22

33
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/Xiao-MoMi/Custom-Fishing)
4-
![Code Size](https://img.shields.io/github/languages/code-size/Xiao-MoMi/Custom-Fishing)
5-
![bStats Servers](https://img.shields.io/bstats/servers/16648)
6-
![bStats Players](https://img.shields.io/bstats/players/16648)
7-
![GitHub](https://img.shields.io/github/license/Xiao-MoMi/Custom-Fishing)
84
[![](https://jitpack.io/v/Xiao-MoMi/Custom-Fishing.svg)](https://jitpack.io/#Xiao-MoMi/Custom-Fishing)
95
<a href="https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customfishing" alt="GitBook">
106
<img src="https://img.shields.io/badge/docs-gitbook-brightgreen" alt="Gitbook"/>
117
</a>
8+
![GitHub](https://img.shields.io/github/license/Xiao-MoMi/Custom-Fishing)
9+
![Code Size](https://img.shields.io/github/languages/code-size/Xiao-MoMi/Custom-Fishing)
10+
![bStats Servers](https://img.shields.io/bstats/servers/16648)
11+
![bStats Players](https://img.shields.io/bstats/players/16648)
1212

1313
CustomFishing is a Paper plugin that provides minigames and a powerful condition & action system for fishing.
1414
With the new concept of weight system, CustomFishing brings unlimited customization possibilities and best performance.
@@ -33,7 +33,7 @@ If you are using a proxy, configurate the proxy in gradle.properties. Otherwise
3333
Polymart: https://polymart.org/resource/customfishing.2723 \
3434
Afdian: https://afdian.net/@xiaomomi
3535

36-
## Use CustomFishing API
36+
## CustomFishing API
3737

3838
### Maven
3939

@@ -50,7 +50,7 @@ Afdian: https://afdian.net/@xiaomomi
5050
<dependency>
5151
<groupId>com.github.Xiao-MoMi</groupId>
5252
<artifactId>Custom-Fishing</artifactId>
53-
<version>{LATEST}</version>
53+
<version>{VERSION}</version>
5454
<scope>provided</scope>
5555
</dependency>
5656
</dependencies>
@@ -64,7 +64,7 @@ repositories {
6464
```
6565
```
6666
dependencies {
67-
compileOnly 'com.github.Xiao-MoMi:Custom-Fishing:{LATEST}'
67+
compileOnly 'com.github.Xiao-MoMi:Custom-Fishing:{VERSION}'
6868
}
6969
```
7070
### Gradle (Kotlin)
@@ -76,6 +76,6 @@ repositories {
7676
```
7777
```
7878
dependencies {
79-
compileOnly("com.github.Xiao-MoMi:Custom-Fishing:{LATEST}")
79+
compileOnly("com.github.Xiao-MoMi:Custom-Fishing:{VERSION}")
8080
}
8181
```

api/src/main/java/net/momirealms/customfishing/api/mechanic/competition/CompetitionGoal.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public final class CompetitionGoal {
5454
public static final CompetitionGoal MIN_SIZE = new CompetitionGoal(
5555
"min_size", true,
5656
((rankingProvider, player, score) -> {
57-
if (-rankingProvider.getPlayerScore(player) > score) {
57+
double previousScore = -rankingProvider.getPlayerScore(player);
58+
if (previousScore == 0 || previousScore > score) {
5859
rankingProvider.setData(player, -score);
5960
}
6061
}),

api/src/main/java/net/momirealms/customfishing/api/mechanic/config/ConfigManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,9 @@ public YamlDocument loadData(File file) {
369369
@Override
370370
public YamlDocument loadData(File file, char routeSeparator) {
371371
try (InputStream inputStream = new FileInputStream(file)) {
372-
return YamlDocument.create(inputStream, GeneralSettings.builder().setRouteSeparator(routeSeparator).build());
372+
return YamlDocument.create(inputStream, GeneralSettings.builder()
373+
.setRouteSeparator(routeSeparator)
374+
.build());
373375
} catch (IOException e) {
374376
plugin.getPluginLogger().severe("Failed to load config " + file, e);
375377
throw new RuntimeException(e);

api/src/main/java/net/momirealms/customfishing/api/mechanic/effect/EffectImpl.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,4 +231,24 @@ public Effect copy() {
231231
.properties(this.properties);
232232

233233
}
234+
235+
@Override
236+
public String toString() {
237+
return "Effect{" +
238+
"properties=" + properties +
239+
", multipleLootChance=" + multipleLootChance +
240+
", sizeAdder=" + sizeAdder +
241+
", sizeMultiplier=" + sizeMultiplier +
242+
", scoreAdder=" + scoreAdder +
243+
", scoreMultiplier=" + scoreMultiplier +
244+
", gameTimeAdder=" + gameTimeAdder +
245+
", gameTimeMultiplier=" + gameTimeMultiplier +
246+
", waitTimeAdder=" + waitTimeAdder +
247+
", waitTimeMultiplier=" + waitTimeMultiplier +
248+
", difficultyAdder=" + difficultyAdder +
249+
", difficultyMultiplier=" + difficultyMultiplier +
250+
", weightOperations=" + weightOperations +
251+
", weightOperationsIgnored=" + weightOperationsIgnored +
252+
'}';
253+
}
234254
}

api/src/main/java/net/momirealms/customfishing/api/mechanic/fishing/CustomFishingHook.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@ public CustomFishingHook(BukkitCustomFishingPlugin plugin, FishHook hook, Fishin
163163
// to update some properties
164164
mechanic.preStart();
165165
Effect tempEffect = effect.copy();
166+
166167
for (EffectModifier modifier : gears.effectModifiers()) {
167168
for (TriConsumer<Effect, Context<Player>, Integer> consumer : modifier.modifiers()) {
168169
consumer.accept(tempEffect, context, 1);
@@ -175,7 +176,7 @@ public CustomFishingHook(BukkitCustomFishingPlugin plugin, FishHook hook, Fishin
175176
context.arg(ContextKeys.OTHER_Z, hook.getLocation().getBlockZ());
176177

177178
// get the next loot
178-
Loot loot = plugin.getLootManager().getNextLoot(effect, context);
179+
Loot loot = plugin.getLootManager().getNextLoot(tempEffect, context);
179180
if (loot != null) {
180181
this.nextLoot = loot;
181182

@@ -517,7 +518,7 @@ private void doSuccessActions() {
517518
competition.refreshData(context.getHolder(), score);
518519
} else if (competition.getGoal() == CompetitionGoal.MAX_SIZE || competition.getGoal() == CompetitionGoal.MIN_SIZE) {
519520
Float size = context.arg(ContextKeys.SIZE);
520-
if (size != null) {
521+
if (size != null && size > 0) {
521522
competition.refreshData(context.getHolder(), size);
522523
}
523524
} else if (competition.getGoal() == CompetitionGoal.TOTAL_SCORE) {

api/src/main/java/net/momirealms/customfishing/api/mechanic/loot/LootManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.jetbrains.annotations.NotNull;
2525
import org.jetbrains.annotations.Nullable;
2626

27+
import java.util.Collection;
2728
import java.util.List;
2829
import java.util.Map;
2930
import java.util.Optional;
@@ -41,6 +42,13 @@ public interface LootManager extends Reloadable {
4142
*/
4243
boolean registerLoot(@NotNull Loot loot);
4344

45+
/**
46+
* Get all the registered loots
47+
*
48+
* @return registered loots
49+
*/
50+
Collection<Loot> getRegisteredLoots();
51+
4452
/**
4553
* Retrieves the members of a loot group identified by the given key.
4654
*

core/src/main/java/net/momirealms/customfishing/bukkit/competition/actionbar/ActionBarSender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public ActionBarSender(Player player, ActionBarConfig config, Competition compet
6565
@SuppressWarnings("DuplicatedCode")
6666
private void updatePrivatePlaceholders() {
6767
double score = competition.getRanking().getPlayerScore(player.getName());
68-
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, String.format("%.2f", competition.getGoal().isReversed() ? -score : score));
68+
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, score == 0 ? TranslationManager.miniMessageTranslation(MessageConstants.COMPETITION_NO_SCORE.build().key()) : String.format("%.2f", competition.getGoal().isReversed() ? -score : score));
6969
this.privateContext.arg(ContextKeys.SCORE, competition.getGoal().isReversed() ? -score : score);
7070
int rank = competition.getRanking().getPlayerRank(player.getName());
7171
this.privateContext.arg(ContextKeys.RANK, rank != -1 ? String.valueOf(rank) : TranslationManager.miniMessageTranslation(MessageConstants.COMPETITION_NO_RANK.build().key()));

core/src/main/java/net/momirealms/customfishing/bukkit/competition/bossbar/BossBarSender.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public BossBarSender(Player player, BossBarConfig config, Competition competitio
7575
@SuppressWarnings("DuplicatedCode")
7676
private void updatePrivatePlaceholders() {
7777
double score = competition.getRanking().getPlayerScore(player.getName());
78-
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, String.format("%.2f", competition.getGoal().isReversed() ? -score : score));
78+
this.privateContext.arg(ContextKeys.SCORE_FORMATTED, score == 0 ? TranslationManager.miniMessageTranslation(MessageConstants.COMPETITION_NO_SCORE.build().key()) : String.format("%.2f", competition.getGoal().isReversed() ? -score : score));
7979
this.privateContext.arg(ContextKeys.SCORE, competition.getGoal().isReversed() ? -score : score);
8080
int rank = competition.getRanking().getPlayerRank(player.getName());
8181
this.privateContext.arg(ContextKeys.RANK, rank != -1 ? String.valueOf(rank) : TranslationManager.miniMessageTranslation(MessageConstants.COMPETITION_NO_RANK.build().key()));

core/src/main/java/net/momirealms/customfishing/bukkit/loot/BukkitLootManager.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ public boolean registerLoot(@NotNull Loot loot) {
106106
return true;
107107
}
108108

109+
@Override
110+
public Collection<Loot> getRegisteredLoots() {
111+
return lootMap.values();
112+
}
113+
109114
private void addGroupMember(String group, String member) {
110115
List<String> members = groupMembersMap.get(group);
111116
if (members == null) {
@@ -155,13 +160,16 @@ public Loot getNextLoot(Effect effect, Context<Player> context) {
155160
}
156161
for (Pair<String, BiFunction<Context<Player>, Double, Double>> pair : effect.weightOperations()) {
157162
double previous = lootWeightMap.getOrDefault(pair.left(), 0d);
158-
if (previous > 0)
163+
if (previous > 0) {
159164
lootWeightMap.put(pair.left(), pair.right().apply(context, previous));
165+
}
160166
}
161167
for (Pair<String, BiFunction<Context<Player>, Double, Double>> pair : effect.weightOperationsIgnored()) {
162168
double previous = lootWeightMap.getOrDefault(pair.left(), 0d);
163169
lootWeightMap.put(pair.left(), pair.right().apply(context, previous));
164170
}
171+
172+
plugin.debug(lootWeightMap);
165173
String lootID = WeightUtils.getRandom(lootWeightMap);
166174
return Optional.ofNullable(lootID)
167175
.map(id -> getLoot(lootID).orElseThrow(() -> new RuntimeException("Could not find loot " + lootID)))

core/src/main/resources/contents/item/default.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ red_snapper_fish:
916916
base: 10
917917
bonus: 2.3
918918
red_snapper_fish_silver_star:
919+
amount: 7~9
919920
show-in-fishfinder: false
920921
material: cod
921922
display:

0 commit comments

Comments
 (0)