Skip to content

Commit

Permalink
Tracking if NDatabase is shaded
Browse files Browse the repository at this point in the history
  • Loading branch information
NivixX committed Oct 29, 2024
1 parent b3758a8 commit e42efe8
Show file tree
Hide file tree
Showing 19 changed files with 84 additions and 66 deletions.
2 changes: 1 addition & 1 deletion ndatabase-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ndatabase</artifactId>
<groupId>com.nivixx</groupId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,40 @@ public class NDatabase {

private static NDatabaseAPI instance;

private final static String API_BASE_PACKAGE = "com.nivixx.ndatabase.api";

/**
*
* @return the api interface to operate NDatabase.
* The actual implementation will differ depending on what platform
* you are currently using.
*/
public static NDatabaseAPI api() {
NDatabaseAPI instance = NDatabase.instance;
if (instance == null) {
throw new IllegalStateException("NDatabase has not loaded yet. Verify that your plugin configuration include NDatabase in dependencies.");
} else {

if (instance != null) {
return instance;
}

// Check if NDatabase is not shaded into the plugin
// That may prevent from retrieving the correct singleton API instance
String callerPackage = NDatabase.class.getPackage().getName();
if (!Objects.equals(API_BASE_PACKAGE, callerPackage)) {
throw new IllegalStateException(String.format(
"NDatabase has not loaded yet. " +
"it looks like you are calling NDatabase.api() from a different package location:" +
"%s instead of the original instance located in %s." +
"Perhaps you are shading NDatabase into your .jar ? Make sure to declare " +
"NDatabase dependency with scope \"provided\" or exclude it from your packaging.",
callerPackage, API_BASE_PACKAGE));

}

// Trying to get api while not loaded yet, probably because NDatabase is not added into dependencies
throw new IllegalStateException("NDatabase has not loaded yet. Verify that your plugin configuration include NDatabase in dependencies.");
}

// Note: the NDatabaseAPI instance is set by the core module after loaded
static void set(NDatabaseAPI nDatabaseAPI) {
static void set(NDatabaseAPI nDatabaseAPI){
Objects.requireNonNull(nDatabaseAPI,
"The NDatabase instance is null, probably due to a Google Guice incompatibility issue with java/spigot or other plugin.");
instance = nDatabaseAPI;
Expand All @@ -35,4 +52,5 @@ static void set(NDatabaseAPI nDatabaseAPI) {
private NDatabase() {
throw new AssertionError("illegal constructor called");
}
}

}
22 changes: 11 additions & 11 deletions ndatabase-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>ndatabase</artifactId>
<groupId>com.nivixx</groupId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -20,52 +20,52 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-expressiontree</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-core</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-jdbc</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-mysql</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-sqlite</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-mongodb</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-mariadb</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>core-platform</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
8 changes: 4 additions & 4 deletions ndatabase-dbms-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>

<artifactId>ndatabase-dbms-api</artifactId>
Expand All @@ -21,19 +21,19 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-expressiontree</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>core-platform</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
10 changes: 5 additions & 5 deletions ndatabase-dbms-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>

<artifactId>ndatabase-dbms-core</artifactId>
Expand All @@ -21,24 +21,24 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-expressiontree</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>core-platform</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
6 changes: 3 additions & 3 deletions ndatabase-dbms-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>

<artifactId>ndatabase-dbms-jdbc</artifactId>
Expand All @@ -21,13 +21,13 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-core</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
6 changes: 3 additions & 3 deletions ndatabase-dbms-mariadb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>

<artifactId>ndatabase-dbms-mariadb</artifactId>
Expand All @@ -21,13 +21,13 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-jdbc</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
6 changes: 3 additions & 3 deletions ndatabase-dbms-mongodb/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>

<artifactId>ndatabase-dbms-mongodb</artifactId>
Expand All @@ -20,13 +20,13 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-core</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
Expand Down
6 changes: 3 additions & 3 deletions ndatabase-dbms-mysql/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>

<artifactId>ndatabase-dbms-mysql</artifactId>
Expand All @@ -21,13 +21,13 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-jdbc</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
6 changes: 3 additions & 3 deletions ndatabase-dbms-sqlite/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>

<artifactId>ndatabase-dbms-sqlite</artifactId>
Expand All @@ -22,13 +22,13 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-dbms-jdbc</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
4 changes: 2 additions & 2 deletions ndatabase-expressiontree/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>

<artifactId>ndatabase-expressiontree</artifactId>
Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-api</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>

</dependencies>
Expand Down
10 changes: 5 additions & 5 deletions ndatabase-packaging-jar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
<parent>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</parent>
<packaging>jar</packaging>
<artifactId>ndatabase-packaging-jar</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>


<build>
Expand Down Expand Up @@ -51,17 +51,17 @@
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>ndatabase-core</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>app-platform</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.nivixx</groupId>
<artifactId>bukkit-platform</artifactId>
<version>1.4.1-SNAPSHOT</version>
<version>1.4.2-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
2 changes: 1 addition & 1 deletion ndatabase-packaging-jar/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: NDatabase
main: com.nivixx.ndatabase.platforms.bukkitplatform.NDatabasePlugin
version: 1.4.1
version: 1.4.2
description: A lightweight centralised Key-value style database
api-version: 1.13
authors: [NivixX]
Expand Down
Loading

0 comments on commit e42efe8

Please sign in to comment.