From 3e7787a3545036bf10189fc60b6a37f136528083 Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Sun, 12 Oct 2014 20:57:17 -0700 Subject: [PATCH] Fix for customer support GemHunterCommand Fix for UUIDFethcer pulling while player is online. --- Plugins/BuildFiles/common.xml | 1 + .../src/mineplex/core/account/CoreClientManager.java | 4 ++-- .../core/account/event/ClientWebResponseEvent.java | 11 ++++++++++- .../src/mineplex/core/donation/DonationManager.java | 6 +++--- .../core/donation/repository/DonationRepository.java | 6 ++++-- .../salespackage/command/GemHunterCommand.java | 9 +++++++-- 6 files changed, 27 insertions(+), 10 deletions(-) diff --git a/Plugins/BuildFiles/common.xml b/Plugins/BuildFiles/common.xml index 334654e20..ddad3caf4 100644 --- a/Plugins/BuildFiles/common.xml +++ b/Plugins/BuildFiles/common.xml @@ -107,6 +107,7 @@ + diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java index 6e6c6e9fc..92fb4215d 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/CoreClientManager.java @@ -182,7 +182,7 @@ public class CoreClientManager extends MiniPlugin }); // JSON sql response - Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response)); + Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); // Load client in miniplugins Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client)); @@ -239,7 +239,7 @@ public class CoreClientManager extends MiniPlugin _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString()); // JSON sql response - Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response)); + Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid)); // Load client in miniplugins Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client)); diff --git a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientWebResponseEvent.java b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientWebResponseEvent.java index 291b3961c..8916647fe 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientWebResponseEvent.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/account/event/ClientWebResponseEvent.java @@ -1,5 +1,7 @@ package mineplex.core.account.event; +import java.util.UUID; + import org.bukkit.event.Event; import org.bukkit.event.HandlerList; @@ -8,10 +10,12 @@ public class ClientWebResponseEvent extends Event private static final HandlerList handlers = new HandlerList(); private String _response; + private UUID _uuid; - public ClientWebResponseEvent(String response) + public ClientWebResponseEvent(String response, UUID uuid) { _response = response; + _uuid = uuid; } public String GetResponse() @@ -28,4 +32,9 @@ public class ClientWebResponseEvent extends Event { return handlers; } + + public UUID getUniqueId() + { + return _uuid; + } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java index 2e5acf719..b9dc22e31 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/DonationManager.java @@ -48,7 +48,7 @@ public class DonationManager extends MiniPlugin public void OnClientWebResponse(ClientWebResponseEvent event) { DonorTokenWrapper token = new Gson().fromJson(event.GetResponse(), DonorTokenWrapper.class); - LoadDonor(token); + LoadDonor(token, event.getUniqueId()); } @EventHandler @@ -60,12 +60,12 @@ public class DonationManager extends MiniPlugin } } - private void LoadDonor(DonorTokenWrapper token) + private void LoadDonor(DonorTokenWrapper token, UUID uuid) { synchronized (_donorLock) { _donors.put(token.Name, new Donor(token.DonorToken)); - _repository.updateGemsAndCoins(token.Name, Get(token.Name).GetGems(), Get(token.Name).getCoins()); + _repository.updateGemsAndCoins(uuid, Get(token.Name).GetGems(), Get(token.Name).getCoins()); } } diff --git a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java index dc5277b46..9523c2e06 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/donation/repository/DonationRepository.java @@ -1,5 +1,7 @@ package mineplex.core.donation.repository; +import java.util.UUID; + import org.bukkit.plugin.java.JavaPlugin; import mineplex.core.common.util.Callback; @@ -172,13 +174,13 @@ public class DonationRepository extends RepositoryBase { } - public void updateGemsAndCoins(final String name, final int gems, final int coins) + public void updateGemsAndCoins(final UUID uuid, final int gems, final int coins) { handleDatabaseCall(new DatabaseRunnable(new Runnable() { public void run() { - executeUpdate(UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_, new ColumnInt("gems", gems), new ColumnInt("coins", coins), new ColumnVarChar("uuid", 100, UUIDFetcher.getUUIDOf(name).toString())); + executeUpdate(UPDATE_NULL_ACCOUNT_GEMS_AND_COINS_, new ColumnInt("gems", gems), new ColumnInt("coins", coins), new ColumnVarChar("uuid", 100, uuid.toString())); } }), "Error updating player's null gems and coins DonationRepository : "); } diff --git a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java index af4c99490..00a277c64 100644 --- a/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java +++ b/Plugins/Mineplex.StaffServer/src/mineplex/staffServer/salespackage/command/GemHunterCommand.java @@ -25,11 +25,16 @@ public class GemHunterCommand extends CommandBase String playerName = args[0]; int amount = Integer.parseInt(args[1]); - + int experience = 0; UUID uuid = UUIDFetcher.getUUIDOf(playerName); + if (amount == 4) + experience = 70000; + else if (amount == 8) + experience = 220000; + Plugin.getDonationManager().PurchaseUnknownSalesPackage(null, playerName, uuid, "Gem Hunter Level " + amount, false, 0, false); - Plugin.getStatsManager().incrementStat(uuid.toString(), "Global.GemsEarned", 5000 + (amount * 5000)); + Plugin.getStatsManager().incrementStat(uuid.toString(), "Global.GemsEarned", experience); caller.sendMessage(F.main(Plugin.GetName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!")); } }