Merge pull request #1 from Acrobot/master

Up
This commit is contained in:
Gabriele C. 2015-08-07 15:16:06 +02:00
commit 897127976a

View File

@ -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);
}
});