@EventHandler(priority = EventPriority.HIGH) public void onPlayerLogin(PlayerLoginEvent event) { if (event.getResult() != Result.ALLOWED) return; // Define the player Player p = event.getPlayer(); // Pretty sure this isn't even necessary, but I just can't figure out wtf is throwing the NPE if (p == null) return; // Check if player is banned if (!p.isBanned()) return; // Check to see that they have a bantime, and that if they do, if the timestamp is invalid. if (PConfManager.getPVal(p, "bantime") != null && !RUtils.isTimeStampValid(p, "bantime")) { // Set them unbanned p.setBanned(false); // Stop the method return; } // Get the banreason from the player's userdata file String kickMessage = PConfManager.getPValString(p, "banreason"); // Returns string or null // Check if there was none, and if there wasn't, set it to default ban message. if (kickMessage == null) kickMessage = plugin.banMessage; // Set the kick message to the ban reason event.setKickMessage(kickMessage); // Disallow the event event.disallow(Result.KICK_BANNED, kickMessage); }
@EventHandler public void displayNames(PlayerLoginEvent e) { if (e.getResult() != Result.ALLOWED) return; Player p = e.getPlayer(); if (p == null) return; String dispname = PConfManager.getPValString(p, "dispname"); if (dispname == null || dispname.equals("")) dispname = p.getName().trim(); dispname = dispname.trim(); if (dispname == null) return; p.setDisplayName(dispname); if (dispname.length() <= 16) p.setPlayerListName(dispname); }
@EventHandler(priority = EventPriority.HIGHEST) public void vipLogin(PlayerLoginEvent e) { if (e.getResult() != Result.KICK_FULL) return; if (!PConfManager.getPConfExists(e.getPlayer())) return; if (e.getPlayer().isBanned()) return; if (PConfManager.getPVal(e.getPlayer(), "vip") != null && PConfManager.getPValBoolean(e.getPlayer(), "vip")) e.allow(); }
@EventHandler public void whitelist(PlayerLoginEvent e) { if (!plugin.useWhitelist) return; if (!plugin.whitelist.contains(e.getPlayer().getName())) e.disallow(Result.KICK_WHITELIST, "You are not whitelisted on this server!"); }