mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 18:32:24 +00:00
Players should be able to open their sell-only shops
Also, they should be able to open shops even when they don't have permission to buy something
This commit is contained in:
parent
1666051eb8
commit
f155b67f4c
@ -4,7 +4,6 @@ import com.griefcraft.lwc.LWC;
|
|||||||
import com.griefcraft.model.Protection;
|
import com.griefcraft.model.Protection;
|
||||||
import de.epiceric.shopchest.ShopChest;
|
import de.epiceric.shopchest.ShopChest;
|
||||||
import de.epiceric.shopchest.config.Config;
|
import de.epiceric.shopchest.config.Config;
|
||||||
import de.epiceric.shopchest.utils.Utils;
|
|
||||||
import de.epiceric.shopchest.shop.Shop;
|
import de.epiceric.shopchest.shop.Shop;
|
||||||
import de.epiceric.shopchest.shop.Shop.ShopType;
|
import de.epiceric.shopchest.shop.Shop.ShopType;
|
||||||
import de.epiceric.shopchest.sql.Database;
|
import de.epiceric.shopchest.sql.Database;
|
||||||
@ -155,30 +154,29 @@ public class InteractShop implements Listener {
|
|||||||
e.setCancelled(false);
|
e.setCancelled(false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (shop.getBuyPrice() > 0) {
|
if (shop.getShopType() == ShopType.ADMIN || !shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
if (perm.has(p, "shopchest.buy")) {
|
if (shop.getBuyPrice() > 0) {
|
||||||
if (shop.getShopType() == ShopType.ADMIN) {
|
if (perm.has(p, "shopchest.buy")) {
|
||||||
buy(p, shop);
|
if (shop.getShopType() == ShopType.ADMIN) {
|
||||||
} else {
|
buy(p, shop);
|
||||||
if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
} else {
|
||||||
Chest c = (Chest) b.getState();
|
Chest c = (Chest) b.getState();
|
||||||
if (Utils.getAmount(c.getInventory(), shop.getProduct()) >= shop.getProduct().getAmount()) {
|
if (Utils.getAmount(c.getInventory(), shop.getProduct()) >= shop.getProduct().getAmount()) {
|
||||||
buy(p, shop);
|
buy(p, shop);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.out_of_stock());
|
p.sendMessage(Config.out_of_stock());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
e.setCancelled(false);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
p.sendMessage(Config.noPermission_buy());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.noPermission_buy());
|
p.sendMessage(Config.buying_disabled());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.buying_disabled());
|
e.setCancelled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -190,24 +188,23 @@ public class InteractShop implements Listener {
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
Shop shop = ShopUtils.getShop(b.getLocation());
|
Shop shop = ShopUtils.getShop(b.getLocation());
|
||||||
|
|
||||||
if (shop.getSellPrice() > 0) {
|
if ((shop.getShopType() == ShopType.ADMIN) || (!shop.getVendor().getUniqueId().equals(p.getUniqueId()))) {
|
||||||
if (perm.has(p, "shopchest.sell")) {
|
if (shop.getSellPrice() > 0) {
|
||||||
if ((shop.getShopType() == ShopType.ADMIN) || (!shop.getVendor().getUniqueId().equals(p.getUniqueId()))) {
|
if (perm.has(p, "shopchest.sell")) {
|
||||||
if (Utils.getAmount(p.getInventory(), shop.getProduct()) >= shop.getProduct().getAmount()) {
|
if (Utils.getAmount(p.getInventory(), shop.getProduct()) >= shop.getProduct().getAmount()) {
|
||||||
sell(p, shop);
|
sell(p, shop);
|
||||||
} else {
|
|
||||||
p.sendMessage(Config.not_enough_items());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
e.setCancelled(false);
|
p.sendMessage(Config.not_enough_items());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
p.sendMessage(Config.noPermission_sell());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.noPermission_sell());
|
p.sendMessage(Config.selling_disabled());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.selling_disabled());
|
e.setCancelled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user