1818import java .sql .SQLException ;
1919import java .util .ArrayList ;
2020import java .util .List ;
21+ import java .util .Objects ;
2122import java .util .concurrent .CompletableFuture ;
2223import java .util .concurrent .CompletionStage ;
2324import java .util .concurrent .TimeUnit ;
@@ -60,7 +61,7 @@ private void registerEventListeners() {
6061 @ Override
6162 public void entryAdded (Entry entry ) {
6263 try {
63- PunishmentData data = convertEntryToData (entry );
64+ PunishmentData data = convertEntryToData (entry , false );
6465 ReportPlayerPunishment .reportSync (data );
6566 } catch (Exception e ) {
6667 LoggingUtil .error ("[BanWarden] EntryAdded -> Error reporting event to Minetrax: " + e .getMessage ());
@@ -70,7 +71,7 @@ public void entryAdded(Entry entry) {
7071 @ Override
7172 public void entryRemoved (Entry entry ) {
7273 try {
73- PunishmentData data = convertEntryToData (entry );
74+ PunishmentData data = convertEntryToData (entry , true );
7475 ReportPlayerPunishment .reportSync (data );
7576 } catch (Exception e ) {
7677 LoggingUtil .error ("[BanWarden] EntryRemoved -> Error reporting event to Minetrax: " + e .getMessage ());
@@ -152,7 +153,7 @@ private CompletionStage<List<PunishmentData>> fetchPunishmentChunk(int limit, in
152153 });
153154 }
154155
155- private PunishmentData convertEntryToData (Entry entry ) {
156+ private PunishmentData convertEntryToData (Entry entry , boolean isRemoved ) {
156157 String type = getBanWardenPunishmentType (entry .getType ()).name ().toLowerCase ();
157158 PunishmentData punishmentData = new PunishmentData ();
158159 punishmentData .plugin_name = BanWardenPluginType .LITEBANS .name ().toLowerCase ();
@@ -162,17 +163,20 @@ private PunishmentData convertEntryToData(Entry entry) {
162163 punishmentData .end_at = entry .getDateEnd ();
163164 punishmentData .reason = entry .getReason ();
164165 punishmentData .is_active = entry .isActive ();
165- punishmentData .server_scope = entry .getServerScope ();
166+ punishmentData .server_scope = Objects . equals ( entry . getServerScope (), "global" ) ? "*" : entry .getServerScope ();
166167 punishmentData .origin_server_name = entry .getServerOrigin ();
167168 punishmentData .uuid = entry .getUuid ();
168169 punishmentData .ip_address = entry .getIp ();
169- punishmentData .is_ipban = entry .getType (). equalsIgnoreCase ( "ipban" );
170+ punishmentData .is_ipban = entry .isIpban ( );
170171 punishmentData .creator_uuid = entry .getExecutorUUID ();
171172 punishmentData .creator_username = entry .getExecutorName ();
172173
173- punishmentData .removed_at = 0 ; // TODO
174- punishmentData .remover_uuid = entry .getRemovedByUUID ();
175- punishmentData .remover_username = entry .getRemovedByName ();
174+ if (isRemoved ) {
175+ punishmentData .removed_at = System .currentTimeMillis ();
176+ punishmentData .remover_uuid = entry .getRemovedByUUID ();
177+ punishmentData .remover_username = entry .getRemovedByName ();
178+ punishmentData .removed_reason = entry .getRemovalReason ();
179+ }
176180
177181 return punishmentData ;
178182 }
@@ -185,14 +189,22 @@ private PunishmentData convertResultSetToData(ResultSet rs) throws SQLException
185189 punishmentData .start_at = rs .getLong ("time" );
186190 punishmentData .end_at = rs .getLong ("until" );
187191 punishmentData .reason = rs .getString ("reason" );
188- punishmentData .is_active = true ;
192+ punishmentData .is_active = rs . getBoolean ( "active" ) ;
189193 punishmentData .server_scope = rs .getString ("server_scope" );
194+ punishmentData .origin_server_name = rs .getString ("server_origin" );
190195 punishmentData .uuid = rs .getString ("uuid" );
191196 punishmentData .ip_address = rs .getString ("ip" );
192- punishmentData .is_ipban = punishmentData . type . equals ( "ban" ) && rs .getBoolean ("ipban" );
197+ punishmentData .is_ipban = rs .getBoolean ("ipban" );
193198 punishmentData .creator_uuid = rs .getString ("banned_by_uuid" );
194199 punishmentData .creator_username = rs .getString ("banned_by_name" );
195200
201+ if (rs .getTimestamp ("removed_by_date" ) != null ) {
202+ punishmentData .removed_at = rs .getTimestamp ("removed_by_date" ).getTime ();
203+ punishmentData .remover_uuid = rs .getString ("removed_by_uuid" );
204+ punishmentData .remover_username = rs .getString ("removed_by_name" );
205+ punishmentData .removed_reason = rs .getString ("removed_by_reason" );
206+ }
207+
196208 return punishmentData ;
197209 }
198210
0 commit comments