Help on AsyncPlayerPreLoginEvent

Discussion in 'Plugin Development' started by neriodev, Jul 2, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    neriodev

    @EventHandler
    public void joinBan(AsyncPlayerPreLoginEvent e) {
    Player p = (Player) e.getName();
    if(Main.getPlugin().getConfig().getBoolean("Players. " + p.getUniqueId().toString() + ".Ban", true)) {
    e.disallow(Result.KICK_BANNED, ChatColor.RED + "You're BANNED");;
    }
    }

    How can I get the entity in this event?
     
  2. Offline

    caseif

    The entity doesn't exist yet, because the player hasn't fully logged in. So in other terms, you can't.
     
  3. Offline

    567legodude

    @neriodev You can pretty much do the same exact thing with PlayerLoginEvent, which has event.getPlayer()
    Then you just event.disallow(PlayerLoginEvent.Result.KICK_BANNED, "§cYou are banned");
     
  4. Offline

    dlange

    @neriodev You can use OfflinePlayer op = Bukkit.getOfflinePlayer(e.getName());
    Also, you can't cast player to a string, use the Bukkit.getPlayer() methods
     
  5. Offline

    schwabfl

    Use PlayerLoginEvent
    PlayerLoginEvent has a method called getPlayer() and from there you can grab the player's UUID

    Also, don't cast a String to a Player
    won't work
     
  6. Offline

    _Error

    In minecraft, When he pre-logs in that means he attempts to and he is not a player YET, pre-logging in mean loading up your files, and Logging in means that he is a player now. And you can only execute codes at him when he is a player.
     
  7. Offline

    neriodev

    Thanks its works

    Thanks for the opinion, but i used with PlayerLoginEvent

    Thanks for the opinion, its works but i used PlayerLoginEvent

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  8. @neriodev
    Instead of making 3 posts, make 1 containing everything instead...
     
  9. Offline

    Konato_K

    @neriodev As a little note, AsyncPlayerPreLogin has a getUniqueId method
     
Thread Status:
Not open for further replies.

Share This Page