Skip to content

Getting Started

TehBrian edited this page Feb 10, 2021 · 16 revisions

Using

1. get the dependency in your project

RestrictionHelper is published on Maven Central.

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]'
}

2. shade and relocate the dependency

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'
}

3. get an instance of 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;
    }
}

4. register the appropriate restrictions

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

5. check restrictions whenever you need to

Clone this wiki locally