From cdcac2b3180b1969a05cff82aaa0a04a53c35fc2 Mon Sep 17 00:00:00 2001 From: XiaoMoMi <972454774@qq.com> Date: Mon, 27 Nov 2023 04:42:53 +0800 Subject: [PATCH] fix size --- .../customfishing/command/sub/DebugCommand.java | 16 ++++++++++++---- .../mechanic/item/ItemManagerImpl.java | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/plugin/src/main/java/net/momirealms/customfishing/command/sub/DebugCommand.java b/plugin/src/main/java/net/momirealms/customfishing/command/sub/DebugCommand.java index 40080b61..0238d1f5 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/command/sub/DebugCommand.java +++ b/plugin/src/main/java/net/momirealms/customfishing/command/sub/DebugCommand.java @@ -55,7 +55,8 @@ public class DebugCommand { getSeasonCommand(), getGroupCommand(), getCategoryCommand(), - getNBTCommand() + getNBTCommand(), + getLocationCommand() ); } @@ -66,6 +67,13 @@ public class DebugCommand { }); } + public CommandAPICommand getLocationCommand() { + return new CommandAPICommand("location") + .executesPlayer((player, arg) -> { + AdventureManagerImpl.getInstance().sendMessage(player, player.getLocation().toString()); + }); + } + public CommandAPICommand getNBTCommand() { return new CommandAPICommand("nbt") .executesPlayer((player, arg) -> { @@ -168,7 +176,7 @@ public class DebugCommand { public record LootWithWeight(String key, double weight) { } - public static void quickSort(LootWithWeight[] loot, int low, int high) { + private static void quickSort(LootWithWeight[] loot, int low, int high) { if (low < high) { int pi = partition(loot, low, high); quickSort(loot, low, pi - 1); @@ -176,7 +184,7 @@ public class DebugCommand { } } - public static int partition(LootWithWeight[] loot, int low, int high) { + private static int partition(LootWithWeight[] loot, int low, int high) { double pivot = loot[high].weight(); int i = low - 1; for (int j = low; j <= high - 1; j++) { @@ -189,7 +197,7 @@ public class DebugCommand { return i + 1; } - public static void swap(LootWithWeight[] loot, int i, int j) { + private static void swap(LootWithWeight[] loot, int i, int j) { LootWithWeight temp = loot[i]; loot[i] = loot[j]; loot[j] = temp; diff --git a/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java b/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java index d96f8117..161dcc64 100644 --- a/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java +++ b/plugin/src/main/java/net/momirealms/customfishing/mechanic/item/ItemManagerImpl.java @@ -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() + size.left() <= size.right() ? 0 : 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;