Teach how to use maven modules

michqql.jr

Premium
Feedback score
0
Posts
176
Reactions
34
Resources
0
If someone could teach me how to setup maven modules in IntelliJ for multi-version support for Spigot plugins. Please leave your discord!
Shouldn't take long as I have understanding of maven, just have never been able to get modules to work with multiple spigot versions.

Please name a price if you have one for the time...
 
Type
Requesting
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Superbility

Developer
Supreme
Feedback score
2
Posts
99
Reactions
30
Resources
0
I can help - Superbility#6039. Also don't pay someone to help you unless it's professional lessons, there are plenty of resources / people out there that will help for free (if you want to give them something for their time that's fine tho :p)
 

Itzdlg

Java and Kotlin Developer
Premium
Feedback score
2
Posts
73
Reactions
21
Resources
0
In case anyone else is wondering:
You would create a module say "common", then one "v1.8", and another "v1.17". The common module would contain all of your code, and then depend on v1.8 and v1.17 modules. In the common module, you would add an interface that defines version-dependent methods.

For example, if you need to have 2 different pieces of code for 1.8 and 1.17, you could have:
Code:
package me.michqqljr.myplugin.common; // Inside your common module
interface IVersionAdapter {
  void doSomething(Player player);
}

package me.michqqljr.myplugin.v8; // Inside your v1.8 module
public final class VersionAdapter implements IVersionAdapter {
  public void doSomething(Player player) {
    /* Version Dependent Code */
  }
}

package me.michqqljr.myplugin.v17; // Inside your v1.17 module
public final class VersionAdapter implements IVersionAdapter {
  public void doSomething(Player player) {
    /* Version Dependent Code */
  }
}

Now, to actually make this work, you would need an instance of IVersionAdapter that matches one of these two:
Code:
public class MyPlugin extends JavaPlugin {
  private IVersionAdapter versionAdapter;

  @Override
  public void onEnable() {
    int version = /* Obtain the server version somehow */;
    if (version == 8) versionAdapter = me.michqqljr.myplugin.v8.VersionAdapter();
    else if (version == 17) versionAdapter = me.michqqljr.myplugin.v17.VersionAdapter();
 
    /* Your other #onEnable() code */
  }

  public IVersionAdapter versionAdapter() { return versionAdapter; }
}
 
Last edited:

CSV

Feedback score
0
Posts
5
Reactions
0
Resources
0
I might be able to help clear some things up Brandon#9592
 
Top