mirror of
https://github.com/amalthea-mc/ShopChest.git
synced 2024-11-22 18:32:24 +00:00
Shortened method to check WorldGuard permission
This commit is contained in:
parent
8217cdef6f
commit
f54c2ff7ff
@ -45,40 +45,28 @@ public class WorldGuardListener implements Listener {
|
|||||||
LocalPlayer localPlayer = worldGuard.wrapPlayer(player);
|
LocalPlayer localPlayer = worldGuard.wrapPlayer(player);
|
||||||
RegionContainer container = worldGuard.getRegionContainer();
|
RegionContainer container = worldGuard.getRegionContainer();
|
||||||
RegionQuery query = container.createQuery();
|
RegionQuery query = container.createQuery();
|
||||||
|
Shop shop = plugin.getShopUtils().getShop(location);
|
||||||
|
|
||||||
if (action == Action.RIGHT_CLICK_BLOCK) {
|
if (action == Action.RIGHT_CLICK_BLOCK && shop != null) {
|
||||||
|
if (shop.getVendor().getUniqueId().equals(player.getUniqueId()) && shop.getShopType() != Shop.ShopType.ADMIN) {
|
||||||
if (ClickType.getPlayerClickType(player) != null) {
|
return true;
|
||||||
|
|
||||||
switch (ClickType.getPlayerClickType(player).getClickType()) {
|
|
||||||
|
|
||||||
case CREATE:
|
|
||||||
return query.testState(location, localPlayer, ShopFlag.CREATE_SHOP);
|
|
||||||
case REMOVE:
|
|
||||||
case INFO:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (plugin.getShopUtils().isShop(location)) {
|
|
||||||
Shop shop = plugin.getShopUtils().getShop(location);
|
|
||||||
|
|
||||||
if (shop.getVendor().getUniqueId().equals(player.getUniqueId()) && shop.getShopType() != Shop.ShopType.ADMIN) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!shop.getVendor().getUniqueId().equals(player.getUniqueId()) && player.isSneaking()) {
|
|
||||||
return player.hasPermission(Permissions.OPEN_OTHER);
|
|
||||||
}
|
|
||||||
|
|
||||||
StateFlag flag = (shop.getShopType() == Shop.ShopType.NORMAL ? ShopFlag.USE_SHOP : ShopFlag.USE_ADMIN_SHOP);
|
|
||||||
|
|
||||||
return query.testState(location, localPlayer, flag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (action == Action.LEFT_CLICK_BLOCK) {
|
|
||||||
if (plugin.getShopUtils().isShop(location)) {
|
|
||||||
Shop shop = plugin.getShopUtils().getShop(location);
|
|
||||||
|
|
||||||
|
if (!shop.getVendor().getUniqueId().equals(player.getUniqueId()) && player.isSneaking()) {
|
||||||
|
return player.hasPermission(Permissions.OPEN_OTHER);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ClickType.getPlayerClickType(player) != null) {
|
||||||
|
switch (ClickType.getPlayerClickType(player).getClickType()) {
|
||||||
|
case CREATE:
|
||||||
|
return query.testState(location, localPlayer, ShopFlag.CREATE_SHOP);
|
||||||
|
case REMOVE:
|
||||||
|
case INFO:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (shop != null) {
|
||||||
StateFlag flag = (shop.getShopType() == Shop.ShopType.NORMAL ? ShopFlag.USE_SHOP : ShopFlag.USE_ADMIN_SHOP);
|
StateFlag flag = (shop.getShopType() == Shop.ShopType.NORMAL ? ShopFlag.USE_SHOP : ShopFlag.USE_ADMIN_SHOP);
|
||||||
|
|
||||||
return query.testState(location, localPlayer, flag);
|
return query.testState(location, localPlayer, flag);
|
||||||
@ -131,7 +119,7 @@ public class WorldGuardListener implements Listener {
|
|||||||
if (e.getType() == EntityType.ARMOR_STAND) {
|
if (e.getType() == EntityType.ARMOR_STAND) {
|
||||||
for (Shop shop : plugin.getShopUtils().getShops()) {
|
for (Shop shop : plugin.getShopUtils().getShops()) {
|
||||||
if (shop.getHologram().contains((ArmorStand) e)) {
|
if (shop.getHologram().contains((ArmorStand) e)) {
|
||||||
if (isAllowed(player, shop.getLocation(), Action.RIGHT_CLICK_BLOCK)) {
|
if (isAllowed(player, shop.getLocation(), Action.LEFT_CLICK_BLOCK)) {
|
||||||
event.setAllowed(true);
|
event.setAllowed(true);
|
||||||
orig.setCancelled(false);
|
orig.setCancelled(false);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user