Merge branch '2.x' into ajmaacc
This commit is contained in:
commit
40babb9da5
|
@ -1,11 +1,9 @@
|
||||||
package com.earth2me.essentials;
|
package com.earth2me.essentials;
|
||||||
|
|
||||||
public class ChargeException extends Exception {
|
import net.ess3.api.TranslatableException;
|
||||||
public ChargeException(final String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ChargeException(final String message, final Throwable throwable) {
|
public class ChargeException extends TranslatableException {
|
||||||
super(message, throwable);
|
public ChargeException(String tlKey, Object... args) {
|
||||||
|
super(tlKey, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,23 +191,23 @@ public class Trade {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMoney() != null && getMoney().signum() > 0 && !user.canAfford(getMoney())) {
|
if (getMoney() != null && getMoney().signum() > 0 && !user.canAfford(getMoney())) {
|
||||||
future.completeExceptionally(new ChargeException(user.playerTl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess))));
|
future.completeExceptionally(new ChargeException("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getItemStack() != null && !Inventories.containsAtLeast(user.getBase(), itemStack, itemStack.getAmount())) {
|
if (getItemStack() != null && !Inventories.containsAtLeast(user.getBase(), itemStack, itemStack.getAmount())) {
|
||||||
future.completeExceptionally(new ChargeException(user.playerTl("missingItems", getItemStack().getAmount(), ess.getItemDb().name(getItemStack()))));
|
future.completeExceptionally(new ChargeException("missingItems", getItemStack().getAmount(), ess.getItemDb().name(getItemStack())));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final BigDecimal money;
|
final BigDecimal money;
|
||||||
if (command != null && !command.isEmpty() && (money = getCommandCost(user)).signum() > 0 && !user.canAfford(money)) {
|
if (command != null && !command.isEmpty() && (money = getCommandCost(user)).signum() > 0 && !user.canAfford(money)) {
|
||||||
future.completeExceptionally(new ChargeException(user.playerTl("notEnoughMoney", NumberUtil.displayCurrency(money, ess))));
|
future.completeExceptionally(new ChargeException("notEnoughMoney", NumberUtil.displayCurrency(money, ess)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exp != null && exp > 0 && SetExpFix.getTotalExperience(user.getBase()) < exp) {
|
if (exp != null && exp > 0 && SetExpFix.getTotalExperience(user.getBase()) < exp) {
|
||||||
future.completeExceptionally(new ChargeException(user.playerTl("notEnoughExperience")));
|
future.completeExceptionally(new ChargeException("notEnoughExperience"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +285,7 @@ public class Trade {
|
||||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " money " + getMoney().toPlainString());
|
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " money " + getMoney().toPlainString());
|
||||||
}
|
}
|
||||||
if (!user.canAfford(getMoney()) && getMoney().signum() > 0) {
|
if (!user.canAfford(getMoney()) && getMoney().signum() > 0) {
|
||||||
future.completeExceptionally(new ChargeException(user.playerTl("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess))));
|
future.completeExceptionally(new ChargeException("notEnoughMoney", NumberUtil.displayCurrency(getMoney(), ess)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.takeMoney(getMoney());
|
user.takeMoney(getMoney());
|
||||||
|
@ -295,7 +295,7 @@ public class Trade {
|
||||||
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
|
ess.getLogger().log(Level.INFO, "charging user " + user.getName() + " itemstack " + getItemStack().toString());
|
||||||
}
|
}
|
||||||
if (!Inventories.containsAtLeast(user.getBase(), getItemStack(), getItemStack().getAmount())) {
|
if (!Inventories.containsAtLeast(user.getBase(), getItemStack(), getItemStack().getAmount())) {
|
||||||
future.completeExceptionally(new ChargeException(user.playerTl("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " "))));
|
future.completeExceptionally(new ChargeException("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Inventories.removeItemAmount(user.getBase(), getItemStack(), getItemStack().getAmount());
|
Inventories.removeItemAmount(user.getBase(), getItemStack(), getItemStack().getAmount());
|
||||||
|
@ -304,7 +304,7 @@ public class Trade {
|
||||||
if (command != null) {
|
if (command != null) {
|
||||||
final BigDecimal cost = getCommandCost(user);
|
final BigDecimal cost = getCommandCost(user);
|
||||||
if (!user.canAfford(cost) && cost.signum() > 0) {
|
if (!user.canAfford(cost) && cost.signum() > 0) {
|
||||||
future.completeExceptionally(new ChargeException(user.playerTl("notEnoughMoney", NumberUtil.displayCurrency(cost, ess))));
|
future.completeExceptionally(new ChargeException("notEnoughMoney", NumberUtil.displayCurrency(cost, ess)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
user.takeMoney(cost);
|
user.takeMoney(cost);
|
||||||
|
@ -315,7 +315,7 @@ public class Trade {
|
||||||
}
|
}
|
||||||
final int experience = SetExpFix.getTotalExperience(user.getBase());
|
final int experience = SetExpFix.getTotalExperience(user.getBase());
|
||||||
if (experience < getExperience() && getExperience() > 0) {
|
if (experience < getExperience() && getExperience() > 0) {
|
||||||
future.completeExceptionally(new ChargeException(user.playerTl("notEnoughExperience")));
|
future.completeExceptionally(new ChargeException("notEnoughExperience"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
SetExpFix.setTotalExperience(user.getBase(), experience - getExperience());
|
SetExpFix.setTotalExperience(user.getBase(), experience - getExperience());
|
||||||
|
|
|
@ -271,7 +271,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
|
||||||
final TransactionEvent transactionEvent = new TransactionEvent(this.getSource(), reciever, value);
|
final TransactionEvent transactionEvent = new TransactionEvent(this.getSource(), reciever, value);
|
||||||
ess.getServer().getPluginManager().callEvent(transactionEvent);
|
ess.getServer().getPluginManager().callEvent(transactionEvent);
|
||||||
} else {
|
} else {
|
||||||
throw new ChargeException(tlLocale(playerLocale, "notEnoughMoney", NumberUtil.displayCurrency(value, ess)));
|
throw new ChargeException("notEnoughMoney", NumberUtil.displayCurrency(value, ess));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue