Search in sources :

Example 1 with ExcInfo

use of net.dzikoysk.funnyguilds.command.ExcInfo in project FunnyGuilds by FunnyGuilds.

the class PlayerInteract method onInteract.

@EventHandler
public void onInteract(PlayerInteractEvent event) {
    Action eventAction = event.getAction();
    Player p = event.getPlayer();
    if (eventAction == Action.RIGHT_CLICK_BLOCK || eventAction == Action.LEFT_CLICK_BLOCK) {
        Block clicked = event.getClickedBlock();
        if (RegionUtils.isIn(clicked.getLocation())) {
            Region region = RegionUtils.getAt(clicked.getLocation());
            Block heart = region.getCenter().getBlock().getRelative(BlockFace.DOWN);
            if (clicked.equals(heart)) {
                Guild g = region.getGuild();
                if (SecuritySystem.getSecurity().checkPlayer(p, g)) {
                    return;
                }
                if (eventAction == Action.LEFT_CLICK_BLOCK) {
                    WarSystem.getInstance().attack(p, g);
                    event.setCancelled(true);
                    return;
                } else if (eventAction == Action.RIGHT_CLICK_BLOCK) {
                    PluginConfig config = Settings.getConfig();
                    if (config.informationMessageCooldowns.cooldown(p, TimeUnit.SECONDS, config.infoPlayerCooldown)) {
                        return;
                    }
                    new ExcInfo().execute(p, new String[] { g.getTag() });
                    event.setCancelled(true);
                    return;
                }
            }
        }
    }
    if (ProtectionUtils.action(eventAction, event.getClickedBlock())) {
        event.setCancelled(false);
    }
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) Action(org.bukkit.event.block.Action) Player(org.bukkit.entity.Player) ExcInfo(net.dzikoysk.funnyguilds.command.ExcInfo) Block(org.bukkit.block.Block) Region(net.dzikoysk.funnyguilds.basic.Region) Guild(net.dzikoysk.funnyguilds.basic.Guild) EventHandler(org.bukkit.event.EventHandler)

Aggregations

Guild (net.dzikoysk.funnyguilds.basic.Guild)1 Region (net.dzikoysk.funnyguilds.basic.Region)1 ExcInfo (net.dzikoysk.funnyguilds.command.ExcInfo)1 PluginConfig (net.dzikoysk.funnyguilds.data.configs.PluginConfig)1 Block (org.bukkit.block.Block)1 Player (org.bukkit.entity.Player)1 EventHandler (org.bukkit.event.EventHandler)1 Action (org.bukkit.event.block.Action)1