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'
|
group = 'xyz.hynse'
|
||||||
version = "2.3_a"
|
version = "2.4"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
@ -14,10 +14,10 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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 {
|
java {
|
||||||
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
def javaVersion = JavaVersion.toVersion(targetJavaVersion)
|
||||||
sourceCompatibility = javaVersion
|
sourceCompatibility = javaVersion
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import xyz.hynse.foliaflow.command.ReloadCommand;
|
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 xyz.hynse.foliaflow.watcher.PortalWatcher;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
@ -14,11 +14,13 @@ import java.io.InputStreamReader;
|
||||||
|
|
||||||
public class FoliaFlow extends JavaPlugin {
|
public class FoliaFlow extends JavaPlugin {
|
||||||
private boolean isFirstEnable = true;
|
private boolean isFirstEnable = true;
|
||||||
|
//public boolean isUnSafeTeleport = false;
|
||||||
public static FoliaFlow instance;
|
public static FoliaFlow instance;
|
||||||
public static double horizontalCoefficient;
|
public static double horizontalCoefficient;
|
||||||
public static double verticalCoefficient;
|
public static double verticalCoefficient;
|
||||||
public static double spawnHeight;
|
public static double spawnHeight;
|
||||||
public static double TeleportOffset;
|
public static double TeleportOffset;
|
||||||
|
//public static CheckSafeTeleportation checkSafeTeleportation;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
@ -46,15 +48,6 @@ public class FoliaFlow extends JavaPlugin {
|
||||||
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultConfigStream));
|
YamlConfiguration defaultConfig = YamlConfiguration.loadConfiguration(new InputStreamReader(defaultConfigStream));
|
||||||
config.options().copyDefaults(true);
|
config.options().copyDefaults(true);
|
||||||
config.setDefaults(defaultConfig);
|
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 {
|
try {
|
||||||
config.save(configFile);
|
config.save(configFile);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
@ -73,6 +66,8 @@ public class FoliaFlow extends JavaPlugin {
|
||||||
|
|
||||||
private void register() {
|
private void register() {
|
||||||
getCommand("flowreload").setExecutor(new ReloadCommand());
|
getCommand("flowreload").setExecutor(new ReloadCommand());
|
||||||
|
// checkSafeTeleportation = new CheckSafeTeleportation();
|
||||||
|
// checkSafeTeleportation.updateSafeTeleportation();
|
||||||
getServer().getPluginManager().registerEvents(new PortalWatcher(), this);
|
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);
|
dummyVel.setY(vel.getY() * FoliaFlow.verticalCoefficient);
|
||||||
dummy.setVelocity(dummyVel);
|
dummy.setVelocity(dummyVel);
|
||||||
|
|
||||||
// Add vector seems vanilla.
|
|
||||||
SchedulerUtil.runLaterEntity(dummy, FoliaFlow.instance, () -> {
|
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.teleportAsync(dummy.getLocation().add(0, FoliaFlow.TeleportOffset, 0));
|
||||||
dummy.setVelocity(dummyVel);
|
dummy.setVelocity(dummyVel);
|
||||||
},
|
},
|
||||||
4
|
2
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# Default value for horizontal_coefficient
|
# Default value for horizontal_coefficient
|
||||||
# - Folia (1.499)
|
# - Folia (1.499)
|
||||||
# - Paper (2)
|
# - Paper (2)
|
||||||
horizontal_coefficient: 2
|
horizontal_coefficient: 1.499
|
||||||
# -----------------------------------------
|
# -----------------------------------------
|
||||||
|
|
||||||
vertical_coefficient: -1.7
|
vertical_coefficient: -1.7
|
||||||
|
|
@ -15,5 +15,5 @@ spawn_height: 0.08
|
||||||
# Default value for teleport_offset
|
# Default value for teleport_offset
|
||||||
# - Folia (0.5)
|
# - Folia (0.5)
|
||||||
# - Paper (2.4)
|
# - Paper (2.4)
|
||||||
teleport_offset: 2.4
|
teleport_offset: 0.5
|
||||||
# -----------------------------------------
|
# -----------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
name: FoliaFlow
|
name: FoliaFlow
|
||||||
version: '${version}'
|
version: '${version}'
|
||||||
main: xyz.hynse.foliaflow.FoliaFlow
|
main: xyz.hynse.foliaflow.FoliaFlow
|
||||||
api-version: 1.19
|
api-version: 1.20
|
||||||
folia-supported: true
|
folia-supported: true
|
||||||
commands:
|
commands:
|
||||||
flowreload:
|
flowreload:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue