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);
}
}
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);
}
}
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);
}
}
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()));
}
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);
}
}
Aggregations