Skip to content

Commit

Permalink
1.0.8: ignore missing random source class
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Jan 1, 2024
1 parent c17d6f5 commit c5fa834
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,23 @@ public class RandomSourceSuggester implements LvtSuggester {

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

private final ClassData randomSourceClass;
private final @Nullable ClassData randomSourceClass;

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

@Override
public @Nullable String suggestFromMethod(
final MethodCallContext call, final MethodInsnContext insn, final ContainerContext container) {
if (this.randomSourceClass == null) {
return null;
}

final String methodName = call.data().name();
ClassData ownerClass = insn.owner();
if (ownerClass.doesExtendOrImplement(this.randomSourceClass)) {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
group = io.papermc.codebook
version = 1.0.7
version = 1.0.8

0 comments on commit c5fa834

Please sign in to comment.