- Fixed compatibility for MC <= 1.21.4
This commit is contained in:
nulli0n committed 2025-06-04 15:08:39 +05:00
1 parent 12a85ce198
commit 753ca2dfc4
4 files changed
+16 -5

No files matched your search

@@ -157,7 +157,7 @@ public class BukkitThing {
public static <T extends Keyed> List<NamespacedKey> getKeys(@NotNull RegistryType<T> registryType) { public static <T extends Keyed> List<NamespacedKey> getKeys(@NotNull RegistryType<T> registryType) {
var registry = registryType.getRegistry(); var registry = registryType.getRegistry();
return Version.isPaper() ? registry.keyStream().toList() : registry.stream().map(Keyed::getKey).toList(); return Version.isPaper() && Version.isAtLeast(Version.MC_1_21_5) ? registry.keyStream().toList() : registry.stream().map(Keyed::getKey).toList();
} }
@NotNull @NotNull
@@ -246,7 +246,7 @@ public class ConfigValue<T> {
@NotNull Writer<Map<K, V>> writer, @NotNull Writer<Map<K, V>> writer,
@NotNull Map<K, V> defaultValue, @NotNull Map<K, V> defaultValue,
@Nullable String... description) { @Nullable String... description) {
return forMap(path, keyFun, valFun, HashMap::new, writer, defaultValue, description); return forMap(path, keyFun, valFun, LinkedHashMap::new, writer, defaultValue, description);
} }
@NotNull @NotNull
@@ -300,7 +300,7 @@ public class ConfigValue<T> {
@NotNull Consumer<Map<K, V>> defaultValue, @NotNull Consumer<Map<K, V>> defaultValue,
@Nullable String... description) { @Nullable String... description) {
Loader<Map<K, V>> reader = (config, readPath) -> { Loader<Map<K, V>> reader = (config, readPath) -> {
var map = new HashMap<K, V>(); var map = new LinkedHashMap<K, V>(); // Preserve config order
for (String keyRaw : config.getSection(readPath)) { for (String keyRaw : config.getSection(readPath)) {
K key = keyReadFun.apply(keyRaw); K key = keyReadFun.apply(keyRaw);
V val = valReadFun.read(config, readPath + "." + keyRaw, keyRaw); V val = valReadFun.read(config, readPath + "." + keyRaw, keyRaw);
@@ -181,6 +181,12 @@ public class TextRoot {
for (int index = 0; index < length; index++) { for (int index = 0; index < length; index++) {
char letter = string.charAt(index); char letter = string.charAt(index);
if (letter == '\\' && index != (length - 1) && string.charAt(index + 1) == TagUtils.OPEN_BRACKET) {
index++;
consumer.accept(TagUtils.OPEN_BRACKET);
continue;
}
Tag: Tag:
if (letter == TagUtils.OPEN_BRACKET && index != (length - 1)) { if (letter == TagUtils.OPEN_BRACKET && index != (length - 1)) {
int indexEnd = indexOfIgnoreEscaped(string, TagUtils.CLOSE_BRACKET, index);//string.indexOf(Tag.CLOSE_BRACKET, index); int indexEnd = indexOfIgnoreEscaped(string, TagUtils.CLOSE_BRACKET, index);//string.indexOf(Tag.CLOSE_BRACKET, index);
@@ -318,7 +318,12 @@ public class PaperBridge implements Software {
} }
public static void hidePaperComponents(@NotNull ItemStack itemStack, @NotNull Set<DataComponentType> componentTypes) { public static void hidePaperComponents(@NotNull ItemStack itemStack, @NotNull Set<DataComponentType> componentTypes) {
TooltipDisplay tooltipDisplay = TooltipDisplay.tooltipDisplay().hiddenComponents(componentTypes).build(); try {
itemStack.setData(DataComponentTypes.TOOLTIP_DISPLAY, tooltipDisplay); TooltipDisplay tooltipDisplay = TooltipDisplay.tooltipDisplay().hiddenComponents(componentTypes).build();
itemStack.setData(DataComponentTypes.TOOLTIP_DISPLAY, tooltipDisplay);
}
catch (NoSuchElementException exception) {
exception.printStackTrace();
}
} }
} }