Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-7775

Add a way to be able to spawn in fake player entities via spigot API

XMLWordPrintable

    • Icon: New Feature New Feature
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • None
    • This server is running CraftBukkit version 4221-Spigot-146439e-3f8e416 (MC: 1.21) (Implementing API version 1.21-R0.1-SNAPSHOT)
    • Yes

          TL:DR - Player spawning really needs to be something you can do using the spigot API, as well as managing their skin and other vanilla-parity like whether they appear in tablist or not. Its way too difficult to do this as without it

          The title of this issue is pretty self-explanatory, but there is a lot more behind it that it may seem at first, and it always perplexed me as to why this isn't doable in spigot's api. I can't seem to find both someone asking "why is this not doable" or someone providing an answer, especially given the absolute nightmare you have to go through to do this without spigot's API. I feel like there has to be SOME reason this hasn't been changed, as this seems like something that should've been resolved over a decade ago, but since I can't find it, I'll ask it.

            I might as well say what basically every server owner who wants to make their own server software has to go through to do this. It starts with 2 major things.

        • 1, many large servers will have tons of plugins* (50-100 usually), and they will soon realize that relying on 50-100 different developers to add features or keep supporting newer versions is just a completely unreasonable task to do, especially if you're using only or mostly free stuff, so said owner may decide to stop looking for more and replace everything they use with their own plugins to never have to worry about that again.
        • 2. Almost every large server uses NPCs* for a variety of reasons, ranging from navigating across the server to having actual NPCs that can talk, move, fight, chat, pretty much do everything a player can do. Most people who want to use NPCs want to be able to use players, so when developing your NPC plugin, you go to run World#spawn(Player,...), only to find out you can't, after a quick google search, you realize there is no API for this, so you're stuck using either someone else's stuff or NMS, both options are totally not viable for this type of owner, which i'll explain

          - Using someone else's stuff: Weather this is a plugin that can do everything (example: Citizens) or just to make the process of handling the protocol easier (example: ProtocolLib), they both have a fatal flaw: You have to rely on someone else's stuff, which defeats the purpose of making your own plugin to begin with. Not to mention they could be horribly optimized which is something you will definitely have to find solutions for when you have so much software.

          - Using NMS: You will no longer have the issue of relying on others, but working with NMS is nearly impossible. With no documentation and a horrific name system basically forces you to have to search the internet for help. This may not be that big of a deal if you're a server that stays on the same, old version, since version upgrades are the largest problem when it comes to NMS, but if that's not the case, you're screwed. You will be lucky to find any issues that can actually help you since they will all be for older versions, and especially since 1.19.3, player spawning has drastically changed multiple times, making you being stuck either fending for yourself, or asking online, which is incredibly annoying to do for all parties involved. Nobody wants to ask how to re-do the same thing over and over again and nobody wants to answer that. In my experience, it took me at least 15 hours (not an exaggeration) to get players spawnable and interactable back in 1.20.1,  ever since 1.20.2 despite spending basically that same amount of time to try and get it working again, I still haven't cracked it. I have found a few pages made about fake players since 1.20.2, but every single solution doesn't work. So that's 30 total hours and that's just simply to make them have a skin and be interactable, stuf you could consider as "easy". Imagine trying to add something as complicated as AI... safe to say relying on NMS is just not doable. Even if you use reflection, that's likely going to do nothing as very rarely would any code regarding players not be changed at all.

          Hopefully this essay worth of an explanation can get across how much of a pain it is to do this without an alternative in spigot's API. However a few other notes. Since the normal Player API lacks some stuff you'd likely use there's a few extra methods a FakePlayer should have. I've figured these 2 out already (as of 1.20.1 at least) and if this request gets accepted I am willing to send what i can:

      1. setSkin(URL) and setSkin(File). You'd likely want the ability to manage a fake player's skin, so being able to do so would help immensely. The URL one would let you download one from a url, so you can choose to use Mojang's skin service or someone elses like Mineskin's. The file option is basically the same, but its mostly for using a service like Mineskin, where you can upload any valid skin png and get a working player skin for it. Having some way to access third party tools like that is an absolute requirement if skin support is added.

       

      2. setViewableFromServer(boolean). This is pretty much the same as the Player#hidePlayer methods, however this would hide everything but the fakeplayer themselves, so they wont appear in tab completion, tablist, scoreboards, etc.

          Hopefully an official FakePlayer API can get added, or at the very least, a reasonable explanation as to why this can't be done, because it really is perplexing to have seen nobody ask this question before since I'm sure so many people wanting to make NPC-based plugins (and possibly other types of plugins too) would want to ask it.

            Unassigned Unassigned
            Budderman18 Budderman18
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: