9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-29 11:59:11 +00:00
This commit is contained in:
XiaoMoMi
2023-11-20 16:19:31 +08:00
parent 76fb4b9dc2
commit 8ecd670fb9
3 changed files with 22 additions and 4 deletions

View File

@@ -17,6 +17,7 @@
package net.momirealms.customfishing.command.sub;
import de.tr7zw.changeme.nbtapi.NBTItem;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.IStringTooltip;
import dev.jorel.commandapi.StringTooltip;
@@ -32,7 +33,10 @@ import net.momirealms.customfishing.api.mechanic.condition.FishingPreparation;
import net.momirealms.customfishing.api.mechanic.effect.EffectCarrier;
import net.momirealms.customfishing.api.mechanic.effect.EffectModifier;
import net.momirealms.customfishing.api.mechanic.effect.FishingEffect;
import net.momirealms.customfishing.util.ConfigUtils;
import net.momirealms.customfishing.util.NBTUtils;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
@@ -50,7 +54,8 @@ public class DebugCommand {
getBiomeCommand(),
getSeasonCommand(),
getGroupCommand(),
getCategoryCommand()
getCategoryCommand(),
getNBTCommand()
);
}
@@ -61,6 +66,20 @@ public class DebugCommand {
});
}
public CommandAPICommand getNBTCommand() {
return new CommandAPICommand("nbt")
.executesPlayer((player, arg) -> {
ItemStack item = player.getInventory().getItemInMainHand();
if (item.getType() == Material.AIR)
return;
ArrayList<String> list = new ArrayList<>();
ConfigUtils.mapToReadableStringList(NBTUtils.compoundToMap(new NBTItem(item)), list, 0, false);
for (String line : list) {
AdventureManagerImpl.getInstance().sendMessage(player, line);
}
});
}
public CommandAPICommand getSeasonCommand() {
return new CommandAPICommand("season")
.executesPlayer((player, arg) -> {

View File

@@ -182,13 +182,11 @@ public class Competition implements FishingCompetition {
Pair<String, Double> competitionPlayer = iterator.next();
this.publicPlaceholders.put("{" + i + "_player}", competitionPlayer.left());
this.publicPlaceholders.put("{" + i + "_score}", String.format("%.2f", competitionPlayer.right()));
i++;
if (i < rewardsMap.size()) {
Player player = Bukkit.getPlayer(competitionPlayer.left());
if (player != null)
for (Action action : rewardsMap.get(String.valueOf(i)))
action.trigger(new Condition(player));
} else {
Action[] actions = rewardsMap.get("participation");
if (actions != null) {
@@ -199,6 +197,7 @@ public class Competition implements FishingCompetition {
}
}
}
i++;
}
}

View File

@@ -726,7 +726,7 @@ public class ItemManagerImpl implements ItemManager, Listener {
if (size == null) return this;
editors.put("size", (player, nbtItem, placeholders) -> {
NBTCompound cfCompound = nbtItem.getOrCreateCompound("CustomFishing");
float random = size.left() + ThreadLocalRandom.current().nextFloat(size.right() - size.left());
float random = size.left() + size.left() <= size.right() ? 0 : ThreadLocalRandom.current().nextFloat(size.right() - size.left());
float bonus = Float.parseFloat(placeholders.getOrDefault("{size-multiplier}", "1.0"));
double fixed = Double.parseDouble(placeholders.getOrDefault("{size-fixed}", "0.0"));
random *= bonus;