Search in sources :

Example 1 with MessageTranslator

use of net.dzikoysk.funnyguilds.data.util.MessageTranslator in project FunnyGuilds by FunnyGuilds.

the class ExcLeave 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()) {
        player.sendMessage(messages.leaveIsOwner);
        return;
    }
    Guild guild = user.getGuild();
    if (!SimpleEventHandler.handle(new GuildMemberLeaveEvent(EventCause.USER, user, guild, user))) {
        return;
    }
    guild.removeMember(user);
    user.removeGuild();
    // IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_PLAYER, user.getName());
    // IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
    ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
    concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(user.getName()), new PrefixGlobalUpdatePlayer(player));
    MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", user.getName());
    player.sendMessage(translator.translate(messages.leaveToUser));
    Bukkit.broadcastMessage(translator.translate(messages.broadcastLeave));
}
Also used : PrefixGlobalUpdatePlayer(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer) Player(org.bukkit.entity.Player) PrefixGlobalUpdatePlayer(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer) User(net.dzikoysk.funnyguilds.basic.User) ConcurrencyManager(net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager) PrefixGlobalRemovePlayerRequest(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalRemovePlayerRequest) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) GuildMemberLeaveEvent(net.dzikoysk.funnyguilds.event.guild.member.GuildMemberLeaveEvent) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator)

Example 2 with MessageTranslator

use of net.dzikoysk.funnyguilds.data.util.MessageTranslator in project FunnyGuilds by FunnyGuilds.

the class AxcAdd method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    if (args.length < 1) {
        sender.sendMessage(messages.generalNoTagGiven);
        return;
    }
    if (!GuildUtils.tagExists(args[0])) {
        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 (user.hasGuild()) {
        sender.sendMessage(messages.generalUserHasGuild);
        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 GuildMemberJoinEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
        return;
    }
    guild.addMember(user);
    user.setGuild(guild);
    // IndependentThread.action(ActionType.PREFIX_GLOBAL_ADD_PLAYER, user.getName());
    ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
    concurrencyManager.postRequests(new PrefixGlobalAddPlayerRequest(user.getName()));
    MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", user.getName());
    Player player = user.getPlayer();
    Player owner = guild.getOwner().getPlayer();
    if (player != null) {
        player.sendMessage(translator.translate(messages.joinToMember));
    }
    if (owner != null) {
        owner.sendMessage(translator.translate(messages.joinToOwner));
    }
    Bukkit.broadcastMessage(translator.translate(messages.broadcastJoin));
}
Also used : Player(org.bukkit.entity.Player) PrefixGlobalAddPlayerRequest(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddPlayerRequest) User(net.dzikoysk.funnyguilds.basic.User) ConcurrencyManager(net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager) GuildMemberJoinEvent(net.dzikoysk.funnyguilds.event.guild.member.GuildMemberJoinEvent) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator)

Example 3 with MessageTranslator

use of net.dzikoysk.funnyguilds.data.util.MessageTranslator in project FunnyGuilds by FunnyGuilds.

the class AxcBan method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    if (args.length < 1) {
        sender.sendMessage(messages.generalNoTagGiven);
        return;
    } else if (args.length < 2) {
        sender.sendMessage(messages.adminNoBanTimeGiven);
        return;
    } else if (args.length < 3) {
        sender.sendMessage(messages.adminNoReasonGiven);
        return;
    }
    Guild guild = GuildUtils.getByTag(args[0]);
    if (guild == null) {
        sender.sendMessage(messages.generalNoGuildFound);
        return;
    }
    if (guild.isBanned()) {
        sender.sendMessage(messages.adminGuildBanned);
        return;
    }
    long time = Parser.parseTime(args[1]);
    if (time < 1) {
        sender.sendMessage(messages.adminTimeError);
        return;
    }
    StringBuilder reasonBuilder = new StringBuilder();
    for (int i = 2; i < args.length; i++) {
        reasonBuilder.append(args[i]);
        reasonBuilder.append(" ");
    }
    String reason = reasonBuilder.toString();
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new GuildBanEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, time, reason))) {
        return;
    }
    BanUtils.ban(guild, time, reason);
    MessageTranslator translator = new MessageTranslator().register("{GUILD", guild.getName()).register("{TAG}", guild.getTag()).register("{TIME}", args[1]).register("{REASON}", StringUtils.colored(reason));
    sender.sendMessage(translator.translate(messages.adminGuildBan));
    Bukkit.broadcastMessage(translator.translate(messages.broadcastBan));
}
Also used : GuildBanEvent(net.dzikoysk.funnyguilds.event.guild.GuildBanEvent) 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 4 with MessageTranslator

use of net.dzikoysk.funnyguilds.data.util.MessageTranslator in project FunnyGuilds by FunnyGuilds.

the class AxcDeputy 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]);
    Player player = user.getPlayer();
    if (!guild.getMembers().contains(user)) {
        sender.sendMessage(messages.adminUserNotMemberOf);
        return;
    }
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new GuildMemberDeputyEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
        return;
    }
    MessageTranslator translator = new MessageTranslator().register("{PLAYER}", user.getName());
    if (user.isDeputy()) {
        guild.removeDeputy(user);
        sender.sendMessage(messages.deputyRemove);
        if (player != null) {
            player.sendMessage(messages.deputyMember);
        }
        String message = translator.translate(messages.deputyNoLongerMembers);
        for (User member : guild.getOnlineMembers()) {
            member.getPlayer().sendMessage(message);
        }
        return;
    }
    guild.addDeputy(user);
    sender.sendMessage(messages.deputySet);
    if (player != null) {
        player.sendMessage(messages.deputyOwner);
    }
    String message = translator.translate(messages.deputyMembers);
    for (User member : guild.getOnlineMembers()) {
        member.getPlayer().sendMessage(message);
    }
}
Also used : Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) GuildMemberDeputyEvent(net.dzikoysk.funnyguilds.event.guild.member.GuildMemberDeputyEvent) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator)

Example 5 with MessageTranslator

use of net.dzikoysk.funnyguilds.data.util.MessageTranslator in project FunnyGuilds by FunnyGuilds.

the class AxcKick 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;
    }
    User user = User.get(args[0]);
    if (!user.hasGuild()) {
        sender.sendMessage(messages.generalPlayerHasNoGuild);
        return;
    }
    if (user.isOwner()) {
        sender.sendMessage(messages.adminGuildOwner);
        return;
    }
    Guild guild = user.getGuild();
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new GuildMemberKickEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
        return;
    }
    // IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_PLAYER, user.getName());
    ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
    concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(user.getName()));
    Player player = user.getPlayer();
    guild.removeMember(user);
    user.removeGuild();
    MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", user.getName());
    if (player != null) {
        // IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
        concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player));
        player.sendMessage(translator.translate(messages.kickToPlayer));
    }
    sender.sendMessage(translator.translate(messages.kickToOwner));
    Bukkit.broadcastMessage(translator.translate(messages.broadcastKick));
}
Also used : PrefixGlobalUpdatePlayer(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer) Player(org.bukkit.entity.Player) PrefixGlobalUpdatePlayer(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer) User(net.dzikoysk.funnyguilds.basic.User) ConcurrencyManager(net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager) PrefixGlobalRemovePlayerRequest(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalRemovePlayerRequest) GuildMemberKickEvent(net.dzikoysk.funnyguilds.event.guild.member.GuildMemberKickEvent) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) MessageTranslator(net.dzikoysk.funnyguilds.data.util.MessageTranslator)

Aggregations

Guild (net.dzikoysk.funnyguilds.basic.Guild)12 User (net.dzikoysk.funnyguilds.basic.User)12 MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)12 MessageTranslator (net.dzikoysk.funnyguilds.data.util.MessageTranslator)12 Player (org.bukkit.entity.Player)12 ConcurrencyManager (net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager)6 PrefixGlobalAddPlayerRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddPlayerRequest)3 PrefixGlobalRemovePlayerRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalRemovePlayerRequest)3 PrefixGlobalUpdatePlayer (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer)3 Region (net.dzikoysk.funnyguilds.basic.Region)2 PluginConfig (net.dzikoysk.funnyguilds.data.configs.PluginConfig)2 GuildDeleteEvent (net.dzikoysk.funnyguilds.event.guild.GuildDeleteEvent)2 GuildMemberJoinEvent (net.dzikoysk.funnyguilds.event.guild.member.GuildMemberJoinEvent)2 GuildMemberKickEvent (net.dzikoysk.funnyguilds.event.guild.member.GuildMemberKickEvent)2 Location (org.bukkit.Location)2 ItemStack (org.bukkit.inventory.ItemStack)2 PrefixGlobalAddGuildRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalAddGuildRequest)1 RankUpdateGuildRequest (net.dzikoysk.funnyguilds.concurrency.requests.rank.RankUpdateGuildRequest)1 GuildBanEvent (net.dzikoysk.funnyguilds.event.guild.GuildBanEvent)1 GuildCreateEvent (net.dzikoysk.funnyguilds.event.guild.GuildCreateEvent)1