Improved CMI support for Alerts.yml
mrfloris opened this issue ยท 0 comments
Why?
Hey, hopefully, I do this the correct way, but after some chit-chat and spending some time trying out a bunch of stuff to get basically only send an alert if the user has not vanished
to happen. It seems that maybe DSRV needs to (slightly) adjust in order to make this a realization for plugins such as CMI.
https://ptb.discord.com/channels/135634590575493120/889139760067645460/955385583465807903
CMI has the command /cmi vanish
(/vanish) which puts a player in vanish mode. I want to use DSRV's Alerts.yml to Trigger on CMIAfkEnterEvent
and send an embed to our global channel (which all works), but using Conditions:
to limit it only when the player has Not vanished (is not in vanish mode).
com.Zrips.CMI.CMI.getInstance().getPlayerManager().getUser(#player).isVanished()
This should do the trick.
However, no matter what I have tried (and others), it seems that DSRV's Spring Expression returns an error, expecting EssentialsX classes as return types/parameters of methods .. or something (I am not a developer, I don't fully understand the specifics)
> discord reload
[09:42:00 INFO]: [DiscordSRV] 16 alerts registered
[09:42:00 INFO]: The DiscordSRV config & lang have been reloaded.
[09:42:06 INFO]: mrfloris issued server command: /afk 9
[09:42:06 WARN]: [DiscordSRV] Plugin DiscordSRV v1.25.1 generated an exception while executing task 13866
java.lang.NoClassDefFoundError: com/earth2me/essentials/Essentials
at java.lang.Class.getDeclaredMethods0(Native Method) ~[?:?]
at java.lang.Class.privateGetDeclaredMethods(Class.java:3402) ~[?:?]
at java.lang.Class.privateGetPublicMethods(Class.java:3427) ~[?:?]
at java.lang.Class.getMethods(Class.java:2019) ~[?:?]
at org.springframework.expression.spel.support.ReflectiveMethodResolver.getMethods(ReflectiveMethodResolver.java:272) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.support.ReflectiveMethodResolver.getMethods(ReflectiveMethodResolver.java:253) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.support.ReflectiveMethodResolver.resolve(ReflectiveMethodResolver.java:118) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.MethodReference.findAccessorForMethod(MethodReference.java:206) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:135) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.MethodReference.getValueInternal(MethodReference.java:95) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:61) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:91) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:188) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.OperatorNot.getValueInternal(OperatorNot.java:47) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.OperatorNot.getValueInternal(OperatorNot.java:36) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.ast.SpelNodeImpl.getTypedValue(SpelNodeImpl.java:117) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:308) ~[DiscordSRV-Build-1.25.1.jar:?]
at github.scarsz.discordsrv.util.SpELExpressionBuilder.evaluate(SpELExpressionBuilder.java:73) ~[DiscordSRV-Build-1.25.1.jar:?]
at github.scarsz.discordsrv.modules.alerts.AlertListener.process(AlertListener.java:427) ~[DiscordSRV-Build-1.25.1.jar:?]
at github.scarsz.discordsrv.modules.alerts.AlertListener.lambda$runAlertsForEvent$2(AlertListener.java:262) ~[DiscordSRV-Build-1.25.1.jar:?]
at org.bukkit.craftbukkit.v1_18_R2.scheduler.CraftTask.run(CraftTask.java:101) ~[paper-1.18.2.jar:git-Paper-265]
at org.bukkit.craftbukkit.v1_18_R2.scheduler.CraftAsyncTask.run(CraftAsyncTask.java:57) ~[paper-1.18.2.jar:git-Paper-265]
at com.destroystokyo.paper.ServerSchedulerReportingWrapper.run(ServerSchedulerReportingWrapper.java:22) ~[paper-1.18.2.jar:git-Paper-265]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: java.lang.ClassNotFoundException: com.earth2me.essentials.Essentials
at org.bukkit.plugin.java.PluginClassLoader.loadClass0(PluginClassLoader.java:151) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.PluginClassLoader.loadClass(PluginClassLoader.java:103) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[?:?]
... 26 more
[09:42:06 INFO]: * mrfloris has gone AFK (9)
Above, is an example of one of the errors; which looks almost the same for each type of Conditions:
that I've tried.
> ver
[09:58:58 INFO]: Checking version, please wait...
[09:58:58 INFO]: This server is running Paper version git-Paper-265 (MC: 1.18.2) (Implementing API version 1.18.2-R0.1-SNAPSHOT) (Git: 993f828)
You are running the latest version
Previous version: git-Paper-264 (MC: 1.18.2)
> ver DiscordSRV
[09:59:01 INFO]: DiscordSRV version 1.25.1
[09:59:01 INFO]: The most powerful, configurable, open-source Discord bridge plugin out there.
[09:59:01 INFO]: Website: https://github.com/DiscordSRV/DiscordSRV
[09:59:01 INFO]: Authors: Scarsz, Androkai and Vankka
> cmi version
[09:59:02 INFO]: --------------------------------------------------
[09:59:02 INFO]: CMI plugin version: 9.1.3.1 SqLite
[09:59:02 INFO]: CMILib: 1.1.2.3
[09:59:02 INFO]: Server: Paper(265) 1.18.2-R0.1-SNAPSHOT
[09:59:02 INFO]: CMI economy: Enabled Vault: 1.7.3-b CMI Chat: Enabled
[09:59:02 INFO]: Modules -> 55 enabled 1 disabled: flightCharge
[09:59:02 INFO]: --------------------------------------------------
>
What and How?
I have no idea code wise what a solution would be, if the spring expressions could get an update, so Conditionals: using the CMI plugin for events could be used, then we can check properly against 'is the player vanished true/false?', which would make this work.
Are there alternatives?
CMI has a placeholder for the vanished symbol, by default it's ''
when the player is not vanished. If we could use placeholders in Conditionals:
, then perhaps we could compare those against the values in the cmi's locale for that symbol. But I saw on Discord that someone mentioned they couldn't get this to work either. Plus, everybody could use different locale, so it's not an ideal solution anyway.
Checks
- I have used the search at least once to check if my idea has already been suggested and perhaps already implemented.
Anything else
It is appreciated that you are reviewing/considering this, I understand that CMI is a premium plugin. It's not obfuscated code, decompiling for development isn't difficult. If Scarsz lol#4227
needs a temporary development copy if they have no license they're free to DM me on Discord. If a license for a more long-term solution is desirable Scarsz lol#4227
can also DM me and we can discuss it there.
Thank you in advance,