mirror of
https://gitlab.com/SamB440/rpgregions-2.git
synced 2026-01-03 22:16:18 +00:00
Ensure RPGRegions account can be loaded before allowing server access
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
package net.islandearth.rpgregions.listener;
|
||||
|
||||
import net.islandearth.rpgregions.RPGRegions;
|
||||
import net.islandearth.rpgregions.managers.data.account.RPGRegionsAccount;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class ConnectionListener implements Listener {
|
||||
|
||||
private final RPGRegions plugin;
|
||||
@@ -14,6 +19,19 @@ public class ConnectionListener implements Listener {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(AsyncPlayerPreLoginEvent event) {
|
||||
UUID uuid = event.getUniqueId();
|
||||
try {
|
||||
RPGRegionsAccount account = plugin.getManagers().getStorageManager().getAccount(uuid).get();
|
||||
if (account != null) return;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, ChatColor.RED + "RPGRegions account could not be loaded.");
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onLeave(PlayerQuitEvent pqe) {
|
||||
Player player = pqe.getPlayer();
|
||||
|
||||
Reference in New Issue
Block a user