-
-
Notifications
You must be signed in to change notification settings - Fork 1
Getting Started
Welcome to the Getting Started guide! The goal of this little document is to help you learn how to use RestrictionHelper as fast as possible, so that you can stop worrying about restrictions and start writing code.
First, you'll need to set up your build tool so that you can actually use RestrictionHelper in your project. For that, see these guides:
RestrictionHelper is published on Maven Central.
Replace [latest version] with the version found above.
For Maven:
<dependency>
<groupId>xyz.tehbrian</groupId>
<artifactId>restrictionhelper</artifactId>
<version>[latest version]</version>
<scope>provided</scope>
</dependency>For Gradle:
repositories {
mavenCentral()
}
dependencies {
compile 'xyz.tehbrian:restrictionhelper:[latest version]'
}Replace [your plugin package] with your plugin's package.
For Maven:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<configuration>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml
</dependencyReducedPomLocation>
<relocations>
<relocation>
<pattern>xyz.tehbrian.restrictionhelper</pattern>
<shadedPattern>[your plugin package].restrictionhelper</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>For Gradle, using shadow:
plugins {
id 'com.github.johnrengelman.shadow' version '6.1.0'
}
shadowJar {
relocate 'xyz.tehbrian.restrictionhelper', '[your plugin package].restrictionhelper'
}To get an instance of RestrictionHelper, simply instantiate a new instance with
new and pass in your plugin's logger as the constructor's argument.
class MyPlugin extends JavaPlugin {
private RestrictionHelper restrictionHelper;
public void onEnable() {
this.restrictionHelper = new RestrictionHelper(this.getLogger());
}
public RestrictionHelper getRestrictionHelper() {
return restrictionHelper;
}
}In the future, this may be done automatically for you by RestrictionHelper, but for now, your plugin must do it manually.
All you need to do is check if a specific plugin is