mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2024-11-26 04:25:30 +01:00
Merge pull request #207 from tmantti/bungee-destifix
Fix timing issues with bungeecord destination warps
This commit is contained in:
commit
5718d789d9
@ -12,6 +12,8 @@ import org.bukkit.configuration.ConfigurationSection;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class AdvancedPortalsPlugin extends JavaPlugin {
|
public class AdvancedPortalsPlugin extends JavaPlugin {
|
||||||
|
|
||||||
//public CraftBukkit compat = null;
|
//public CraftBukkit compat = null;
|
||||||
@ -21,7 +23,7 @@ public class AdvancedPortalsPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
public boolean registeredBungeeChannels = false;
|
public boolean registeredBungeeChannels = false;
|
||||||
|
|
||||||
// public HashMap<OfflinePlayer, String> PlayerDestiMap = new HashMap<>();
|
public HashMap<String, String> PlayerDestiMap = new HashMap<>();
|
||||||
|
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
|
||||||
|
@ -89,7 +89,20 @@ public class Listeners implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoinEvent(PlayerJoinEvent event) {
|
public void onJoinEvent(PlayerJoinEvent event) {
|
||||||
Portal.joinCooldown.put(event.getPlayer().getName(), System.currentTimeMillis());
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
Portal.joinCooldown.put(player.getName(), System.currentTimeMillis());
|
||||||
|
|
||||||
|
String uuid = player.getUniqueId().toString();
|
||||||
|
|
||||||
|
if (plugin.PlayerDestiMap.containsKey(uuid)) {
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||||
|
Destination.warp(player, plugin.PlayerDestiMap.get(uuid), false, true);
|
||||||
|
plugin.PlayerDestiMap.remove(uuid);
|
||||||
|
|
||||||
|
}, 1L);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
@ -31,20 +31,24 @@ public class PluginMessageReceiver implements PluginMessageListener {
|
|||||||
|
|
||||||
if (subchannel.equals(BungeeMessages.SERVER_DESTI)) {
|
if (subchannel.equals(BungeeMessages.SERVER_DESTI)) {
|
||||||
String targetDestination = in.readUTF();
|
String targetDestination = in.readUTF();
|
||||||
UUID bungeeUUID = UUID.fromString(in.readUTF());
|
String bungeeUUID = in.readUTF();
|
||||||
|
|
||||||
Player targetPlayer = this.plugin.getServer().getPlayer(bungeeUUID);
|
Player targetPlayer = this.plugin.getServer().getPlayer(UUID.fromString(bungeeUUID));
|
||||||
|
|
||||||
if (targetPlayer != null) {
|
if (targetPlayer != null) {
|
||||||
Player finalTargetPlayer = targetPlayer;
|
Player finalTargetPlayer = targetPlayer;
|
||||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin,
|
Destination.warp(finalTargetPlayer, targetDestination, false, true);
|
||||||
() -> Destination.warp(finalTargetPlayer, targetDestination, false, true),
|
|
||||||
20L
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
plugin.getLogger().warning("Could not find player to teleport to destination");
|
plugin.PlayerDestiMap.put(bungeeUUID, targetDestination);
|
||||||
|
|
||||||
|
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||||
|
plugin.PlayerDestiMap.remove(bungeeUUID),
|
||||||
|
20L*10
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user