Resource Prevent Offline Servers Using Your Plugin

Discussion in 'Spigot Plugin Development' started by Haileykins, Aug 16, 2018.

Thread Status:
Not open for further replies.
  1. First off let me state a few things:

    1. While I do not necessarily approve of offline servers (with the exception of Bungeecorded servers that aren't the hub) and cracked MC accounts, I also do not think there is much reason to restrict the usage of your plugin to only online mode servers
    2. This tactic is probably well known if you are familiar at all with getServer in the SpigotAPI.
    So how do we do it? It's honestly so simple it needs not much of an explanation. First, we check the servers online mode, then we disable the plugin if it's not online.

    Code (Java):

    if (!getServer().getOnlineMode()) {
    You, of course, don't need to disable it, or you could and also send a message to the console saying why it was disabled. While I don't find this useful, maybe others will, which is why I decided to share it.
    #1 Haileykins, Aug 16, 2018
    Last edited: Aug 16, 2018
  2. Very nice and simple but anyone can easily remove this check, don't you think?
    • Agree Agree x 1
  3. Well..
    First of, your source code snippet above is not actually working. getServer as well as getOnlineMode are methods, not fields, you have to call them.
    Furthermore, this makes using your plugin with BungeeCord impossible, as that requires the individual servers to be in offline-mode. So actually rather wait for a PlayerJoinEvent/PlayerPreLoginEvent, check if
    Code (Text):
    , which indicates an offline player.

    Edit: This works because this gets the "version" field from the uuid. See
    Bungeecord sends the actual uuid and stuff to the server with the Handshake packet, so if BungeeCord is in offline mode, this will still detect an offline server. As long as both BungeeCord and Spigot are vanilla, this will accurately detect whether this is an online server.
    #3 JoJoModding, Aug 16, 2018
    Last edited: Aug 16, 2018
    • Friendly Friendly x 2
    • Agree Agree x 1
    • Informative Informative x 1
  4. TheJavaHacker


    I'm 100% certain that this is against Spigot's Premium Resource Rules.
    • Agree Agree x 1
  5. Screen Shot 2018-08-16 at 10.40.23.png

    It doesn't shut the server down or something, it just doesn't load the plugin. Simple as that. While I agree with you (calm down, im on your side), i dont see in this batch of drm points something that makes it 'not allowed'.
    - no internet is required for this to run, it's not a licensing system, it only affects that plugin, it doesn't seem to disable the server.
    • Agree Agree x 1
    • Informative Informative x 1
  6. My fault for the source not working, I wrote this when I was half asleep, the OP source has been repaired. For those who are saying its against Spigot, its not, it's your personal choice how to code your plugin and how you want it to work, personally I don't agree with locking it to online only servers (one reason being bungee cord), so what I would do personally instead, is a console message just saying something like

    I detected your server is in offline mode, please understand I will not give you any support for the plugin unless this server is a bungee-corded server or something to that effect. This was just something I thought would be an interesting learning moment for new devs or old devs, and to give ideas on the kinds of things you can do.
  7. Also Spigots premium resource rules wouldn't apply here since this post is not pertaining to just premium resources. Just a neat thing that can be done to prevent unauthorized servers from running your plugin. But @JoJoModding does have a point, it would render the plugin useless to Bungeecord servers, which is why I said you don't have to disable the plugin, you could instead send a console message, or a message admins on login, telling them if the server is in offline mode and is not bungee, you will not provide support.
  8. There is so much wrong with the implementation.
    1. You disable the plugin WHEN it is in online mode. Instead of when it's NOT in online mode.
    2. The implementation completely disregards bungeecord servers, that require the server to run in offline mode. How can you forget, you even mentioned this: "with the exception of Bungeecorded servers that aren't the hub"
    "I wrote this when I was half asleep"

    Conclusion: goodnight.
    • Funny Funny x 1
  9. Okay, I don't need the smart-ass stuff. It was already stated I wrote this when I was half asleep. I've also been trying to take care of other things in my life right now. Yes, I see the mistakes I made, also, as you can see, it states you don't need to disable the plugin, you can do other things, that was designed as a secondary option to disabling, useful in the case of bungee-cord servers. Do you have anything better to do than be an ass? Constructive criticism gets you further than trying to make people feel stupid especially when you have no idea what might be going on around them at the time they are trying to do something. Have a nice day.
    • Optimistic Optimistic x 1
Thread Status:
Not open for further replies.