From dbde6890a00164c3504aa37ff96826ed2a226125 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sat, 20 Jun 2015 03:36:55 -0500 Subject: [PATCH] Add fallback to load by name if no uuid. --- .../core/account/CoreClientManager.java | 18 ++++++++++-------- .../account/repository/AccountRepository.java | 5 +++++ .../src/mineplex/enjinTranslator/Enjin.java | 9 +++++++++ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 8ba8f1650..a76be2fcd 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -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 diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java index b2fbd8368..954f3eaa9 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/repository/AccountRepository.java @@ -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); + } } diff --git a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java index e663d6e77..0c37445b6 100644 --- a/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java +++ b/Plugins/Mineplex.EnjinTranslator/src/mineplex/enjinTranslator/Enjin.java @@ -423,6 +423,15 @@ public class Enjin extends MiniPlugin implements CommandExecutor { exception.printStackTrace(); } + + try + { + Thread.sleep(20); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } } return true;