1.15.2 Fake player

Discussion in 'Spigot Plugin Development' started by lolbob2win, Feb 23, 2020.

  1. how do I fake an online player? I want Bukkit to add it to its online player Collection.

    I need this in order to send plugin messages without worrying about player count.
     
  2. What do you want to do exactly?
     
  3. Hey lolbob!

    Not sure if faking the online player is quite the solution you're looking for.

    "send plugin messages without worrying about player count" tells me you may just need something simple like a null check or a for loop that would handle this for you. If you'd like to get help with this issue let me know!

    Happy Coding
     
  4. Sending commands across servers.

    Maybe do your research first. If it were that easy, I wouldn’t be creating this thread. Just creating an EntityPlayer NPC doesnt make the server consider it as an online player in Bukkit#getOnlinePlayers.

    Uhh that’s not plugin messages work. These messages don’t send to the server unless there is at least one player online, but they will be stored in a queue that will be gone when the server restarts. Null checks and for loops have nothing to do with this. So this is why I need a fake player to make it seem as if there is one player online on the server so the messages will send immediately.
     
  5. Not sure if this is possible, since plugin messages might require a proper player connection to send plugin messages through. You may be able to use sockets to communicate between servers without the plugin messaging channel, but I can't speak for how difficult or secure it is.
     
  6. I thought about using sockets but it’s hard for my other servers to know which port is hooked by the socket I want. In my other thread, someone suggested to store the ports and addresses in a file, but if the port changes for the socket, I have to go to each server and change the file. Also yeah, anyone can connect to a server socket so I have to figure out a way to verify that the client is from my servers and not from some random person.

    So, I would like to stick with the messaging channel, and I feel like there’s a way to fake a real player connection. Does anyone know how bukkit handles player when they join? Maybe that code might help me fake a real player connection...
     
  7. Updating a couple of config files sounds like a small price to pay, but I don't see why you might need to change ports. Another thread looking to do the same thing you're doing came up with the same suggestion though: plugin messages just aren't the way to go, suggesting instead to just use sockets or netty. I don't think security should be an issue so long as your firewall is properly configured.
     
  8. Thing is, I’m using a shared host so someone could be occupying a port that my sockets are using. So I have to change the port.
     
    • Informative Informative x 1