folia ?
This commit is contained in:
parent
e0e1c77777
commit
a5f969edb2
3 changed files with 37 additions and 8 deletions
|
|
@ -18,7 +18,7 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "io.papermc.paper:paper-api:1.19.4-R0.1-SNAPSHOT"
|
||||
compileOnly "dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
def targetJavaVersion = 17
|
||||
|
|
|
|||
|
|
@ -35,10 +35,8 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
|||
Block movingTo = getBlockMovingTo(loc, vel);
|
||||
|
||||
if (movingTo != null && movingTo.getType() == Material.END_PORTAL) {
|
||||
Location spawnLoc = movingTo.getLocation();
|
||||
spawnLoc.setX(spawnLoc.getX()+0.5);
|
||||
spawnLoc.setY(spawnLoc.getY()+0.5);
|
||||
spawnLoc.setZ(spawnLoc.getZ()+0.5);
|
||||
Location obsidianPlatformCenter = new Location(movingTo.getWorld(), 100, 50, 0); // change coordinates to the center of the obsidian platform in the end dimension
|
||||
Location spawnLoc = obsidianPlatformCenter.clone().add(0, 1, 0); // spawn the new falling block entity one block above the obsidian platform
|
||||
|
||||
FallingBlock dummy = loc.getWorld().spawnFallingBlock(spawnLoc, ((FallingBlock) entity).getBlockData());
|
||||
Vector dummyVel = vel.clone();
|
||||
|
|
@ -54,6 +52,7 @@ public class Bbsdfia extends JavaPlugin implements Listener {
|
|||
}
|
||||
|
||||
|
||||
|
||||
Block getBlockMovingTo(Location loc, Vector vel){
|
||||
double absMax = 0, max = 0;
|
||||
char dir = ' ';
|
||||
|
|
|
|||
30
src/main/java/xyz/hynse/bbsdfia/Compatibility.java
Normal file
30
src/main/java/xyz/hynse/bbsdfia/Compatibility.java
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package xyz.hynse.bbsdfia;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public class Compatibility {
|
||||
|
||||
public static Boolean IS_FOLIA = null;
|
||||
|
||||
private static boolean methodExist(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
|
||||
try {
|
||||
clazz.getDeclaredMethod(methodName, parameterTypes);
|
||||
return true;
|
||||
} catch (Throwable ignored) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Boolean isFolia() {
|
||||
if (IS_FOLIA == null) IS_FOLIA = methodExist(Bukkit.class, "getGlobalRegionScheduler");
|
||||
return IS_FOLIA;
|
||||
}
|
||||
|
||||
public static void runTaskAsync(Plugin plugin, Runnable runnable) {
|
||||
if (isFolia()) {
|
||||
Bukkit.getAsyncScheduler().runNow(plugin, (task) -> runnable.run());
|
||||
return;
|
||||
}
|
||||
Bukkit.getScheduler().runTaskAsynchronously(plugin, runnable);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue