Skip to content

Commit

Permalink
fix exception if ItemsAdder Entities API is unavailable
Browse files Browse the repository at this point in the history
  • Loading branch information
steve4744 committed Nov 1, 2023
1 parent c13c292 commit 4aea707
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* MIT License
Copyright (c) 2022 steve4744
Copyright (c) 2023 steve4744
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -43,7 +43,7 @@ public static String getDisplayName(Block block) {
}

public static boolean isItemsAdderEntity(Entity entity) {
return CustomEntity.isCustomEntity(entity);
return isApiEnabled() ? CustomEntity.isCustomEntity(entity) : false;
}

public static String getEntityDisplayName(Entity entity) {
Expand All @@ -57,4 +57,18 @@ public static String getEntityDisplayName(Entity entity) {
}
return CustomEntity.byAlreadySpawned(entity).getNamespace();
}

/*
* ItemsAdder only loads the Entity API if its enabled in the config.
*
* @return is entity API available
*/
private static boolean isApiEnabled() {
try {
Class.forName("dev.lone.itemsadder.api.CustomEntity");
} catch (ClassNotFoundException e) {
return false;
}
return true;
}
}

0 comments on commit 4aea707

Please sign in to comment.