use of net.dzikoysk.funnyguilds.data.util.MessageTranslator in project FunnyGuilds by FunnyGuilds.
the class ExcLeave method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
Player player = (Player) sender;
User user = User.get(player);
if (!user.hasGuild()) {
player.sendMessage(messages.generalHasNoGuild);
return;
}
if (user.isOwner()) {
player.sendMessage(messages.leaveIsOwner);
return;
}
Guild guild = user.getGuild();
if (!SimpleEventHandler.handle(new GuildMemberLeaveEvent(EventCause.USER, user, guild, user))) {
return;
}
guild.removeMember(user);
user.removeGuild();
// IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_PLAYER, user.getName());
// IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(user.getName()), new PrefixGlobalUpdatePlayer(player));
MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", user.getName());
player.sendMessage(translator.translate(messages.leaveToUser));
Bukkit.broadcastMessage(translator.translate(messages.broadcastLeave));
}
use of net.dzikoysk.funnyguilds.data.util.MessageTranslator in project FunnyGuilds by FunnyGuilds.
the class AxcAdd method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
if (args.length < 1) {
sender.sendMessage(messages.generalNoTagGiven);
return;
}
if (!GuildUtils.tagExists(args[0])) {
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 (user.hasGuild()) {
sender.sendMessage(messages.generalUserHasGuild);
return;
}
Guild guild = GuildUtils.getByTag(args[0]);
if (guild == null) {
sender.sendMessage(messages.generalNoGuildFound);
return;
}
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildMemberJoinEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, user))) {
return;
}
guild.addMember(user);
user.setGuild(guild);
// IndependentThread.action(ActionType.PREFIX_GLOBAL_ADD_PLAYER, user.getName());
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalAddPlayerRequest(user.getName()));
MessageTranslator translator = new MessageTranslator().register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag()).register("{PLAYER}", user.getName());
Player player = user.getPlayer();
Player owner = guild.getOwner().getPlayer();
if (player != null) {
player.sendMessage(translator.translate(messages.joinToMember));
}
if (owner != null) {
owner.sendMessage(translator.translate(messages.joinToOwner));
}
Bukkit.broadcastMessage(translator.translate(messages.broadcastJoin));
}
use of net.dzikoysk.funnyguilds.data.util.MessageTranslator in project FunnyGuilds by FunnyGuilds.
the class AxcBan method execute.
@Override
public void execute(CommandSender sender, String[] args) {
MessagesConfig messages = Messages.getInstance();
if (args.length < 1) {
sender.sendMessage(messages.generalNoTagGiven);
return;
} else if (args.length < 2) {
sender.sendMessage(messages.adminNoBanTimeGiven);
return;
} else if (args.length < 3) {
sender.sendMessage(messages.adminNoReasonGiven);
return;
}
Guild guild = GuildUtils.getByTag(args[0]);
if (guild == null) {
sender.sendMessage(messages.generalNoGuildFound);
return;
}
if (guild.isBanned()) {
sender.sendMessage(messages.adminGuildBanned);
return;
}
long time = Parser.parseTime(args[1]);
if (time < 1) {
sender.sendMessage(messages.adminTimeError);
return;
}
StringBuilder reasonBuilder = new StringBuilder();
for (int i = 2; i < args.length; i++) {
reasonBuilder.append(args[i]);
reasonBuilder.append(" ");
}
String reason = reasonBuilder.toString();
User admin = (sender instanceof Player) ? User.get(sender.getName()) : null;
if (!SimpleEventHandler.handle(new GuildBanEvent(admin == null ? EventCause.CONSOLE : EventCause.ADMIN, admin, guild, time, reason))) {
return;
}
BanUtils.ban(guild, time, reason);
MessageTranslator translator = new MessageTranslator().register("{GUILD", guild.getName()).register("{TAG}", guild.getTag()).register("{TIME}", args[1]).register("{REASON}", StringUtils.colored(reason));
sender.sendMessage(translator.translate(messages.adminGuildBan));
Bukkit.broadcastMessage(translator.translate(messages.broadcastBan));
}
use of net.dzikoysk.funnyguilds.data.util.MessageTranslator 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);
}
}
use of net.dzikoysk.funnyguilds.data.util.MessageTranslator 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));
}
Aggregations