use of net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer 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.concurrency.requests.prefix.PrefixGlobalUpdatePlayer 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));
}
use of net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer in project FunnyGuilds by FunnyGuilds.
the class ExcKick 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() && !user.isDeputy()) {
player.sendMessage(messages.generalIsNotOwner);
return;
}
if (args.length < 1) {
player.sendMessage(messages.generalNoNickGiven);
return;
}
User formerUser = User.get(args[0]);
if (!formerUser.hasGuild()) {
player.sendMessage(messages.generalPlayerHasNoGuild);
return;
}
if (!user.getGuild().equals(formerUser.getGuild())) {
player.sendMessage(messages.kickOtherGuild);
return;
}
if (formerUser.isOwner()) {
player.sendMessage(messages.kickOwner);
return;
}
Guild guild = user.getGuild();
if (!SimpleEventHandler.handle(new GuildMemberKickEvent(EventCause.USER, user, guild, formerUser))) {
return;
}
// IndependentThread.action(ActionType.PREFIX_GLOBAL_REMOVE_PLAYER, formerUser.getName());
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalRemovePlayerRequest(formerUser.getName()));
guild.removeMember(formerUser);
formerUser.removeGuild();
if (formerUser.isOnline()) {
// IndependentThread.action(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player));
}
MessageTranslator translator = new MessageTranslator().register("{PLAYER}", formerUser.getName()).register("{GUILD}", guild.getName()).register("{TAG}", guild.getTag());
player.sendMessage(translator.translate(messages.kickToOwner));
Bukkit.broadcastMessage(translator.translate(messages.broadcastKick));
Player formerPlayer = formerUser.getPlayer();
if (formerPlayer != null) {
formerPlayer.sendMessage(translator.translate(messages.kickToPlayer));
}
}
use of net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer in project FunnyGuilds by FunnyGuilds.
the class PlayerJoin method onJoin.
@EventHandler
public void onJoin(PlayerJoinEvent e) {
Player player = e.getPlayer();
User user = User.get(player);
PluginConfig config = Settings.getConfig();
if (config.playerlistEnable && !AbstractTablist.hasTablist(player)) {
AbstractTablist.createTablist(config.playerList, config.playerListHeader, config.playerListFooter, config.playerListPing, player);
}
user.getScoreboard();
/*
IndependentThread.actions(ActionType.PREFIX_GLOBAL_UPDATE_PLAYER, player);
IndependentThread.actions(ActionType.DUMMY_GLOBAL_UPDATE_USER, user);
IndependentThread.actions(ActionType.RANK_UPDATE_USER, user);
*/
ConcurrencyManager concurrencyManager = FunnyGuilds.getInstance().getConcurrencyManager();
concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player), new DummyGlobalUpdateUserRequest(user), new RankUpdateUserRequest(user));
this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, () -> {
PacketExtension.registerPlayer(player);
Version.isNewAvailable(player, false);
Region region = RegionUtils.getAt(player.getLocation());
if (region == null || region.getGuild() == null) {
return;
}
if (config.createEntityType != null) {
EntityUtil.spawn(region.getGuild(), player);
}
}, 30L);
}
Aggregations