[1.12.2-R0.1] Hiding a fake player's username using packets

Discussion in 'Spigot Plugin Development' started by GreatThane, Jun 7, 2018.

  1. I'm attempting to make a method for making a player lay face down (I know face up options are readily available, but I wanted to attempt to make a face-down option).
    Right now, I basically have what I want except for one small bug. I cannot figure out a way to hide the fake player I have spawned's username.
    [​IMG]
    Currently, I'm trying to use the ScoreboardTeam packet (using protocol lib and this packet wrapper) to set username visibility to "never".
    This is my current attempt:
    Code (Java):

    WrapperPlayServerScoreboardTeam createTeam = new WrapperPlayServerScoreboardTeam();
    createTeam.setMode(WrapperPlayServerScoreboardTeam.Mode.TEAM_CREATED);
    createTeam.setName("prone");
    createTeam.setDisplayName("Prone");
    createTeam.setCollisionRule("never");
    createTeam.setNameTagVisibility("never");
    createTeam.setPlayers(new ArrayList<String>() {{
        add(event.getPlayer().getName());
    }});

    WrapperPlayServerScoreboardTeam updateTeam = new WrapperPlayServerScoreboardTeam();
    updateTeam.setMode(WrapperPlayServerScoreboardTeam.Mode.PLAYERS_ADDED);
    updateTeam.setPlayers(new ArrayList<String>() {{
        add(event.getPlayer().getName());
    }});

    for (Player player : Bukkit.getOnlinePlayers()) {
        if (!(player.getUniqueId().equals(event.getPlayer().getUniqueId()))) {
           // -snip-
            if (gottenCreationPacket.contains(player.getUniqueId())) {
                    updateTeam.sendPacket(player);
            } else {
                createTeam.sendPacket(player);
                gottenCreationPacket.add(player.getUniqueId());
            }
        }
    }
     
    This is the selection of code I feel is related to to problem, but if the entire class is required, I can supply it.
     
  2. Just put an invisible entity on the fake player's head.
     
  3. I would like to avoid having a continuous teleportation loop if possible. Is the trick of putting a negatively-sized slime and an entity on that onto the player's head trick still possible?
     
  4. Why would you need a teleportation loop? You just need to mount any entity on the fake player.
     
  5. Oh, I didn't actually know that! I'll look into it.