moved removing items from inventory
This commit is contained in:
parent
f34ba069ee
commit
f0c9edfdac
|
|
@ -63,9 +63,25 @@ public class SellGUI extends GUIMerchant {
|
||||||
|
|
||||||
econ.depositPlayer(player, cost);
|
econ.depositPlayer(player, cost);
|
||||||
econUser.addPoints(villagerType.getName(), -price.getPoints());
|
econUser.addPoints(villagerType.getName(), -price.getPoints());
|
||||||
|
|
||||||
|
removeItems(inventory, material, amount);
|
||||||
|
|
||||||
|
player.sendMessage(MiniMessage.get().parse(Config.SOLD_ITEM,
|
||||||
|
Template.of("amount", String.valueOf(amount)),
|
||||||
|
Template.of("item", StringUtils.capitalize(material.name()
|
||||||
|
.toLowerCase().replaceAll("_", " "))),
|
||||||
|
Template.of("price", String.valueOf(cost))));
|
||||||
|
|
||||||
|
Bukkit.getServer().getPluginManager()
|
||||||
|
.callEvent(new SpawnShopEvent(player, amount, cost, material,
|
||||||
|
oldPoints, econUser.getPointsMap().get(villagerType.getName()), false));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeItems(Inventory inventory, Material material, int amount) {
|
||||||
var ref = new Object() {
|
var ref = new Object() {
|
||||||
int tmpAmount = amount;
|
int tmpAmount = amount;
|
||||||
};
|
};
|
||||||
|
|
||||||
Arrays.stream(inventory.getContents())
|
Arrays.stream(inventory.getContents())
|
||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.filter(itemStack -> itemStack.getType().equals(material))
|
.filter(itemStack -> itemStack.getType().equals(material))
|
||||||
|
|
@ -81,16 +97,6 @@ public class SellGUI extends GUIMerchant {
|
||||||
itemStack.setAmount(0);
|
itemStack.setAmount(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//TODO remove items from inv
|
|
||||||
player.sendMessage(MiniMessage.get().parse(Config.SOLD_ITEM,
|
|
||||||
Template.of("amount", String.valueOf(amount)),
|
|
||||||
Template.of("item", StringUtils.capitalize(material.name()
|
|
||||||
.toLowerCase().replaceAll("_", " "))),
|
|
||||||
Template.of("price", String.valueOf(cost))));
|
|
||||||
|
|
||||||
Bukkit.getServer().getPluginManager()
|
|
||||||
.callEvent(new SpawnShopEvent(player, amount, cost, material,
|
|
||||||
oldPoints, econUser.getPointsMap().get(villagerType.getName()), false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ItemStack getPriceItem(double price) {
|
private ItemStack getPriceItem(double price) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user