I am trying to program a plugin for BungeeCord (Minecraft) with geoip2. I am trying to contain the dependency "com.maxmind.geoip2" and the BungeeCord API jar file in my jar file because I'm getting a java.lang.NoClassDefFoundError: com/maxmind/geoip2/exception/GeoIp2Exception
java.lang.NoClassDefFoundError: com/maxmind/geoip2/exception/GeoIp2Exception
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:2671)
at java.lang.Class.getConstructor0(Class.java:3075)
at java.lang.Class.getDeclaredConstructor(Class.java:2178)
at net.md_5.bungee.api.plugin.PluginManager.enablePlugin(PluginManager.java:305)
at net.md_5.bungee.api.plugin.PluginManager.loadPlugins(PluginManager.java:212)
at net.md_5.bungee.BungeeCord.start(BungeeCord.java:259)
at net.md_5.bungee.BungeeCordLauncher.main(BungeeCordLauncher.java:56)
at net.md_5.bungee.Bootstrap.main(Bootstrap.java:15)
Caused by: java.lang.ClassNotFoundException: com.maxmind.geoip2.exception.GeoIp2Exception
at net.md_5.bungee.api.plugin.PluginClassloader.loadClass0(PluginClassloader.java:53)
at net.md_5.bungee.api.plugin.PluginClassloader.loadClass(PluginClassloader.java:27)
at java.lang.Cl
I've tried this, but it didn't work for me.
While researching more I came across maven shader and I currently have this in my pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>general</groupId>
<artifactId>CubenexBungee</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>CubenexBungee</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>com.maxmind.geoip2</groupId>
<artifactId>geoip2</artifactId>
<version>2.11.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<excludes>
<exclude>org:*</exclude>
</excludes>
<includes>
<include>com.maxmind.geoip2:geoip2</include>
<include>Referenced Libraries:BungeeCord.jar</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
And my App.java is:
public class App extends Plugin implements Listener{
public static DatabaseReader database;
@Override
public void onEnable(){
getProxy().getPluginManager().registerListener(this, this);
try {
database = new DatabaseReader.Builder(new File(this.getDataFolder().getPath()+"//countrydatabase.csv")).build();
} catch (IOException e) {
e.printStackTrace();
}
}
@EventHandler
public void login(LoginEvent e){
CountryResponse response;
try {
response = database.country(e.getConnection().getAddress().getAddress());
System.out.println(e.getConnection().getName()+" comes from "+response.getCountry().getName());
} catch (IOException e1) {
e1.printStackTrace();
} catch (GeoIp2Exception e1) {
e1.printStackTrace();
}
}
}
I must say that I've only just found out about maven and don't really understand it very goodly and haven't found any tutorials that I understand.