RefineDevelopment / TablistAPI

Refine TablistAPI | Custom
12 stars 5 forks source link

Some tablist entries are not appearing #4

Open hardcorefactions opened 1 month ago

hardcorefactions commented 1 month ago

Today I was trying Refine's Tablist API with my hub plugin as the other tab api which I was running was really outdated and used a bunch of resources. I've realized for the short time I've been using Refine's Tablist API that some entries are being registered but not shown, I don't know what is causing this.

image image

the first image is the tablist in "1.7", tho on "1.8" they still not appear, on the second image it's a part of the tablist that isn't appearing.

DevDrizzy commented 1 month ago

Attach your full Tablist adapter

hardcorefactions commented 4 weeks ago

Attach your full Tablist adapter

package club.vexpvp.hub.providers.tablist;

import club.vexpvp.hub.utils.CC;
import club.vexpvp.hub.utils.SkinUtil;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.Player;
import xyz.refinedev.api.tablist.adapter.TabAdapter;
import xyz.refinedev.api.tablist.setup.TabEntry;
import xyz.refinedev.api.tablist.util.Skin;
import xyz.refinedev.phoenix.SharedAPI;
import xyz.refinedev.phoenix.profile.Profile;
import xyz.refinedev.phoenix.profile.grant.Grant;
import xyz.refinedev.phoenix.server.ServerData;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class TablistProvider implements TabAdapter {
    @Override
    public String getHeader(Player player) {
        return String.join("\n", Arrays.asList(
                "&f",
                "&d&lVexPvP Network &7┃ &fThe Flowering Era",
                "&fCheck out for &6Keys, &9Kits, &2Ranks &fand more at &d&ostore.vexpvp.club",
                "&f"
        ));
    }

    @Override
    public String getFooter(Player player) {
        return String.join("\n", Arrays.asList(
                "&f",
                "&9Discord: &fvexpvp.club/discord &7┃ &2Store: &fstore.vexpvp.club &7┃ &bTwitter: &fvexpvp.club/twitter",
                "&f"
        ));
    }

    @Override
    public List<TabEntry> getLines(Player player) {
        List<TabEntry> entries = new ArrayList<>();
        SharedAPI phoenix      = SharedAPI.getInstance();
        Profile profile        = phoenix.getProfileHandler().getProfile(player.getUniqueId());

        entries.add(new TabEntry(0, 1, CC.translate("&dProfile"), Skin.getPlayer(player)));
        entries.add(new TabEntry(0, 1, CC.translate("&dProfile")));
        entries.add(new TabEntry(0, 2, CC.translate("&8┃ &fRank&7: " + profile.getHighestRank().getDisplayName())));
        Grant grant = profile.getBestGrant();
        entries.add(new TabEntry(0, 3, CC.translate("&8┃ &fExpiration&7: &d" + (grant == null ?
                "Never" :
                grant.getDuration() != 0 ?
                        "Never" :
                        grant.getDuration()
        ))));
        entries.add(new TabEntry(0, 4, CC.translate("&8┃ &fPing&7: &d" + ((CraftPlayer) player).getHandle().ping + "ms")));

        ServerData kitmap = phoenix.getNetworkHandler().getServerByName("KitMap");
        String kitmapStatus = "&4Loading...";
        int kitmapOnline = 0;
        int kitmapMax = 0;
        if (kitmap != null) {
            boolean kitmapUp = kitmap.isOnline();
            boolean kitmapWhitelist = kitmap.isWhitelisted();
            kitmapOnline = kitmapUp ? kitmap.getOnlinePlayers().size() : 0;
            kitmapMax = kitmapUp ? kitmap.getMaxPlayers() : 0;

            if (!kitmapUp) kitmapStatus = "&4Offline";
            if (kitmapUp && kitmapWhitelist) kitmapStatus = "&eWhitelisted";
            if (kitmapUp && !kitmapWhitelist) kitmapStatus = "&aOnline";
        }

        entries.add(new TabEntry(0, 7, CC.translate("&dKitMap")).setSkin(SkinUtil.PING));
        entries.add(new TabEntry(0, 8, CC.translate("&8┃ &fStatus: " + kitmapStatus)));
        entries.add(new TabEntry(0, 9, CC.translate("&8┃ &fOnline: &d" + kitmapOnline + "&7/&d" + kitmapMax)));

        int hubsOnline = phoenix.getNetworkHandler().getServersInGroup("Lobbies").stream().mapToInt(server -> phoenix.getNetworkHandler().getNonVanishedOnlinePlayers(server).size()).sum();
        int hubsMax    = phoenix.getNetworkHandler().getServersInGroup("Lobbies").stream().mapToInt(ServerData::getMaxPlayers).sum();
        int modsOnline = phoenix.getNetworkHandler().getServersInGroup("Modalities").stream().mapToInt(server -> phoenix.getNetworkHandler().getNonVanishedOnlinePlayers(server).size()).sum();
        int modsMax    = phoenix.getNetworkHandler().getServersInGroup("Modalities").stream().mapToInt(ServerData::getMaxPlayers).sum();

        entries.add(new TabEntry(1, 1, CC.translate("&dOnline")).setSkin(SkinUtil.SHIELD));
        entries.add(new TabEntry(1, 2, CC.translate("&8┃ &fGlobal: &d" + phoenix.getNetworkHandler().getOnline() + "/" + (hubsMax + modsMax))));
        entries.add(new TabEntry(1, 3, CC.translate("&8┃ &fHubs: &d" + hubsOnline + "/" + hubsMax)));
        entries.add(new TabEntry(1, 4, CC.translate("&8┃ &fModalities: &d" + modsOnline + "/" + modsMax)));

        ServerData hcf = phoenix.getNetworkHandler().getServerByName("HCF");
        String hcfStatus = "&4Loading...";
        int hcfOnline = 0;
        int hcfMax = 0;
        if (hcf != null) {
            boolean hcfUp = hcf.isOnline();
            boolean hcfWhitelist = hcf.isWhitelisted();
            hcfOnline = hcfUp ? hcf.getOnlinePlayers().size() : 0;
            hcfMax = hcfUp ? hcf.getMaxPlayers() : 0;

            if (!hcfUp) hcfStatus = "&4Offline";
            if (hcfUp && hcfWhitelist) hcfStatus = "&eWhitelisted";
            if (hcfUp && !hcfWhitelist) hcfStatus = "&aOnline";
        }
        entries.add(new TabEntry(1, 7, CC.translate("&dHCF")).setSkin(SkinUtil.PING));
        entries.add(new TabEntry(1, 8, CC.translate("&8┃ &fStatus: " + hcfStatus)));
        entries.add(new TabEntry(1, 9, CC.translate("&8┃ &fOnline: &d" + hcfOnline + "&7/&d" + hcfMax)));

        ServerData practice = phoenix.getNetworkHandler().getServerByName("Practice");
        String practiceStatus = "&4Loading...";
        int practiceOnline = 0;
        int practiceMax = 0;
        if (practice != null) {
            boolean practiceUp = practice.isOnline();
            boolean practiceWhitelist = practice.isWhitelisted();
            practiceOnline = practiceUp ? practice.getOnlinePlayers().size() : 0;
            practiceMax = practiceUp ? practice.getMaxPlayers() : 0;

            if (!practiceUp) practiceStatus = "&4Offline";
            if (practiceUp && practiceWhitelist) practiceStatus = "&eWhitelisted";
            if (practiceUp && !practiceWhitelist) practiceStatus = "&aOnline";
        }

        entries.add(new TabEntry(2, 7, CC.translate("&dPractice")).setSkin(SkinUtil.PING));
        entries.add(new TabEntry(2, 8, CC.translate("&8┃ &fStatus: " + practiceStatus)));
        entries.add(new TabEntry(2, 9, CC.translate("&8┃ &fOnline: &d" + practiceOnline + "&7/&d" + practiceMax)));

        return entries;
    }
}
NimxDev commented 3 weeks ago

you tried adding the fourth tab or adding all the lines including the ones that are empties? probably its not what you want but maybe that fixes the problem

hardcorefactions commented 3 weeks ago

I did trying to add all lines but not the fourth tab, recently I added server timers and I used it tho and still same issue, the thing is that the server timers do appear.

DevDrizzy commented 2 weeks ago

The x and y calculations might be messed up because I changed how it's done, instead of the double for loops, it's using math. So its possible specifying x and y manually is broken. I'll look into it once I'm free.

hardcorefactions commented 2 weeks ago

still no fix?