mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-02-24 08:11:58 +01:00
Add command + money queues to process after items in kits (#3434)
Fixes #3431
This commit is contained in:
parent
b7f38517ef
commit
b6c9bc1439
@ -162,12 +162,11 @@ public class Kit {
|
|||||||
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
final boolean allowUnsafe = ess.getSettings().allowUnsafeEnchantments();
|
||||||
final boolean currencyIsSuffix = ess.getSettings().isCurrencySymbolSuffixed();
|
final boolean currencyIsSuffix = ess.getSettings().isCurrencySymbolSuffixed();
|
||||||
List<ItemStack> itemList = new ArrayList<>();
|
List<ItemStack> itemList = new ArrayList<>();
|
||||||
|
List<String> commandQueue = new ArrayList<>();
|
||||||
|
List<String> moneyQueue = new ArrayList<>();
|
||||||
for (String kitItem : output.getLines()) {
|
for (String kitItem : output.getLines()) {
|
||||||
if (!currencyIsSuffix ? kitItem.startsWith(ess.getSettings().getCurrencySymbol()) : kitItem.endsWith(ess.getSettings().getCurrencySymbol())) {
|
if (!currencyIsSuffix ? kitItem.startsWith(ess.getSettings().getCurrencySymbol()) : kitItem.endsWith(ess.getSettings().getCurrencySymbol())) {
|
||||||
final String valueString = NumberUtil.sanitizeCurrencyString(kitItem, ess);
|
moneyQueue.add(NumberUtil.sanitizeCurrencyString(kitItem, ess));
|
||||||
BigDecimal value = new BigDecimal(valueString.trim());
|
|
||||||
Trade t = new Trade(value, ess);
|
|
||||||
t.pay(user, OverflowType.DROP);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +174,7 @@ public class Kit {
|
|||||||
String command = kitItem.substring(1);
|
String command = kitItem.substring(1);
|
||||||
String name = user.getName();
|
String name = user.getName();
|
||||||
command = command.replace("{player}", name);
|
command = command.replace("{player}", name);
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
|
commandQueue.add(command);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,6 +228,20 @@ public class Kit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
user.getBase().updateInventory();
|
user.getBase().updateInventory();
|
||||||
|
|
||||||
|
// Process money & command queues
|
||||||
|
// Done after all items have been processed so commands are not run and money is not given if
|
||||||
|
// an error occurs during the item giving process
|
||||||
|
for (String valueString : moneyQueue) {
|
||||||
|
BigDecimal value = new BigDecimal(valueString.trim());
|
||||||
|
Trade t = new Trade(value, ess);
|
||||||
|
t.pay(user, OverflowType.DROP);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String cmd : commandQueue) {
|
||||||
|
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), cmd);
|
||||||
|
}
|
||||||
|
|
||||||
if (spew) {
|
if (spew) {
|
||||||
user.sendMessage(tl("kitInvFull"));
|
user.sendMessage(tl("kitInvFull"));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user