DiscordSRV

DiscordSRV

86.8k Downloads

A ChannelTopicUpdater placeholder for world time

mbravorus opened this issue · 6 comments

commented

Why?

My players would like to be able to see the current Overworld time in the chat channel topic

What and How?

I would expect a variable like %overworld_time% or similar should work?

Are there alternatives?

I haven't found any. I did search through the issues and didn't find anything suitable - it is possible I just didn't use the correct keywords, though

Checks

  • I have used the search at least once to check if my idea has already been suggested and perhaps already implemented.

Anything else

No response

commented

https://github.com/PlaceholderAPI/PlaceholderAPI/wiki/Placeholders#world %world_time_<world>%

Thank you for the suggestion, I even looked at the World PAPI expansion source, but still failing to understand what the trailing <world> value should be :( - given that I have a single world installation and want to display the time in the overworld

commented

And using %world_time_$% causes this:

[PlaceholderAPI] Successfully registered internal expansion: discordsrv [1.26.2]
[08:38:58 WARN]: Exception in thread "DiscordSRV - Channel Topic Updater" java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getWorld()" because "player" is null
[08:38:58 WARN]:        at me.thienbao860.expansion.world.WorldExpansion.getWorld(WorldExpansion.java:173)
[08:38:58 WARN]:        at me.thienbao860.expansion.world.WorldExpansion.onRequest(WorldExpansion.java:102)
[08:38:58 WARN]:        at 6245.jar//me.clip.placeholderapi.replacer.CharsReplacer.apply(CharsReplacer.java:119)
[08:38:58 WARN]:        at 6245.jar//me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(PlaceholderAPI.java:71)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.util.PlaceholderUtil.replacePlaceholders(PlaceholderUtil.java:46)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.util.PlaceholderUtil.replacePlaceholdersToDiscord(PlaceholderUtil.java:70)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.util.PlaceholderUtil.replacePlaceholdersToDiscord(PlaceholderUtil.java:56)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.util.PlaceholderUtil.replaceChannelUpdaterPlaceholders(PlaceholderUtil.java:87)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.objects.threads.ChannelTopicUpdater.run(ChannelTopicUpdater.java:42)
commented

reopening the enhancement issue as perhaps a native placeholder for overworld time would be simpler and more reliable than going through PlaceholderAPI+expansion

commented

@Vankka thank you for your very helpful explanation

commented

Thank you for the suggestion, I even looked at the World PAPI expansion source, but still failing to understand what the trailing <world> value should be :( - given that I have a single world installation and want to display the time in the overworld

<world> wants the name of the world, by default that is simply world (set in the server.properties level-name), the same as the directory, in which it is stored. So what you want is (most likely) %world_time_world%

And using %world_time_$% causes this:

[PlaceholderAPI] Successfully registered internal expansion: discordsrv [1.26.2]
[08:38:58 WARN]: Exception in thread "DiscordSRV - Channel Topic Updater" java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.Player.getWorld()" because "player" is null
[08:38:58 WARN]:        at me.thienbao860.expansion.world.WorldExpansion.getWorld(WorldExpansion.java:173)
[08:38:58 WARN]:        at me.thienbao860.expansion.world.WorldExpansion.onRequest(WorldExpansion.java:102)
[08:38:58 WARN]:        at 6245.jar//me.clip.placeholderapi.replacer.CharsReplacer.apply(CharsReplacer.java:119)
[08:38:58 WARN]:        at 6245.jar//me.clip.placeholderapi.PlaceholderAPI.setPlaceholders(PlaceholderAPI.java:71)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.util.PlaceholderUtil.replacePlaceholders(PlaceholderUtil.java:46)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.util.PlaceholderUtil.replacePlaceholdersToDiscord(PlaceholderUtil.java:70)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.util.PlaceholderUtil.replacePlaceholdersToDiscord(PlaceholderUtil.java:56)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.util.PlaceholderUtil.replaceChannelUpdaterPlaceholders(PlaceholderUtil.java:87)
[08:38:58 WARN]:        at 18494.jar//github.scarsz.discordsrv.objects.threads.ChannelTopicUpdater.run(ChannelTopicUpdater.java:42)

In WorldExpansion's case $ means the world which the player is in, but for the topic updater, no player is specified (because that isn't related to any specific player) and the expansion doesn't check if the player is set; thus causing a error

reopening the enhancement issue as perhaps a native placeholder for overworld time would be simpler and more reliable than going through PlaceholderAPI+expansion

This seems like really a niche use case, closing as the PlaceholderAPI expansion exists