ChestShop-3/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java
Phoenix616 dd4177e7cb Query server's player cache for missing players
This uses a cache for players that we haven't found before so to not check the cache too often and also checks if the online mode of the queried OfflinePlayer matches the server's mode (gotten from the first logged-in player in order to be compatible with BungeeCord requiring the server to be in offline-mode.
2018-08-29 21:29:27 +01:00

37 lines
1.2 KiB
Java

package com.Acrobot.ChestShop.Listeners.Player;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import com.Acrobot.ChestShop.ChestShop;
import com.Acrobot.ChestShop.UUIDs.NameManager;
import com.Acrobot.ChestShop.UUIDs.PlayerDTO;
/**
* @author Acrobot
*/
public class PlayerConnect implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public static void onPlayerConnect(final PlayerJoinEvent event) {
if (NameManager.getUuidVersion() < 0) {
NameManager.setUuidVersion(event.getPlayer().getUniqueId().version());
}
final PlayerDTO playerDTO = new PlayerDTO(event.getPlayer());
Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), new Runnable() {
@Override
public void run() {
// String playerName = NameUtil.stripUsername(playerDTO.getName());
// UUID uuid = NameManager.getUUID(playerName);
NameManager.storeUsername(playerDTO);
}
});
}
}