More global stuff! Added GlobalGiveGems.
This commit is contained in:
parent
0f7c52391f
commit
a28adc9673
@ -11,7 +11,9 @@ import mineplex.core.account.CoreClientManager;
|
||||
import mineplex.core.common.Rank;
|
||||
import mineplex.core.common.util.F;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.donation.DonationManager;
|
||||
import mineplex.core.globalpacket.command.GlobalPacketCommand;
|
||||
import mineplex.core.globalpacket.event.GlobalGiveGems;
|
||||
import mineplex.core.globalpacket.listeners.GlobalGiveItem;
|
||||
import mineplex.core.globalpacket.redis.GlobalPacketHandler;
|
||||
import mineplex.core.globalpacket.redis.GlobalPacketMessage;
|
||||
@ -24,18 +26,21 @@ public class GlobalPacketManager extends MiniPlugin
|
||||
private CoreClientManager _clientManager;
|
||||
private ServerStatusManager _statusManager;
|
||||
private InventoryManager _inventoryManager;
|
||||
private DonationManager _donationManager;
|
||||
|
||||
public GlobalPacketManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, InventoryManager inventoryManager)
|
||||
public GlobalPacketManager(JavaPlugin plugin, CoreClientManager clientManager, ServerStatusManager statusManager, InventoryManager inventoryManager, DonationManager donationManager)
|
||||
{
|
||||
super("Global Packet Manager", plugin);
|
||||
|
||||
_clientManager = clientManager;
|
||||
_statusManager = statusManager;
|
||||
_inventoryManager = inventoryManager;
|
||||
_donationManager = donationManager;
|
||||
|
||||
ServerCommandManager.getInstance().registerCommandType("GlobalPacketMessage", GlobalPacketMessage.class, new GlobalPacketHandler(statusManager));
|
||||
|
||||
getPluginManager().registerEvents(new GlobalGiveItem(inventoryManager), getPlugin());
|
||||
getPluginManager().registerEvents(new GlobalGiveGems(donationManager), getPlugin());
|
||||
}
|
||||
|
||||
public void callGlobalCommand(Player caller, String[] args)
|
||||
|
@ -0,0 +1,74 @@
|
||||
package mineplex.core.globalpacket.event;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* Created by William (WilliamTiger).
|
||||
* 17/11/15
|
||||
*/
|
||||
public class GlobalGiveGems implements Listener
|
||||
{
|
||||
|
||||
private DonationManager _donationManager;
|
||||
|
||||
public GlobalGiveGems(DonationManager donationManager)
|
||||
{
|
||||
_donationManager = donationManager;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void giveGems(GlobalPacketEvent e)
|
||||
{
|
||||
if (e.getParts() == null || e.getParts().length < 1)
|
||||
return;
|
||||
|
||||
if (!e.getParts()[0].equalsIgnoreCase("givegems"))
|
||||
return;
|
||||
|
||||
if (e.getParts().length != 2)
|
||||
{
|
||||
if (e.getCaller().isOnline())
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "/global givegems <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.RewardGems(new Callback<Boolean>()
|
||||
{
|
||||
@Override
|
||||
public void run(Boolean data)
|
||||
{
|
||||
UtilPlayer.message(p, F.main("Global", "You received " + F.elem(fAmount + " Gems") + "."));
|
||||
UtilTextMiddle.display(C.cGold + p.getName() + " gave everyone", C.cYellow + fAmount + " Gems" + "!", p);
|
||||
}
|
||||
}, "Global Gems", p.getName(), p.getUniqueId(), amount);
|
||||
}
|
||||
}
|
||||
}
|
@ -55,6 +55,14 @@ public class GlobalGiveItem implements Listener
|
||||
if (!e.getParts()[0].equalsIgnoreCase("giveitem"))
|
||||
return;
|
||||
|
||||
if (e.getParts().length != 3)
|
||||
{
|
||||
if (e.getCaller().isOnline())
|
||||
UtilPlayer.message(e.getCaller(), F.main("Global", "/global giveitem <item> <amount>"));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
GlobalItem item = null;
|
||||
|
||||
try
|
||||
|
@ -147,7 +147,7 @@ public class Arcade extends JavaPlugin
|
||||
cosmeticManager.setInterfaceSlot(7);
|
||||
cosmeticManager.disableTeamArmor();
|
||||
|
||||
new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager);
|
||||
new GlobalPacketManager(this, _clientManager, serverStatusManager, inventoryManager, _donationManager);
|
||||
|
||||
GiveawayManager giveawayManager = new GiveawayManager(this, _clientManager, serverStatusManager);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user