@@ -4,49 +4,135 @@ import co.aikar.commands.BaseCommand
44import co.aikar.commands.CommandHelp
55import co.aikar.commands.annotation.*
66import co.aikar.commands.bukkit.contexts.OnlinePlayer
7- import com.lunarclient.bukkitapi.LunarClientAPI
7+ import com.lunarclient.apollo.Apollo
8+ import com.lunarclient.apollo.module.notification.Notification
9+ import com.lunarclient.apollo.module.notification.NotificationModule
10+ import com.lunarclient.apollo.module.staffmod.StaffMod
11+ import com.lunarclient.apollo.module.staffmod.StaffModModule
12+ import com.lunarclient.apollo.player.ApolloPlayer
813import ltd.matrixstudios.alchemist.api.AlchemistAPI
914import ltd.matrixstudios.alchemist.util.Chat
15+ import net.kyori.adventure.text.Component
16+ import net.kyori.adventure.text.format.NamedTextColor
1017import org.bukkit.Bukkit
1118import org.bukkit.command.CommandSender
19+ import java.time.Duration
20+
21+ object LunarClientNotifier {
22+
23+ /* *
24+ *
25+ *
26+ * @param apolloPlayer The Apollo player to send the notification to.
27+ * @param title The title component
28+ * @param description The description component
29+ * @param icon Optional resource icon path (default: "icons/golden_apple.png").
30+ * @param duration Duration to display the notification (default: 5 seconds).
31+ */
32+ fun sendNotification (
33+ apolloPlayer : ApolloPlayer ,
34+ title : Component ,
35+ description : Component ,
36+ icon : String = "icons/golden_apple.png",
37+ duration : Duration = Duration .ofSeconds(5)
38+ ) {
39+ val notificationModule = Apollo .getModuleManager()
40+ .getModule(NotificationModule ::class .java) ? : return
41+
42+ try {
43+ // Build the notification via reflection kinda scuff need to unrelocate adventure api
44+ val builder = Notification ::class .java.getDeclaredMethod(" builder" ).invoke(null )
45+
46+ val titleMethod = builder.javaClass.getMethod(" titleComponent" , Any ::class .java)
47+ val descriptionMethod = builder.javaClass.getMethod(" descriptionComponent" , Any ::class .java)
48+ val resourceMethod = builder.javaClass.getMethod(" resourceLocation" , String ::class .java)
49+ val displayTimeMethod = builder.javaClass.getMethod(" displayTime" , Duration ::class .java)
50+ val buildMethod = builder.javaClass.getMethod(" build" )
51+
52+ titleMethod.invoke(builder, title)
53+ descriptionMethod.invoke(builder, description)
54+ resourceMethod.invoke(builder, icon)
55+ displayTimeMethod.invoke(builder, duration)
56+
57+ val notification = buildMethod.invoke(builder)
58+ val displayMethod = notificationModule.javaClass.getMethod(" displayNotification" , ApolloPlayer ::class .java, Notification ::class .java)
59+ displayMethod.invoke(notificationModule, apolloPlayer, notification)
60+
61+ } catch (e: Exception ) {
62+ e.printStackTrace()
63+ }
64+ }
65+ }
1266
13- /* *
14- * Class created on 9/13/2023
1567
16- * @author 98ping
17- * @project Alchemist
18- * @website https://solo.to/redis
19- */
2068@CommandAlias(" lunarclient|lc" )
2169@CommandPermission(" alchemist.clients.lunar" )
22- object LunarClientCommands : BaseCommand()
23- {
70+ object LunarClientCommands : BaseCommand() {
2471
2572 @HelpCommand
26- fun help (help : CommandHelp )
27- {
73+ fun help (help : CommandHelp ) {
2874 help.showHelp()
2975 }
3076
77+
78+ fun enableStaffModules (apolloPlayer : ApolloPlayer ) {
79+ val staffModModule = Apollo .getModuleManager().getModule(StaffModModule ::class .java)
80+ staffModModule?.enableStaffMods(apolloPlayer, listOf (StaffMod .XRAY ))
81+ }
82+ fun disableStaffModules (apolloPlayer : ApolloPlayer ) {
83+ val staffModModule = Apollo .getModuleManager().getModule(StaffModModule ::class .java)
84+ staffModModule?.disableStaffMods(apolloPlayer, listOf (StaffMod .XRAY ))
85+ }
86+
87+
88+
3189 @Subcommand(" players" )
32- fun players (player : CommandSender )
33- {
90+ fun players (sender : CommandSender ) {
3491 val start = System .currentTimeMillis()
3592 val count = Bukkit .getOnlinePlayers().count {
36- LunarClientAPI .getInstance ().isRunningLunarClient (it)
93+ Apollo .getPlayerManager ().hasSupport (it.uniqueId )
3794 }
3895
39- player .sendMessage(Chat .format(" &eThis server has a total of &a${ count} &eplayers that run &bLunar Client&e." ))
40- player .sendMessage(Chat .format(" &7To check a specific user's status, execute /lc check <player>" ))
41- player .sendMessage(Chat .format(" &8(This lookup took ${System .currentTimeMillis().minus( start)} milliseconds )" ))
96+ sender .sendMessage(Chat .format(" &eThere are &a$count &eplayers running &bLunar Client&e." ))
97+ sender .sendMessage(Chat .format(" &7To check a specific user's status: /lc check <player>" ))
98+ sender .sendMessage(Chat .format(" &8(This lookup took ${System .currentTimeMillis() - start} ms )" ))
4299 }
43100
44101 @Subcommand(" check" )
45102 @CommandCompletion(" @players" )
46- fun check (player : CommandSender , @Name(" target" ) target : OnlinePlayer )
47- {
48- val isUsing = LunarClientAPI .getInstance().isRunningLunarClient(target.player)
103+ fun check (sender : CommandSender , @Name(" target" ) target : OnlinePlayer ) {
104+ val isUsing = Apollo .getPlayerManager().hasSupport(target.player.uniqueId)
105+ sender.sendMessage(
106+ Chat .format(
107+ " &r${AlchemistAPI .getRankDisplay(target.player.uniqueId)} &eis " +
108+ " ${if (isUsing) " &acurrently" else " &cnot currently" } &eusing &bLunar Client&e."
109+ )
110+ )
111+ }
112+
113+ @Subcommand(" staffmodules" )
114+ @CommandCompletion(" @players" )
115+ fun staffModules (sender : CommandSender , @Name(" target" ) target : OnlinePlayer ) {
116+ val uuid = target.player.uniqueId
117+ val apolloOpt = Apollo .getPlayerManager().getPlayer(uuid)
118+
119+ if (! apolloOpt.isPresent) {
120+ sender.sendMessage(Chat .format(" &cThat player is not running Lunar Client." ))
121+ return
122+ }
123+
124+ val apolloPlayer = apolloOpt.get()
125+
126+ enableStaffModules(apolloPlayer)
127+
128+ // LunarClientNotifier.sendNotification(
129+ // apolloPlayer,
130+ // Component.text("Staff Modules Enabled", NamedTextColor.GREEN),
131+ // Component.text("XRAY staff mod has been enabled.", NamedTextColor.WHITE)
132+ // Need to un relocate adventure api )
49133
50- player.sendMessage(Chat .format(" &r${AlchemistAPI .getRankDisplay(target.player.uniqueId)} &eis ${if (isUsing) " &acurrently" else " &cnot currently" } &eusing &bLunar Client&e." ))
134+ sender.sendMessage(
135+ Chat .format(" &r${AlchemistAPI .getRankDisplay(uuid)} &ehas been given &bLunar Client &eStaff Modules." )
136+ )
51137 }
52- }
138+ }
0 commit comments