Search in sources :

Example 1 with GuildBaseChangeEvent

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);
}
Also used : GuildBaseChangeEvent(net.dzikoysk.funnyguilds.event.guild.GuildBaseChangeEvent) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) Region(net.dzikoysk.funnyguilds.basic.Region) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) Location(org.bukkit.Location)

Aggregations

Guild (net.dzikoysk.funnyguilds.basic.Guild)1 Region (net.dzikoysk.funnyguilds.basic.Region)1 User (net.dzikoysk.funnyguilds.basic.User)1 MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)1 GuildBaseChangeEvent (net.dzikoysk.funnyguilds.event.guild.GuildBaseChangeEvent)1 Location (org.bukkit.Location)1 Player (org.bukkit.entity.Player)1