Search in sources :

Example 1 with IndividualPlayerList

use of net.dzikoysk.funnyguilds.feature.tablist.IndividualPlayerList in project FunnyGuilds by FunnyGuilds.

the class FunnyGuilds method handleReload.

private void handleReload() {
    for (Player player : this.getServer().getOnlinePlayers()) {
        final FunnyGuildsChannelHandler channelHandler = nmsAccessor.getPacketAccessor().getOrInstallChannelHandler(player);
        Option<User> userOption = userManager.findByPlayer(player);
        if (userOption.isEmpty()) {
            continue;
        }
        User user = userOption.get();
        channelHandler.getPacketCallbacksRegistry().registerPacketCallback(new WarPacketCallbacks(user));
        UserCache cache = user.getCache();
        cache.updateScoreboardIfNull(player);
        cache.getDummy();
        if (!this.tablistConfiguration.playerListEnable) {
            continue;
        }
        IndividualPlayerList individualPlayerList = new IndividualPlayerList(user, this.getNmsAccessor().getPlayerListAccessor(), this.tablistConfiguration.playerList, this.tablistConfiguration.playerListHeader, this.tablistConfiguration.playerListFooter, this.tablistConfiguration.pages, this.tablistConfiguration.playerListPing, this.tablistConfiguration.playerListFillCells, this.pluginConfiguration.top.enableLegacyPlaceholders);
        cache.setPlayerList(individualPlayerList);
    }
    for (Guild guild : this.guildManager.getGuilds()) {
        if (this.pluginConfiguration.heart.createEntityType != null) {
            GuildEntityHelper.spawnGuildHeart(guild);
        }
    }
}
Also used : IndividualPlayerList(net.dzikoysk.funnyguilds.feature.tablist.IndividualPlayerList) Player(org.bukkit.entity.Player) User(net.dzikoysk.funnyguilds.user.User) FunnyGuildsChannelHandler(net.dzikoysk.funnyguilds.nms.api.packet.FunnyGuildsChannelHandler) WarPacketCallbacks(net.dzikoysk.funnyguilds.feature.war.WarPacketCallbacks) UserCache(net.dzikoysk.funnyguilds.user.UserCache) Guild(net.dzikoysk.funnyguilds.guild.Guild)

Example 2 with IndividualPlayerList

use of net.dzikoysk.funnyguilds.feature.tablist.IndividualPlayerList in project FunnyGuilds by FunnyGuilds.

the class ReloadRequest method execute.

@Override
public void execute() throws Exception {
    this.plugin.reloadConfiguration();
    this.plugin.getDataPersistenceHandler().reloadHandler();
    this.plugin.getDynamicListenerManager().reloadAll();
    Bukkit.getScheduler().runTaskAsynchronously(plugin, new HologramUpdateLocationHandler(plugin));
    if (this.plugin.getTablistConfiguration().playerListEnable) {
        PluginConfiguration config = this.plugin.getPluginConfiguration();
        TablistConfiguration tablistConfig = this.plugin.getTablistConfiguration();
        UserManager userManager = this.plugin.getUserManager();
        DefaultTablistVariables.clearFunnyVariables();
        PandaStream.of(Bukkit.getOnlinePlayers()).flatMap(userManager::findByPlayer).forEach(user -> {
            IndividualPlayerList playerList = new IndividualPlayerList(user, plugin.getNmsAccessor().getPlayerListAccessor(), tablistConfig.playerList, tablistConfig.playerListHeader, tablistConfig.playerListFooter, tablistConfig.pages, tablistConfig.playerListPing, tablistConfig.playerListFillCells, config.top.enableLegacyPlaceholders);
            user.getCache().setPlayerList(playerList);
        });
    }
    long endTime = System.currentTimeMillis();
    String diff = String.format("%.2f", ((endTime - startTime) / 1000.0));
    sender.sendMessage(ChatColor.AQUA + "FunnyGuilds " + ChatColor.GRAY + "przeladowano! (" + ChatColor.AQUA + diff + "s" + ChatColor.GRAY + ")");
}
Also used : TablistConfiguration(net.dzikoysk.funnyguilds.config.tablist.TablistConfiguration) IndividualPlayerList(net.dzikoysk.funnyguilds.feature.tablist.IndividualPlayerList) UserManager(net.dzikoysk.funnyguilds.user.UserManager) PluginConfiguration(net.dzikoysk.funnyguilds.config.PluginConfiguration) HologramUpdateLocationHandler(net.dzikoysk.funnyguilds.feature.hologram.HologramUpdateLocationHandler)

Example 3 with IndividualPlayerList

use of net.dzikoysk.funnyguilds.feature.tablist.IndividualPlayerList in project FunnyGuilds by FunnyGuilds.

the class PlayerJoin method onJoin.

@EventHandler
public void onJoin(PlayerJoinEvent event) {
    Player player = event.getPlayer();
    User user = this.userManager.findByPlayer(player).orElseGet(() -> userManager.create(player));
    String playerName = player.getName();
    if (!user.getName().equals(playerName)) {
        this.userManager.updateUsername(user, playerName);
    }
    user.updateReference(player);
    UserCache cache = user.getCache();
    IndividualPlayerList individualPlayerList = new IndividualPlayerList(user, plugin.getNmsAccessor().getPlayerListAccessor(), tablistConfig.playerList, tablistConfig.playerListHeader, tablistConfig.playerListFooter, tablistConfig.pages, tablistConfig.playerListPing, tablistConfig.playerListFillCells, config.top.enableLegacyPlaceholders);
    individualPlayerList.send();
    cache.setPlayerList(individualPlayerList);
    cache.updateScoreboardIfNull(player);
    if (cache.getIndividualPrefix() == null && config.guildTagEnabled) {
        IndividualPrefix prefix = new IndividualPrefix(user);
        prefix.initialize();
        cache.setIndividualPrefix(prefix);
    }
    this.concurrencyManager.postRequests(new PrefixGlobalUpdatePlayer(player), new DummyGlobalUpdateUserRequest(user));
    final FunnyGuildsChannelHandler channelHandler = this.plugin.getNmsAccessor().getPacketAccessor().getOrInstallChannelHandler(player);
    channelHandler.getPacketCallbacksRegistry().registerPacketCallback(new WarPacketCallbacks(user));
    this.plugin.getServer().getScheduler().runTaskLaterAsynchronously(this.plugin, () -> {
        this.plugin.getVersion().isNewAvailable(player, false);
        if (config.heart.createEntityType != null) {
            this.regionManager.findRegionAtLocation(player.getLocation()).map(Region::getGuild).peek(guild -> GuildEntityHelper.spawnGuildHeart(guild, player));
        }
    }, 30L);
}
Also used : IndividualPlayerList(net.dzikoysk.funnyguilds.feature.tablist.IndividualPlayerList) PrefixGlobalUpdatePlayer(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer) Player(org.bukkit.entity.Player) PrefixGlobalUpdatePlayer(net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer) User(net.dzikoysk.funnyguilds.user.User) FunnyGuildsChannelHandler(net.dzikoysk.funnyguilds.nms.api.packet.FunnyGuildsChannelHandler) IndividualPrefix(net.dzikoysk.funnyguilds.feature.prefix.IndividualPrefix) WarPacketCallbacks(net.dzikoysk.funnyguilds.feature.war.WarPacketCallbacks) DummyGlobalUpdateUserRequest(net.dzikoysk.funnyguilds.concurrency.requests.dummy.DummyGlobalUpdateUserRequest) UserCache(net.dzikoysk.funnyguilds.user.UserCache) EventHandler(org.bukkit.event.EventHandler)

Aggregations

IndividualPlayerList (net.dzikoysk.funnyguilds.feature.tablist.IndividualPlayerList)3 WarPacketCallbacks (net.dzikoysk.funnyguilds.feature.war.WarPacketCallbacks)2 FunnyGuildsChannelHandler (net.dzikoysk.funnyguilds.nms.api.packet.FunnyGuildsChannelHandler)2 User (net.dzikoysk.funnyguilds.user.User)2 UserCache (net.dzikoysk.funnyguilds.user.UserCache)2 Player (org.bukkit.entity.Player)2 DummyGlobalUpdateUserRequest (net.dzikoysk.funnyguilds.concurrency.requests.dummy.DummyGlobalUpdateUserRequest)1 PrefixGlobalUpdatePlayer (net.dzikoysk.funnyguilds.concurrency.requests.prefix.PrefixGlobalUpdatePlayer)1 PluginConfiguration (net.dzikoysk.funnyguilds.config.PluginConfiguration)1 TablistConfiguration (net.dzikoysk.funnyguilds.config.tablist.TablistConfiguration)1 HologramUpdateLocationHandler (net.dzikoysk.funnyguilds.feature.hologram.HologramUpdateLocationHandler)1 IndividualPrefix (net.dzikoysk.funnyguilds.feature.prefix.IndividualPrefix)1 Guild (net.dzikoysk.funnyguilds.guild.Guild)1 UserManager (net.dzikoysk.funnyguilds.user.UserManager)1 EventHandler (org.bukkit.event.EventHandler)1