Add fallback to load by name if no uuid.
This commit is contained in:
parent
cf152c4897
commit
dbde6890a0
@ -190,9 +190,7 @@ public class CoreClientManager extends MiniPlugin
|
||||
}
|
||||
|
||||
public void loadClientByName(final String playerName, final Runnable runnable)
|
||||
{
|
||||
final CoreClient client = Add(playerName);
|
||||
|
||||
{
|
||||
Bukkit.getServer().getScheduler().runTaskAsynchronously(getPlugin(), new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@ -208,17 +206,21 @@ public class CoreClientManager extends MiniPlugin
|
||||
if (uuid == null)
|
||||
uuid = UUIDFetcher.getUUIDOf(playerName);
|
||||
|
||||
String response = "";
|
||||
|
||||
if (uuid == null)
|
||||
{
|
||||
System.out.println("ERROR uuid is null. Can't load client by name.");
|
||||
return;
|
||||
response = _repository.getClientByName(playerName);
|
||||
}
|
||||
else
|
||||
{
|
||||
response = _repository.getClientByUUID(uuid);
|
||||
}
|
||||
|
||||
String response = _repository.getClientByUUID(uuid);
|
||||
token = gson.fromJson(response, ClientToken.class);
|
||||
|
||||
client.SetRank(Rank.valueOf(token.Rank));
|
||||
|
||||
CoreClient client = Add(playerName);
|
||||
client.SetRank(Rank.valueOf(token.Rank));
|
||||
client.setAccountId(_repository.login(_loginProcessors, uuid.toString(), client.GetPlayerName()));
|
||||
|
||||
// JSON sql response
|
||||
|
@ -267,4 +267,9 @@ public class AccountRepository extends RepositoryBase
|
||||
}
|
||||
}), "Error updating player's mysql rank AccountRepository : ");
|
||||
}
|
||||
|
||||
public String getClientByName(String playerName)
|
||||
{
|
||||
return new JsonWebCall(_webAddress + "PlayerAccount/GetAccount").ExecuteReturnStream(playerName);
|
||||
}
|
||||
}
|
||||
|
@ -423,6 +423,15 @@ public class Enjin extends MiniPlugin implements CommandExecutor
|
||||
{
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Thread.sleep(20);
|
||||
}
|
||||
catch (InterruptedException e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user