Fix for customer support GemHunterCommand

Fix for UUIDFethcer pulling while player is online.
This commit is contained in:
Jonathan Williams 2014-10-12 20:57:17 -07:00
parent 3e92b02bab
commit 3e7787a354
6 changed files with 27 additions and 10 deletions

View File

@ -107,6 +107,7 @@
<zipfileset src="../Libraries/commons-logging-1.1.1.jar" /> <zipfileset src="../Libraries/commons-logging-1.1.1.jar" />
<zipfileset src="../Libraries/commons-io-2.4.jar" /> <zipfileset src="../Libraries/commons-io-2.4.jar" />
<zipfileset src="../Libraries/commons-codec-1.6.jar" /> <zipfileset src="../Libraries/commons-codec-1.6.jar" />
<zipfileset src="../Libraries/jooq-3.4.2.jar" />
<zipfileset src="../Libraries/jedis-2.4.2.jar" /> <zipfileset src="../Libraries/jedis-2.4.2.jar" />
<zipfileset src="../Libraries/commons-pool2-2.2.jar" /> <zipfileset src="../Libraries/commons-pool2-2.2.jar" />
</jar> </jar>

View File

@ -182,7 +182,7 @@ public class CoreClientManager extends MiniPlugin
}); });
// JSON sql response // JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
// Load client in miniplugins // Load client in miniplugins
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client)); 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()); _repository.updateMysqlRank(uuid.toString(), token.Rank, token.RankPerm, new Timestamp(Date.parse(token.RankExpire)).toString());
// JSON sql response // JSON sql response
Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response)); Bukkit.getServer().getPluginManager().callEvent(new ClientWebResponseEvent(response, uuid));
// Load client in miniplugins // Load client in miniplugins
Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client)); Bukkit.getServer().getPluginManager().callEvent(new AsyncClientLoadEvent(token, client));

View File

@ -1,5 +1,7 @@
package mineplex.core.account.event; package mineplex.core.account.event;
import java.util.UUID;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
@ -8,10 +10,12 @@ public class ClientWebResponseEvent extends Event
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private String _response; private String _response;
private UUID _uuid;
public ClientWebResponseEvent(String response) public ClientWebResponseEvent(String response, UUID uuid)
{ {
_response = response; _response = response;
_uuid = uuid;
} }
public String GetResponse() public String GetResponse()
@ -28,4 +32,9 @@ public class ClientWebResponseEvent extends Event
{ {
return handlers; return handlers;
} }
public UUID getUniqueId()
{
return _uuid;
}
} }

View File

@ -48,7 +48,7 @@ public class DonationManager extends MiniPlugin
public void OnClientWebResponse(ClientWebResponseEvent event) public void OnClientWebResponse(ClientWebResponseEvent event)
{ {
DonorTokenWrapper token = new Gson().fromJson(event.GetResponse(), DonorTokenWrapper.class); DonorTokenWrapper token = new Gson().fromJson(event.GetResponse(), DonorTokenWrapper.class);
LoadDonor(token); LoadDonor(token, event.getUniqueId());
} }
@EventHandler @EventHandler
@ -60,12 +60,12 @@ public class DonationManager extends MiniPlugin
} }
} }
private void LoadDonor(DonorTokenWrapper token) private void LoadDonor(DonorTokenWrapper token, UUID uuid)
{ {
synchronized (_donorLock) synchronized (_donorLock)
{ {
_donors.put(token.Name, new Donor(token.DonorToken)); _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());
} }
} }

View File

@ -1,5 +1,7 @@
package mineplex.core.donation.repository; package mineplex.core.donation.repository;
import java.util.UUID;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.common.util.Callback; 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() handleDatabaseCall(new DatabaseRunnable(new Runnable()
{ {
public void run() 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 : "); }), "Error updating player's null gems and coins DonationRepository : ");
} }

View File

@ -25,11 +25,16 @@ public class GemHunterCommand extends CommandBase<SalesPackageManager>
String playerName = args[0]; String playerName = args[0];
int amount = Integer.parseInt(args[1]); int amount = Integer.parseInt(args[1]);
int experience = 0;
UUID uuid = UUIDFetcher.getUUIDOf(playerName); 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.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!")); caller.sendMessage(F.main(Plugin.GetName(), "Added Level " + amount + " Gem Hunter to " + playerName + "'s account!"));
} }
} }