Fix teleportDelay not working

also making fractions of a second possible
This commit is contained in:
Joey 2021-12-01 23:53:54 +01:00
parent 659fcca7ee
commit cd919c4d33
1 changed files with 5 additions and 7 deletions

View File

@ -15,12 +15,12 @@ import java.util.UUID;
public class PluginMessageReceiver implements PluginMessageListener {
private final AdvancedPortalsPlugin plugin;
private final int teleportDelay;
private final double teleportDelay;
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) {
this.plugin = plugin;
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
teleportDelay = config.getConfig().getInt(ConfigHelper.PROXY_TELEPORT_DELAY, 0);
teleportDelay = config.getConfig().getDouble(ConfigHelper.PROXY_TELEPORT_DELAY, 0);
}
@Override
@ -37,14 +37,12 @@ public class PluginMessageReceiver implements PluginMessageListener {
String targetDestination = in.readUTF();
String bungeeUUID = in.readUTF();
Player targetPlayer = this.plugin.getServer().getPlayer(UUID.fromString(bungeeUUID));
if(teleportDelay <= 0) {
teleportPlayerToDesti(targetPlayer, targetDestination, bungeeUUID);
teleportPlayerToDesti(player, targetDestination, bungeeUUID);
} else {
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
teleportPlayerToDesti(targetPlayer, targetDestination, bungeeUUID),
20L * teleportDelay
teleportPlayerToDesti(player, targetDestination, bungeeUUID),
(long)(20.0 * teleportDelay)
);
}