Skip to content
This repository has been archived by the owner on Feb 17, 2025. It is now read-only.

Commit

Permalink
Update all examples to support the latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
bristermitten committed Feb 15, 2021
1 parent 568a267 commit 95d25ce
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ Declaration can be done programmatically or via JSON file:

**Programmatically (Java)**:

Create a new `PluginDependencyManager` with `PluginDependencyManager#of(Plugin)`, and call `PluginDependencyManager#loadAllDependencies`
Create a new `PluginDependencyManager` with `SpigotDependencyManager.of(Plugin)`, and call `PluginDependencyManager#loadAllDependencies`

For example:
```java
PluginDependencyManager dependencyManager = PluginDependencyManager.of(this);
PluginDependencyManager dependencyManager = SpigotDependencyManager.of(this);
CompletableFuture<Void> onLoad = dependencyManager.loadAllDependencies();
//loadAllDependencies is async, the returned future is completed when downloading and loading completes
onLoad.thenRun(() -> System.out.println("Everything is loaded!"));
Expand Down
2 changes: 1 addition & 1 deletion example/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'me.bristermitten.pdm' version '0.0.30' //change to latest version
id 'me.bristermitten.pdm' version '0.0.33' //change to latest version
id 'org.jetbrains.kotlin.jvm' version '1.4.0'
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
package me.bristermitten.pdmexample;

import me.bristermitten.pdm.PluginDependencyManager;
import me.bristermitten.pdm.SpigotDependencyManager;
import org.bukkit.plugin.java.JavaPlugin;

public final class PDMExample extends JavaPlugin
{

@Override
public void onEnable()
{
//Create a new PluginDependencyManager with data from the JavaPlugin
PluginDependencyManager dependencyManager = PluginDependencyManager.of(this);
PluginDependencyManager dependencyManager = SpigotDependencyManager.of(this);

dependencyManager
.loadAllDependencies() //Reads dependencies.json and starts downloading / loading all dependencies async
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package me.bristermitten.pdmexample

import me.bristermitten.pdm.PluginDependencyManager
import me.bristermitten.pdm.SpigotDependencyManager
import org.bukkit.plugin.java.JavaPlugin

class PDMExampleKotlin : JavaPlugin()
Expand All @@ -14,7 +14,7 @@ class PDMExampleKotlin : JavaPlugin()
Alternatively, make a Java bootstrap class that calls PDM, or use any of Kotlin's null safety operators
which should also avoid this issue
*/
PluginDependencyManager.of(this) //Create a new PluginDependencyManager with data from the JavaPlugin
SpigotDependencyManager.of(this) //Create a new PluginDependencyManager with data from the JavaPlugin
.loadAllDependencies() //Reads dependencies.json and starts downloading / loading all dependencies async
.join() //Block until all dependencies are downloaded - in production a callback is advised to avoid lag
}
Expand Down

0 comments on commit 95d25ce

Please sign in to comment.