Hub Gem Queueing
This commit is contained in:
parent
f2d1709adb
commit
a8dda4ef8b
@ -9,6 +9,8 @@ import mineplex.core.common.util.NautHashMap;
|
|||||||
import mineplex.core.donation.repository.DonationRepository;
|
import mineplex.core.donation.repository.DonationRepository;
|
||||||
import mineplex.core.donation.repository.token.DonorTokenWrapper;
|
import mineplex.core.donation.repository.token.DonorTokenWrapper;
|
||||||
import mineplex.core.server.util.TransactionResponse;
|
import mineplex.core.server.util.TransactionResponse;
|
||||||
|
import mineplex.core.updater.UpdateType;
|
||||||
|
import mineplex.core.updater.event.UpdateEvent;
|
||||||
|
|
||||||
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
|
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -22,6 +24,8 @@ public class DonationManager extends MiniPlugin
|
|||||||
|
|
||||||
private Object _donorLock = new Object();
|
private Object _donorLock = new Object();
|
||||||
|
|
||||||
|
private NautHashMap<String, NautHashMap<String, Integer>> _gemQueue = new NautHashMap<String, NautHashMap<String, Integer>>();
|
||||||
|
|
||||||
public DonationManager(JavaPlugin plugin, String webAddress)
|
public DonationManager(JavaPlugin plugin, String webAddress)
|
||||||
{
|
{
|
||||||
super("Donation", plugin);
|
super("Donation", plugin);
|
||||||
@ -127,7 +131,12 @@ public class DonationManager extends MiniPlugin
|
|||||||
}, name, salesPackageId);
|
}, name, salesPackageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RewardGems(final Callback<Boolean> callback, final String caller, final String name, final int greenGems)
|
public void RewardGems(final Callback<Boolean> callback, final String caller, final String name, final int amount)
|
||||||
|
{
|
||||||
|
RewardGems(callback, caller, name, amount, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RewardGems(final Callback<Boolean> callback, final String caller, final String name, final int amount, final boolean updateTotal)
|
||||||
{
|
{
|
||||||
_repository.PlayerUpdate(new Callback<Boolean>()
|
_repository.PlayerUpdate(new Callback<Boolean>()
|
||||||
{
|
{
|
||||||
@ -135,17 +144,72 @@ public class DonationManager extends MiniPlugin
|
|||||||
{
|
{
|
||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
Donor donor = Get(name);
|
if (updateTotal)
|
||||||
|
|
||||||
if (donor != null)
|
|
||||||
{
|
{
|
||||||
donor.AddGems(greenGems);
|
Donor donor = Get(name);
|
||||||
|
|
||||||
|
if (donor != null)
|
||||||
|
{
|
||||||
|
donor.AddGems(amount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (callback != null)
|
if (callback != null)
|
||||||
callback.run(true);
|
callback.run(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, caller, name, greenGems);
|
}, caller, name, amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RewardGemsLater(final String caller, final String name, final int amount)
|
||||||
|
{
|
||||||
|
if (!_gemQueue.containsKey(name))
|
||||||
|
_gemQueue.put(name, new NautHashMap<String, Integer>());
|
||||||
|
|
||||||
|
int totalAmount = amount;
|
||||||
|
|
||||||
|
if (_gemQueue.get(name).containsKey(caller))
|
||||||
|
totalAmount += _gemQueue.get(name).get(caller);
|
||||||
|
|
||||||
|
_gemQueue.get(name).put(caller, totalAmount);
|
||||||
|
|
||||||
|
//Do Temp Change
|
||||||
|
Donor donor = Get(name);
|
||||||
|
|
||||||
|
if (donor != null)
|
||||||
|
donor.AddGems(amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void UpdateGemQueue(UpdateEvent event)
|
||||||
|
{
|
||||||
|
if (event.getType() != UpdateType.SLOWER)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (String name : _gemQueue.keySet())
|
||||||
|
{
|
||||||
|
String caller = null;
|
||||||
|
int total = 0;
|
||||||
|
|
||||||
|
for (String curCaller : _gemQueue.get(name).keySet())
|
||||||
|
{
|
||||||
|
caller = curCaller;
|
||||||
|
total += _gemQueue.get(name).get(curCaller);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (caller == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
//Actually Add Gems
|
||||||
|
RewardGems(null, caller, name, total, false);
|
||||||
|
|
||||||
|
System.out.println("Queue Added [" + name + "] with Gems [" + total + "] for [" + caller + "]");
|
||||||
|
|
||||||
|
//Clean
|
||||||
|
_gemQueue.get(name).clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
//Clean
|
||||||
|
_gemQueue.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -144,16 +144,6 @@ public class MessageManager extends MiniClientPlugin<ClientMessage>
|
|||||||
UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly.");
|
UtilPlayer.message(from, C.cPurple + "Please be patient if he does not reply instantly.");
|
||||||
}
|
}
|
||||||
|
|
||||||
//Youtuber
|
|
||||||
if (_clientManager.Get(to).GetRank() == Rank.YOUTUBE)
|
|
||||||
{
|
|
||||||
if (!_clientManager.Get(from).GetRank().Has(from, Rank.MODERATOR, true))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(from, C.cPurple + "YouTubers cannot be private messaged.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
//Logger().logChat("Private Message", from, to.getName(), message);
|
//Logger().logChat("Private Message", from, to.getName(), message);
|
||||||
|
|
||||||
|
@ -126,7 +126,7 @@ public abstract class ItemGadget extends Gadget
|
|||||||
{
|
{
|
||||||
if (Manager.Manager.GetDonation().Get(player.getName()).GetGems() > _gemsPerUse)
|
if (Manager.Manager.GetDonation().Get(player.getName()).GetGems() > _gemsPerUse)
|
||||||
{
|
{
|
||||||
Manager.Manager.GetDonation().RewardGems(null, this.GetName(), player.getName(), -_gemsPerUse);
|
Manager.Manager.GetDonation().RewardGemsLater(GetName(), player.getName(), -_gemsPerUse);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -112,16 +112,6 @@ public class StackerManager extends MiniPlugin implements IThrown
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
//YouTuber
|
|
||||||
if (stackee instanceof Player && Manager.GetClients().Get((Player)stackee).GetRank() == Rank.YOUTUBE)
|
|
||||||
{
|
|
||||||
if (!Manager.GetClients().Get(stacker).GetRank().Has(Rank.YOUTUBE))
|
|
||||||
{
|
|
||||||
UtilPlayer.message(stacker, F.main("Stacker", F.name(UtilEnt.getName(stackee)) + " cannot be stacked! Leave him/her alone!"));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stackee instanceof LivingEntity)
|
if (stackee instanceof LivingEntity)
|
||||||
{
|
{
|
||||||
if (((LivingEntity)stackee).isCustomNameVisible())
|
if (((LivingEntity)stackee).isCustomNameVisible())
|
||||||
|
Loading…
Reference in New Issue
Block a user