-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
13 changed files
with
129 additions
and
10 deletions.
There are no files selected for viewing
14 changes: 14 additions & 0 deletions
14
API/src/main/java/de/corneliusmay/silkspawners/api/PluginPlatform.java
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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package de.corneliusmay.silkspawners.api; | ||
|
||
import org.bukkit.Location; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public abstract class PluginPlatform { | ||
protected final JavaPlugin plugin; | ||
|
||
public PluginPlatform(JavaPlugin plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
public abstract void runTaskLater(Location location, Runnable runnable, long delay); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
group = "de.corneliusmay.silkspawners" | ||
|
||
dependencies { | ||
implementation(project(":API")) | ||
|
||
compileOnly("org.bukkit:bukkit:1.13-R0.1-SNAPSHOT") | ||
} |
17 changes: 17 additions & 0 deletions
17
...it/src/main/java/de/corneliusmay/silkspawners/platform/bukkit/PlatformImplementation.java
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package de.corneliusmay.silkspawners.platform.bukkit; | ||
|
||
import de.corneliusmay.silkspawners.api.PluginPlatform; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class PlatformImplementation extends PluginPlatform { | ||
public PlatformImplementation(JavaPlugin plugin) { | ||
super(plugin); | ||
} | ||
|
||
@Override | ||
public void runTaskLater(Location location, Runnable runnable, long delay) { | ||
Bukkit.getScheduler().runTaskLater(this.plugin, runnable, delay); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
group = "de.corneliusmay.silkspawners" | ||
|
||
dependencies { | ||
implementation(project(":API")) | ||
|
||
compileOnly("dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT") | ||
} |
16 changes: 16 additions & 0 deletions
16
...lia/src/main/java/de/corneliusmay/silkspawners/platform/folia/PlatformImplementation.java
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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package de.corneliusmay.silkspawners.platform.folia; | ||
|
||
import de.corneliusmay.silkspawners.api.PluginPlatform; | ||
import org.bukkit.Location; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class PlatformImplementation extends PluginPlatform { | ||
public PlatformImplementation(JavaPlugin plugin) { | ||
super(plugin); | ||
} | ||
|
||
@Override | ||
public void runTaskLater(Location location, Runnable runnable, long delay) { | ||
this.plugin.getServer().getRegionScheduler().runDelayed(this.plugin, location, task -> runnable.run(), delay); | ||
} | ||
} |
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
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
34 changes: 34 additions & 0 deletions
34
Plugin/src/main/java/de/corneliusmay/silkspawners/plugin/platform/PlatformLoader.java
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 |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.corneliusmay.silkspawners.plugin.platform; | ||
|
||
import de.corneliusmay.silkspawners.api.PluginPlatform; | ||
import de.corneliusmay.silkspawners.plugin.SilkSpawners; | ||
import lombok.Getter; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class PlatformLoader { | ||
|
||
private final SilkSpawners plugin; | ||
|
||
@Getter | ||
private PluginPlatform pluginPlatform; | ||
|
||
public PlatformLoader(SilkSpawners plugin) { | ||
this.plugin = plugin; | ||
} | ||
|
||
private Class<?> loadClass(String platformName) throws ClassNotFoundException { | ||
return Class.forName("de.corneliusmay.silkspawners.platform." + platformName + ".PlatformImplementation"); | ||
} | ||
|
||
public void load() { | ||
String platform = ServerPlatform.isFolia() ? "folia" : "bukkit"; | ||
try { | ||
Class<?> clazz = loadClass(platform); | ||
this.pluginPlatform = (PluginPlatform) clazz.getConstructor(JavaPlugin.class).newInstance(this.plugin); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
|
||
plugin.getLog().info("Initialized plugin for " + platform + " server"); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
Plugin/src/main/java/de/corneliusmay/silkspawners/plugin/platform/ServerPlatform.java
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package de.corneliusmay.silkspawners.plugin.platform; | ||
|
||
class ServerPlatform { | ||
static boolean isFolia() { | ||
try { | ||
Class.forName("io.papermc.paper.threadedregions.RegionizedServer"); | ||
return true; | ||
} catch (ClassNotFoundException e) { | ||
return false; | ||
} | ||
} | ||
} |
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
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