Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created PlaceholderAPI soft dependency #311

Closed
wants to merge 2 commits into from

Conversation

mart-r
Copy link

@mart-r mart-r commented Oct 14, 2020

Allows parsing PAPI placeholders in MOTD and in player hover message
Should address #146

@stephan-gh
Copy link
Member

Thanks for the PR. I think my primary concerns with the changes are the following:

  • I don't think it's a good idea to pass the TemporaryPlayer (event.getPlayer().getPlayer()) from ProtocolLib to PlaceholderAPI. As you noticed it's highly limited (throws UnsupportedOperationException for many methods) and it does not even expose all information that we have.
    • In particular, we may have the UUID of the player from tracking, so some of the player placeholders in PlaceholderAPI could be used.
  • Some placeholders might conflict with the ones in ServerListPlus (which also uses %placeholder%).
    • Perhaps the easiest solution here is to use PlaceholderAPI.setBracketPlaceholders(...), which seems to use {placeholder} instead.
  • The PlaceholderAPI hook is a bit "hacked" into the ProtocolLibHandler and therefore won't work at all when using the PaperEventHandler for example.

I think it would be cleaner to hook in PlaceholderAPI as DynamicReplacer into the ServerListPlus replacement API. This could even be done from an external plugin without changes in ServerListPlus, although I think it's better to have it built-in. Something like

public class PlaceholderAPIDynamicReplacer implements DynamicReplacer {

    @Override
    public boolean find(String s) {
        return PlaceholderAPI.containsBracketPlaceholders(s);
    }

    @Override
    public String replace(StatusResponse response, String s) {
        PlayerIdentity identity = response.getRequest().getIdentity();
        if (identity != null) {
            // Note: I'm not sure if getOfflinePlayer is really safe here.
            // Server status pings are handled asynchronously (not on main thread)
            return PlaceholderAPI.setBracketPlaceholders(Bukkit.getOfflinePlayer(identity.getUuid()), s);
        } else {
            return replace(response.getCore(), s);
        }
    }

    @Override
    public String replace(ServerListPlusCore core, String s) {
        return PlaceholderAPI.setBracketPlaceholders((OfflinePlayer) null, s);
    }

}

This would be registered like ReplacementManager.getDynamic().add(new PlaceholderAPIDynamicReplacer()); if PlaceholderAPI is installed. Then it would automatically work everywhere where SLP allows placeholders.

Main problem perhaps is that I'm not entirely sure if Bukkit.getOfflinePlayer() is safe when processing server status pings, as they are handled asynchronously and not on the main thread. Any thoughts?

@SlimeDog
Copy link

From a user perspective, the PAPI placeholder standard is %placeholder%. It would be preferable to retain that syntax. It works fine in the fork I tested, but I tested only on Spigot, so cannot comment on Paper support.

SLP supports very few placeholders natively -- 16 currently. I would hope that conflicts with PAPI placeholders could be managed, and should have the same values in any event.

As a lesser alternative, you could add a few -- %server_name% and %server_version% (and any others specifically requested) -- to the supported SLP placeholders, and this PR would be unnecessary.

@stephan-gh
Copy link
Member

I think the primary advantage of PlaceholderAPI is that it allows ServerListPlus to integrate with other plugins that hook into PlaceholderAPI. I do not have the time to add every little placeholder someone requests.

But from a support perspective I would rather like to have a clear way to differentiate SLP placeholders and PAPI placeholders. Originally I was thinking about wrapping the PlaceholderAPI placeholders (e.g. %papi:server_name%) but this seems comparatively complicated to implement when we can just use the bracket syntax that is already supported in PAPI. I don't know why they added it, but I guess there are already some other plugins that use it.

@SlimeDog
Copy link

SlimeDog commented Oct 21, 2020

I think the primary advantage of PlaceholderAPI is that it allows ServerListPlus to integrate with other plugins that hook into PlaceholderAPI.

Agreed.

... we can just use the bracket syntax that is already supported in PAPI ...

I would prefer you didn't, but it's your plugin.

@Andre601
Copy link
Contributor

Andre601 commented Apr 25, 2021

Heyo!
Bit late but would like to adress some of the concerns you @Minecrell raised.

  • I don't think it's a good idea to pass the TemporaryPlayer (event.getPlayer().getPlayer()) from ProtocolLib to PlaceholderAPI. As you noticed it's highly limited (throws UnsupportedOperationException for many methods) and it does not even expose all information that we have.

    • In particular, we may have the UUID of the player from tracking, so some of the player placeholders in PlaceholderAPI could be used.

When the UUID is available would the easiest thing to do be to use Bukkit.getOfflinePlayer(UUID) or Server.getOfflinePlayer(UUID) (Is both the same, isn't it?) since PlaceholderAPI recognizes and supports Offline players.

  • Some placeholders might conflict with the ones in ServerListPlus (which also uses %placeholder%).

    • Perhaps the easiest solution here is to use PlaceholderAPI.setBracketPlaceholders(...), which seems to use {placeholder} instead.

Looking at the Placeholder page on the wiki do I see no placeholder conflicting with any of the known placeholders in PlaceholderAPI, so I doubt there is any conflicts to happen.

From a user perspective, the PAPI placeholder standard is %placeholder%. It would be preferable to retain that syntax. It works fine in the fork I tested, but I tested only on Spigot, so cannot comment on Paper support.

@SlimeDog Technically speaking is the pattern more %identifier_values% and not %placeholder% as each expansion needs to have an identifier AND at least a single character as value or PlaceholderAPI won't recognize it as a placeholder.

Also shouldn't it be that big of an issue if you translate the internal placeholders first, before passing them on to PlaceholderAPI to process.
That way is there pretty much no way that PlaceholderAPI would parse them before SLP has the chance, messing stuff up.

@Andre601
Copy link
Contributor

I don't know why they added it, but I guess there are already some other plugins that use it.

To my knowledge was it added to provide support with MVdW Placeholders in some way (or to at least allow placeholders in placeholders)

@SlimeDog
Copy link

We now use a different, dev-responsive, server-list plugin which fully supports PAPI.

@Andre601
Copy link
Contributor

We now use a different, dev-responsive, server-list plugin which fully supports PAPI.

By dev-responsive you mean a not semi-dead one?

@SlimeDog
Copy link

SlimeDog commented Apr 25, 2021

That is what I meant.

Fortunately, we found a fully functional alternative.

@Andre601
Copy link
Contributor

That is what I meant.

Fortunately, we found a fully functional alternative.

To be honest, I myself also use an alternative now that provides HEX colors.
Sure, certain features are either missing or a bit more limited but it's updated and maintained.

@SlimeDog
Copy link

It's the nature of MC plugins:

  • A good idea
  • A decent release
  • Further releases with new features (and the inevitable bug fixes)
  • Enthusiastic support
  • Embrace by the community
  • Virtual abandonment

There were 98,900 downloads of SLP 3.4.8, but alternatives have passed it by, functionally. Sad, but expected.

@stephan-gh
Copy link
Member

@Andre601

When the UUID is available would the easiest thing to do be to use Bukkit.getOfflinePlayer(UUID) or Server.getOfflinePlayer(UUID) (Is both the same, isn't it?) since PlaceholderAPI recognizes and supports Offline players.

Yes. Bukkit" is just a singleton wrapper around Server.

Looking at the Placeholder page on the wiki do I see no placeholder conflicting with any of the known placeholders in PlaceholderAPI, so I doubt there is any conflicts to happen.

The problem is that you cannot implement the find(...) method in DynamicPlaceholder properly if SLP and PlaceholderAPI use the same replacement format. PlaceholderAPI will likely return true for all of SLP's placeholders too if you call PlaceholderAPI.containsPlaceholders(s). (Note how I used containsBracketPlaceholders(s) in my example above.)

This is kind of unfortunate, because the the placeholder implementation in SLP is optimized to find the used placeholder during configuration load. Later, when all the requests are handled, only the used placeholders are actually processed. If you cannot implement find(...) correctly, we will start calling PlaceholderAPI for all requests, no matter if there are actually placeholders from PAPI used.

@SlimeDog

We now use a different, dev-responsive, server-list plugin which fully supports PAPI.

If you have found a true replacement of ServerListPlus: open-source, a similarly clean and flexible configuration format, feel free to post a link here. There is no need to duplicate effort if someone else is already maintaining a truly better replacement.

As for all your concerns about the semi-abandonment of ServerListPlus: I am sorry that it came to this. I have been collecting ideas and concepts for ServerListPlus 4.0 for a long time, and had a clear integration plan for most of the open feature requests in the new architecture. (Note for example the trigger and placeholder labels on open issues, these would have been two of the main core concepts of ServerListPlus 4.0 that would have allowed a lot of flexibility.)

I started work on SLP 4.0 twice but I never came very far because of an overall change of interests. I haven't played Minecraft for years and therefore have no personal use for any Minecraft-related projects anymore. It's unfortunate, but I guess this applies to a lot of people who made Minecraft-related projects.

I do however care enough about my previous projects to somehow try to keep them somewhat alive (without spending much time on them). This is the reason why SLP (and all my other MC-related projects) are in this weird semi-abandoned state. For some of them, the situation is better because they were taken over by other people (and I just provide suggestions/review occasionally). Unfortunately SLP is not one of them.

@Andre601
Copy link
Contributor

I started work on SLP 4.0 twice but I never came very far because of an overall change of interests. I haven't played Minecraft for years and therefore have no personal use for any Minecraft-related projects anymore. It's unfortunate, but I guess this applies to a lot of people who made Minecraft-related projects.

I do however care enough about my previous projects to somehow try to keep them somewhat alive (without spending much time on them). This is the reason why SLP (and all my other MC-related projects) are in this weird semi-abandoned state. For some of them, the situation is better because they were taken over by other people (and I just provide suggestions/review occasionally). Unfortunately SLP is not one of them.

Even if this may sound harsh, but perhaps it would be best to move on.
At most should you consider transferring this project to someone else (i.e. a highly active member like BrainStone?) so that they could maintain it. But if your interest in MC has become less should you honestly consider moving on and not keep this semi-dead plugin alive.
This plugin has been in a coma for such a long time now that you should honestly pull the plug on it. If you really care about it, you would put it to rest so that people can get the alternatives available out there.

@stephan-gh
Copy link
Member

Even if this may sound harsh, but perhaps it would be best to move on.
At most should you consider transferring this project to someone else (i.e. a highly active member like BrainStone?) so that they could maintain it.

I assume if someone was willing to take over development of the plugin, they would let me know. (And if someone is reading this and is interested in doing this, please DO let me know!)

But if your interest in MC has become less should you honestly consider moving on and not keep this semi-dead plugin alive.
This plugin has been in a coma for such a long time now that you should honestly pull the plug on it. If you really care about it, you would put it to rest so that people can get the alternatives available out there.

I appreciate your comment but it's not entirely clear to me if you're concerned about the (maybe not so well-spent) time I still invest in keeping SLP semi-alive, or concerned about all the people who still consider using this plugin because it seems somewhat alive.

I limit my involvement to occasionally helping people who end up here on the GitHub project asking for help. If there are really better replacements I would expect that people don't show up here anymore, and that would therefore result in SLP being put "to rest".

@Andre601
Copy link
Contributor

I limit my involvement to occasionally helping people who end up here on the GitHub project asking for help. If there are really better replacements I would expect that people don't show up here anymore, and that would therefore result in SLP being put "to rest".

The problem is, that people will be unsure about using other plugins, especially if they don't know it.
I mean how did LP start? Sure not as popular as it is now.
And the fact that SLP is still maintained by you, be it on the most basic, lets people keep it.
"Why use a new plugin when I SLP is still updated?"
"Why use newer mc versions when networks use 1.8?"
"Why use newer Java versions when Java 8 still gets updates?"
I hope you get my point.

Keeping SLP alive stops people from looking for alternatives and for those alternatives getting exposure.

@SlimeDog
Copy link

I don't generally (publicly) recommend alternatives until they have some history. Over six years of MC experience tells me that most plugins end up in the dustbin, when the original developer moves on with real life. Only occasionally does another developer pick up a project and truly run with it. It is the nature of the beast.

The vast majority of MC plugins are simple projects that help someone learn to code in Java. But there is no framework or forum for people to learn good software development skills, with the result that most plugins are very poorly written (nevertheless self-advertised as "the best ever") and full of bugs. Rather than develop a new idea, they simply write yet-another plugin that does the same thing as scores of others (search SpigotMC for "motd" for an example of this phenomenon). That is also the nature of the beast.

@SlimeDog
Copy link

SlimeDog commented Apr 25, 2021

I have no issue with SLP remaining on life support. It works for a lot of people, obviously. It just doesn't work for me, and others who want full PAPI support.

It's open source. Anyone is free to take it on.

@stephan-gh
Copy link
Member

The problem is, that people will be unsure about using other plugins, especially if they don't know it.
I mean how did LP start? Sure not as popular as it is now.
And the fact that SLP is still maintained by you, be it on the most basic, lets people keep it.
"Why use a new plugin when I SLP is still updated?"
"Why use newer mc versions when networks use 1.8?"
"Why use newer Java versions when Java 8 still gets updates?"
I hope you get my point.
Keeping SLP alive stops people from looking for alternatives and for those alternatives getting exposure.

So you're essentially suggesting that I make the status of the plugin more clear in the README etc? I think that's a fair point.

I'm also not opposed to actually link to some good alternatives, provided that they fulfill certain criteria that I found important for ServerListPlus (open-source, reasonable code quality).

@Andre601
Copy link
Contributor

Andre601 commented Apr 25, 2021

I quickly list two alternatives I know:

  • MiniMOTD (Source)
    • + Support for MiniMessage in the MOTD
    • + Supports Spigot/Paper, BungeeCord/Waterfall, Velocity and Fabric
    • + Multiple MOTDs possible
    • + Multiple (random) Favicon support
    • + Pair MOTD and Icons together
    • + Hideable player count
    • + Enable/Disable Features (Only MOTD and icon changes)
    • - No Hover for player count
    • - Uses HOCON configuration (Slightly more confusing to setup?)
  • PistonMOTD (Source)
    • + Support for MiniMessage in the MOTD
    • + Separate RGB support through &#ffffff format
    • + Supports Spigot/Paper and BungeeCord/Waterfall
    • + Multiple MOTDs possible
    • + Multiple (random) Favicon support
    • + Hover text support
    • + Custom "Out of date" message
    • + Hideable Player count (Bukkit only)
    • + Enable/Disable features
    • - Uses %newline% placeholder for new lines... Why?

This list is of course not official and the positives and negatives are only from my personal perspective.

@SlimeDog
Copy link

two alternatives:

PAPI support? That was the (initial) focus of this issue.

@Andre601
Copy link
Contributor

PAPI support? That was the (initial) focus of this issue.

Yeah. Sadly don't know if any of them does provide this... I mean the second one at least mentions that you can add your own through the API (I feel like this plugin tries to be like SLP...)

@stephan-gh
Copy link
Member

@Andre601 Thanks for listing alternatives that you know! Can you repeat that list in a comment for #338? I think I'll link to that issue from the README later.

@SlimeDog
Copy link

:(

OK. We are currently using ServerListMOTD which is a resurrection/continuation of this one. It has 300+ downloads (the original had 1800). It's only 6 months old, but the developer seems committed. He supports only two plugins, both of which he resurrected. You can read about him at the bottom of the Overview page.

@stephan-gh
Copy link
Member

@Andre601 Thanks for listing alternatives that you know! Can you repeat that list in a comment for #338? I think I'll link to that issue from the README later.

@SlimeDog And you too if you want :)

@SlimeDog
Copy link

Done.

@Andre601
Copy link
Contributor

❤️

@stephan-gh
Copy link
Member

The discussion here somehow motivated me to do something about the open PRs at least. I tried the suggestion from my comment and it seems to work fine: #311 (comment). I realize the bracket syntax is not ideal, but it's the easiest way to integrate PlaceholderAPI with SLP right now and I'd argue it's better than nothing.

@SlimeDog
Copy link

Or you could have just merged the PR, which rendered all placeholders equal in terms of syntax, instead of inventing additional syntax. :(

@stephan-gh
Copy link
Member

I appreciate that your developer made this PR @SlimeDog. But IMO the PR has several problems that my implementation does not have, as documented in the comments. Even if there are no actual conflicts with existing placeholders, the following problems do exist in this PR:

  • It works only for ProtocolLib, not the Bukkit fallback handler or the Paper handler.
  • It does not apply to custom player slots, custom outdated version.
  • It calls into PlaceholderAPI no matter if there are any PlaceholderAPI placeholders used.

The last one may not seem very significant from a user perspective, but it's a design decision that I described in #311 (comment). The solution I suggested integrates directly with SLP's placeholder system, which is the least intrusive way to support PlaceholderAPI for SLP, even if that means using a slightly different syntax.

@Momshroom
Copy link

Momshroom commented Apr 28, 2021 via email

@SlimeDog
Copy link

All good. Agree with the thanks for keeping it alive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants