2222import fr .baba .deltamanager .utils .PlayerUtils ;
2323import fr .baba .deltamanager .utils .TimeUtils ;
2424import net .md_5 .bungee .api .ProxyServer ;
25+ import net .md_5 .bungee .api .chat .TextComponent ;
2526import net .md_5 .bungee .api .config .ServerInfo ;
2627
2728public class MonitorManager {
@@ -114,7 +115,7 @@ public static void refresh(){
114115 webhook .execute ();
115116 } catch (IOException e ) {
116117 e .printStackTrace ();
117- ProxyServer .getInstance ().getConsole ().sendMessage ("[DeltaManagerBungee] Error when sending the Webhook" );
118+ ProxyServer .getInstance ().getConsole ().sendMessage (TextComponent . fromLegacyText ( "[DeltaManagerBungee] Error when sending the Webhook" ) );
118119 }
119120 });
120121 }
@@ -128,51 +129,51 @@ public static void refresh(){
128129 error = true ;
129130 }
130131
131- if (error ){
132- status .put (name , status .get (name ) + 1 );
133-
134- if (status .get (name ) != Config .getConfig ().getInt ("monitor.detected-offline" )) continue ;
135- dates .put (name , Instant .now ());
136-
137- if (Config .getConfig ().getBoolean ("monitor.notify.offline.log.enabled" )){
138- System .out .println (Config .getConfig ().getString ("monitor.notify.offline.log.log" )
139- .replace ("%server%" , name )
140- .replace ("&" , "§" ));
141- }
142-
143- PlayerUtils .broadcast (Config .getConfig ().getString ("monitor.notify.offline.staff-message" )
132+ if (!error ) return ;
133+
134+ status .put (name , status .get (name ) + 1 );
135+
136+ if (status .get (name ) != Config .getConfig ().getInt ("monitor.detected-offline" )) continue ;
137+ dates .put (name , Instant .now ());
138+
139+ if (Config .getConfig ().getBoolean ("monitor.notify.offline.log.enabled" )){
140+ System .out .println (Config .getConfig ().getString ("monitor.notify.offline.log.log" )
144141 .replace ("%server%" , name )
145- .replace ("&" , "§" ), "deltamanager.monitor.alerts" );
146-
147- if (Config .getConfig ().getBoolean ("monitor.notify.offline.webhook.enabled" )){
148- ProxyServer .getInstance ().getScheduler ().runAsync (main , () -> {
149- String path = "monitor.notify.offline.webhook." ;
150- DateTimeFormatter dtf = DateTimeFormatter .ofPattern ("yyyy/MM/dd HH:mm:ss" );
151- ZonedDateTime now = ZonedDateTime .now ();
152- ZonedDateTime zone = now .withZoneSameInstant (ZoneId .of (Config .getConfig ().getString ("ZoneId" )));
153-
154- Webhook webhook = new Webhook (Config .getConfig ().getString (path + "url" ));
155-
156- EmbedObject embed = new Webhook .EmbedObject ();
157- embed .setAuthor (Config .getConfig ().getString (path + "author" )
158- .replace ("%server%" , name ), "" , Config .getConfig ().getString (path + "authoricon" )
142+ .replace ("&" , "§" ));
143+ }
144+
145+ PlayerUtils .broadcast (Config .getConfig ().getString ("monitor.notify.offline.staff-message" )
146+ .replace ("%server%" , name )
147+ .replace ("&" , "§" ), "deltamanager.monitor.alerts" );
148+
149+ if (Config .getConfig ().getBoolean ("monitor.notify.offline.webhook.enabled" )){
150+ ProxyServer .getInstance ().getScheduler ().runAsync (main , () -> {
151+ String path = "monitor.notify.offline.webhook." ;
152+ DateTimeFormatter dtf = DateTimeFormatter .ofPattern ("yyyy/MM/dd HH:mm:ss" );
153+ ZonedDateTime now = ZonedDateTime .now ();
154+ ZonedDateTime zone = now .withZoneSameInstant (ZoneId .of (Config .getConfig ().getString ("ZoneId" )));
155+
156+ Webhook webhook = new Webhook (Config .getConfig ().getString (path + "url" ));
157+
158+ EmbedObject embed = new Webhook .EmbedObject ();
159+ embed .setAuthor (Config .getConfig ().getString (path + "author" )
160+ .replace ("%server%" , name ), "" , Config .getConfig ().getString (path + "authoricon" )
161+ .replace ("%server%" , name ))
162+ .setTitle (Config .getConfig ().getString (path + "title" )
159163 .replace ("%server%" , name ))
160- .setTitle (Config .getConfig ().getString (path + "title" )
161- .replace ("%server%" , name ))
162- .setColor (Color .red )
163- .setFooter (dtf .format (zone ), "" );
164-
165- webhook .addEmbed (embed );
166-
167- try {
168- webhook .execute ();
169- } catch (IOException e ) {
170- e .printStackTrace ();
171- ProxyServer .getInstance ().getConsole ().sendMessage ("[DeltaManagerBungee] Error when sending the Webhook" );
172- }
173- });
174- }
175- }
164+ .setColor (Color .red )
165+ .setFooter (dtf .format (zone ), "" );
166+
167+ webhook .addEmbed (embed );
168+
169+ try {
170+ webhook .execute ();
171+ } catch (IOException e ) {
172+ e .printStackTrace ();
173+ ProxyServer .getInstance ().getConsole ().sendMessage (TextComponent .fromLegacyText ("[DeltaManagerBungee] Error when sending the Webhook" ));
174+ }
175+ });
176+ }
176177 }
177178 }
178179
0 commit comments