diff --git a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java index 931494a..f76503f 100644 --- a/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java +++ b/src/main/java/com/Acrobot/ChestShop/Listeners/Player/PlayerConnect.java @@ -1,5 +1,6 @@ package com.Acrobot.ChestShop.Listeners.Player; +import com.Acrobot.Breeze.Utils.NameUtil; import com.Acrobot.ChestShop.ChestShop; import com.Acrobot.ChestShop.UUIDs.NameManager; import com.Acrobot.ChestShop.UUIDs.PlayerDTO; @@ -9,6 +10,8 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.PlayerJoinEvent; +import java.util.UUID; + /** * @author Acrobot */ @@ -21,6 +24,15 @@ public class PlayerConnect implements Listener { Bukkit.getScheduler().runTaskAsynchronously(ChestShop.getPlugin(), new Runnable() { @Override public void run() { + String playerName = NameUtil.stripUsername(playerDTO.getName()); + UUID uuid = NameManager.getUUID(playerName); + + if (uuid != null && !playerDTO.getUniqueId().equals(uuid)) { + Bukkit.getPlayer(playerDTO.getUniqueId()).kickPlayer("[ChestShop]" + + "Unfortunately, this username was already used by " + + "another player."); + } + NameManager.storeUsername(playerDTO); } });