mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-29 05:55:19 +01:00
feat: Added configurable proxy teleport delay
This commit is contained in:
parent
e8cbb403c5
commit
a1121adc10
@ -4,13 +4,15 @@ import org.bukkit.configuration.file.FileConfiguration;
|
|||||||
|
|
||||||
public class ConfigHelper {
|
public class ConfigHelper {
|
||||||
|
|
||||||
public static String CONFIG_VERSION = "ConfigVersion";
|
public static final String CONFIG_VERSION = "ConfigVersion";
|
||||||
|
|
||||||
public static String COMMAND_LOGS = "CommandLogs";
|
public static final String COMMAND_LOGS = "CommandLogs";
|
||||||
|
|
||||||
public static String FORCE_ENABLE_PROXY_SUPPORT = "ForceEnableProxySupport";
|
public static final String FORCE_ENABLE_PROXY_SUPPORT = "ForceEnableProxySupport";
|
||||||
|
|
||||||
public static String DISABLE_GATEWAY_BEAM = "DisableGatewayBeam";
|
public static final String PROXY_TELEPORT_DELAY = "ProxyTeleportDelay";
|
||||||
|
|
||||||
|
public static final String DISABLE_GATEWAY_BEAM = "DisableGatewayBeam";
|
||||||
|
|
||||||
private final FileConfiguration config;
|
private final FileConfiguration config;
|
||||||
|
|
||||||
@ -22,7 +24,7 @@ public class ConfigHelper {
|
|||||||
* Recursively for each time there is a future update
|
* Recursively for each time there is a future update
|
||||||
*/
|
*/
|
||||||
public void update() {
|
public void update() {
|
||||||
String configVersion = config.getString("ConfigVersion");
|
String configVersion = config.getString(CONFIG_VERSION);
|
||||||
// Added in 0.5.4
|
// Added in 0.5.4
|
||||||
if(configVersion == null || configVersion.equals("true") || configVersion.equals("0.5.3")) {
|
if(configVersion == null || configVersion.equals("true") || configVersion.equals("0.5.3")) {
|
||||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.4");
|
config.set(ConfigHelper.CONFIG_VERSION, "0.5.4");
|
||||||
@ -35,6 +37,7 @@ public class ConfigHelper {
|
|||||||
} else if(configVersion.equals("0.5.10") || configVersion.equals("0.5.11")) {
|
} else if(configVersion.equals("0.5.10") || configVersion.equals("0.5.11")) {
|
||||||
config.set(ConfigHelper.CONFIG_VERSION, "0.5.13");
|
config.set(ConfigHelper.CONFIG_VERSION, "0.5.13");
|
||||||
config.set(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT, false);
|
config.set(ConfigHelper.FORCE_ENABLE_PROXY_SUPPORT, false);
|
||||||
|
config.set(ConfigHelper.PROXY_TELEPORT_DELAY, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,8 @@ package com.sekwah.advancedportals.bukkit.listeners;
|
|||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
import com.google.common.io.ByteStreams;
|
import com.google.common.io.ByteStreams;
|
||||||
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
import com.sekwah.advancedportals.bukkit.AdvancedPortalsPlugin;
|
||||||
|
import com.sekwah.advancedportals.bukkit.config.ConfigAccessor;
|
||||||
|
import com.sekwah.advancedportals.bukkit.config.ConfigHelper;
|
||||||
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
import com.sekwah.advancedportals.bukkit.destinations.Destination;
|
||||||
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -13,9 +15,12 @@ import java.util.UUID;
|
|||||||
public class PluginMessageReceiver implements PluginMessageListener {
|
public class PluginMessageReceiver implements PluginMessageListener {
|
||||||
|
|
||||||
private final AdvancedPortalsPlugin plugin;
|
private final AdvancedPortalsPlugin plugin;
|
||||||
|
private final int teleportDelay;
|
||||||
|
|
||||||
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) {
|
public PluginMessageReceiver(AdvancedPortalsPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
ConfigAccessor config = new ConfigAccessor(plugin, "config.yml");
|
||||||
|
teleportDelay = config.getConfig().getInt(ConfigHelper.PROXY_TELEPORT_DELAY, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -34,22 +39,33 @@ public class PluginMessageReceiver implements PluginMessageListener {
|
|||||||
|
|
||||||
Player targetPlayer = this.plugin.getServer().getPlayer(UUID.fromString(bungeeUUID));
|
Player targetPlayer = this.plugin.getServer().getPlayer(UUID.fromString(bungeeUUID));
|
||||||
|
|
||||||
if (targetPlayer != null) {
|
if(teleportDelay <= 0) {
|
||||||
Destination.warp(targetPlayer, targetDestination, false, true);
|
teleportPlayerToDesti(targetPlayer, targetDestination, bungeeUUID);
|
||||||
|
} else {
|
||||||
}
|
|
||||||
else {
|
|
||||||
plugin.getPlayerDestiMap().put(bungeeUUID, targetDestination);
|
|
||||||
|
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||||
plugin.getPlayerDestiMap().remove(bungeeUUID),
|
teleportPlayerToDesti(targetPlayer, targetDestination, bungeeUUID),
|
||||||
20L * 10
|
20L * teleportDelay
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void teleportPlayerToDesti(Player player, String desti, String bungeeUUID) {
|
||||||
|
if (player != null) {
|
||||||
|
Destination.warp(player, desti, false, true);
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
plugin.getPlayerDestiMap().put(bungeeUUID, desti);
|
||||||
|
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||||
|
plugin.getPlayerDestiMap().remove(bungeeUUID),
|
||||||
|
20L * 10
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Example forward packet.
|
* Example forward packet.
|
||||||
*
|
*
|
||||||
|
@ -91,3 +91,7 @@ CommandLogs: true
|
|||||||
|
|
||||||
# If you want to use bungee or velocity and it is not automatically detected (make sure you have advanced portals on the proxy, especially with velocity)
|
# If you want to use bungee or velocity and it is not automatically detected (make sure you have advanced portals on the proxy, especially with velocity)
|
||||||
ForceEnableProxySupport: false
|
ForceEnableProxySupport: false
|
||||||
|
|
||||||
|
# How many seconds after the proxy event fires should the player be teleported (should help with on spawn plugins and such)
|
||||||
|
# 0 is disabled and anything higher causes a delay.
|
||||||
|
ProxyTeleportDelay: 0
|
||||||
|
Loading…
Reference in New Issue
Block a user