use of net.dzikoysk.funnyguilds.event.guild.GuildHeartAttackEvent in project FunnyGuilds by FunnyGuilds.
the class WarAttackRequest method execute.
@Override
public void execute() throws Exception {
for (Map.Entry<Guild, FakeEntity> entry : GuildEntityHelper.getGuildEntities().entrySet()) {
if (entry.getValue().getId() != entityId) {
continue;
}
Guild guild = entry.getKey();
Option<Player> playerOption = this.user.getPlayer();
if (playerOption.isEmpty()) {
return;
}
Player player = playerOption.get();
if (SecuritySystem.onHitCrystal(player, guild)) {
return;
}
if (!SimpleEventHandler.handle(new GuildHeartAttackEvent(EventCause.SYSTEM, user, guild))) {
return;
}
WarSystem.getInstance().attack(player, entry.getKey());
return;
}
}
use of net.dzikoysk.funnyguilds.event.guild.GuildHeartAttackEvent in project FunnyGuilds by FunnyGuilds.
the class PlayerInteract method onInteract.
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInteract(PlayerInteractEvent event) {
Action eventAction = event.getAction();
Player player = event.getPlayer();
Block clicked = event.getClickedBlock();
if (eventAction != Action.RIGHT_CLICK_BLOCK && eventAction != Action.LEFT_CLICK_BLOCK) {
return;
}
if (clicked == null) {
return;
}
Option<Region> regionOption = this.regionManager.findRegionAtLocation(clicked.getLocation());
if (regionOption.isEmpty()) {
return;
}
Region region = regionOption.get();
boolean returnMethod = region.getHeartBlock().filter(heart -> heart.equals(clicked)).peek(heart -> {
if (heart.getType() == Material.DRAGON_EGG) {
event.setCancelled(true);
}
Guild guild = region.getGuild();
if (SecuritySystem.onHitCrystal(player, guild)) {
return;
}
Option<User> userOption = this.userManager.findByPlayer(player);
if (userOption.isEmpty()) {
return;
}
User user = userOption.get();
if (!SimpleEventHandler.handle(new GuildHeartAttackEvent(EventCause.USER, user, guild))) {
return;
}
event.setCancelled(true);
if (eventAction == Action.LEFT_CLICK_BLOCK) {
WarSystem.getInstance().attack(player, guild);
return;
}
if (!config.informationMessageCooldowns.cooldown(player, TimeUnit.SECONDS, config.infoPlayerCooldown)) {
try {
infoExecutor.execute(player, new String[] { guild.getTag() });
} catch (ValidationException validatorException) {
validatorException.getValidationMessage().peek(message -> ChatUtils.sendMessage(player, message));
}
}
}).isPresent();
if (returnMethod) {
return;
}
if (eventAction == Action.RIGHT_CLICK_BLOCK) {
Guild guild = region.getGuild();
this.userManager.findByPlayer(player).peek(user -> {
boolean blocked = config.blockedInteract.contains(clicked.getType());
if (guild.getMembers().contains(user)) {
event.setCancelled(blocked && config.regionExplodeBlockInteractions && !guild.canBuild());
} else {
event.setCancelled(blocked && !player.hasPermission("funnyguilds.admin.interact"));
}
});
}
}
Aggregations