Search in sources :

Example 16 with GameProfile

use of net.minecraft.util.com.mojang.authlib.GameProfile in project mc-dev by Bukkit.

the class ThreadPlayerLookupUUID method run.

public void run() {
    GameProfile gameprofile = LoginListener.a(this.a);
    try {
        String s = (new BigInteger(MinecraftEncryption.a(LoginListener.b(this.a), LoginListener.c(this.a).K().getPublic(), LoginListener.d(this.a)))).toString(16);
        LoginListener.a(this.a, LoginListener.c(this.a).av().hasJoinedServer(new GameProfile((UUID) null, gameprofile.getName()), s));
        if (LoginListener.a(this.a) != null) {
            LoginListener.e().info("UUID of player " + LoginListener.a(this.a).getName() + " is " + LoginListener.a(this.a).getId());
            LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
        } else if (LoginListener.c(this.a).N()) {
            LoginListener.e().warn("Failed to verify username but will let them in anyway!");
            LoginListener.a(this.a, this.a.a(gameprofile));
            LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
        } else {
            this.a.disconnect("Failed to verify username!");
            LoginListener.e().error("Username \'" + LoginListener.a(this.a).getName() + "\' tried to join with an invalid session");
        }
    } catch (AuthenticationUnavailableException authenticationunavailableexception) {
        if (LoginListener.c(this.a).N()) {
            LoginListener.e().warn("Authentication servers are down but will let them in anyway!");
            LoginListener.a(this.a, this.a.a(gameprofile));
            LoginListener.a(this.a, EnumProtocolState.READY_TO_ACCEPT);
        } else {
            this.a.disconnect("Authentication servers are down. Please try again later, sorry!");
            LoginListener.e().error("Couldn\'t verify username because servers are unavailable");
        }
    }
}
Also used : AuthenticationUnavailableException(net.minecraft.util.com.mojang.authlib.exceptions.AuthenticationUnavailableException) GameProfile(net.minecraft.util.com.mojang.authlib.GameProfile) BigInteger(java.math.BigInteger)

Example 17 with GameProfile

use of net.minecraft.util.com.mojang.authlib.GameProfile in project mc-dev by Bukkit.

the class WhiteListEntry method b.

private static GameProfile b(JsonObject jsonobject) {
    if (jsonobject.has("uuid") && jsonobject.has("name")) {
        String s = jsonobject.get("uuid").getAsString();
        UUID uuid;
        try {
            uuid = UUID.fromString(s);
        } catch (Throwable throwable) {
            return null;
        }
        return new GameProfile(uuid, jsonobject.get("name").getAsString());
    } else {
        return null;
    }
}
Also used : GameProfile(net.minecraft.util.com.mojang.authlib.GameProfile) UUID(java.util.UUID)

Example 18 with GameProfile

use of net.minecraft.util.com.mojang.authlib.GameProfile in project mc-dev by Bukkit.

the class UserCache method a.

private static GameProfile a(MinecraftServer minecraftserver, String s) {
    GameProfile[] agameprofile = new GameProfile[1];
    GameProfileLookup gameprofilelookup = new GameProfileLookup(agameprofile);
    minecraftserver.getGameProfileRepository().findProfilesByNames(new String[] { s }, Agent.MINECRAFT, gameprofilelookup);
    if (!minecraftserver.getOnlineMode() && agameprofile[0] == null) {
        UUID uuid = EntityHuman.a(new GameProfile((UUID) null, s));
        GameProfile gameprofile = new GameProfile(uuid, s);
        gameprofilelookup.onProfileLookupSucceeded(gameprofile);
    }
    return agameprofile[0];
}
Also used : GameProfile(net.minecraft.util.com.mojang.authlib.GameProfile) UUID(java.util.UUID)

Example 19 with GameProfile

use of net.minecraft.util.com.mojang.authlib.GameProfile in project mc-dev by Bukkit.

the class CommandWhitelist method execute.

public void execute(ICommandListener icommandlistener, String[] astring) {
    if (astring.length >= 1) {
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        if (astring[0].equals("on")) {
            minecraftserver.getPlayerList().setHasWhitelist(true);
            a(icommandlistener, this, "commands.whitelist.enabled", new Object[0]);
            return;
        }
        if (astring[0].equals("off")) {
            minecraftserver.getPlayerList().setHasWhitelist(false);
            a(icommandlistener, this, "commands.whitelist.disabled", new Object[0]);
            return;
        }
        if (astring[0].equals("list")) {
            icommandlistener.sendMessage(new ChatMessage("commands.whitelist.list", new Object[] { Integer.valueOf(minecraftserver.getPlayerList().getWhitelisted().length), Integer.valueOf(minecraftserver.getPlayerList().getSeenPlayers().length) }));
            String[] astring1 = minecraftserver.getPlayerList().getWhitelisted();
            icommandlistener.sendMessage(new ChatComponentText(a(astring1)));
            return;
        }
        GameProfile gameprofile;
        if (astring[0].equals("add")) {
            if (astring.length < 2) {
                throw new ExceptionUsage("commands.whitelist.add.usage", new Object[0]);
            }
            gameprofile = minecraftserver.getUserCache().getProfile(astring[1]);
            if (gameprofile == null) {
                throw new CommandException("commands.whitelist.add.failed", new Object[] { astring[1] });
            }
            minecraftserver.getPlayerList().addWhitelist(gameprofile);
            a(icommandlistener, this, "commands.whitelist.add.success", new Object[] { astring[1] });
            return;
        }
        if (astring[0].equals("remove")) {
            if (astring.length < 2) {
                throw new ExceptionUsage("commands.whitelist.remove.usage", new Object[0]);
            }
            gameprofile = minecraftserver.getPlayerList().getWhitelist().a(astring[1]);
            if (gameprofile == null) {
                throw new CommandException("commands.whitelist.remove.failed", new Object[] { astring[1] });
            }
            minecraftserver.getPlayerList().removeWhitelist(gameprofile);
            a(icommandlistener, this, "commands.whitelist.remove.success", new Object[] { astring[1] });
            return;
        }
        if (astring[0].equals("reload")) {
            minecraftserver.getPlayerList().reloadWhitelist();
            a(icommandlistener, this, "commands.whitelist.reloaded", new Object[0]);
            return;
        }
    }
    throw new ExceptionUsage("commands.whitelist.usage", new Object[0]);
}
Also used : GameProfile(net.minecraft.util.com.mojang.authlib.GameProfile)

Example 20 with GameProfile

use of net.minecraft.util.com.mojang.authlib.GameProfile in project mc-dev by Bukkit.

the class CommandBan method execute.

public void execute(ICommandListener icommandlistener, String[] astring) {
    if (astring.length >= 1 && astring[0].length() > 0) {
        MinecraftServer minecraftserver = MinecraftServer.getServer();
        GameProfile gameprofile = minecraftserver.getUserCache().getProfile(astring[0]);
        if (gameprofile == null) {
            throw new CommandException("commands.ban.failed", new Object[] { astring[0] });
        } else {
            String s = null;
            if (astring.length >= 2) {
                s = a(icommandlistener, astring, 1).c();
            }
            GameProfileBanEntry gameprofilebanentry = new GameProfileBanEntry(gameprofile, (Date) null, icommandlistener.getName(), (Date) null, s);
            minecraftserver.getPlayerList().getProfileBans().add(gameprofilebanentry);
            EntityPlayer entityplayer = minecraftserver.getPlayerList().getPlayer(astring[0]);
            if (entityplayer != null) {
                entityplayer.playerConnection.disconnect("You are banned from this server.");
            }
            a(icommandlistener, this, "commands.ban.success", new Object[] { astring[0] });
        }
    } else {
        throw new ExceptionUsage("commands.ban.usage", new Object[0]);
    }
}
Also used : GameProfile(net.minecraft.util.com.mojang.authlib.GameProfile)

Aggregations

GameProfile (net.minecraft.util.com.mojang.authlib.GameProfile)26 UUID (java.util.UUID)10 Iterator (java.util.Iterator)6 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 Property (net.minecraft.util.com.mojang.authlib.properties.Property)3 Date (java.util.Date)2 JsonObject (net.minecraft.util.com.google.gson.JsonObject)2 BigInteger (java.math.BigInteger)1 ParseException (java.text.ParseException)1 JsonArray (net.minecraft.util.com.google.gson.JsonArray)1 JsonElement (net.minecraft.util.com.google.gson.JsonElement)1 AuthenticationUnavailableException (net.minecraft.util.com.mojang.authlib.exceptions.AuthenticationUnavailableException)1