mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-12-24 17:17:49 +01:00
Added protection from buy and sell prices == 0
Also fixed the formattedItem NPE.
This commit is contained in:
parent
45fa6d5c75
commit
ac71113f3e
@ -106,6 +106,11 @@ public class SignChange implements Listener {
|
||||
double buyPrice = PriceUtil.getBuyPrice(formattedPrice);
|
||||
double sellPrice = PriceUtil.getSellPrice(formattedPrice);
|
||||
|
||||
if (buyPrice == 0 && sellPrice == 0) {
|
||||
sendMessageAndExit(YOU_CANNOT_CREATE_SHOP, event);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isAdmin && (!canCreateShop(player, stock.getType(), buyPrice, sellPrice) || !MaxPrice.canCreate(buyPrice, sellPrice, stock.getType()))) {
|
||||
sendMessageAndExit(YOU_CANNOT_CREATE_SHOP, event);
|
||||
return;
|
||||
@ -180,7 +185,7 @@ public class SignChange implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (buy && !Permission.has(player, Permission.SHOP_CREATION_BUY)){
|
||||
if (buy && !Permission.has(player, Permission.SHOP_CREATION_BUY)) {
|
||||
return false;
|
||||
} else {
|
||||
return !(sell && !Permission.has(player, Permission.SHOP_CREATION_SELL));
|
||||
@ -228,7 +233,9 @@ public class SignChange implements Listener {
|
||||
formatted = formatted.substring(0, (15 - data.length()));
|
||||
}
|
||||
|
||||
if (MaterialUtil.getItem(formatted).getType() != item.getType()) {
|
||||
ItemStack formattedItem = MaterialUtil.getItem(formatted);
|
||||
|
||||
if (formattedItem == null || formattedItem.getType() != item.getType()) {
|
||||
formatted = String.valueOf(item.getTypeId());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user