Development Assistance TabAPI

Discussion in 'Plugin Help/Development/Requests' started by DaveLillo, Jan 28, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    DaveLillo

    Whats with the TabAPI? Is there going to be an update for at least 1.7.10? Or can i change the Tab Players List in any other way except using the API? Btw I mean this:
    dev.bukkit.org/bukkit-plugins/tabapi/
     
  2. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit help
    @DaveLillo Does it need the update?
     
  3. Offline

    DaveLillo

    Yes, I'm coding on 1.7.10 and there occures always errors. When Im at home will sned you the error message and my Code okay?
     
  4. Online

    timtower Administrator Administrator Moderator

    @DaveLillo Never ask if you need help. Just post the errors and code anyways.
     
  5. Offline

    DaveLillo

    Console:

    Code:
    [06:59:37 INFO]: UUID of player DaveLillo is c5b553ef-c174-3aec-a89b-9e9e174f7f0
    2
    [06:59:37 INFO]: DaveLillo[/127.0.0.1:59567] logged in with entity id 57 at ([wo
    rld] 202.6585881788615, 69.0, 138.34391682198319)
    [06:59:42 WARN]: [testAPI] Task #6 for testAPI v1.0 generated an exception
    com.comphenix.protocol.reflect.FieldAccessException: Field index must be within
    0 - count
            at com.comphenix.protocol.reflect.StructureModifier.write(StructureModif
    ier.java:285) ~[?:?]
            at org.mcsg.double0negative.tabapi.TabAPI.sendPacket(TabAPI.java:151) ~[
    ?:?]
            at org.mcsg.double0negative.tabapi.TabAPI.updatePlayer(TabAPI.java:275)
    ~[?:?]
            at me.DaveLillo.test.main.updateTab(main.java:51) ~[?:?]
            at me.DaveLillo.test.main$1.run(main.java:34) ~[?:?]
            at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java
    :71) ~[start.jar:git-Spigot-1649]
            at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHea
    rtbeat(CraftScheduler.java:350) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:6
    41) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:2
    89) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:5
    84) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :490) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [start.jar:git-Spigot-1649]
    Caused by: java.lang.IndexOutOfBoundsException: Out of bounds
            ... 12 more
    >
    Code:

    Code:
    package me.DaveLillo.test;
    
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;
    import org.mcsg.double0negative.tabapi.TabAPI;
    
    public class main extends JavaPlugin implements Listener {
       
       
       
        private static main plugin; {plugin = this;}
    
       
       
        public void onEnable(){
            System.out.println("[TestAPI] Plugin started");
            Bukkit.getPluginManager().registerEvents(this, this);
        }
       
        @EventHandler
        public void PlayerJoin(PlayerJoinEvent e){
            final Player p = e.getPlayer();
            p.sendMessage("AA");
            TabAPI.setPriority(plugin, p, 2);
            new BukkitRunnable() {
            @Override
                public void run() {
                p.sendMessage("A");
                updateTab(p);
                }
            }.runTaskLater(getPlugin(), 100);
        }
       
        public void playerJoin(Player p){ //add player to the game, set their priority here
              TabAPI.setPriority(this, p, 2);
              TabAPI.updatePlayer(p); //always good to update the player after priority change so that the plugin with priority gets displayed
            //other code
            }
    
            public void updateTab(Player p){ //update the tab for a player
               
                p.sendMessage("B");
                TabAPI.setTabString(this, p, 0, 0, "players");
                TabAPI.updatePlayer(p);
            }
           
            public static main getPlugin() {
                return plugin;
            }
    
            public void removePlayer(Player p){ //player died or left, return priority
              TabAPI.setPriority(this, p, -2); //-2 means this plugin isn't using the tab anymore, dont show
              TabAPI.updatePlayer(p); //always good to update the player after priority change so that the plugin with priority gets displayed
                                              
            //other code
    
        }
           
    }
    The messages send to the player are only for debugging.
     
  6. Online

    timtower Administrator Administrator Moderator

    Moved to Bukkit alternatives.
    @DaveLillo System.out.println("[TestAPI] Plugin started"); no need for that line, Bukkit does that for you already.
    And I have no idea why it does this, maybe this is a ProtocolLib issue
     
  7. Offline

    DaveLillo

    I'm using the latest version... Does it work at your PC?
     
  8. Online

    timtower Administrator Administrator Moderator

  9. Offline

    DaveLillo

    Does someone know how to change the TabList without the TabAPI?
     
  10. Online

    timtower Administrator Administrator Moderator

  11. Offline

    8jy89hui

    Could it be that when you set priority you are setting the priority out of bounds?
    Code:
    TabAPI.setPriority(this, p, 2);
    I have never done anything with TabAPI but an out of bounds exception would seem to point to this.
     
  12. Offline

    DaveLillo

    I never had an out of bounds exception, can you explain please what this is?
    I deleted the line
    Code:
    TabAPI.setPriority(this, p, 2);
     
  13. Offline

    8jy89hui

    Nevermind. After looking through your code it seems your UpdateTab code is having the problem. (You can readd the .setPrority() code I was mistaken and did not have time to read through the error message fully)
    Code:
            public void updateTab(Player p){ //update the tab for a player
             
                p.sendMessage("B");
                TabAPI.setTabString(this, p, 0, 0, "players");
                TabAPI.updatePlayer(p);
            }
    I would bet that the setTabString is the problem although I dont know.
    ^ Is most likely the case.
    Try different numbers with the setTabString(). (If this does not work please look for line 56 and line 34 and tell me what they are doing).
     
  14. Offline

    DaveLillo

    I tried with 1, 2 and other combinations but I get every time the same error...

    Line 56: is empty

    Line 34: Closes PlayerJoinEvent.

    I changed the code a little, heres the new Code and the new error:

    Code:
    package me.DaveLillo.test;
    
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scheduler.BukkitRunnable;
    import org.mcsg.double0negative.tabapi.TabAPI;
    
    public class main extends JavaPlugin implements Listener {
       
       
       
        private static main plugin; {plugin = this;}
    
       
       
        public void onEnable(){
            System.out.println("[TestAPI] Plugin started");
            Bukkit.getPluginManager().registerEvents(this, this);
        }
       
        @EventHandler
        public void PlayerJoin(PlayerJoinEvent e){
            final Player p = e.getPlayer();
            new BukkitRunnable() {
            @Override
                public void run() {
                updateTab(p);
                }
            }.runTaskLater(getPlugin(), 3);
        }
       
        public void playerJoin(Player p){ //add player to the game, set their priority here
              TabAPI.setPriority(this, p, 2);
              TabAPI.updatePlayer(p); //always good to update the player after priority change so that the plugin with priority gets displayed
            //other code
            }
    
            public void updateTab(Player p){ //update the tab for a player
                TabAPI.setTabString(this, p, 1, 2, "test");
                TabAPI.updatePlayer(p);
            }
           
            public static main getPlugin() {
                return plugin;
            }
    
            public void removePlayer(Player p){ //player died or left, return priority
              TabAPI.setPriority(this, p, -2); //-2 means this plugin isn't using the tab anymore, dont show
              TabAPI.updatePlayer(p); //always good to update the player after priority change so that the plugin with priority gets displayed
                                              
            //other code
    
        }
           
    }
    Code:
    [09:22:50 INFO]: UUID of player DaveLillo is c5b553ef-c174-3aec-a89b-9e9e174f7f0
    2
    [09:22:50 INFO]: DaveLillo[/127.0.0.1:49225] logged in with entity id 57 at ([wo
    rld] 198.6394277772562, 69.0, 137.30926268784418)
    [09:22:50 WARN]: [testAPI] Task #9 for testAPI v1.0 generated an exception
    com.comphenix.protocol.reflect.FieldAccessException: Field index must be within
    0 - count
            at com.comphenix.protocol.reflect.StructureModifier.write(StructureModif
    ier.java:285) ~[?:?]
            at org.mcsg.double0negative.tabapi.TabAPI.sendPacket(TabAPI.java:151) ~[
    ?:?]
            at org.mcsg.double0negative.tabapi.TabAPI.updatePlayer(TabAPI.java:275)
    ~[?:?]
            at me.DaveLillo.test.main.updateTab(main.java:44) ~[?:?]
            at me.DaveLillo.test.main$1.run(main.java:31) ~[?:?]
            at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftTask.run(CraftTask.java
    :71) ~[start.jar:git-Spigot-1649]
            at org.bukkit.craftbukkit.v1_7_R4.scheduler.CraftScheduler.mainThreadHea
    rtbeat(CraftScheduler.java:350) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:6
    41) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:2
    89) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:5
    84) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java
    :490) [start.jar:git-Spigot-1649]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:6
    28) [start.jar:git-Spigot-1649]
    Caused by: java.lang.IndexOutOfBoundsException: Out of bounds
            ... 12 more
    >
     
  15. Offline

    8jy89hui

    Nvm. found it. This time when you posted your code the code was on the correct lines.
    This is your problem:
    Code:
      public void updateTab(Player p){ //update the tab for a player
                TabAPI.setTabString(this, p, 1, 2, "test"); // <--- Idk... might aswell try setting it back to 0,0
                TabAPI.updatePlayer(p); // <------- Is the problem (Try removing it)
            }
     
  16. Offline

    DaveLillo

    Thank you man.
    So now if I join, I don't see anything in my Tab list, but I also don't get an error... I hate that TabAPI -.-
     
    Roptitou :D likes this.
Thread Status:
Not open for further replies.

Share This Page