Search in sources :

Example 6 with InvalidNameException

use of com.palmergames.bukkit.towny.exceptions.InvalidNameException in project Towny by TownyAdvanced.

the class TownyDatabaseHandler method newResident.

@Override
public void newResident(String name, UUID uuid) throws AlreadyRegisteredException, NotRegisteredException {
    String filteredName;
    try {
        filteredName = NameValidation.checkAndFilterPlayerName(name);
    } catch (InvalidNameException e) {
        throw new NotRegisteredException(e.getMessage());
    }
    if (universe.hasResident(name))
        throw new AlreadyRegisteredException("A resident with the name " + filteredName + " is already in use.");
    Resident resident = new Resident(filteredName);
    if (uuid != null)
        resident.setUUID(uuid);
    universe.registerResident(resident);
}
Also used : InvalidNameException(com.palmergames.bukkit.towny.exceptions.InvalidNameException) NotRegisteredException(com.palmergames.bukkit.towny.exceptions.NotRegisteredException) AlreadyRegisteredException(com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException) Resident(com.palmergames.bukkit.towny.object.Resident)

Aggregations

InvalidNameException (com.palmergames.bukkit.towny.exceptions.InvalidNameException)6 AlreadyRegisteredException (com.palmergames.bukkit.towny.exceptions.AlreadyRegisteredException)5 NotRegisteredException (com.palmergames.bukkit.towny.exceptions.NotRegisteredException)4 Nation (com.palmergames.bukkit.towny.object.Nation)3 Resident (com.palmergames.bukkit.towny.object.Resident)3 ArrayList (java.util.ArrayList)3 TownyException (com.palmergames.bukkit.towny.exceptions.TownyException)2 EOFException (java.io.EOFException)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 RenameNationEvent (com.palmergames.bukkit.towny.event.RenameNationEvent)1 RenameTownEvent (com.palmergames.bukkit.towny.event.RenameTownEvent)1 PlotGroup (com.palmergames.bukkit.towny.object.PlotGroup)1 Town (com.palmergames.bukkit.towny.object.Town)1 TownBlock (com.palmergames.bukkit.towny.object.TownBlock)1 TownyWorld (com.palmergames.bukkit.towny.object.TownyWorld)1 File (java.io.File)1 UUID (java.util.UUID)1 Nullable (org.jetbrains.annotations.Nullable)1