use of net.dzikoysk.funnyguilds.event.guild.GuildBaseChangeEvent in project FunnyGuilds by FunnyGuilds.
the class MxcBase method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
Player player = (Player) sender;
User user = User.get(player);
if (!Settings.getConfig().regionsEnabled) {
player.sendMessage(messages.regionsDisabled);
return;
}
if (!user.hasGuild()) {
player.sendMessage(messages.generalHasNoGuild);
return;
}
if (!user.isOwner() && !user.isDeputy()) {
player.sendMessage(messages.generalIsNotOwner);
return;
}
Guild guild = user.getGuild();
Region region = RegionUtils.get(guild.getName());
Location loc = player.getLocation();
if (!region.isIn(loc)) {
player.sendMessage(messages.setbaseOutside);
return;
}
if (!SimpleEventHandler.handle(new GuildBaseChangeEvent(EventCause.USER, user, guild, loc))) {
return;
}
guild.setHome(loc);
if (guild.getHome().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
for (int i = guild.getHome().getBlockY(); i > 0; i--) {
guild.getHome().setY(i);
if (guild.getHome().getBlock().getType() != Material.AIR) {
break;
}
}
}
player.sendMessage(messages.setbaseDone);
}
Aggregations