24
24
25
25
26
26
import github .scarsz .discordsrv .DiscordSRV ;
27
+ import github .scarsz .discordsrv .dependencies .jda .api .entities .Role ;
28
+ import github .scarsz .discordsrv .dependencies .jda .api .events .guild .member .GuildMemberJoinEvent ;
27
29
import github .scarsz .discordsrv .dependencies .jda .api .events .message .guild .GuildMessageReceivedEvent ;
28
30
import github .scarsz .discordsrv .dependencies .jda .api .hooks .ListenerAdapter ;
29
31
import tk .bluetree242 .discordsrvutils .DiscordSRVUtils ;
30
32
import tk .bluetree242 .discordsrvutils .events .DiscordLevelupEvent ;
31
33
import tk .bluetree242 .discordsrvutils .leveling .LevelingManager ;
32
34
import tk .bluetree242 .discordsrvutils .leveling .MessageType ;
35
+ import tk .bluetree242 .discordsrvutils .leveling .PlayerStats ;
33
36
import tk .bluetree242 .discordsrvutils .messages .MessageManager ;
34
37
import tk .bluetree242 .discordsrvutils .placeholder .PlaceholdObject ;
35
38
import tk .bluetree242 .discordsrvutils .placeholder .PlaceholdObjectList ;
@@ -80,4 +83,19 @@ public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
80
83
}
81
84
});
82
85
}
86
+
87
+
88
+ //give leveling roles when they rejoin the discord server
89
+ public void onGuildMemberJoin (GuildMemberJoinEvent e ) {
90
+ core .executeAsync (() -> {
91
+ if (DiscordSRV .getPlugin ().getAccountLinkManager ().getUuid (e .getUser ().getId ()) != null ) {
92
+ PlayerStats stats = core .handleCFOnAnother (LevelingManager .get ().getPlayerStats (e .getUser ().getIdLong ()));
93
+ if (stats == null ) return ;
94
+ Role role = LevelingManager .get ().getRoleForLevel (stats .getLevel ());
95
+ if (role != null ) {
96
+ e .getGuild ().addRoleToMember (e .getMember (), role ).queue ();
97
+ }
98
+ }
99
+ });
100
+ }
83
101
}
0 commit comments