mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-26 04:12:22 +00:00
The creator of an admin shop should be able to use it
This commit is contained in:
parent
341f6b1fb0
commit
c4bc318a25
@ -147,35 +147,39 @@ 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 (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
if (perm.has(p, "shopchest.openOther")) {
|
if (perm.has(p, "shopchest.openOther")) {
|
||||||
p.sendMessage(Config.opened_shop(shop.getVendor().getName()));
|
p.sendMessage(Config.opened_shop(shop.getVendor().getName()));
|
||||||
e.setCancelled(false);
|
e.setCancelled(false);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.noPermission_openOthers());
|
p.sendMessage(Config.noPermission_openOthers());
|
||||||
e.setCancelled(true);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
e.setCancelled(false);
|
||||||
|
}
|
||||||
|
} 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) {
|
||||||
|
if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
buy(p, shop);
|
buy(p, shop);
|
||||||
} else {
|
} else {
|
||||||
|
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();
|
Chest c = (Chest) b.getState();
|
||||||
if (Utils.getAmount(c.getInventory(), shop.getProduct().clone().getType(), shop.getProduct().clone().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) {
|
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());
|
p.sendMessage(Config.out_of_stock());
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
e.setCancelled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.noPermission_buy());
|
p.sendMessage(Config.noPermission_buy());
|
||||||
@ -189,30 +193,42 @@ 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 (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);
|
||||||
|
} else {
|
||||||
|
if (!shop.getVendor().getUniqueId().equals(p.getUniqueId())) {
|
||||||
if (Utils.getAmount(p.getInventory(), shop.getProduct().getType(), shop.getProduct().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) {
|
if (Utils.getAmount(p.getInventory(), shop.getProduct().getType(), shop.getProduct().getDurability(), shop.getProduct().getItemMeta()) >= shop.getProduct().getAmount()) {
|
||||||
sell(p, shop);
|
sell(p, shop);
|
||||||
} else {
|
} else {
|
||||||
p.sendMessage(Config.not_enough_items());
|
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