use of net.dzikoysk.funnyguilds.event.guild.GuildLivesChangeEvent in project FunnyGuilds by FunnyGuilds.
the class AxcLives method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
if (args.length < 1) {
sender.sendMessage(messages.generalNoTagGiven);
return;
}
if (args.length < 2) {
sender.sendMessage(messages.adminNoLivesGiven);
return;
}
Guild guild = GuildUtils.getByTag(args[0]);
if (guild == null) {
sender.sendMessage(messages.generalNoGuildFound);
return;
}
int lives;
try {
lives = Integer.valueOf(args[1]);
} catch (NumberFormatException e) {
sender.sendMessage(messages.adminErrorInNumber.replace("{ERROR}", args[1]));
return;
}
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildLivesChangeEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, lives))) {
return;
}
guild.setLives(lives);
sender.sendMessage(messages.adminLivesChanged.replace("{GUILD}", guild.getTag()).replace("{LIVES}", Integer.toString(lives)));
}
Aggregations