Search in sources :

Example 46 with User

use of net.dzikoysk.funnyguilds.basic.User 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)

Example 47 with User

use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.

the class MxcPvP method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    Player player = (Player) sender;
    User user = User.get(player);
    if (!user.hasGuild()) {
        player.sendMessage(messages.generalHasNoGuild);
        return;
    }
    if (!user.isOwner() && !user.isDeputy()) {
        player.sendMessage(messages.generalIsNotOwner);
        return;
    }
    Guild guild = user.getGuild();
    if (guild.getPvP()) {
        guild.setPvP(false);
        player.sendMessage(messages.pvpOff);
    } else {
        guild.setPvP(true);
        player.sendMessage(messages.pvpOn);
    }
}
Also used : Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild)

Example 48 with User

use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.

the class AxcDeaths method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    if (args.length < 1) {
        sender.sendMessage(messages.generalNoNickGiven);
        return;
    }
    if (!UserUtils.playedBefore(args[0])) {
        sender.sendMessage(messages.generalNotPlayedBefore);
        return;
    }
    if (args.length < 2) {
        sender.sendMessage(messages.adminNoDeathsGiven);
        return;
    }
    int deaths;
    try {
        deaths = Integer.valueOf(args[1]);
    } catch (NumberFormatException e) {
        sender.sendMessage(messages.adminErrorInNumber.replace("{ERROR}", args[1]));
        return;
    }
    User user = User.get(args[0]);
    Rank userRank = user.getRank();
    int change = deaths - userRank.getDeaths();
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new DeathsChangeEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, userRank, admin, change))) {
        return;
    }
    userRank.setDeaths(deaths);
    sender.sendMessage(messages.adminDeathsChanged.replace("{PLAYER}", user.getName()).replace("{DEATHS}", Integer.toString(deaths)));
}
Also used : Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) Rank(net.dzikoysk.funnyguilds.basic.Rank) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) DeathsChangeEvent(net.dzikoysk.funnyguilds.event.rank.DeathsChangeEvent)

Example 49 with User

use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.

the class AxcDelete method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    if (args.length < 1) {
        sender.sendMessage(messages.generalNoTagGiven);
        return;
    }
    Guild guild = GuildUtils.getByTag(args[0]);
    if (guild == null) {
        sender.sendMessage(messages.generalNoGuildFound);
        return;
    }
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new GuildDeleteEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild))) {
        return;
    }
    GuildUtils.deleteGuild(guild);
    Player owner = guild.getOwner().getPlayer();
    MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{ADMIN}", sender.getName()).register("{PLAYER}", sender.getName());
    if (owner != null) {
        owner.sendMessage(translator.translate(messages.adminGuildBroken));
    }
    sender.sendMessage(translator.translate(messages.deleteSuccessful));
    Bukkit.getServer().broadcastMessage(translator.translate(messages.broadcastDelete));
}
Also used : GuildDeleteEvent(net.dzikoysk.funnyguilds.event.guild.GuildDeleteEvent) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator)

Example 50 with User

use of net.dzikoysk.funnyguilds.basic.User in project FunnyGuilds by FunnyGuilds.

the class AxcLeader method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    if (args.length < 1) {
        sender.sendMessage(messages.generalNoTagGiven);
        return;
    }
    Guild guild = GuildUtils.getByTag(args[0]);
    if (guild == null) {
        sender.sendMessage(messages.generalNoGuildFound);
        return;
    }
    if (args.length < 2) {
        sender.sendMessage(messages.generalNoNickGiven);
        return;
    }
    if (!UserUtils.playedBefore(args[1])) {
        sender.sendMessage(messages.generalNotPlayedBefore);
        return;
    }
    User user = User.get(args[1]);
    if (!guild.getMembers().contains(user)) {
        sender.sendMessage(messages.adminUserNotMemberOf);
        return;
    }
    if (guild.getOwner().equals(user)) {
        sender.sendMessage(messages.adminAlreadyLeader);
        return;
    }
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new GuildMemberLeaderEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
        return;
    }
    Player leaderPlayer = user.getPlayer();
    guild.setOwner(user);
    sender.sendMessage(messages.leaderSet);
    if (leaderPlayer != null) {
        leaderPlayer.sendMessage(messages.leaderOwner);
    }
    String message = messages.leaderMembers.replace("{PLAYER}", user.getName());
    for (User member : guild.getOnlineMembers()) {
        member.getPlayer().sendMessage(message);
    }
}
Also used : Player(org.bukkit.entity.Player) GuildMemberLeaderEvent(net.dzikoysk.funnyguilds.event.guild.member.GuildMemberLeaderEvent) User(net.dzikoysk.funnyguilds.basic.User) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild)

Aggregations

User (net.dzikoysk.funnyguilds.basic.User)66 Player (org.bukkit.entity.Player)50 Guild (net.dzikoysk.funnyguilds.basic.Guild)43 MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)39 PluginConfig (net.dzikoysk.funnyguilds.data.configs.PluginConfig)25 Region (net.dzikoysk.funnyguilds.basic.Region)13 MessageTranslator (net.dzikoysk.funnyguilds.data.util.MessageTranslator)12 ConcurrencyManager (net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager)11 EventHandler (org.bukkit.event.EventHandler)10 Location (org.bukkit.Location)8 ItemStack (org.bukkit.inventory.ItemStack)6 ArrayList (java.util.ArrayList)5 Rank (net.dzikoysk.funnyguilds.basic.Rank)5 PrefixGlobalUpdatePlayer (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer)4 Date (java.util.Date)3 ConcurrencyTask (net.dzikoysk.funnyguilds.concurrency.ConcurrencyTask)3 ConcurrencyTaskBuilder (net.dzikoysk.funnyguilds.concurrency.ConcurrencyTaskBuilder)3 PrefixGlobalAddPlayerRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddPlayerRequest)3 PrefixGlobalRemovePlayerRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalRemovePlayerRequest)3 GuildDeleteEvent (net.dzikoysk.funnyguilds.event.guild.GuildDeleteEvent)3