diff --git a/bukkit/pom.xml b/bukkit/pom.xml index df239e38..9d50d22e 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -4,7 +4,7 @@ com.github.games647 - fastlogin-parent + fastlogin 0.8 ../pom.xml diff --git a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/ForceLoginTask.java b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/ForceLoginTask.java index 3a5603a0..577b3d77 100644 --- a/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/ForceLoginTask.java +++ b/bukkit/src/main/java/com/github/games647/fastlogin/bukkit/ForceLoginTask.java @@ -2,15 +2,18 @@ package com.github.games647.fastlogin.bukkit; import com.github.games647.fastlogin.bukkit.hooks.BukkitAuthPlugin; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutionException; import java.util.logging.Level; +import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import org.bukkit.metadata.FixedMetadataValue; public class ForceLoginTask implements Runnable { - private final FastLoginBukkit plugin; + protected final FastLoginBukkit plugin; private final Player player; public ForceLoginTask(FastLoginBukkit plugin, Player player) { @@ -32,7 +35,7 @@ public class ForceLoginTask implements Runnable { player.setMetadata(plugin.getName(), new FixedMetadataValue(plugin, true)); //check if it's the same player as we checked before - BukkitAuthPlugin authPlugin = plugin.getAuthPlugin(); + final BukkitAuthPlugin authPlugin = plugin.getAuthPlugin(); if (session == null || !player.getName().equals(session.getUsername()) || authPlugin == null) { return; } @@ -52,17 +55,37 @@ public class ForceLoginTask implements Runnable { } if (success) { - if (session.needsRegistration()) { - forceRegister(authPlugin, player); - } else { - forceLogin(authPlugin, player); - } + performForceAction(session, authPlugin); } } else if (playerProfile != null) { storage.save(playerProfile); } } + private void performForceAction(PlayerSession session, final BukkitAuthPlugin authPlugin) { + try { + if (session.needsRegistration()) { + Bukkit.getScheduler().callSyncMethod(plugin, new Callable() { + @Override + public Object call() throws Exception { + forceRegister(authPlugin, player); + return null; + } + }).get(); + } else { + Bukkit.getScheduler().callSyncMethod(plugin, new Callable() { + @Override + public Object call() throws Exception { + forceLogin(authPlugin, player); + return null; + } + }).get(); + } + } catch (InterruptedException | ExecutionException exception) { + plugin.getLogger().log(Level.SEVERE, "Failed to perform sync force action", exception); + } + } + private void forceRegister(BukkitAuthPlugin authPlugin, Player player) { plugin.getLogger().log(Level.FINE, "Register player {0}", player.getName()); diff --git a/bungee/pom.xml b/bungee/pom.xml index b57ee6e3..ad5da301 100644 --- a/bungee/pom.xml +++ b/bungee/pom.xml @@ -4,7 +4,7 @@ com.github.games647 - fastlogin-parent + fastlogin 0.8 ../pom.xml diff --git a/universal/pom.xml b/universal/pom.xml index ba080623..5426e22f 100644 --- a/universal/pom.xml +++ b/universal/pom.xml @@ -4,7 +4,7 @@ com.github.games647 - fastlogin-parent + fastlogin 0.8 ../pom.xml