mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 18:32:24 +00:00
The creator of an admin shop should be able to use it
This commit is contained in:
parent
341f6b1fb0
commit
c4bc318a25
@ -147,34 +147,38 @@ public class InteractShop implements Listener{
|
|||||||
e.setCancelled(true);
|
e.setCancelled(true);
|
||||||
Shop shop = ShopUtils.getShop(b.getLocation());
|
Shop shop = ShopUtils.getShop(b.getLocation());
|
||||||
|
|
||||||
if (p.getUniqueId().equals(shop.getVendor().getUniqueId())) {
|
|
||||||
e.setCancelled(false);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (p.isSneaking()) {
|
if (p.isSneaking()) {
|
||||||
if (perm.has(p, "shopchest.openOther")) {
|
if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
p.sendMessage(Config.opened_shop(shop.getVendor().getName()));
|
if (perm.has(p, "shopchest.openOther")) {
|
||||||
e.setCancelled(false);
|
p.sendMessage(Config.opened_shop(shop.getVendor().getName()));
|
||||||
|
e.setCancelled(false);
|
||||||
|
} else {
|
||||||
|
p.sendMessage(Config.noPermission_openOthers());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.noPermission_openOthers());
|
e.setCancelled(false);
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (shop.getBuyPrice() > 0) {
|
if (shop.getBuyPrice() > 0) {
|
||||||
e.setCancelled(true);
|
|
||||||
|
|
||||||
if (perm.has(p, "shopchest.buy")) {
|
if (perm.has(p, "shopchest.buy")) {
|
||||||
if (shop.getShopType() == ShopType.INFINITE || shop.getShopType() == ShopType.ADMIN) {
|
if (shop.getShopType() == ShopType.INFINITE) {
|
||||||
buy(p, shop);
|
if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
} else {
|
|
||||||
Chest c = (Chest) b.getState();
|
|
||||||
if (Utils.getAmount(c.getInventory(), shop.getProduct().clone().getType(), shop.getProduct().clone().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) {
|
|
||||||
buy(p, shop);
|
buy(p, shop);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.out_of_stock());
|
e.setCancelled(false);
|
||||||
|
}
|
||||||
|
} else if (shop.getShopType() == ShopType.ADMIN) {
|
||||||
|
buy(p, shop);
|
||||||
|
} else {
|
||||||
|
if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
|
Chest c = (Chest) b.getState();
|
||||||
|
if (Utils.getAmount(c.getInventory(), shop.getProduct().clone().getType(), shop.getProduct().clone().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) {
|
||||||
|
buy(p, shop);
|
||||||
|
} else {
|
||||||
|
p.sendMessage(Config.out_of_stock());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
e.setCancelled(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -185,8 +189,6 @@ public class InteractShop implements Listener{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -196,23 +198,37 @@ public class InteractShop implements Listener{
|
|||||||
} else if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
|
} else if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
|
||||||
|
|
||||||
if (ShopUtils.isShop(b.getLocation())) {
|
if (ShopUtils.isShop(b.getLocation())) {
|
||||||
|
e.setCancelled(true);
|
||||||
Shop shop = ShopUtils.getShop(b.getLocation());
|
Shop shop = ShopUtils.getShop(b.getLocation());
|
||||||
|
|
||||||
if (!p.getUniqueId().equals(shop.getVendor().getUniqueId())) {
|
|
||||||
if (shop.getSellPrice() > 0) {
|
if (shop.getSellPrice() > 0) {
|
||||||
if (perm.has(p, "shopchest.sell")) {
|
if (perm.has(p, "shopchest.sell")) {
|
||||||
if (Utils.getAmount(p.getInventory(), shop.getProduct().getType(), shop.getProduct().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) {
|
if (shop.getShopType() == ShopType.INFINITE) {
|
||||||
|
if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
|
sell(p, shop);
|
||||||
|
} else {
|
||||||
|
e.setCancelled(false);
|
||||||
|
}
|
||||||
|
} else if (shop.getShopType() == ShopType.ADMIN) {
|
||||||
sell(p, shop);
|
sell(p, shop);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.not_enough_items());
|
if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
|
if (Utils.getAmount(p.getInventory(), shop.getProduct().getType(), shop.getProduct().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) {
|
||||||
|
sell(p, shop);
|
||||||
|
} else {
|
||||||
|
p.sendMessage(Config.not_enough_items());
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
e.setCancelled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.noPermission_sell());
|
p.sendMessage(Config.noPermission_sell());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.selling_disabled());
|
p.sendMessage(Config.selling_disabled());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user