mirror of
https://github.com/sekwah41/Advanced-Portals.git
synced 2025-01-27 10:31:34 +01:00
Fixed for the new more reliable event
This commit is contained in:
parent
69176c379b
commit
f14fd9f692
@ -90,19 +90,19 @@ public class Listeners implements Listener {
|
||||
@EventHandler
|
||||
public void onJoinEvent(PlayerJoinEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
||||
|
||||
Portal.joinCooldown.put(player.getName(), System.currentTimeMillis());
|
||||
|
||||
|
||||
String uuid = player.getUniqueId().toString();
|
||||
|
||||
if (plugin.PlayerDestiMap.containsKey(uuid)) {
|
||||
|
||||
/*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)
|
||||
|
@ -32,23 +32,27 @@ public class PluginMessageReceiver implements PluginMessageListener {
|
||||
if (subchannel.equals(BungeeMessages.SERVER_DESTI)) {
|
||||
String targetDestination = in.readUTF();
|
||||
String bungeeUUID = in.readUTF();
|
||||
|
||||
|
||||
Player targetPlayer = this.plugin.getServer().getPlayer(UUID.fromString(bungeeUUID));
|
||||
|
||||
if (targetPlayer != null) {
|
||||
|
||||
Player finalTargetPlayer = targetPlayer;
|
||||
Destination.warp(finalTargetPlayer, targetDestination, false, true);
|
||||
|
||||
/*if (targetPlayer != null) {
|
||||
Player finalTargetPlayer = targetPlayer;
|
||||
Destination.warp(finalTargetPlayer, targetDestination, false, true);
|
||||
|
||||
}
|
||||
else {
|
||||
plugin.PlayerDestiMap.put(bungeeUUID, targetDestination);
|
||||
|
||||
|
||||
plugin.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () ->
|
||||
plugin.PlayerDestiMap.remove(bungeeUUID),
|
||||
20L*10
|
||||
);
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,9 @@ import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class EventListener implements Listener {
|
||||
private AdvancedPortalsPlugin plugin;
|
||||
|
||||
@ -17,13 +20,14 @@ public class EventListener implements Listener {
|
||||
public void onServerConnected(ServerConnectedEvent event) {
|
||||
String uuid = event.getPlayer().getUniqueId().toString();
|
||||
|
||||
if (plugin.PlayerDestiMap.containsKey(uuid)) {
|
||||
String[] val = plugin.PlayerDestiMap.get(uuid);
|
||||
String[] val = plugin.PlayerDestiMap.get(uuid);
|
||||
|
||||
if (val != null) {
|
||||
|
||||
// key: UUID (string)
|
||||
// value: [0] targetServer, [1] targetDestination, [2] onlineUUID
|
||||
|
||||
if (event.getPlayer().getServer().getInfo().getName().equalsIgnoreCase(val[0])) {
|
||||
if (event.getServer().getInfo().getName().equalsIgnoreCase(val[0])) {
|
||||
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
|
||||
@ -31,7 +35,7 @@ public class EventListener implements Listener {
|
||||
out.writeUTF(val[1]);
|
||||
out.writeUTF(val[2]);
|
||||
|
||||
event.getPlayer().getServer().sendData(plugin.channelName, out.toByteArray());
|
||||
event.getServer().sendData(plugin.channelName, out.toByteArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,9 @@ public class PluginMessageReceiver implements Listener {
|
||||
String targetUUID = in.readUTF();
|
||||
|
||||
plugin.PlayerDestiMap.put(targetUUID, new String[]{targetServer, targetDestination, targetUUID});
|
||||
plugin.PlayerDestiMap.remove(targetUUID);
|
||||
|
||||
plugin.getProxy().getScheduler().schedule(plugin, () -> plugin.PlayerDestiMap.remove(targetUUID),
|
||||
10, TimeUnit.SECONDS);
|
||||
}
|
||||
else if (subChannel.equalsIgnoreCase(BungeeMessages.BUNGEE_COMMAND)) {
|
||||
String command = in.readUTF();
|
||||
|
Loading…
Reference in New Issue
Block a user