diff --git a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java index 20aa7ad66..62cefef27 100644 --- a/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java +++ b/Plugins/Mineplex.Core/src/mineplex/core/bonuses/commands/TicketCommand.java @@ -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 { 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() { - 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) {