Merge branch 'master' of ssh://184.154.0.242:7999/min/mineplex

This commit is contained in:
Mini-Chiss 2015-08-13 20:56:20 +02:00
commit 7157aaee2b

View File

@ -2,6 +2,7 @@ package mineplex.core.bonuses.commands;
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;
import mineplex.core.bonuses.BonusManager;
@ -12,7 +13,7 @@ public class TicketCommand extends CommandBase<BonusManager>
{
public TicketCommand(BonusManager plugin)
{
super(plugin, Rank.DEVELOPER, "ticket");
super(plugin, Rank.ADMIN, "ticket");
}
@Override
@ -36,15 +37,28 @@ public class TicketCommand extends CommandBase<BonusManager>
{
try
{
int tickets = Integer.parseInt(ticketString);
Plugin.Get(target).setTickets(Plugin.Get(targetName).getTickets() + tickets);
UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + "."));
if (target != null)
final int tickets = Integer.parseInt(ticketString);
int accountId = Plugin.getClientManager().getAccountId(target);
Plugin.getRepository().attemptAddTickets(accountId, Plugin.Get(target), tickets, new Callback<Boolean>()
{
UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + "."));
}
@Override
public void run(Boolean data)
{
if (data)
{
UtilPlayer.message(caller, F.main("Carl", "You gave " + F.elem(tickets + " Carl Tickets") + " to " + F.name(targetName) + "."));
if (target != null && !target.equals(caller))
{
UtilPlayer.message(target, F.main("Carl", F.name(caller.getName()) + " gave you " + F.elem(tickets + " Carl Tickets") + "."));
}
}
else
{
UtilPlayer.message(caller, F.main("Carl", "Failed to give tickets. Try again later!"));
}
}
});
}
catch (Exception e)
{