9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-19 15:09:24 +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

@@ -1,14 +1,14 @@
# Custom-Fishing
![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/Xiao-MoMi/Custom-Fishing)
![Code Size](https://img.shields.io/github/languages/code-size/Xiao-MoMi/Custom-Fishing)
![bStats Servers](https://img.shields.io/bstats/servers/16648)
![bStats Players](https://img.shields.io/bstats/players/16648)
![GitHub](https://img.shields.io/github/license/Xiao-MoMi/Custom-Fishing)
[![](https://jitpack.io/v/Xiao-MoMi/Custom-Fishing.svg)](https://jitpack.io/#Xiao-MoMi/Custom-Fishing)
<a href="https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customfishing" alt="GitBook">
<img src="https://img.shields.io/badge/docs-gitbook-brightgreen" alt="Gitbook"/>
</a>
![GitHub](https://img.shields.io/github/license/Xiao-MoMi/Custom-Fishing)
![Code Size](https://img.shields.io/github/languages/code-size/Xiao-MoMi/Custom-Fishing)
![bStats Servers](https://img.shields.io/bstats/servers/16648)
![bStats Players](https://img.shields.io/bstats/players/16648)
CustomFishing is a Paper plugin that provides minigames and a powerful condition & action system for fishing.
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
Polymart: https://polymart.org/resource/customfishing.2723 \
Afdian: https://afdian.net/@xiaomomi
## Use CustomFishing API
## CustomFishing API
### Maven
@@ -50,7 +50,7 @@ Afdian: https://afdian.net/@xiaomomi
<dependency>
<groupId>com.github.Xiao-MoMi</groupId>
<artifactId>Custom-Fishing</artifactId>
<version>{LATEST}</version>
<version>{VERSION}</version>
<scope>provided</scope>
</dependency>
</dependencies>
@@ -64,7 +64,7 @@ repositories {
```
```
dependencies {
compileOnly 'com.github.Xiao-MoMi:Custom-Fishing:{LATEST}'
compileOnly 'com.github.Xiao-MoMi:Custom-Fishing:{VERSION}'
}
```
### Gradle (Kotlin)
@@ -76,6 +76,6 @@ repositories {
```
```
dependencies {
compileOnly("com.github.Xiao-MoMi:Custom-Fishing:{LATEST}")
compileOnly("com.github.Xiao-MoMi:Custom-Fishing:{VERSION}")
}
```

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.
*

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:

View File

@@ -1,6 +1,6 @@
# Project settings
# Rule: [major update].[feature update].[bug fix]
project_version=2.2.0
project_version=2.2.1
config_version=34
project_group=net.momirealms