mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-26 11:07:55 +01:00
Reduce calls to bukkit getPlayer();
This commit is contained in:
parent
0bc33554f3
commit
48d04216a7
@ -467,15 +467,21 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
if (base instanceof String)
|
||||
{
|
||||
final User user = userMap.getUser((String)base);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName((String)base);
|
||||
}
|
||||
return user;
|
||||
return getOfflineUser((String)base);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
{
|
||||
final User user = userMap.getUser(name);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
private <T extends Player> User getUser(final T base)
|
||||
{
|
||||
@ -508,17 +514,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
{
|
||||
final User user = userMap.getUser(name);
|
||||
if (user != null && user.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((OfflinePlayer)user.getBase()).setName(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld(final String name)
|
||||
{
|
||||
|
@ -8,7 +8,6 @@ import com.earth2me.essentials.Util;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
@ -72,17 +71,7 @@ public final class Economy
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
User user;
|
||||
Player player = ess.getServer().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
user = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
user = ess.getOfflineUser(name);
|
||||
}
|
||||
return user;
|
||||
return ess.getUser(name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,16 +45,7 @@ public class Commandmail extends EssentialsCommand
|
||||
throw new Exception(_("noPerm", "essentials.mail.send"));
|
||||
}
|
||||
|
||||
Player player = server.getPlayer(args[1]);
|
||||
User u;
|
||||
if (player != null)
|
||||
{
|
||||
u = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[1]);
|
||||
}
|
||||
User u = ess.getUser(args[0]);
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(_("playerNeverOnServer", args[1]));
|
||||
@ -113,16 +104,7 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
Player player = server.getPlayer(args[1]);
|
||||
User u;
|
||||
if (player != null)
|
||||
{
|
||||
u = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[1]);
|
||||
}
|
||||
User u = ess.getUser(args[0]);
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(_("playerNeverOnServer", args[1]));
|
||||
@ -138,16 +120,7 @@ public class Commandmail extends EssentialsCommand
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
//allow sending from console without "send" argument, since it's the only thing the console can do
|
||||
Player player = server.getPlayer(args[0]);
|
||||
User u;
|
||||
if (player != null)
|
||||
{
|
||||
u = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[0]);
|
||||
}
|
||||
User u = ess.getUser(args[0]);
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(_("playerNeverOnServer", args[0]));
|
||||
|
@ -39,11 +39,7 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.others"))
|
||||
{
|
||||
usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
|
||||
if (usersHome == null)
|
||||
{
|
||||
usersHome = ess.getOfflineUser(args[0]);
|
||||
}
|
||||
usersHome = ess.getUser(args[0]);
|
||||
if (usersHome == null)
|
||||
{
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
|
Loading…
Reference in New Issue
Block a user