Skip to content

Some tablist entries are not appearing #4

Open

Description

@hardcorefactions

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.

Activity

  1. DevDrizzy commented on Aug 14, 2024

    @DevDrizzy
    Member

    Attach your full Tablist adapter

  2. hardcorefactions commented on Aug 16, 2024

    @hardcorefactions
    Author

    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;
        }
    }
  3. NimxDev commented on Aug 18, 2024

    @NimxDev

    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

  4. hardcorefactions commented on Aug 18, 2024

    @hardcorefactions
    Author

    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.

  5. DevDrizzy commented on Aug 25, 2024

    @DevDrizzy
    Member

    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.

  6. hardcorefactions commented on Aug 30, 2024

    @hardcorefactions
    Author

    still no fix?

  7. hardcorefactions commented on Oct 13, 2024

    @hardcorefactions
    Author

    hello?

  8. DevDrizzy commented on Oct 13, 2024

    @DevDrizzy
    Member

    I cannot replicate this issue on my side

  9. hardcorefactions commented on Oct 19, 2024

    @hardcorefactions
    Author

    oh ok ;(

  10. hardcorefactions commented on Dec 20, 2024

    @hardcorefactions
    Author

    reopening since i found somewhat of a workaround if anyone is having the same issue:

    • fill all the tab gaps

    code i used at the end of the entries:

    for (int x = 0; x < 4; x++) {
                for (int y = 1; y <= 20; y++) {
                    int finalX = x;
                    int finalY = y;
                    boolean isOccupied = entries.stream().anyMatch(entry -> entry.getX() == finalX && entry.getY() == finalY);
    
                    if (!isOccupied && entries.size() < 80) {
                        entries.add(new TabEntry(x, y, ""));
                    }
                }
            }

    throws an error of 83 entries but i've forked it on my own and removed that check lul

  11. DevDrizzy commented on Dec 20, 2024

    @DevDrizzy
    Member

    You can make a pull request if you want

  12. hardcorefactions commented on Dec 20, 2024

    @hardcorefactions
    Author

    I'm trying to check out on what's the issue first so yh.

  13. hardcorefactions commented on Dec 20, 2024

    @hardcorefactions
    Author

    yeah uh, no idea but when I use that code i mentioned above it throws this error if it helps in some way.

    [23:39:12 FATAL]: [gHub] There was an error updating tablist for jsexp
    [23:39:12 ERROR]: java.lang.ArrayIndexOutOfBoundsException: Index 83 out of bounds for length 80
    [23:39:12 WARN]: java.lang.ArrayIndexOutOfBoundsException: Index 83 out of bounds for length 80
    [23:39:12 WARN]:        at xyz.refinedev.api.tablist.setup.TabLayout.getTeamAt(TabLayout.java:563)
    [23:39:12 WARN]:        at xyz.refinedev.api.tablist.setup.TabLayout.update(TabLayout.java:315)
    [23:39:12 WARN]:        at xyz.refinedev.api.tablist.setup.TabLayout.refresh(TabLayout.java:223)
    [23:39:12 WARN]:        at xyz.refinedev.api.tablist.thread.TablistThread.tick(TablistThread.java:49)
    [23:39:12 WARN]:        at xyz.refinedev.api.tablist.thread.TablistThread.run(TablistThread.java:31)
  14. DevDrizzy commented on Jan 16, 2025

    @DevDrizzy
    Member

    It's 0 indexed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions