77import me .truemb .discordnotify .enums .InformationType ;
88import me .truemb .discordnotify .main .DiscordNotifyMain ;
99import me .truemb .universal .listener .UniversalEventhandler ;
10+ import me .truemb .universal .player .UniversalLocation ;
1011import me .truemb .universal .player .UniversalPlayer ;
1112import net .dv8tion .jda .api .entities .Member ;
1213
@@ -26,17 +27,22 @@ public void onPlayerJoin(UniversalPlayer up, String serverName) {
2627
2728 UUID uuid = up .getUUID ();
2829
30+ //DO NOTHING - Since Management Server does it already
31+ if (this .instance .getUniversalServer ().isProxySubServer ())
32+ return ;
33+
2934 //IF FEATURE ENABLED
30- if (! this . instance . getUniversalServer (). isProxySubServer () && this .instance .getConfigManager ().isFeatureEnabled (FeatureType .PlayerJoinLeave ))
35+ if (this .instance .getConfigManager ().isFeatureEnabled (FeatureType .PlayerJoinLeave ))
3136 this .onPlayerJoinFeature (up , serverName );
3237
3338 //ALWAYS ON JOIN
34- if (!this .instance .getUniversalServer ().isProxySubServer ())
35- this .instance .getJoinTime ().put (uuid , System .currentTimeMillis ());
39+ this .instance .getJoinTime ().put (uuid , System .currentTimeMillis ());
3640
3741 //CHECK FOR NAME CHANGE
3842 this .instance .getOfflineInformationsSQL ().checkForNameChange (uuid , up .getIngameName ());
39-
43+
44+ // ========[ OFFLINE DATA ]=======
45+
4046 //INACTIVITY
4147 if (this .instance .getOfflineInformationManager ().getInformationString (uuid , InformationType .Inactivity ) != null
4248 && this .instance .getOfflineInformationsSQL ().getOfflineInfoManager ().getInformationString (uuid , InformationType .Inactivity ).equalsIgnoreCase ("true" )) {
@@ -45,13 +51,21 @@ public void onPlayerJoin(UniversalPlayer up, String serverName) {
4551 this .instance .getOfflineInformationsSQL ().getOfflineInfoManager ().setInformation (uuid , InformationType .Inactivity , "false" );
4652 this .instance .getPluginMessenger ().sendInformationUpdate (uuid , serverName , InformationType .Inactivity , "false" );
4753 }
54+
55+ //IP
56+ String ipAddress = up .getIP ();
57+ this .instance .getOfflineInformationsSQL ().updateInformation (uuid , InformationType .IP , ipAddress );
58+ this .instance .getOfflineInformationManager ().setInformation (uuid , InformationType .IP , ipAddress );
59+ this .instance .getPluginMessenger ().sendInformationUpdate (uuid , InformationType .IP , ipAddress );
4860
61+ // ========[ OFFLINE DATA ]=======
62+
4963 //REMINDER - If not verified
5064 if (this .instance .getDiscordManager () != null && this .instance .getDiscordManager ().isAddonEnabled ("disnotify::verify" ) && !this .instance .getVerifyManager ().isVerified (uuid ))
5165 up .sendMessage (this .instance .getConfigManager ().getMinecraftMessage ("verification.reminder" , true ));
5266
5367 //ROLE UPDATES
54- if (! this . instance . getUniversalServer (). isProxySubServer () && this .instance .getVerifyManager ().isVerified (uuid ) && this .instance .getConfigManager ().isFeatureEnabled (FeatureType .RoleSync )) {
68+ if (this .instance .getVerifyManager ().isVerified (uuid ) && this .instance .getConfigManager ().isFeatureEnabled (FeatureType .RoleSync )) {
5569
5670 if (this .instance .getDiscordManager ().getDiscordBot () == null )
5771 return ;
@@ -115,17 +129,37 @@ private void onPlayerJoinFeature(UniversalPlayer up, String serverName) {
115129 }
116130
117131 }
118-
132+
119133 @ Override
120134 public void onPlayerQuit (UniversalPlayer up , String serverName ) {
121135
122136 UUID uuid = up .getUUID ();
137+
138+ //LOCATION - Needs to be sent from the Bukkit Servers, even if it is a Network.
139+ if (!this .instance .getUniversalServer ().isProxy ()) {
140+ UniversalLocation loc = up .getLocation ();
141+ String location = this .instance .getConfigManager ().getConfig ().getString ("Options.OtherFormats.Location" )
142+ .replaceAll ("(?i)%" + "world" + "%" , loc .getWorldname ())
143+ .replaceAll ("(?i)%" + "x" + "%" , String .valueOf (loc .getBlockX ()))
144+ .replaceAll ("(?i)%" + "y" + "%" , String .valueOf (loc .getBlockY ()))
145+ .replaceAll ("(?i)%" + "z" + "%" , String .valueOf (loc .getBlockZ ()))
146+ .replaceAll ("(?i)%" + "yaw" + "%" , String .valueOf (Math .round (loc .getYaw () * 100D ) / 100D ))
147+ .replaceAll ("(?i)%" + "pitch" + "%" , String .valueOf (Math .round (loc .getPitch () * 100D ) / 100D ));
148+
149+ this .instance .getOfflineInformationsSQL ().updateInformation (uuid , InformationType .Location , location );
150+ this .instance .getOfflineInformationManager ().setInformation (uuid , InformationType .Location , location );
151+ this .instance .getPluginMessenger ().sendInformationUpdate (uuid , InformationType .Location , location );
152+ }
153+
154+ //DO NOTHING - Since Management Server does it already
155+ if (this .instance .getUniversalServer ().isProxySubServer ())
156+ return ;
123157
124158 //IF FEATURE ENABLED
125- if (! this . instance . getUniversalServer (). isProxySubServer () && this .instance .getConfigManager ().isFeatureEnabled (FeatureType .PlayerJoinLeave ))
159+ if (this .instance .getConfigManager ().isFeatureEnabled (FeatureType .PlayerJoinLeave ))
126160 this .onPlayerQuitFeature (up , serverName );
127161
128- if (! this . instance . getUniversalServer (). isProxySubServer () && this .instance .getJoinTime ().get (uuid ) != null ) {
162+ if (this .instance .getJoinTime ().get (uuid ) != null ) {
129163 long time = System .currentTimeMillis () - this .instance .getJoinTime ().get (uuid );
130164
131165 this .instance .getOfflineInformationsSQL ().addToInformation (uuid , InformationType .Playtime , time );
@@ -137,16 +171,22 @@ public void onPlayerQuit(UniversalPlayer up, String serverName) {
137171
138172 //VERIFICATION
139173 this .instance .getVerifyManager ().clearVerficationProgress (uuid );
174+
175+ // ========[ OFFLINE DATA - START]=======
140176
177+ //LAST CONNECTED SERVER
141178 this .instance .getOfflineInformationsSQL ().updateInformation (uuid , InformationType .Bungee_Server , serverName );
142179 this .instance .getOfflineInformationManager ().setInformation (uuid , InformationType .Bungee_Server , serverName );
143180 this .instance .getPluginMessenger ().sendInformationUpdate (uuid , InformationType .Bungee_Server , serverName );
144-
181+
182+ //LAST CONNECTION
145183 long lastConnection = System .currentTimeMillis ();
146184 this .instance .getOfflineInformationsSQL ().updateInformation (uuid , InformationType .LastConnection , lastConnection );
147185 this .instance .getOfflineInformationManager ().setInformation (uuid , InformationType .LastConnection , lastConnection );
148186 this .instance .getPluginMessenger ().sendInformationUpdate (uuid , InformationType .LastConnection , lastConnection );
149187
188+ // ========[ OFFLINE DATA - END]=======
189+
150190 }
151191
152192 /**
0 commit comments