Universal slot override config

This commit is contained in:
Ranzu committed 2026-05-15 11:47:40 +02:00
1 parent 1d268a76c8
commit 257e65d296
6 files changed
+110 -28

No files matched your search

@@ -2,6 +2,7 @@ package baubles.common;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import baubles.api.expanded.BaubleExpandedSlots;
@@ -20,7 +21,9 @@ public class BaublesConfig {
public static boolean manualSlotSelection = false;
public static boolean displayTooltipOnHover = true;
public static String[] slotStackLimitOverrides = new String[] {};
public static String[] slotUniversalOverrides = new String[] {};
private static final Map<String, Integer> stackLimitsByType = new HashMap<>();
private static final ArrayList<String> universalOverrideTypes = new ArrayList<>();
public static String[] overrideSlotTypes = new String[] {
BaubleExpandedSlots.amuletType,
@@ -80,8 +83,31 @@ public class BaublesConfig {
+ "Unspecified types default to a stack limit of 1.\n",
currentlyRegisteredTypes.stream().map(type -> type + "=1").toArray(String[]::new)
);
slotUniversalOverrides = config.getStringList("slotUniversalOverrides", categoryOverride, slotUniversalOverrides,
"Bauble types listed here are also allowed in " + BaubleExpandedSlots.universalType + " slots.\n"
+ "Use registered slot type names like " + BaubleExpandedSlots.ringType + ", " + BaubleExpandedSlots.amuletType
+ ", " + BaubleExpandedSlots.beltType + ".\n",
currentlyRegisteredTypes.toArray(new String[0])
);
stackLimitsByType.clear();
universalOverrideTypes.clear();
for (String type : slotUniversalOverrides) {
if (type == null) continue;
String trimmedType = type.trim();
if (trimmedType.isEmpty()) continue;
if (!BaubleExpandedSlots.isTypeRegistered(trimmedType)) {
Baubles.log.warn("Ignoring slotUniversalOverrides entry '{}': unknown slot type '{}'", type, trimmedType);
continue;
}
if (trimmedType.equals(BaubleExpandedSlots.universalType) || trimmedType.equals(BaubleExpandedSlots.unknownType)) {
continue;
}
if (!universalOverrideTypes.contains(trimmedType)) {
universalOverrideTypes.add(trimmedType);
}
}
for (String entry : slotStackLimitOverrides) {
if (entry == null) continue;
String[] split = entry.split("=", 2);
@@ -119,4 +145,31 @@ public class BaublesConfig {
return stackLimitsByType.getOrDefault(type, 1);
}
public static boolean canTypeFitSlot(String itemType, String slotType) {
if (itemType == null || slotType == null) {
return false;
}
if (itemType.equals(BaubleExpandedSlots.universalType) || itemType.equals(slotType)) {
return true;
}
return slotType.equals(BaubleExpandedSlots.universalType) && universalOverrideTypes.contains(itemType);
}
public static String[] getDisplayTypesWithUniversalOverrides(String[] types) {
if (types == null || types.length == 0) {
return new String[0];
}
LinkedHashSet<String> displayTypes = new LinkedHashSet<>();
for (String type : types) {
if (type == null) continue;
String trimmed = type.trim();
if (trimmed.isEmpty()) continue;
displayTypes.add(trimmed);
if (universalOverrideTypes.contains(trimmed)) {
displayTypes.add(BaubleExpandedSlots.universalType);
}
}
return displayTypes.toArray(new String[0]);
}
}