Add a GiveGemsCommand

This commit is contained in:
Sam 2017-02-12 15:23:50 +00:00
parent bc6cae9b5e
commit 652d6d0f84
2 changed files with 54 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import mineplex.core.ReflectivelyCreateMiniPlugin;
import mineplex.core.common.currency.GlobalCurrency;
import mineplex.core.common.util.F;
import mineplex.gemhunters.death.events.PlayerCustomRespawnEvent;
import mineplex.gemhunters.economy.command.GiveGemsCommand;
@ReflectivelyCreateMiniPlugin
public class EconomyModule extends MiniPlugin
@ -32,6 +33,12 @@ public class EconomyModule extends MiniPlugin
_storedGems = new HashMap<>();
}
@Override
public void addCommands()
{
addCommand(new GiveGemsCommand(this));
}
@EventHandler
public void respawn(PlayerCustomRespawnEvent event)
{

View File

@ -0,0 +1,47 @@
package mineplex.gemhunters.economy.command;
import org.bukkit.entity.Player;
import mineplex.core.command.CommandBase;
import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayer;
import mineplex.gemhunters.economy.EconomyModule;
public class GiveGemsCommand extends CommandBase<EconomyModule>
{
public GiveGemsCommand(EconomyModule plugin)
{
super(plugin, Rank.ADMIN, "givegems");
}
@Override
public void Execute(Player caller, String[] args)
{
if (args.length < 2)
{
caller.sendMessage(F.help("/" + _aliasUsed + " <player> <amount>", "Adds an amount of gems to a player's gems earned.", Rank.ADMIN));
return;
}
Player target = UtilPlayer.searchOnline(caller, args[0], true);
if (target == null)
{
return;
}
try
{
int amount = Integer.parseInt(args[1]);
Plugin.addToStore(target, "Given by " + F.name(caller.getName()), amount);
}
catch (NumberFormatException e)
{
caller.sendMessage(F.main(Plugin.getName(), "That is not a number."));
}
}
}