Add coin command for online players, better way to handle this soon

This commit is contained in:
Shaun Bennett 2014-10-16 17:46:00 -05:00
parent 76dc735b6b
commit c855c46940
2 changed files with 57 additions and 5 deletions

View File

@ -0,0 +1,51 @@
package mineplex.core.donation;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.Callback;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
public class CoinCommand extends CommandBase<DonationManager>
{
public CoinCommand(DonationManager plugin)
{
super(plugin, Rank.ADMIN, "coin");
}
@Override
public void Execute(final Player caller, String[] args)
{
if (args.length < 2)
{
UtilPlayer.message(caller, F.main("Coin", "Missing Args"));
return;
}
//Try Online
final Player target = UtilPlayer.searchOnline(caller, args[0], true);
if (target == null)
return;
//Give Coins to Target
try
{
final int coins = Integer.parseInt(args[1]);
Plugin.RewardCoins(new Callback<Boolean>()
{
public void run(Boolean completed)
{
UtilPlayer.message(caller, F.main("Coin", "You gave " + F.elem(coins + " Coins") + " to " + F.name(target.getName()) + "."));
UtilPlayer.message(target, F.main("Coin", F.name(caller.getName()) + " gave you " + F.elem(coins + " Coins") + "."));
}
}, caller.getName(), target.getName(), target.getUniqueId(), coins);
}
catch (Exception e)
{
UtilPlayer.message(caller, F.main("Coin", "Invalid Coins Amount"));
}
}
}

View File

@ -2,6 +2,11 @@ package mineplex.core.donation;
import java.util.UUID;
import org.bukkit.craftbukkit.libs.com.google.gson.Gson;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.account.event.ClientUnloadEvent;
import mineplex.core.account.event.ClientWebResponseEvent;
@ -14,11 +19,6 @@ 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.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin;
public class DonationManager extends MiniPlugin
{
private DonationRepository _repository;
@ -42,6 +42,7 @@ public class DonationManager extends MiniPlugin
public void AddCommands()
{
AddCommand(new GemCommand(this));
AddCommand(new CoinCommand(this));
}
@EventHandler