Search in sources :

Example 31 with MessagesConfig

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

the class ExcLeader method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    Player player = (Player) sender;
    User owner = User.get(player);
    if (!owner.hasGuild()) {
        player.sendMessage(messages.generalHasGuild);
        return;
    }
    if (!owner.isOwner()) {
        player.sendMessage(messages.generalIsNotOwner);
        return;
    }
    if (args.length < 1) {
        player.sendMessage(messages.generalNoNickGiven);
        return;
    }
    if (!UserUtils.playedBefore(args[0])) {
        player.sendMessage(messages.generalNotPlayedBefore);
        return;
    }
    User leaderUser = User.get(args[0]);
    if (owner.equals(leaderUser)) {
        player.sendMessage(messages.leaderMustBeDifferent);
        return;
    }
    Guild guild = owner.getGuild();
    if (!guild.getMembers().contains(leaderUser)) {
        player.sendMessage(messages.generalIsNotMember);
        return;
    }
    if (!SimpleEventHandler.handle(new GuildMemberLeaderEvent(EventCause.USER, owner, guild, leaderUser))) {
        return;
    }
    Player leaderPlayer = leaderUser.getPlayer();
    guild.setOwner(leaderUser);
    player.sendMessage(messages.leaderSet);
    if (leaderPlayer != null) {
        leaderPlayer.sendMessage(messages.leaderOwner);
    }
}
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)

Example 32 with MessagesConfig

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

the class ExcPlayer method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    PluginConfig config = Settings.getConfig();
    if (args.length == 0 && !(sender instanceof Player)) {
        sender.sendMessage(messages.playerOnly);
        return;
    }
    String name = args.length == 0 ? sender.getName() : args[0];
    if (!UserUtils.playedBefore(name, config.playerLookupIgnorecase)) {
        sender.sendMessage(messages.playerInfoExists);
        return;
    }
    User user = UserUtils.get(name, config.playerLookupIgnorecase);
    if (user == null) {
        sender.sendMessage(messages.playerInfoExists);
        return;
    }
    Rank rank = user.getRank();
    for (String messageLine : messages.playerInfoList) {
        if (user.hasGuild()) {
            messageLine = StringUtils.replace(messageLine, "{GUILD}", user.getGuild().getName());
            messageLine = StringUtils.replace(messageLine, "{TAG}", user.getGuild().getTag());
        } else {
            messageLine = StringUtils.replace(messageLine, "{GUILD}", messages.gNameNoValue);
            messageLine = StringUtils.replace(messageLine, "{TAG}", messages.gTagNoValue);
        }
        messageLine = StringUtils.replace(messageLine, "{PLAYER}", user.getName());
        messageLine = StringUtils.replace(messageLine, "{POINTS-FORMAT}", IntegerRange.inRange(rank.getPoints(), config.pointsFormat));
        messageLine = StringUtils.replace(messageLine, "{POINTS}", Integer.toString(rank.getPoints()));
        messageLine = StringUtils.replace(messageLine, "{KILLS}", Integer.toString(rank.getKills()));
        messageLine = StringUtils.replace(messageLine, "{DEATHS}", Integer.toString(rank.getDeaths()));
        messageLine = StringUtils.replace(messageLine, "{KDR}", String.format(Locale.US, "%.2f", rank.getKDR()));
        messageLine = StringUtils.replace(messageLine, "{RANK}", Integer.toString(rank.getPosition()));
        sender.sendMessage(messageLine);
    }
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) Rank(net.dzikoysk.funnyguilds.basic.Rank) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig)

Example 33 with MessagesConfig

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

the class ExcRankReset method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    PluginConfig config = Settings.getConfig();
    MessagesConfig messages = Messages.getInstance();
    Player player = (Player) sender;
    List<ItemStack> requiredItems = config.rankResetItems;
    for (ItemStack requiredItem : requiredItems) {
        if (player.getInventory().containsAtLeast(requiredItem, requiredItem.getAmount())) {
            continue;
        }
        String msg = ItemUtils.translatePlaceholder(messages.createItems, requiredItems, requiredItem);
        player.sendMessage(msg);
        return;
    }
    User user = User.get(player);
    if (user != null) {
        int lastRank = user.getRank().getPoints();
        user.getRank().setPoints(config.rankStart);
        player.getInventory().removeItem(ItemUtils.toArray(requiredItems));
        String resetMessage = messages.rankResetMessage;
        resetMessage = StringUtils.replace(resetMessage, "{LAST-RANK}", String.valueOf(lastRank));
        resetMessage = StringUtils.replace(resetMessage, "{CURRENT-RANK}", String.valueOf(user.getRank().getPoints()));
        player.sendMessage(resetMessage);
    }
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) ItemStack(org.bukkit.inventory.ItemStack)

Example 34 with MessagesConfig

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

the class AxcName method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    PluginConfig config = Settings.getConfig();
    if (args.length < 1) {
        sender.sendMessage(messages.generalNoTagGiven);
        return;
    } else if (args.length < 2) {
        sender.sendMessage(messages.adminNoNewNameGiven);
        return;
    }
    Guild guild = GuildUtils.getByTag(args[0]);
    if (guild == null) {
        sender.sendMessage(messages.generalNoGuildFound);
        return;
    }
    if (GuildUtils.nameExists(args[1])) {
        sender.sendMessage(messages.createNameExists);
        return;
    }
    User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
    if (!SimpleEventHandler.handle(new GuildRenameEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, args[1]))) {
        return;
    }
    Manager.getInstance().stop();
    PluginConfig.DataType dataType = Settings.getConfig().dataType;
    if (config.regionsEnabled) {
        Region region = RegionUtils.get(guild.getRegion());
        if (dataType.flat) {
            Flat.getRegionFile(region).delete();
        }
        if (dataType.mysql) {
            new DatabaseRegion(region).delete();
        }
        region.setName(args[1]);
    }
    if (dataType.flat) {
        Flat.getGuildFile(guild).delete();
    }
    if (dataType.mysql) {
        new DatabaseGuild(guild).delete();
    }
    guild.setName(args[1]);
    Manager.getInstance().start();
    sender.sendMessage(messages.adminNameChanged.replace("{GUILD}", guild.getName()));
}
Also used : PluginConfig(net.dzikoysk.funnyguilds.data.configs.PluginConfig) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.basic.User) DatabaseGuild(net.dzikoysk.funnyguilds.data.database.DatabaseGuild) DatabaseRegion(net.dzikoysk.funnyguilds.data.database.DatabaseRegion) DatabaseRegion(net.dzikoysk.funnyguilds.data.database.DatabaseRegion) Region(net.dzikoysk.funnyguilds.basic.Region) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig) DatabaseGuild(net.dzikoysk.funnyguilds.data.database.DatabaseGuild) Guild(net.dzikoysk.funnyguilds.basic.Guild) GuildRenameEvent(net.dzikoysk.funnyguilds.event.guild.GuildRenameEvent)

Example 35 with MessagesConfig

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

the class AxcSpy method execute.

@Override
public void execute(CommandSender sender, String[] args) {
    MessagesConfig messages = Messages.getInstance();
    User user = User.get((Player) sender);
    if (user.isSpy()) {
        user.setSpy(false);
        sender.sendMessage(messages.adminStopSpy);
    } else {
        user.setSpy(true);
        sender.sendMessage(messages.adminStartSpy);
    }
}
Also used : User(net.dzikoysk.funnyguilds.basic.User) MessagesConfig(net.dzikoysk.funnyguilds.data.configs.MessagesConfig)

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