Skip to content

Commit a8e7ecd

Browse files
committed
Display class when throwing exception
1 parent 75b94ce commit a8e7ecd

7 files changed

Lines changed: 17 additions & 14 deletions

File tree

adventure/src/main/java/net/j4c0b3y/api/config/platform/adventure/provider/BannerComponentProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class BannerComponentProvider implements TypeProvider<BannerComponent> {
1616
if (context.getObject() instanceof Collection<?> collection) {
1717
return new BannerComponent(collection.stream().map(Object::toString).toArray(String[]::new));
1818
}
19-
throw new IllegalStateException("Failed to parse MiniMessage");
19+
throw new IllegalStateException("Failed to parse Banner: " + context.getObject().getClass().getName());
2020
}
2121

2222
@Override

adventure/src/main/java/net/j4c0b3y/api/config/platform/adventure/provider/MiniMessageProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public MiniComponent load(@NonNull LoadContext context) {
1515
if (context.getObject() instanceof String string) {
1616
return new MiniComponent(string);
1717
}
18-
throw new IllegalStateException("Failed to parse MiniMessage");
18+
throw new IllegalStateException("Failed to parse MiniMessage: " + context.getObject().getClass().getName());
1919
}
2020

2121
@Nullable

adventure/src/main/java/net/j4c0b3y/api/config/platform/adventure/provider/PrefixedComponentProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ public PrefixedComponent load(@NonNull LoadContext context) {
1414
if (context.getObject() instanceof String string) {
1515
return new PrefixedComponent(string);
1616
}
17-
throw new IllegalStateException("Failed to parse prefixed component");
17+
throw new IllegalStateException("Failed to parse prefixed component: " + context.getObject().getClass().getName());
1818
}
1919

2020
@NonNull

adventure/src/main/java/net/j4c0b3y/api/config/platform/adventure/provider/TitleComponentProvider.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.j4c0b3y.api.config.platform.adventure.provider;
22

3+
import dev.dejvokep.boostedyaml.block.implementation.Section;
34
import net.j4c0b3y.api.config.platform.adventure.types.TitleComponent;
45
import net.j4c0b3y.api.config.provider.TypeProvider;
56
import net.j4c0b3y.api.config.provider.context.LoadContext;
@@ -14,17 +15,17 @@ public class TitleComponentProvider implements TypeProvider<TitleComponent> {
1415

1516
@Override
1617
public @NonNull TitleComponent load(@NonNull LoadContext context) {
17-
if (context.getObject() instanceof Map<?,?> map) {
18-
Map<?, ?> duration = (Map<?, ?>) map.get("duration");
18+
if (context.getObject() instanceof Section section) {
19+
Section duration = (Section) section.get("duration");
1920
return new TitleComponent(
20-
(String) map.get("title"),
21-
(String) map.get("subtitle"),
22-
(long) duration.get("fade-in"),
23-
(long) duration.get("stay"),
24-
(long) duration.get("fade-out")
21+
(String) section.get("title"),
22+
(String) section.get("subtitle"),
23+
(int) duration.get("fade-in"),
24+
(int) duration.get("stay"),
25+
(int) duration.get("fade-out")
2526
);
2627
}
27-
throw new IllegalStateException("Failed to parse Title component");
28+
throw new IllegalStateException("Failed to parse Title component: " + context.getObject().getClass().getName());
2829
}
2930

3031
@Override

adventure/src/main/java/net/j4c0b3y/api/config/platform/adventure/provider/TitleTimesProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class TitleTimesProvider implements TypeProvider<TitleTimes> {
2121
(long) map.get("fade-out")
2222
);
2323
}
24-
throw new IllegalStateException("Failed to parse Title times");
24+
throw new IllegalStateException("Failed to parse Title times: " + context.getObject().getClass().getName());
2525
}
2626

2727
@Override

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plugins {
1313
object Project {
1414
const val NAME = "ConfigAPI"
1515
const val GROUP = "net.j4c0b3y"
16-
const val VERSION = "1.2.10"
16+
const val VERSION = "1.2.11"
1717
}
1818

1919
allprojects {

paper/src/main/java/net/j4c0b3y/api/config/platform/paper/provider/ItemStackProvider.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.j4c0b3y.api.config.platform.paper.provider;
22

3+
import dev.dejvokep.boostedyaml.block.implementation.Section;
34
import io.papermc.paper.registry.RegistryKey;
45
import net.j4c0b3y.api.config.provider.TypeProvider;
56
import net.j4c0b3y.api.config.provider.context.LoadContext;
@@ -28,7 +29,8 @@ public class ItemStackProvider implements TypeProvider<ItemStack> {
2829
@Override
2930
@SuppressWarnings("unchecked")
3031
public ItemStack load(@NonNull LoadContext context) {
31-
if (context.getObject() instanceof Map<?,?> configMap) {
32+
if (context.getObject() instanceof Section section) {
33+
Map<String, Object> configMap = section.getStringRouteMappedValues(true);
3234
if (configMap.containsKey("schema_version")) {
3335
return Bukkit.getUnsafe().deserializeStack((Map<String, Object>) configMap);
3436
}

0 commit comments

Comments
 (0)