add getPlayer method into Utils class

This commit is contained in:
DNx5 2015-11-17 09:32:33 +07:00
parent 3e1c7edb2d
commit 9a79332933
2 changed files with 9 additions and 3 deletions

View File

@ -225,10 +225,10 @@ public class AuthMePlayerListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onPreLogin(AsyncPlayerPreLoginEvent event) { public void onPreLogin(AsyncPlayerPreLoginEvent event) {
final String name = event.getName().toLowerCase(); final String name = event.getName().toLowerCase();
@SuppressWarnings("deprecation") final Player player = Utils.getPlayer(name);
final Player player = plugin.getServer().getPlayer(name); if (player == null) {
if (player == null)
return; return;
}
// Check if forceSingleSession is set to true, so kick player that has // Check if forceSingleSession is set to true, so kick player that has
// joined with same nick of online player // joined with same nick of online player

View File

@ -273,6 +273,12 @@ public class Utils {
return Collections.emptyList(); return Collections.emptyList();
} }
@SuppressWarnings("deprecation")
public static Player getPlayer(String name) {
name = name.toLowerCase();
return plugin.getServer().getPlayer(name);
}
public static boolean isNPC(final Entity player) { public static boolean isNPC(final Entity player) {
try { try {
if (player.hasMetadata("NPC")) { if (player.hasMetadata("NPC")) {