Changed message in CUST-1

Fixed how QueuedCommands are handled, don't rerun website api call if it succeeded.
This commit is contained in:
Jonathan Williams 2014-12-01 23:53:35 -08:00
parent 7a3b4771ee
commit 63506c9ebc
3 changed files with 84 additions and 34 deletions

View File

@ -215,53 +215,103 @@ public class Enjin extends MiniPlugin implements CommandExecutor
_repository.addGemBooster(name, amount);
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Gem Boosters" + ".");
}
else if (args.length == 3 && args[0].equalsIgnoreCase("key"))
{
else if (args.length >= 3 && args[0].equalsIgnoreCase("key"))
{
final int amount = Integer.parseInt(args[2]);
_donationManager.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
if (args.length == 4)
{
public void run(TransactionResponse data)
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
{
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
public void run(Boolean success)
{
public void run(Boolean success)
if (success)
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Keys" + ".");
else
{
if (success)
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Keys" + ".");
else
{
_commandQueue.add(new QueuedCommand(sender, command, label, args));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later.");
}
// Add arg so we don't add back to windows api call
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later.");
}
}, playerUUID.toString(), "Treasure", "Treasure Key", amount);
}
}, name, playerUUID, "Treasure Key " + amount, false, 0, false);
}
}, playerUUID.toString(), "Treasure", "Treasure Key", amount);
}
else
{
_donationManager.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
{
public void run(TransactionResponse data)
{
if (data == TransactionResponse.Success)
{
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
{
public void run(Boolean success)
{
if (success)
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Keys" + ".");
else
{
// Add arg so we don't add back to windows api call
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later.");
}
}
}, playerUUID.toString(), "Treasure", "Treasure Key", amount);
}
else
{
_commandQueue.add(new QueuedCommand(sender, command, label, args));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Keys. Queuing for run later.");
}
}
}, name, playerUUID, "Treasure Key " + amount, false, 0, false);
}
}
else if (args.length == 3 && args[0].equalsIgnoreCase("chest"))
else if (args.length >= 3 && args[0].equalsIgnoreCase("chest"))
{
final int amount = Integer.parseInt(args[2]);
_donationManager.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
if (args.length == 4)
{
public void run(TransactionResponse data)
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
{
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
public void run(Boolean success)
{
public void run(Boolean success)
if (success)
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Chests" + ".");
else
{
if (success)
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Chests" + ".");
else
{
_commandQueue.add(new QueuedCommand(sender, command, label, args));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Chests. Queuing for run later.");
}
// Add arg so we don't add back to windows api call
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Chests. Queuing for run later.");
}
}, playerUUID.toString(), "Utility", "Treasure Chest", amount);
}
}, name, playerUUID, "Treasure Chest " + amount, false, 0, false);
}
}, playerUUID.toString(), "Utility", "Treasure Chest", amount);
}
else
{
_donationManager.PurchaseUnknownSalesPackage(new Callback<TransactionResponse>()
{
public void run(TransactionResponse data)
{
_inventoryManager.addItemToInventoryForOffline(new Callback<Boolean>()
{
public void run(Boolean success)
{
if (success)
System.out.println("[" + _dateFormat.format(new Date()) + "] " + name + " received " + amount + " Treasure Chests" + ".");
else
{
// Add arg so we don't add back to windows api call
_commandQueue.add(new QueuedCommand(sender, command, label, new String[] { args[0], args[1], args[2], "noaccountchange" }));
System.out.println("[" + _dateFormat.format(new Date()) + "] ERROR processing " + name + " " + amount + " Treasure Chests. Queuing for run later.");
}
}
}, playerUUID.toString(), "Utility", "Treasure Chest", amount);
}
}, name, playerUUID, "Treasure Chest " + amount, false, 0, false);
}
}
else if (args.length == 4 && args[0].equalsIgnoreCase("rank"))
{

View File

@ -10,7 +10,7 @@ public class QueuedCommand
public String Label;
public String[] Args;
public QueuedCommand(CommandSender sender, Command command, String label, String[] args)
public QueuedCommand(CommandSender sender, Command command, String label, String...args)
{
Sender = sender;
Command = command;

View File

@ -151,8 +151,8 @@ public class CustomerSupport extends MiniPlugin
}
caller.sendMessage(C.cBlue + "Enjin Coin Total Received : " + C.cYellow + enjinCoinsReceived);
caller.sendMessage(C.cBlue + "Enjin Chest Total Received : " + C.cYellow + chestsReceived);
caller.sendMessage(C.cBlue + "Enjin Key Total Received : " + C.cYellow + keysReceived);
caller.sendMessage(C.cBlue + "Treasure Chests Received : " + C.cYellow + chestsReceived);
caller.sendMessage(C.cBlue + "Treasure Keys Received : " + C.cYellow + keysReceived);
int coinsMissing = coinTransactionTotal - (donor.getCoins() + coinSpentTotal);