9
0
mirror of https://github.com/Xiao-MoMi/Custom-Fishing.git synced 2025-12-26 18:39:11 +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);

View File

@@ -1,6 +1,6 @@
# Developer: @Xiao-MoMi
# Wiki: https://mo-mi.gitbook.io/xiaomomi-plugins/
config-version: '30'
config-version: '31'
# Debug
debug: false
@@ -147,6 +147,24 @@ mechanics:
min-wait-time: 100
max-wait-time: 600
# Size settings
size:
# Some effects would increase/decrease size so the option decides whether they could ignore the limit
restricted-size-range: true
###### WARNING: THIS IS NOT AN IMPLEMENTED FEATURE AND MIGHT BE REMOVED IN THE FUTURE ######
# It's only available for developers to test for the moment.
# This feature requires much work on preventing dupe, counting price, merging dropped items,
# clicks in inventory, hopper transferring and lore updating...
# It might be removed if dupes or has bad performance.
## Allow players to stack fish with different sizes
#allow-stack: false
## Lore format
#lore-format:
# - ''
# - 'Total Size: {0}cm'
#############################################################################################
# Competition settings
competition:
# Use redis for cross server data synchronization

View File

@@ -1,8 +1,8 @@
enable: true
# Container title
title: '<gradient:#A52A2A:#800000:#A52A2A>Fish Market</gradient>'
enable: true
limitation:
enable: true
# Support expression and placeholders