Skip to content

Commit c5fa834

Browse files
committed
1.0.8: ignore missing random source class
1 parent c17d6f5 commit c5fa834

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

codebook-lvt/src/main/java/io/papermc/codebook/lvt/suggestion/numbers/RandomSourceSuggester.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,23 @@ public class RandomSourceSuggester implements LvtSuggester {
4141

4242
static final JvmType RANDOM_SOURCE_TYPE = new ClassType("net/minecraft/util/RandomSource");
4343

44-
private final ClassData randomSourceClass;
44+
private final @Nullable ClassData randomSourceClass;
4545

4646
@Inject
4747
RandomSourceSuggester(final HypoContext hypoContext) throws IOException {
48-
final @Nullable ClassData random = hypoContext.getContextProvider().findClass(RANDOM_SOURCE_TYPE);
49-
if (random == null) {
50-
throw new IllegalStateException("Cannot find " + RANDOM_SOURCE_TYPE + " on the classpath.");
48+
this.randomSourceClass = hypoContext.getContextProvider().findClass(RANDOM_SOURCE_TYPE);
49+
if (this.randomSourceClass == null) {
50+
System.err.println("Failed to find RandomSource class, disabling RandomSourceSuggester");
5151
}
52-
this.randomSourceClass = random;
5352
}
5453

5554
@Override
5655
public @Nullable String suggestFromMethod(
5756
final MethodCallContext call, final MethodInsnContext insn, final ContainerContext container) {
57+
if (this.randomSourceClass == null) {
58+
return null;
59+
}
60+
5861
final String methodName = call.data().name();
5962
ClassData ownerClass = insn.owner();
6063
if (ownerClass.doesExtendOrImplement(this.randomSourceClass)) {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
group = io.papermc.codebook
2-
version = 1.0.7
2+
version = 1.0.8

0 commit comments

Comments
 (0)