mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-11-27 04:25:14 +01:00
Do not let people with already used usernames connect to the server
This commit is contained in:
parent
757fa85cb7
commit
b0369d8e69
@ -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);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user