mirror of
https://github.com/Flowsqy/ShopChest.git
synced 2024-11-13 23:05:21 +01:00
Use WorldGuardWrapper to support v7 and v6
https://github.com/CodeMC/WorldGuardWrapper
This commit is contained in:
parent
11c6af099b
commit
f40b0b7418
Binary file not shown.
12
pom.xml
12
pom.xml
@ -113,6 +113,11 @@
|
||||
<version>16.6</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codemc.worldguardwrapper</groupId>
|
||||
<artifactId>worldguardwrapper</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.palmergames</groupId>
|
||||
<artifactId>Towny</artifactId>
|
||||
@ -127,13 +132,6 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/IslandWorld-7.0.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>6.1.3-SNAPSHOT</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/lib/worldguard-6.1.3-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.wiefferink</groupId>
|
||||
<artifactId>areashop</artifactId>
|
||||
|
@ -1,7 +1,6 @@
|
||||
package de.epiceric.shopchest;
|
||||
|
||||
import com.palmergames.bukkit.towny.Towny;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.wasteofplastic.askyblock.ASkyBlock;
|
||||
import de.epiceric.shopchest.command.ShopCommand;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
@ -44,6 +43,8 @@ import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.codemc.worldguardwrapper.WorldGuardWrapper;
|
||||
|
||||
import pl.islandworld.IslandWorld;
|
||||
import us.talabrek.ultimateskyblock.api.uSkyBlockAPI;
|
||||
|
||||
@ -73,7 +74,7 @@ public class ShopChest extends JavaPlugin {
|
||||
private String downloadLink = "";
|
||||
private ShopUtils shopUtils;
|
||||
private FileWriter fw;
|
||||
private WorldGuardPlugin worldGuard;
|
||||
private Plugin worldGuard;
|
||||
private Towny towny;
|
||||
private AuthMe authMe;
|
||||
private uSkyBlockAPI uSkyBlock;
|
||||
@ -129,9 +130,8 @@ public class ShopChest extends JavaPlugin {
|
||||
|
||||
debug("Loading ShopChest version " + getDescription().getVersion());
|
||||
|
||||
Plugin worldGuardPlugin = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (worldGuardPlugin instanceof WorldGuardPlugin) {
|
||||
worldGuard = (WorldGuardPlugin) worldGuardPlugin;
|
||||
worldGuard = Bukkit.getServer().getPluginManager().getPlugin("WorldGuard");
|
||||
if (worldGuard != null) {
|
||||
WorldGuardShopFlag.register(this);
|
||||
}
|
||||
}
|
||||
@ -273,6 +273,10 @@ public class ShopChest extends JavaPlugin {
|
||||
areaShop = (AreaShop) areaShopPlugin;
|
||||
}
|
||||
|
||||
if (hasWorldGuard()) {
|
||||
WorldGuardWrapper.getInstance().registerEvents(this);
|
||||
}
|
||||
|
||||
if (hasPlotSquared()) {
|
||||
new PlotSquaredShopFlag().register(this);
|
||||
}
|
||||
@ -369,7 +373,7 @@ public class ShopChest extends JavaPlugin {
|
||||
getServer().getPluginManager().registerEvents(new ShopItemListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new ShopInteractListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new NotifyPlayerOnJoinListener(this), this);
|
||||
getServer().getPluginManager().registerEvents(new ChestProtectListener(this, worldGuard), this);
|
||||
getServer().getPluginManager().registerEvents(new ChestProtectListener(this), this);
|
||||
|
||||
if (!Utils.getServerVersion().equals("v1_8_R1")) {
|
||||
getServer().getPluginManager().registerEvents(new BlockExplodeListener(this), this);
|
||||
@ -527,13 +531,6 @@ public class ShopChest extends JavaPlugin {
|
||||
return worldGuard != null && worldGuard.isEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return An instance of {@link WorldGuardPlugin} or {@code null} if WorldGuard is not enabled
|
||||
*/
|
||||
public WorldGuardPlugin getWorldGuard() {
|
||||
return worldGuard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ShopChest's {@link ShopUtils} containing some important methods
|
||||
*/
|
||||
|
@ -1,29 +1,18 @@
|
||||
package de.epiceric.shopchest.external;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.sk89q.worldguard.protection.flags.Flag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import org.codemc.worldguardwrapper.WorldGuardWrapper;
|
||||
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
|
||||
public class WorldGuardShopFlag {
|
||||
|
||||
private static Flag<?>[] customFlagList;
|
||||
|
||||
public static final StateFlag CREATE_SHOP;
|
||||
public static final StateFlag USE_SHOP;
|
||||
public static final StateFlag USE_ADMIN_SHOP;
|
||||
|
||||
static {
|
||||
CREATE_SHOP = new StateFlag("create-shop", Config.wgAllowCreateShopDefault);
|
||||
USE_SHOP = new StateFlag("use-shop", Config.wgAllowUseShopDefault);
|
||||
USE_ADMIN_SHOP = new StateFlag("use-admin-shop", Config.wgAllowUseAdminShopDefault);
|
||||
|
||||
customFlagList = new Flag[] {CREATE_SHOP, USE_SHOP, USE_ADMIN_SHOP};
|
||||
}
|
||||
|
||||
public static void register(final ShopChest plugin) {
|
||||
plugin.getWorldGuard().getFlagRegistry().registerAll(Lists.newArrayList(customFlagList));
|
||||
WorldGuardWrapper wrapper = WorldGuardWrapper.getInstance();
|
||||
|
||||
plugin.debug("Flag create-shop: " + wrapper.registerStateFlag("create-shop", Config.wgAllowCreateShopDefault));
|
||||
plugin.debug("Flag use-shop: " + wrapper.registerStateFlag("use-shop", Config.wgAllowUseShopDefault));
|
||||
plugin.debug("Flag use-admin-shop: " + wrapper.registerStateFlag("use-admin-shop", Config.wgAllowUseAdminShopDefault));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,5 @@
|
||||
package de.epiceric.shopchest.listeners;
|
||||
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.shop.Shop;
|
||||
@ -12,6 +10,8 @@ import me.wiefferink.areashop.events.notify.UnrentedRegionEvent;
|
||||
import me.wiefferink.areashop.regions.GeneralRegion;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.codemc.worldguardwrapper.WorldGuardWrapper;
|
||||
import org.codemc.worldguardwrapper.implementation.AbstractRegion;
|
||||
|
||||
public class AreaShopListener implements Listener {
|
||||
|
||||
@ -52,12 +52,10 @@ public class AreaShopListener implements Listener {
|
||||
private void removeShopsInRegion(GeneralRegion generalRegion) {
|
||||
if (!plugin.hasWorldGuard()) return;
|
||||
|
||||
RegionManager regionManager = plugin.getWorldGuard().getRegionManager(generalRegion.getWorld());
|
||||
|
||||
for (Shop shop : plugin.getShopUtils().getShops()) {
|
||||
if (!shop.getLocation().getWorld().getName().equals(generalRegion.getWorldName())) continue;
|
||||
|
||||
for (ProtectedRegion r : regionManager.getApplicableRegions(shop.getLocation())) {
|
||||
for (AbstractRegion r : WorldGuardWrapper.getInstance().getRegions(shop.getLocation())) {
|
||||
if (generalRegion.getLowerCaseName().equals(r.getId())) {
|
||||
plugin.getShopUtils().removeShop(shop, true);
|
||||
break;
|
||||
|
@ -4,15 +4,11 @@ import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
import com.sk89q.worldguard.bukkit.RegionContainer;
|
||||
import com.sk89q.worldguard.bukkit.RegionQuery;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
import com.wasteofplastic.askyblock.Island;
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
|
||||
import de.epiceric.shopchest.external.WorldGuardShopFlag;
|
||||
import de.epiceric.shopchest.language.LanguageUtils;
|
||||
import de.epiceric.shopchest.language.Message;
|
||||
import de.epiceric.shopchest.nms.Hologram;
|
||||
@ -41,6 +37,7 @@ import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryMoveItemEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.codemc.worldguardwrapper.WorldGuardWrapper;
|
||||
|
||||
import pl.islandworld.api.IslandWorldApi;
|
||||
import us.talabrek.ultimateskyblock.api.IslandInfo;
|
||||
@ -51,12 +48,10 @@ public class ChestProtectListener implements Listener {
|
||||
|
||||
private ShopChest plugin;
|
||||
private ShopUtils shopUtils;
|
||||
private WorldGuardPlugin worldGuard;
|
||||
|
||||
public ChestProtectListener(ShopChest plugin, WorldGuardPlugin worldGuard) {
|
||||
public ChestProtectListener(ShopChest plugin) {
|
||||
this.plugin = plugin;
|
||||
this.shopUtils = plugin.getShopUtils();
|
||||
this.worldGuard = worldGuard;
|
||||
}
|
||||
|
||||
private void remove(final Shop shop, final Block b, final Player p) {
|
||||
@ -191,9 +186,7 @@ public class ChestProtectListener implements Listener {
|
||||
boolean externalPluginsAllowed = true;
|
||||
|
||||
if (plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
||||
RegionContainer container = worldGuard.getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
externalPluginsAllowed = query.testState(b.getLocation(), p, WorldGuardShopFlag.CREATE_SHOP);
|
||||
externalPluginsAllowed = WorldGuardWrapper.getInstance().queryStateFlag(p, b.getLocation(), "create-shop").orElse(false);
|
||||
}
|
||||
|
||||
if (externalPluginsAllowed && plugin.hasTowny() && Config.enableTownyIntegration) {
|
||||
|
@ -7,10 +7,6 @@ import com.palmergames.bukkit.towny.object.Resident;
|
||||
import com.palmergames.bukkit.towny.object.Town;
|
||||
import com.palmergames.bukkit.towny.object.TownBlock;
|
||||
import com.palmergames.bukkit.towny.object.TownyUniverse;
|
||||
import com.sk89q.worldguard.bukkit.RegionContainer;
|
||||
import com.sk89q.worldguard.bukkit.RegionQuery;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.wasteofplastic.askyblock.ASkyBlockAPI;
|
||||
import com.wasteofplastic.askyblock.Island;
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
@ -22,7 +18,6 @@ import de.epiceric.shopchest.event.ShopInfoEvent;
|
||||
import de.epiceric.shopchest.event.ShopOpenEvent;
|
||||
import de.epiceric.shopchest.event.ShopRemoveEvent;
|
||||
import de.epiceric.shopchest.external.PlotSquaredShopFlag;
|
||||
import de.epiceric.shopchest.external.WorldGuardShopFlag;
|
||||
import de.epiceric.shopchest.language.LanguageUtils;
|
||||
import de.epiceric.shopchest.language.Message;
|
||||
import de.epiceric.shopchest.language.Replacement;
|
||||
@ -66,6 +61,8 @@ import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.codemc.worldguardwrapper.WorldGuardWrapper;
|
||||
|
||||
import pl.islandworld.api.IslandWorldApi;
|
||||
import us.talabrek.ultimateskyblock.api.IslandInfo;
|
||||
|
||||
@ -86,14 +83,12 @@ public class ShopInteractListener implements Listener {
|
||||
private Economy econ;
|
||||
private Database database;
|
||||
private ShopUtils shopUtils;
|
||||
private WorldGuardPlugin worldGuard;
|
||||
|
||||
public ShopInteractListener(ShopChest plugin) {
|
||||
this.plugin = plugin;
|
||||
this.econ = plugin.getEconomy();
|
||||
this.database = plugin.getShopDatabase();
|
||||
this.shopUtils = plugin.getShopUtils();
|
||||
this.worldGuard = plugin.getWorldGuard();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
@ -163,12 +158,10 @@ public class ShopInteractListener implements Listener {
|
||||
|
||||
if (plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
||||
plugin.debug("Checking if WorldGuard allows shop creation...");
|
||||
RegionContainer container = worldGuard.getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
|
||||
for (Location loc : chestLocations) {
|
||||
if (loc != null) {
|
||||
externalPluginsAllowed &= query.testState(loc, p, WorldGuardShopFlag.CREATE_SHOP);
|
||||
externalPluginsAllowed &= WorldGuardWrapper.getInstance().queryStateFlag(p, loc, "create-shop").orElse(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -463,10 +456,8 @@ public class ShopInteractListener implements Listener {
|
||||
}
|
||||
|
||||
if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
||||
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
|
||||
RegionContainer container = worldGuard.getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
externalPluginsAllowed = query.testState(b.getLocation(), p, flag);
|
||||
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
|
||||
externalPluginsAllowed = WorldGuardWrapper.getInstance().queryStateFlag(p, b.getLocation(), flagName).orElse(false);
|
||||
}
|
||||
|
||||
if (shop.getShopType() == ShopType.ADMIN) {
|
||||
@ -574,11 +565,8 @@ public class ShopInteractListener implements Listener {
|
||||
}
|
||||
|
||||
if (externalPluginsAllowed && plugin.hasWorldGuard() && Config.enableWorldGuardIntegration) {
|
||||
RegionContainer container = worldGuard.getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
|
||||
StateFlag flag = (shop.getShopType() == ShopType.ADMIN ? WorldGuardShopFlag.USE_ADMIN_SHOP : WorldGuardShopFlag.USE_SHOP);
|
||||
externalPluginsAllowed = query.testState(b.getLocation(), p, flag);
|
||||
String flagName = (shop.getShopType() == ShopType.ADMIN ? "use-admin-shop" : "use-shop");
|
||||
externalPluginsAllowed = WorldGuardWrapper.getInstance().queryStateFlag(p, b.getLocation(), flagName).orElse(false);
|
||||
}
|
||||
|
||||
if (externalPluginsAllowed || p.hasPermission(Permissions.BYPASS_EXTERNAL_PLUGIN)) {
|
||||
|
@ -1,20 +1,10 @@
|
||||
package de.epiceric.shopchest.listeners;
|
||||
|
||||
import com.sk89q.worldguard.LocalPlayer;
|
||||
import com.sk89q.worldguard.bukkit.RegionContainer;
|
||||
import com.sk89q.worldguard.bukkit.RegionQuery;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.bukkit.event.block.UseBlockEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.DamageEntityEvent;
|
||||
import com.sk89q.worldguard.bukkit.event.entity.UseEntityEvent;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import de.epiceric.shopchest.ShopChest;
|
||||
import de.epiceric.shopchest.config.Config;
|
||||
import de.epiceric.shopchest.nms.Hologram;
|
||||
import de.epiceric.shopchest.shop.Shop;
|
||||
import de.epiceric.shopchest.utils.ClickType;
|
||||
import de.epiceric.shopchest.utils.Permissions;
|
||||
import de.epiceric.shopchest.external.WorldGuardShopFlag;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Chest;
|
||||
@ -25,27 +15,27 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.Event.Result;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.inventory.InventoryOpenEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.codemc.worldguardwrapper.WorldGuardWrapper;
|
||||
import org.codemc.worldguardwrapper.event.DamageEntityEvent;
|
||||
import org.codemc.worldguardwrapper.event.UseBlockEvent;
|
||||
import org.codemc.worldguardwrapper.event.UseEntityEvent;
|
||||
|
||||
public class WorldGuardListener implements Listener {
|
||||
|
||||
private ShopChest plugin;
|
||||
private WorldGuardPlugin worldGuard;
|
||||
|
||||
public WorldGuardListener(ShopChest plugin) {
|
||||
this.plugin = plugin;
|
||||
this.worldGuard = plugin.getWorldGuard();
|
||||
}
|
||||
|
||||
|
||||
private boolean isAllowed(Player player, Location location, Action action) {
|
||||
LocalPlayer localPlayer = worldGuard.wrapPlayer(player);
|
||||
RegionContainer container = worldGuard.getRegionContainer();
|
||||
RegionQuery query = container.createQuery();
|
||||
Shop shop = plugin.getShopUtils().getShop(location);
|
||||
|
||||
if (action == Action.RIGHT_CLICK_BLOCK && shop != null) {
|
||||
@ -57,7 +47,7 @@ public class WorldGuardListener implements Listener {
|
||||
if (ClickType.getPlayerClickType(player) != null) {
|
||||
switch (ClickType.getPlayerClickType(player).getClickType()) {
|
||||
case CREATE:
|
||||
return query.testState(location, localPlayer, WorldGuardShopFlag.CREATE_SHOP);
|
||||
return WorldGuardWrapper.getInstance().queryStateFlag(player, location, "create-shop").orElse(false);
|
||||
case REMOVE:
|
||||
case INFO:
|
||||
case OPEN:
|
||||
@ -65,9 +55,8 @@ public class WorldGuardListener implements Listener {
|
||||
}
|
||||
} else {
|
||||
if (shop != null) {
|
||||
StateFlag flag = (shop.getShopType() == Shop.ShopType.NORMAL ? WorldGuardShopFlag.USE_SHOP : WorldGuardShopFlag.USE_ADMIN_SHOP);
|
||||
|
||||
return query.testState(location, localPlayer, flag);
|
||||
String flagName = (shop.getShopType() == Shop.ShopType.NORMAL ? "use-shop" : "use-admin-shop");
|
||||
return WorldGuardWrapper.getInstance().queryStateFlag(player, location, flagName).orElse(false);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,8 +66,7 @@ public class WorldGuardListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onUseEntity(UseEntityEvent event) {
|
||||
if (Config.enableWorldGuardIntegration) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
if (player == null) return;
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getOriginalEvent() instanceof PlayerInteractAtEntityEvent) {
|
||||
PlayerInteractAtEntityEvent orig = (PlayerInteractAtEntityEvent) event.getOriginalEvent();
|
||||
@ -91,7 +79,7 @@ public class WorldGuardListener implements Listener {
|
||||
for (Shop shop : plugin.getShopUtils().getShops()) {
|
||||
if (shop.getHologram() != null && shop.getHologram().contains((ArmorStand) e)) {
|
||||
if (isAllowed(player, shop.getLocation(), Action.RIGHT_CLICK_BLOCK)) {
|
||||
event.setAllowed(true);
|
||||
event.setResult(Result.ALLOW);
|
||||
orig.setCancelled(false);
|
||||
}
|
||||
|
||||
@ -106,8 +94,7 @@ public class WorldGuardListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onDamageEntity(DamageEntityEvent event) {
|
||||
if (Config.enableWorldGuardIntegration) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
if (player == null) return;
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getOriginalEvent() instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent orig = (EntityDamageByEntityEvent) event.getOriginalEvent();
|
||||
@ -120,7 +107,7 @@ public class WorldGuardListener implements Listener {
|
||||
for (Shop shop : plugin.getShopUtils().getShops()) {
|
||||
if (shop.getHologram() != null && shop.getHologram().contains((ArmorStand) e)) {
|
||||
if (isAllowed(player, shop.getLocation(), Action.LEFT_CLICK_BLOCK)) {
|
||||
event.setAllowed(true);
|
||||
event.setResult(Result.ALLOW);
|
||||
orig.setCancelled(false);
|
||||
}
|
||||
|
||||
@ -135,8 +122,7 @@ public class WorldGuardListener implements Listener {
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onUseBlock(UseBlockEvent event) {
|
||||
if (Config.enableWorldGuardIntegration) {
|
||||
Player player = event.getCause().getFirstPlayer();
|
||||
if (player == null) return;
|
||||
Player player = event.getPlayer();
|
||||
|
||||
if (event.getOriginalEvent() instanceof PlayerInteractEvent) {
|
||||
PlayerInteractEvent orig = (PlayerInteractEvent) event.getOriginalEvent();
|
||||
@ -145,7 +131,7 @@ public class WorldGuardListener implements Listener {
|
||||
Material type = orig.getClickedBlock().getType();
|
||||
if (type == Material.CHEST || type == Material.TRAPPED_CHEST) {
|
||||
if (isAllowed(player, orig.getClickedBlock().getLocation(), orig.getAction())) {
|
||||
event.setAllowed(true);
|
||||
event.setResult(Result.ALLOW);
|
||||
|
||||
ClickType ct = ClickType.getPlayerClickType(player);
|
||||
if (!(ct != null && ct.getClickType() == ClickType.EnumClickType.CREATE)) {
|
||||
@ -161,7 +147,7 @@ public class WorldGuardListener implements Listener {
|
||||
|
||||
if (orig.getInventory().getHolder() instanceof Chest) {
|
||||
if (isAllowed(player, ((Chest)orig.getInventory().getHolder()).getLocation(), Action.RIGHT_CLICK_BLOCK)) {
|
||||
event.setAllowed(true);
|
||||
event.setResult(Result.ALLOW);
|
||||
|
||||
ClickType ct = ClickType.getPlayerClickType(player);
|
||||
if (!(ct != null && ct.getClickType() == ClickType.EnumClickType.CREATE)) {
|
||||
|
Loading…
Reference in New Issue
Block a user