API Change player name tags, once again!

Discussion in 'Resources' started by AlvinB, Feb 10, 2017.

Thread Status:
Not open for further replies.
  1. So, ever since TagAPI was discontinued, we have been lacking a way to change player name tags. And because this is a constant question in the Plugin Development forum (I also needed it for a project), I decided to code a little library you can shade into your plugin and effortlessely change player names. I call it NameTagChanger (I know it's a pretty awful name, but I couldn't come up with anything better..).

    NOTE: If you just want to colour the entire player name or just add prefixes or suffixes, I recommend using scoreboards instead of this, since they allow for a greater total length (32 characters instead of 16 I believe).

    The documentation is now entirely over on the github page:
    https://github.com/Alvin-LB/NameTagChanger

    This works by modifying the outgoing TabList packets (using reflection, so relatively version-independent) to say that the name of the Player is different (the client uses the tablist for this for some reason), but the display name is still the same (also respects player.setDisplayName()), so no change is done to the tablist. The modification of packets is done via ProtocolLib, but if it's not found installed, there is a direct channel injector system to fall back on (although ProtocolLib is more reliable, so I recommend using that instead).
     
    Last edited: Sep 17, 2017
  2. Offline

    PhantomUnicorns

    +1 like because the resource itself is cool and defining what shading is :p
     
  3. Offline

    rj3824

    Is this a 1.11 thing only or is it supposed to compatible with other versions as well?
     
  4. @rj3824
    Yes, this uses reflection, so in theory it should be able to work on all versions from 1.8 to 1.11.
     
  5. Offline

    rj3824

    I tried it on a 1.10.2 server but it hasn't worked.
     
  6. @rj3824
    Describe what happens - does it throw errors in console? Does it just not work?
     
  7. Offline

    Zombie_Striker

    @rj3824
    Why are you using a 1.10.2 server? You should update your server to 1.11.

    Are there any errors in the console?
     
  8. @rj3824
    I actually tested this myself, and I found that when you reset a player's name you would get kicked (I could've sworn that didn't happen before..) if you were using the non-protocollib implementation.

    Anyway, that (along with a couple other minor things) have been fixed. Please redownload the jar.
     
  9. Offline

    rj3824

    So what's this protocolLib implementation, is it better

    So this is my code looks like this :
    code.PNG

    And the error I get is this: error.png

    Am i doing something wrong?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 24, 2017
  10. @rj3824
    You don't seem to have added the library to your buildpath properly. Are you sure you have it setup to be shaded into your plugin? Can you post a screenshot of your configuration of it?

    EDIT: What I mean by the "protocol-lib implementation" is that this will use ProtocolLib to do any packet manipulation, which is more reliable. It won't fix your issue though.
     
    Last edited: Feb 24, 2017
  11. Offline

    rj3824

    I didn't do the add to build path way, I used maven and added the repository and dependency


    Sent from my iPad using Tapatalk
     
  12. @rj3824
    Please post your pom.xml. (Btw, just adding the dependency isn't enough, you have to also use the Maven Shade plugin to shade it into your final jar.)
     
  13. @AlvinB By the way you should be able to use [plain][/plain] in your Pom to remove the parts
     
  14. Offline

    rj3824

    Ok, I don't think I did that, do I just have to download the plugin into IntelliJ and then what?
     
    Last edited by a moderator: Feb 25, 2017
  15. @rj3824
    Updated the main post with instructions for maven shading. Just add the bottom bit to your pom and you should be good to go.

    @bwfcwalshy
    Where exactly do I put the plain tags? I tried both inside and outside the syntax tags, none of them worked.
     
  16. @AlvinB Oh really?

    Hmm, seems you can't :/
     
  17. Offline

    rj3824

    Ok, I'll try it asap


    Sent from my iPad using Tapatalk

    @AlvinB

    So, its now working now that i have shaded the plugin into maven and what not however I have encountered a new problem. If I use this code: code.PNG

    and the player has a long name such as mine, rj3824thesecond which is less then 16 characters, and I add a colour to it, I get this error:
    error.png

    which doesn't really make any sense, especially when i use the same code but without a colour i don't get any errors.

    So in game, the person with the short name gets his name coloured and the person with the long name doesn't.

    You got any ideas why?

    @AlvinB

    Also, there's one more problem just because I know you love those, when a persons name is changed, their skin is also changed back to a default skin, in this case Alex:

    code1.PNG

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Feb 26, 2017
  18. @rj3824
    All your attachments seem to have been removed for some reason, but I can still probably tell what's wrong.

    1. The reason is that there is a 16 character limit for player names (which is imposed by minecraft clients, not me), and when you add a colour code (counts as two characters, ยง and the letter) to "rj3824thesecond" (15 chars) it becomes 17 chars, which the client does not allow (although I prevent the name from even being changed, as the client would be kicked).

    2. I have taken a look at it, and it seems I forgot to carry over some data in the internals of the packets regarding skins. The only problem is that I only own one account, so I can't test if it works, so I'd appreciate it if you would try it. I have pushed out an update to the maven repository, try reloading the maven dependencies by doing mvn -U clean install.

    Also, it seems like you're trying to change the colours of players names, which does work with this library, but it is a bit annoying because of the 16 character limit I mentioned above. What I recommend instead is using Scoreboards to change the colour of player names.
     
  19. Offline

    rj3824

    @AlvinB I will test the skins stuff as soon as I can.


    Sent from my iPad using Tapatalk
     
  20. Offline

    PhantomUnicorns

    Would it change your skin to whom ever name you change your name to? :3

    - PhantomUnicorns, for like you know, testing :p
     
  21. @PhantomUnicorns
    No, it wouldn't, it'd be the same one as you had originally. I could potentially implement that functionality if needed though.
     
  22. Offline

    rj3824

    Not that I know of, I never tested it
     
  23. Offline

    PhantomUnicorns

    @AlvinB I was saying when it went to default skin, I don't know if you mean that :p I like thinking about it though, being able to be in another person's skin XD (Look like them and whatnot)
     
  24. Offline

    mine2012craft

    @AlvinB So I added the shaders to my pom, but for some reason, i'm getting this error:


    Code:
    [18:54:32] [Server thread/ERROR]: Could not load 'plugins\NameTagChanger v1.0-SNAPSHOT (1).jar' in folder 'plugins'
    org.bukkit.plugin.InvalidDescriptionException: Invalid plugin.yml
        at org.bukkit.plugin.java.JavaPluginLoader.getPluginDescription(JavaPluginLoader.java:152) ~[spigot.jar:git-Spigot-7d78b81-70bc70b]
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:133) [spigot.jar:git-Spigot-7d78b81-70bc70b]
        at org.bukkit.craftbukkit.v1_11_R1.CraftServer.loadPlugins(CraftServer.java:300) [spigot.jar:git-Spigot-7d78b81-70bc70b]
        at net.minecraft.server.v1_11_R1.DedicatedServer.init(DedicatedServer.java:204) [spigot.jar:git-Spigot-7d78b81-70bc70b]
        at net.minecraft.server.v1_11_R1.MinecraftServer.run(MinecraftServer.java:542) [spigot.jar:git-Spigot-7d78b81-70bc70b]
        at java.lang.Thread.run(Unknown Source) [?:1.8.0_101]
    Caused by: java.io.FileNotFoundException: Jar does not contain plugin.yml
        ... 6 more
    
    My Pom:

    Code:
        <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <minimizeJar>true</minimizeJar>
                            <artifactSet>
                                <includes>
                                    <include>com.bringholm.nametagchanger:NameTagChanger</include>
                                </includes>
                            </artifactSet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
         </plugins>
    </build>
        <repositories>
        <repository>
            <id>spigot-repo</id>
            <url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
        </repository>
      
            <repository>
            <id>alvinb-repo</id>
            <url>http://repo.bringholm.com/</url>
        </repository>
    </repositories>
    
    <dependencies>
      <dependency>
           <groupId>com.bringholm.nametagchanger</groupId>
           <artifactId>NameTagChanger</artifactId>
           <version>1.0-SNAPSHOT</version>
        </dependency>
    Now unless I need to create A maven project, then that might be the case... But for now, the NameTag plugin won't load

    EDIT: And yes, I added it to my Build path too.
     
  25. @mine2012craft
    Well, you seem to be trying to run the jar I provide, which is just supposed to be shaded into your plugin, it doesn't contain a plugin.yml, main class or anything to make it run on its own.
     
  26. Offline

    mine2012craft

    @AlvinB Oh, sorry. That's usually my first instinct on downloadable jars: import them into my build path (or shade them) and put them in your plugin folder.

    Although, i did try to do it without the jar, but I ran into the same problem asrj3824 did, no class found, even though I shaded it and put it in my build path. Do I need to make a Maven Project for this or something?
     
  27. @mine2012craft
    If you have a maven project: go with the maven instructions above, if not, download the jar and tell whatever you're using to compile to shade it into the final jar.
     
  28. Offline

    mine2012craft

    Hmm... Well I tried to export it while including the jar. Didn't think it would work. I also checked the rest of the jar export steps to see if there was something about shading, but there wasn't... Do I need to use something else?

    [​IMG]
     
  29. @mine2012craft
    I'm not sure about the details on eclipse (I mainly use IntelliJ), you'd either have to google or ask someone with more eclipse experience.
     
  30. Offline

    mine2012craft

    Dang. Well thanks for trying
    If no one still knows when I ask later, I will just switch to IntelliJ
     
Thread Status:
Not open for further replies.

Share This Page