mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-06-26 06:14:44 +02:00
This makes it possible for other plugins to force allow placing of shops and avoid potential issues in the check if multiple plugins are changing the allow settings. ALso while the allow counters were a nice idea they might not have even worked correctly because in the case of only one plugin disallowing it they would've still returned true at the end. Only if one listener allowed it and another disallowed it the end result would be disallow. This also makes the BuildPermissionEvent implement Cancellable (which is an inverted allowed) in order to easily ignore events that are already disallowed by another listener.
27 lines
851 B
Java
27 lines
851 B
Java
package com.Acrobot.ChestShop.Plugins;
|
|
|
|
import br.net.fabiozumbi12.RedProtect.Bukkit.RedProtect;
|
|
import br.net.fabiozumbi12.RedProtect.Bukkit.Region;
|
|
import com.Acrobot.ChestShop.Events.Protection.BuildPermissionEvent;
|
|
import me.ryanhamshire.GriefPrevention.GriefPrevention;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.plugin.Plugin;
|
|
|
|
/**
|
|
* @author Acrobot
|
|
*/
|
|
public class RedProtectBuilding implements Listener {
|
|
private RedProtect redProtect;
|
|
|
|
public RedProtectBuilding(Plugin plugin) {
|
|
this.redProtect = (RedProtect) plugin;
|
|
}
|
|
|
|
@EventHandler(ignoreCancelled = true)
|
|
public void canBuild(BuildPermissionEvent event) {
|
|
Region region = redProtect.getAPI().getRegion(event.getSign());
|
|
event.allow(region != null && region.canBuild(event.getPlayer()));
|
|
}
|
|
}
|