update 2.4
This commit is contained in:
parent
d84aef8126
commit
0a87ba80c6
6 changed files with 66 additions and 23 deletions
|
|
@ -3,7 +3,7 @@ plugins {
|
|||
}
|
||||
|
||||
group = 'xyz.hynse'
|
||||
version = "2.3_a"
|
||||
version = "2.4"
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
|
@ -14,10 +14,10 @@ repositories {
|
|||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "dev.folia:folia-api:1.19.4-R0.1-SNAPSHOT"
|
||||
compileOnly "dev.folia:folia-api:1.20.4-R0.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
def targetJavaVersion = 17
|
||||
def targetJavaVersion = 21
|
||||
java {
|
||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||
sourceCompatibility = javaVersion
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import xyz.hynse.foliaflow.command.ReloadCommand;
|
||||
import xyz.hynse.foliaflow.util.SchedulerUtil;
|
||||
import xyz.hynse.foliaflow.util.CheckSafeTeleportation;
|
||||
import xyz.hynse.foliaflow.watcher.PortalWatcher;
|
||||
|
||||
import java.io.File;
|
||||
|
|
@ -14,11 +14,13 @@ import java.io.InputStreamReader;
|
|||
|
||||
public class FoliaFlow extends JavaPlugin {
|
||||
private boolean isFirstEnable = true;
|
||||
//public boolean isUnSafeTeleport = false;
|
||||
public static FoliaFlow instance;
|
||||
public static double horizontalCoefficient;
|
||||
public static double verticalCoefficient;
|
||||
public static double spawnHeight;
|
||||
public static double TeleportOffset;
|
||||
//public static CheckSafeTeleportation checkSafeTeleportation;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
|
@ -46,15 +48,6 @@ public class FoliaFlow extends JavaPlugin {
|
|||
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultConfigStream));
|
||||
config.options().copyDefaults(true);
|
||||
config.setDefaults(defaultConfig);
|
||||
boolean isFolia = SchedulerUtil.isFolia();
|
||||
if (!config.contains("horizontal_coefficient")) {
|
||||
double horizontalCoefficient = isFolia ? 1.499 : 2;
|
||||
config.set("horizontal_coefficient", horizontalCoefficient);
|
||||
}
|
||||
if (!config.contains("teleport_offset")) {
|
||||
double telportCoefficient = isFolia ? 0.5 : 2.4;
|
||||
config.set("teleport_offset", telportCoefficient);
|
||||
}
|
||||
try {
|
||||
config.save(configFile);
|
||||
} catch (IOException e) {
|
||||
|
|
@ -73,6 +66,8 @@ public class FoliaFlow extends JavaPlugin {
|
|||
|
||||
private void register() {
|
||||
getCommand("flowreload").setExecutor(new ReloadCommand());
|
||||
// checkSafeTeleportation = new CheckSafeTeleportation();
|
||||
// checkSafeTeleportation.updateSafeTeleportation();
|
||||
getServer().getPluginManager().registerEvents(new PortalWatcher(), this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,49 @@
|
|||
package xyz.hynse.foliaflow.util;
|
||||
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
import xyz.hynse.foliaflow.FoliaFlow;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
|
||||
public class CheckSafeTeleportation {
|
||||
|
||||
public boolean checkUnsafeEndPortalTeleportation() {
|
||||
File configFile = new File(getServer().getWorldContainer(), "config/paper-global.yml");
|
||||
if (!configFile.exists()) {
|
||||
FoliaFlow.instance.getLogger().warning("paper-global.yml not found!");
|
||||
return false;
|
||||
}
|
||||
|
||||
try (FileInputStream fis = new FileInputStream(configFile)) {
|
||||
Yaml yaml = new Yaml();
|
||||
Map<String, Object> config = yaml.load(fis);
|
||||
|
||||
Map<String, Object> unsupportedSettings = (Map<String, Object>) config.get("unsupported-settings");
|
||||
if (unsupportedSettings != null) {
|
||||
Boolean setting = (Boolean) unsupportedSettings.get("allow-unsafe-end-portal-teleportation");
|
||||
return setting != null && setting;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
FoliaFlow.instance.getLogger().severe("Failed to read paper-global.yml: " + e.getMessage());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// public void updateSafeTeleportation() {
|
||||
// boolean safeTeleportation = checkUnsafeEndPortalTeleportation();
|
||||
// if (safeTeleportation) {
|
||||
// FoliaFlow.instance.isUnSafeTeleport = true;
|
||||
// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is true.");
|
||||
// } else {
|
||||
// FoliaFlow.instance.isUnSafeTeleport = false;
|
||||
// FoliaFlow.instance.getLogger().info("Unsafe End Portal Teleportation is false.");
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
|
@ -36,13 +36,12 @@ public class PortalWatcher implements Listener {
|
|||
dummyVel.setY(vel.getY() * FoliaFlow.verticalCoefficient);
|
||||
dummy.setVelocity(dummyVel);
|
||||
|
||||
// Add vector seems vanilla.
|
||||
SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> {
|
||||
// Portal teleportation is a bit below vanilla, so we teleport it above (happen on paper 1.20 b169)
|
||||
// Portal teleportation is a bit below vanilla, so we teleport it above
|
||||
dummy.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0));
|
||||
dummy.setVelocity(dummyVel);
|
||||
},
|
||||
4
|
||||
2
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
# Default value for horizontal_coefficient
|
||||
# - Folia (1.499)
|
||||
# - Paper (2)
|
||||
horizontal_coefficient: 2
|
||||
horizontal_coefficient: 1.499
|
||||
# -----------------------------------------
|
||||
|
||||
vertical_coefficient: -1.7
|
||||
|
|
@ -15,5 +15,5 @@ spawn_height: 0.08
|
|||
# Default value for teleport_offset
|
||||
# - Folia (0.5)
|
||||
# - Paper (2.4)
|
||||
teleport_offset: 2.4
|
||||
teleport_offset: 0.5
|
||||
# -----------------------------------------
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
name: FoliaFlow
|
||||
version: '${version}'
|
||||
main: xyz.hynse.foliaflow.FoliaFlow
|
||||
api-version: 1.19
|
||||
api-version: 1.20
|
||||
folia-supported: true
|
||||
commands:
|
||||
flowreload:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue