use of net.dzikoysk.funnyguilds.event.guild.member.GuildMemberLeaderEvent 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.event.guild.member.GuildMemberLeaderEvent in project FunnyGuilds by FunnyGuilds.
the class AxcLeader 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]);
if (!guild.getMembers().contains(user)) {
sender.sendMessage(messages.adminUserNotMemberOf);
return;
}
if (guild.getOwner().equals(user)) {
sender.sendMessage(messages.adminAlreadyLeader);
return;
}
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildMemberLeaderEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
return;
}
Player leaderPlayer = user.getPlayer();
guild.setOwner(user);
sender.sendMessage(messages.leaderSet);
if (leaderPlayer != null) {
leaderPlayer.sendMessage(messages.leaderOwner);
}
String message = messages.leaderMembers.replace("{PLAYER}", user.getName());
for (User member : guild.getOnlineMembers()) {
member.getPlayer().sendMessage(message);
}
}
Aggregations