mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Ignore itemmeta on sell
This commit is contained in:
parent
ce7d83adb6
commit
74b63a6f2d
1 changed files with 17 additions and 5 deletions
|
@ -43,7 +43,7 @@ public class Commandsell extends EssentialsCommand
|
||||||
}
|
}
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
totalWorth += sellItem(user, stack, args, true);
|
totalWorth += sellItem(user, stack, args, true);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -164,11 +164,23 @@ public class Commandsell extends EssentialsCommand
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: Prices for Enchantments
|
//TODO: Prices for Enchantments
|
||||||
final ItemStack ris = is.clone();
|
ItemStack[] pinv = user.getInventory().getContents();
|
||||||
ris.setAmount(amount);
|
int itemIndex = -1;
|
||||||
user.getInventory().removeItem(ris);
|
for (int i = 0; i < pinv.length; i++)
|
||||||
|
{
|
||||||
|
if (pinv[i] != null)
|
||||||
|
{
|
||||||
|
if (pinv[i].getType() == is.getType() && pinv[i].getDurability() == is.getDurability())
|
||||||
|
{
|
||||||
|
itemIndex = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pinv[itemIndex].setAmount(pinv[itemIndex].getAmount() - amount);
|
||||||
|
user.getInventory().setContents(pinv);
|
||||||
user.updateInventory();
|
user.updateInventory();
|
||||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
|
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(pinv[itemIndex], ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
|
||||||
user.giveMoney(worth * amount);
|
user.giveMoney(worth * amount);
|
||||||
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
|
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
|
||||||
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
|
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
|
||||||
|
|
Loading…
Reference in a new issue