Fix ticket command rollback >:D
This commit is contained in:
parent
5fa9135b08
commit
bd7317cf7b
@ -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;
|
||||
@ -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)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user