Added @a argument to /shard, /gem and /giveitem PC-13

This commit is contained in:
Virizion 2016-03-08 19:52:31 -05:00
parent e8d5165634
commit b1c8158e2f
3 changed files with 96 additions and 3 deletions

View File

@ -10,6 +10,7 @@ import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UUIDFetcher;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.donation.DonationManager;
public class GemCommand extends CommandBase<DonationManager>
@ -32,7 +33,11 @@ public class GemCommand extends CommandBase<DonationManager>
String gemsString = args[1];
Player target = UtilPlayer.searchExact(targetName);
if (target == null)
if (targetName.equalsIgnoreCase("@a"))
{
rewardAllGems(caller, gemsString);
}
else if (target == null)
{
UUID uuid = UUIDFetcher.getUUIDOf(targetName);
if (uuid != null)
@ -50,6 +55,42 @@ public class GemCommand extends CommandBase<DonationManager>
}
}
private void rewardAllGems(Player caller, String gemsString)
{
try
{
int gems = Integer.parseInt(gemsString);
if (gems > 1000)
{
UtilPlayer.message(caller, F.main("Gem", "You can only give everybody 1000 gems at a time."));
return;
}
rewardAllGems(caller, gems);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("Gem", "Invalid gems Amount"));
}
}
private void rewardAllGems(Player caller, int gems)
{
for (Player player : UtilServer.getPlayers())
{
Plugin.RewardGems(new Callback<Boolean>()
{
public void run(Boolean completed)
{
}
}, caller.getName(), player.getName(), player.getUniqueId(), gems);
}
UtilPlayer.message(caller, F.main("Gem", "Gave everyone " + F.elem(gems + " gems")));
}
private void rewardGems(final Player caller, final Player target, final String targetName, final UUID uuid, String gemsString)
{
try

View File

@ -6,8 +6,8 @@ import mineplex.core.common.Rank;
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.donation.DonationManager;
import org.bukkit.entity.Player;
public class ShardCommand extends CommandBase<DonationManager>
@ -30,7 +30,11 @@ public class ShardCommand extends CommandBase<DonationManager>
final String coinsString = args[1];
Player target = UtilPlayer.searchExact(targetName);
if (target == null)
if (targetName.equalsIgnoreCase("@a"))
{
rewardAllShards(caller, coinsString);
}
else if (target == null)
{
Plugin.getClientManager().loadClientByName(targetName, new Runnable()
{
@ -53,6 +57,44 @@ public class ShardCommand extends CommandBase<DonationManager>
}
}
private void rewardAllShards(Player caller, String shardsString)
{
try
{
int shards = Integer.parseInt(shardsString);
if (shards > 1000)
{
UtilPlayer.message(caller, F.main("Shards", "You can only give everybody 1000 shards at a time."));
return;
}
rewardAllShards(caller, shards);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("Shards", "Invalid Shards Amount"));
}
}
private void rewardAllShards(Player caller, int shards)
{
for (Player player : UtilServer.getPlayers())
{
CoreClient client = Plugin.getClientManager().Get(player);
Plugin.RewardCoins(new Callback<Boolean>()
{
public void run(Boolean completed)
{
}
}, caller.getName(), player.getName(), client.getAccountId(), shards);
}
UtilPlayer.message(caller, F.main("Shards", "Gave everyone " + F.elem(shards + " Treasure Shards")));
}
private void rewardCoins(final Player caller, final Player target, final String targetName, final int accountId, String coinsString)
{
try

View File

@ -9,6 +9,7 @@ import mineplex.core.common.Rank;
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.inventory.InventoryManager;
import mineplex.core.inventory.data.Item;
@ -47,6 +48,15 @@ public class GiveItemCommand extends CommandBase<InventoryManager>
{
UtilPlayer.message(caller, F.main("Item", "Item with the name " + F.item(itemName) + " not found!"));
}
else if (playerName.equalsIgnoreCase("@a"))
{
for (Player pl : UtilServer.getPlayers())
{
Plugin.addItemToInventory(pl, item.Name, amount);
}
UtilPlayer.message(caller, F.main("Item", "You gave " + F.elem(amount + " " + itemName) + " to everyone"));
}
else if (player != null)
{
Plugin.addItemToInventory(player, item.Name, amount);