The constructor PlayerInfoData is undefined

Discussion in 'Spigot Plugin Development' started by shawshark, May 1, 2015.

  1. Hello, i'm using code that was working in 1.8 but suddenly is now broken in 1.8.3, I'm getting this error in eclipes: "The constructor PacketPlayOutPlayerInfo.PlayerInfoData(PacketPlayOutPlayerInfo, GameProfile, int, null, null) is undefined"

    this is the code i'm using:
    Code (Text):
        public boolean removeallatonce() {
           
            PacketPlayOutPlayerInfo remove = new PacketPlayOutPlayerInfo();
           
            boolean done = false;
             try {
               
                 Field a = remove.getClass().getDeclaredField("a");
                 a.setAccessible(true);
                 a.set(remove, EnumPlayerInfoAction.REMOVE_PLAYER);
               
                 Field b = remove.getClass().getDeclaredField("b");
                 b.setAccessible(true);
                 List<PlayerInfoData> datalist = Lists.newArrayList();
               
                 Iterator< profile > profile = getUserProfiles().iterator();
                   
                 while(profile.hasNext()) {
                    profile user = profile.next();
                   
                    if(getInstance().getServer().getPlayer(user.getUser()) != null) continue;
                   
                    PlayerInfoData data = user.getData();
                    GameProfile gprofile = data.a();
                    datalist.add(new PacketPlayOutPlayerInfo.PlayerInfoData(remove, gprofile, -1, null, null));
                    b.set(remove, datalist);
                   
                    profile.remove();
                }
               
                done = true;
               
             } catch (Exception e) {
                 e.printStackTrace();
                 done = false;
             }
             for(Player player : getInstance().getServer().getOnlinePlayers()) {
               
                 CraftPlayer craftplayer = (CraftPlayer) player;
                 PlayerConnection connection = craftplayer.getHandle().playerConnection;
                 connection.sendPacket(remove);
             }
             return done;
        }
    I'm getting the error on this line
    Code (Text):
    datalist.add(new PacketPlayOutPlayerInfo.PlayerInfoData(remove, gprofile, -1, null, null));
     
  2. gigosaurus

    Supporter

    The constructor is now
    Code (Text):
    GameProfile p2, int p3, EnumGamemode p4, IChatBaseComponent p5
    so change that line to
    Code (Text):
    datalist.add(new PacketPlayOutPlayerInfo.PlayerInfoData(gprofile, -1, null, null));
     
  3. That doesn't seem to work, i get this error in eclipes,
    Code (Text):
    No enclosing instance of type PacketPlayOutPlayerInfo is accessible. Must qualify the allocation with an enclosing instance of type PacketPlayOutPlayerInfo (e.g. x.new A() where x is an instance of PacketPlayOutPlayerInfo).
     
  4. Create an instance of the packet, and then create the PlayerInfoData as
    Code (Java):
    packet.new PlayerInfoData(params);
     
  5. Doesn't work,
    I get this in eclipes when trying "Packet.PlayerInfoData cannot be resolved to a type" and this is the code
    Code (Text):

     PlayerInfoData data = new Packet.new PlayerInfoData(profile, 10, EnumGamemode.SURVIVAL, ChatSerializer.a(name));
                       
     
  6. gigosaurus

    Supporter

    Oops, thought the inner class was static.

    -_- really? You can't work out that you have to put "remove" instead of "packet", because you named your packet "remove"?
    Code (Java):

    datalist.add(remove.new PlayerInfoData(gprofile, -1, null, null));
     
     
    #6 gigosaurus, May 2, 2015
    Last edited: May 2, 2015