Search in sources :

Example 6 with MessagesConfig

use of net.dzikoysk.funnyguilds.data.configs.MessagesConfig in project FunnyGuilds by FunnyGuilds.

the class ExcEscape method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    PluginConfig config = Settings.getConfig();
    MessagesConfig messages = Messages.getInstance();
    Player player = (Player) sender;
    if (!config.regionsEnabled) {
        player.sendMessage(messages.regionsDisabled);
        return;
    }
    if (!config.escapeEnable || !config.baseEnable) {
        player.sendMessage(messages.escapeDisabled);
        return;
    }
    User user = User.get(player);
    if (!user.hasGuild()) {
        player.sendMessage(messages.escapeNoUserGuild);
        return;
    }
    if (user.getTeleportation() != null) {
        player.sendMessage(messages.escapeInProgress);
        return;
    }
    Location playerLocation = player.getLocation();
    Region region = RegionUtils.getAt(playerLocation);
    if (region == null) {
        player.sendMessage(messages.escapeNoNeedToRun);
        return;
    }
    Guild guild = user.getGuild();
    if (guild.equals(region.getGuild())) {
        player.sendMessage(messages.escapeOnYourRegion);
        return;
    }
    int time = Settings.getConfig().escapeDelay;
    if (time < 1) {
        player.teleport(guild.getHome());
        player.sendMessage(messages.escapeSuccessfulUser);
        for (User member : region.getGuild().getOnlineMembers()) {
            member.getPlayer().sendMessage(messages.escapeSuccessfulOpponents.replace("{PLAYER}", player.getName()));
        }
        return;
    }
    player.sendMessage(messages.escapeStartedUser.replace("{TIME}", Integer.toString(time)));
    String msg = messages.escapeStartedOpponents.replace("{TIME}", Integer.toString(time)).replace("{PLAYER}", player.getName()).replace("{X}", Integer.toString(playerLocation.getBlockX())).replace("{Y}", Integer.toString(playerLocation.getBlockY())).replace("{Z}", Integer.toString(playerLocation.getBlockZ()));
    for (User member : region.getGuild().getOnlineMembers()) {
        member.getPlayer().sendMessage(msg);
    }
    Location before = player.getLocation();
    AtomicInteger i = new AtomicInteger(0);
    user.setTeleportation(Bukkit.getScheduler().runTaskTimer(FunnyGuilds.getInstance(), () -> {
        if (!player.isOnline()) {
            user.getTeleportation().cancel();
            user.setTeleportation(null);
            return;
        }
        if (!LocationUtils.equals(player.getLocation(), before)) {
            user.getTeleportation().cancel();
            player.sendMessage(messages.escapeCancelled);
            user.setTeleportation(null);
            return;
        }
        if (i.getAndIncrement() > time) {
            user.getTeleportation().cancel();
            player.teleport(guild.getHome());
            player.sendMessage(messages.escapeSuccessfulUser);
            for (User member : region.getGuild().getOnlineMembers()) {
                member.getPlayer().sendMessage(messages.escapeSuccessfulOpponents.replace("{PLAYER}", player.getName()));
            }
            user.setTeleportation(null);
        }
    }, 0L, 20L));
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Region(net.dzikoysk.funnyguilds.basic.Region) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) Guild(net.dzikoysk.funnyguilds.basic.Guild) Location(org.bukkit.Location)

Example 7 with MessagesConfig

use of net.dzikoysk.funnyguilds.data.configs.MessagesConfig 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 8 with MessagesConfig

use of net.dzikoysk.funnyguilds.data.configs.MessagesConfig in project FunnyGuilds by FunnyGuilds.

the class AxcEnabled method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    PluginConfig config = Settings.getConfig();
    MessagesConfig messages = Messages.getInstance();
    boolean enabled = config.guildsEnabled = !config.guildsEnabled;
    sender.sendMessage(enabled ? messages.adminGuildsEnabled : messages.adminGuildsDisabled);
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig)

Example 9 with MessagesConfig

use of net.dzikoysk.funnyguilds.data.configs.MessagesConfig 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)

Example 10 with MessagesConfig

use of net.dzikoysk.funnyguilds.data.configs.MessagesConfig in project FunnyGuilds by FunnyGuilds.

the class AxcKills 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.adminNoKillsGiven);
        return;
    }
    int kills;
    try {
        kills = 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 = kills - userRank.getDeaths();
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new KillsChangeEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, userRank, admin, change))) {
        return;
    }
    user.getRank().setKills(kills);
    sender.sendMessage(messages.adminKillsChanged.replace("{PLAYER}", user.getName()).replace("{KILLS}", Integer.toString(kills)));
}
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) KillsChangeEvent(net.dzikoysk.funnyguilds.event.rank.KillsChangeEvent)

Aggregations

MessagesConfig (net.dzikoysk.funnyguilds.data.configs.MessagesConfig)42 User (net.dzikoysk.funnyguilds.basic.User)39 Player (org.bukkit.entity.Player)38 Guild (net.dzikoysk.funnyguilds.basic.Guild)31 PluginConfig (net.dzikoysk.funnyguilds.data.configs.PluginConfig)17 MessageTranslator (net.dzikoysk.funnyguilds.data.util.MessageTranslator)12 ConcurrencyManager (net.dzikoysk.funnyguilds.concurrency.ConcurrencyManager)9 Region (net.dzikoysk.funnyguilds.basic.Region)8 Location (org.bukkit.Location)6 ItemStack (org.bukkit.inventory.ItemStack)6 Rank (net.dzikoysk.funnyguilds.basic.Rank)5 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 PrefixGlobalUpdatePlayer (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer)3 ArrayList (java.util.ArrayList)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 PrefixUpdateGuildRequest (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixUpdateGuildRequest)2