9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2026-01-06 15:51:50 +00:00

size range

This commit is contained in:
XiaoMoMi
2023-12-01 21:48:03 +08:00
parent cdcac2b318
commit bcbaa42f4f
4 changed files with 40 additions and 5 deletions

View File

@@ -709,7 +709,7 @@ public class ItemManagerImpl implements ItemManager, Listener {
if (bonus != 0) {
placeholders.put("{bonus}", String.format("%.2f", bonus));
}
float size = Float.parseFloat(placeholders.getOrDefault("{size}", "0").replace(",", "."));
float size = Float.parseFloat(placeholders.getOrDefault("{SIZE}", "0"));
double price = CustomFishingPlugin.get().getMarketManager().getFishPrice(
base,
bonus,
@@ -717,6 +717,7 @@ public class ItemManagerImpl implements ItemManager, Listener {
);
nbtItem.setDouble("Price", price);
placeholders.put("{price}", String.format("%.2f", price));
placeholders.put("{PRICE}", String.valueOf(price));
});
return this;
}
@@ -731,8 +732,16 @@ public class ItemManagerImpl implements ItemManager, Listener {
double fixed = Double.parseDouble(placeholders.getOrDefault("{size-fixed}", "0.0"));
random *= bonus;
random += fixed;
if (CFConfig.restrictedSizeRange) {
if (random > size.right()) {
random = size.right();
} else if (random < size.left()) {
random = size.left();
}
}
cfCompound.setFloat("size", random);
placeholders.put("{size}", String.format("%.2f", random));
placeholders.put("{SIZE}", String.valueOf(random));
});
return this;
}

View File

@@ -40,7 +40,7 @@ import java.util.Objects;
public class CFConfig {
// config version
public static String configVersion = "30";
public static String configVersion = "31";
// Debug mode
public static boolean debug;
// language
@@ -88,6 +88,10 @@ public class CFConfig {
// Lock data on join
public static boolean lockData;
public static boolean restrictedSizeRange;
public static boolean allowSizeStack;
public static List<String> sizeStackLore;
// Legacy color code support
public static boolean legacyColorSupport;
// Durability lore
@@ -151,6 +155,10 @@ public class CFConfig {
lavaMinTime = config.getInt("mechanics.lava-fishing.min-wait-time", 100);
lavaMaxTime = config.getInt("mechanics.lava-fishing.max-wait-time", 600);
restrictedSizeRange = config.getBoolean("mechanics.size.restricted-size-range", true);
allowSizeStack = config.getBoolean("mechanics.size.allow-stack", false);
sizeStackLore = config.getStringList("mechanics.size.lore-format").stream().map(it -> "<!i>" + it).toList();
globalShowInFinder = config.getBoolean("mechanics.global-loot-property.show-in-fishfinder", true);
globalDisableStats = config.getBoolean("mechanics.global-loot-property.disable-stat", false);
globalDisableGame = config.getBoolean("mechanics.global-loot-property.disable-game", false);