This repository has been archived by the owner on May 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Euphillya/ver/1.2.0
Ver/1.2.0
- Loading branch information
Showing
9 changed files
with
275 additions
and
469 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ plugins { | |
} | ||
|
||
group = "fr.euphyllia" | ||
version = "1.1.9" | ||
version = "1.2.0" | ||
|
||
repositories { | ||
mavenCentral() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,111 @@ | ||
## API | ||
## What is Energie ? | ||
Energie is a library allowing you to maintain compatibility between Spigot and Folia. The library is still under development, but can be used. | ||
|
||
Bukkit/Spigot/Paper : | ||
## Lists of plugins that officially use Energie | ||
|
||
```java | ||
// Example Scheduler | ||
Bukkit.getScheduler().runTask(this.plugin, () -> { | ||
// code | ||
}); | ||
``` | ||
| Name | Github | Download | | ||
|---------|------------------------------------------------|------------------------------------------------------------------------| | ||
| Skyllia | [Github](https://github.com/Euphillya/Skyllia) | [Modrinth](https://modrinth.com/plugin/skyllia/versions#all-versions) | | ||
|
||
Folia : | ||
## Setup | ||
```kotlin | ||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar | ||
|
||
plugins { | ||
id("java") | ||
id("com.github.johnrengelman.shadow") version "8.1.1" | ||
} | ||
|
||
val jitpack = "https://jitpack.io" | ||
|
||
repositories { | ||
mavenCentral() | ||
maven(jitpack) | ||
} | ||
|
||
dependencies { | ||
implementation("com.github.Euphillya:Energie:TAG") | ||
} | ||
|
||
tasks.withType<ShadowJar> { | ||
relocate("fr.euphyllia.energie", "[your plugin].dependency.energie") | ||
} | ||
|
||
```java | ||
// Example Scheduler | ||
Bukkit.getGlobalRegionScheduler().run(this.plugin, task -> { | ||
// code | ||
}); | ||
Bukkit.getRegionScheduler().run(this.plugin, location, task -> { | ||
// code | ||
}); | ||
Entity.getScheduler().run(this.plugin, task -> { | ||
// code | ||
}, retired); | ||
``` | ||
## API | ||
The API remains quite simple to use: | ||
|
||
### Bukkit Implementation | ||
```java | ||
// before bukkit | ||
private void runTaskBukkitExample() { | ||
// Sync | ||
Bukkit.getScheduler().runTask(JavaPlugin, Callback); | ||
// Async | ||
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin, Callback); | ||
} | ||
|
||
private void runTaskLaterExample() { | ||
Bukkit.getScheduler().runTaskLater(JavaPlugin, Callback, Long); | ||
} | ||
|
||
Energie : | ||
private void runTaskTimerExample() { | ||
Bukkit.getScheduler().runTaskTimer(JavaPlugin, Callback, Long, Long); | ||
} | ||
|
||
private void runnableExample() { | ||
new BukkitRunnable() { | ||
@Override | ||
public void run() { | ||
|
||
} | ||
}.runTask(JavaPlugin); | ||
} | ||
``` | ||
|
||
### Energie Implementation | ||
```java | ||
Energie energie = new Energie(this.plugin); | ||
|
||
Scheduler minecraftScheduler = energie.getScheduler(SchedulerSoft.MINECRAFT); | ||
// Example getGlobalRegionScheduler | ||
minecraftScheduler.runTask(SchedulerType.SYNC, task -> { | ||
// code | ||
}); | ||
// Example getRegionScheduler | ||
minecraftScheduler.runTask(SchedulerType.SYNC, (location/MultiRecords.WorldChunk), task -> { | ||
// code | ||
}); | ||
// Example EntityScheduler | ||
minecraftScheduler.runTask(SchedulerType.SYNC, entity, task -> { | ||
// code | ||
}, retired); | ||
|
||
private @NotNull Energie energie; | ||
private @NotNull Scheduler scheduler; | ||
|
||
@Override | ||
public void onEnable() { | ||
this.energie = new Energie(JavaPlugin); | ||
this.scheduler = scheduler.getMinecraftScheduler(); | ||
} | ||
|
||
public Scheduler getScheduler() { | ||
return scheduler; | ||
} | ||
|
||
|
||
private void runTaskBukkitExample() { | ||
// Sync | ||
getScheduler().runTask(SchedulerType.SYNC, Callback); // GlobalScheduler | ||
getScheduler().runTask(SchedulerType.SYNC, Location/MultipleRecords.WorldChunk, Callback); // RegionScheduler | ||
getScheduler().runTask(SchedulerType.SYNC, Entity, Callback, Retired); // EntityScheduler | ||
|
||
// Async | ||
getScheduler().runTask(SchedulerType.ASYNC, Callback); | ||
} | ||
|
||
private void runTaskLaterExample() { | ||
getScheduler().runDelayed(SchedulerType.SYNC, Callback, Long); // global | ||
... | ||
} | ||
|
||
private void runTaskTimerExample() { | ||
getScheduler().runAtFixedRate(SchedulerType.SYNC, Callback, Long, Long); | ||
... | ||
} | ||
|
||
private void runnableExample() { | ||
new SchedulerTaskRunnable() { | ||
@Override | ||
public void run() { | ||
|
||
} | ||
}.runTask(JavaPlugin); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.