Skip to content

Commit

Permalink
feat: update to latest version and improve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Silthus committed Jan 14, 2023
1 parent d2c844c commit 22c8521
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 41 deletions.
15 changes: 0 additions & 15 deletions .idea/runConfigurations/Server.xml

This file was deleted.

5 changes: 4 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,12 @@ The template or better boilerplate comes with a lot of features that are useful
* **Delete** the `CHANGELOG.md`. It will be generated on your [first release](#releasing-a-new-version-of-your-plugin).
* **Update** the `README` to point to your project and spigot resource id.
* **Rename** the java package and plugin to match your project.
* Then execute the `Server` run configuration and the template will run the Spigot BuildTools to download and build spigot or paper for you.
* Then execute the `prepareSpigotPlugins` gradle task this will try to download all plugin denpendencies and puts them into `debug/spigot/plugins/`.
* **Start** the Minecraft server by executing the `debugPaper` task. This will start the server in the background and you can connect to it using the `localhost:25565` address.
* **Code away :)** - *and once you are ready, push your commit (in [conventional commit style](#commit-message-format)) to master.*

![Gradle tasks](docs/gradle-tasks.png)

Please read the [Contributing Guidelines](CONTRIBUTING.md) before submitting any pull requests or opening issues.

> **NOTE**
Expand Down
42 changes: 22 additions & 20 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ buildscript {
}

plugins {
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'kr.entree.spigradle' version '2.2.4'
id 'io.freefair.lombok' version '6.3.0'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'kr.entree.spigradle' version '2.4.3'
id 'io.freefair.lombok' version '6.6.1'
id 'java'
id 'jacoco'
id 'idea'
Expand Down Expand Up @@ -36,6 +36,7 @@ spigot {
load = STARTUP
// depends = ['']
softDepends = ['Vault']
excludeLibraries = ['*']
}

compileJava {
Expand All @@ -51,39 +52,40 @@ repositories {
mavenLocal()
mavenCentral()
spigot()
maven { url = 'https://jitpack.io' }
bungeecord()
paper()
essentialsX()
bStats()
enginehub()
protocolLib()
maven { url = 'https://repo.aikar.co/content/groups/aikar/' }
maven { url = 'https://repo.dmulloy2.net/repository/public/' }
maven { url 'https://hub.spigotmc.org/nexus/content/repositories/public/' }
maven { url = 'https://oss.sonatype.org/content/repositories/snapshots/' }
jitpack()
}

dependencies {
// using spigot-api
implementation spigot(mcVersion)
// or using paper-api
// implementation "io.papermc.paper:paper-api:${mcVersion}-R0.1-SNAPSHOT"
// using using paper-api
implementation paper(mcVersion)

// Add your dependencies here
// Here are some opinionated dependencies that might help you with your plugin development:

// Annotation Command Framework: https://github.com/aikar/commands
implementation "co.aikar:acf-paper:0.5.0-SNAPSHOT"
// Use shadow to shade the library into your plugin
shadow "co.aikar:acf-paper:0.5.1-SNAPSHOT"
// Vault (https://github.com/MilkBowl/VaultAPI) for economy, permissions and chat API
implementation "com.github.MilkBowl:VaultAPI:1.7.1"
// this dependency needs to be present at runtime, meaning Vault.jar needs to be in your plugins folder
implementation vaultAll()

// Test dependencies
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.1'
testImplementation 'org.mockito:mockito-core:4.0.0'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.17:1.7.0'
testImplementation 'org.assertj:assertj-core:3.21.0'
testImplementation 'org.junit.jupiter:junit-jupiter:5.9.2'
testImplementation 'org.mockito:mockito-core:4.11.0'
testImplementation 'com.github.seeseemelk:MockBukkit-v1.19:2.144.3'
testImplementation 'org.assertj:assertj-core:3.24.1'
}

shadowJar {
classifier = ''
dependencies {
include(dependency('co.aikar:acf-paper:0.5.0-SNAPSHOT'))
}
configurations = [project.configurations.runtimeClasspath, project.configurations.shadow]
relocate 'co.aikar.commands', "${packageName}.acf"
relocate 'co.aikar.locales', "${packageName}.locales"
}
Expand Down
Binary file added docs/gradle-tasks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ group = net.silthus
packageName = net.silthus.template
pluginName = PluginName
author = Silthus
mcVersion = 1.17.1
apiVersion = 1.17
mcVersion = 1.19.3
apiVersion = 1.13
version = 4.5.3
22 changes: 19 additions & 3 deletions src/main/java/net/silthus/template/TemplatePlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.server.ServiceRegisterEvent;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;

Expand All @@ -24,7 +26,6 @@
import java.util.Locale;
import java.util.Objects;

@PluginMain
public class TemplatePlugin extends JavaPlugin implements Listener {

@Getter
Expand Down Expand Up @@ -60,11 +61,26 @@ public void onPlayerJoin(PlayerJoinEvent event) {
getLogger().info("Player joined.");
}

@EventHandler
public void onServiceRegistration(ServiceRegisterEvent event) {
if (event.getProvider().getService() == Economy.class) {
setVault(new VaultProvider((Economy) event.getProvider().getProvider()));
getLogger().info("Vault integration enabled.");
}
}

private void setupVaultIntegration() {
if (Bukkit.getPluginManager().isPluginEnabled("Vault")) {
vault = new VaultProvider(Objects.requireNonNull(getServer().getServicesManager().getRegistration(Economy.class)).getProvider());
} else {
final RegisteredServiceProvider<Economy> serviceProvider = getServer().getServicesManager()
.getRegistration(Economy.class);
if (serviceProvider != null) {
vault = new VaultProvider(Objects.requireNonNull(serviceProvider).getProvider());
getLogger().info("Vault integration enabled.");
}
}
if (vault == null) {
vault = new VaultProvider();
getLogger().warning("Vault integration is not yet available.");
}
}

Expand Down

0 comments on commit 22c8521

Please sign in to comment.