mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 04:20:41 +00:00
Update /sell command to newer bukkit api
This commit is contained in:
parent
a64cb31211
commit
12786a260e
1 changed files with 5 additions and 13 deletions
|
@ -117,19 +117,7 @@ public class Commandsell extends EssentialsCommand
|
||||||
int max = 0;
|
int max = 0;
|
||||||
for (ItemStack s : user.getInventory().getContents())
|
for (ItemStack s : user.getInventory().getContents())
|
||||||
{
|
{
|
||||||
if (s == null)
|
if (s == null || !s.isSimilar(is))
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (s.getTypeId() != is.getTypeId())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (s.getDurability() != is.getDurability())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!s.getEnchantments().equals(is.getEnchantments()))
|
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -166,6 +154,10 @@ public class Commandsell extends EssentialsCommand
|
||||||
//TODO: Prices for Enchantments
|
//TODO: Prices for Enchantments
|
||||||
final ItemStack ris = is.clone();
|
final ItemStack ris = is.clone();
|
||||||
ris.setAmount(amount);
|
ris.setAmount(amount);
|
||||||
|
if (!user.getInventory().containsAtLeast(ris, amount)) {
|
||||||
|
// This should never happen.
|
||||||
|
throw new IllegalStateException("Trying to remove more items than are available.");
|
||||||
|
}
|
||||||
user.getInventory().removeItem(ris);
|
user.getInventory().removeItem(ris);
|
||||||
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(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
|
||||||
|
|
Loading…
Reference in a new issue