Added GlobalGiveCoins. Changes Gems a little and the manager.

This commit is contained in:
William Burns 2015-11-17 18:54:39 +00:00
parent a28adc9673
commit e19d4e11e1
3 changed files with 83 additions and 2 deletions

View File

@ -13,7 +13,8 @@ import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer; import mineplex.core.common.util.UtilPlayer;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.globalpacket.command.GlobalPacketCommand; import mineplex.core.globalpacket.command.GlobalPacketCommand;
import mineplex.core.globalpacket.event.GlobalGiveGems; import mineplex.core.globalpacket.listeners.GlobalGiveCoins;
import mineplex.core.globalpacket.listeners.GlobalGiveGems;
import mineplex.core.globalpacket.listeners.GlobalGiveItem; import mineplex.core.globalpacket.listeners.GlobalGiveItem;
import mineplex.core.globalpacket.redis.GlobalPacketHandler; import mineplex.core.globalpacket.redis.GlobalPacketHandler;
import mineplex.core.globalpacket.redis.GlobalPacketMessage; import mineplex.core.globalpacket.redis.GlobalPacketMessage;
@ -41,6 +42,7 @@ public class GlobalPacketManager extends MiniPlugin
getPluginManager().registerEvents(new GlobalGiveItem(inventoryManager), getPlugin()); getPluginManager().registerEvents(new GlobalGiveItem(inventoryManager), getPlugin());
getPluginManager().registerEvents(new GlobalGiveGems(donationManager), getPlugin()); getPluginManager().registerEvents(new GlobalGiveGems(donationManager), getPlugin());
getPluginManager().registerEvents(new GlobalGiveCoins(donationManager, clientManager), getPlugin());
} }
public void callGlobalCommand(Player caller, String[] args) public void callGlobalCommand(Player caller, String[] args)

View File

@ -0,0 +1,78 @@
package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import mineplex.core.account.CoreClientManager;
import mineplex.core.common.util.C;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
/**
* Created by William (WilliamTiger).
* 17/11/15
*/
public class GlobalGiveCoins implements Listener
{
private DonationManager _donationManager;
private CoreClientManager _clientManager;
public GlobalGiveCoins(DonationManager donationManager, CoreClientManager coreClientManager)
{
_donationManager = donationManager;
_clientManager = coreClientManager;
}
@EventHandler
public void giveCoins(GlobalPacketEvent e)
{
if (e.getParts() == null || e.getParts().length < 1)
return;
if (!e.getParts()[0].equalsIgnoreCase("givecoins"))
return;
if (e.getParts().length != 2)
{
if (e.getCaller().isOnline())
UtilPlayer.message(e.getCaller(), F.main("Global", "/global givecoins <amount>"));
return;
}
int amount = 1;
try
{
amount = Integer.parseInt(e.getParts()[1]);
}
catch (Exception ex)
{
// No number
if (e.getCaller().isOnline())
UtilPlayer.message(e.getCaller(), F.main("Global", "[" + F.elem(amount + "") + "] is not a valid amount."));
return;
}
final int fAmount = amount;
for (final Player p : UtilServer.getPlayers())
{
_donationManager.RewardCoins(new Callback<Boolean>()
{
@Override
public void run(Boolean data)
{
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " Coins") + "."));
UtilTextMiddle.display(C.cGold + p.getName() + " gave everyone", C.cYellow + fAmount + " Coins" + "!", p);
}
}, "Global Coins", p.getName(), _clientManager.getAccountId(p), amount);
}
}
}

View File

@ -1,4 +1,4 @@
package mineplex.core.globalpacket.event; package mineplex.core.globalpacket.listeners;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
@ -11,6 +11,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTextMiddle; import mineplex.core.common.util.UtilTextMiddle;
import mineplex.core.donation.DonationManager; import mineplex.core.donation.DonationManager;
import mineplex.core.globalpacket.event.GlobalPacketEvent;
/** /**
* Created by William (WilliamTiger). * Created by William (WilliamTiger).