1313import org .bukkit .SoundCategory ;
1414import org .jetbrains .annotations .NotNull ;
1515import org .jetbrains .annotations .Nullable ;
16+ import xyz .srnyx .annoyingapi .AnnoyingPlugin ;
1617import xyz .srnyx .annoyingapi .file .PlayableSound ;
18+ import xyz .srnyx .annoyingapi .libs .javautilities .HttpUtility ;
1719import xyz .srnyx .annoyingapi .libs .javautilities .manipulation .DurationFormatter ;
1820
1921import java .time .Duration ;
2022import java .time .temporal .ChronoUnit ;
2123import java .util .HashSet ;
2224import java .util .Set ;
25+ import java .util .logging .Level ;
2326
2427
2528@ Header ("# --- WIKIS ---" )
@@ -30,8 +33,9 @@ public class ConfigYml extends OkaeriConfig {
3033 * @param plugin Only {@code null} for unit tests
3134 */
3235 public ConfigYml (@ Nullable EventAlertsIntegration plugin ) {
36+ System .out .println ("this: " + this );
3337 this .syncing = new Syncing (plugin );
34- this .linking = new Linking (plugin );
38+ this .linking = new Linking ( plugin );
3539 this .cross_ban = new CrossBan (plugin );
3640 this .event_messages = new EventMessages (plugin );
3741 this .advanced = new Advanced (plugin );
@@ -97,8 +101,9 @@ public String getServer() {
97101 }
98102 }
99103
100- public static class Syncing extends OkaeriConfig {
104+ public static class Syncing extends SubConfig {
101105 public Syncing (@ Nullable EventAlertsIntegration plugin ) {
106+ super (plugin );
102107 this .discord_to_minecraft = new DiscordToMinecraft (plugin );
103108 this .minecraft_to_discord = new MinecraftToDiscord (plugin );
104109 }
@@ -110,19 +115,18 @@ public Syncing(@Nullable EventAlertsIntegration plugin) {
110115 @ Comment ("Settings for Minecraft -> Discord syncing" )
111116 @ NotNull public MinecraftToDiscord minecraft_to_discord ;
112117
113- public static class DiscordToMinecraft extends OkaeriConfig {
118+ public static class DiscordToMinecraft extends SubConfig {
114119 public DiscordToMinecraft (@ Nullable EventAlertsIntegration plugin ) {
120+ super (plugin );
115121 this .messages = new Messages (plugin );
116122 }
117123
118124 @ Comment ("Settings for syncing Discord messages to Minecraft in-game chat" )
119125 @ NotNull public Messages messages ;
120126
121- public static class Messages extends OkaeriConfig {
122- @ Nullable private transient final EventAlertsIntegration plugin ;
123-
127+ public static class Messages extends SubConfig {
124128 public Messages (@ Nullable EventAlertsIntegration plugin ) {
125- this . plugin = plugin ;
129+ super ( plugin ) ;
126130 }
127131
128132 @ Comment ("Whether to send messages to the Minecraft in-game chat from the event's Event Alerts thread" )
@@ -141,7 +145,6 @@ public Messages(@Nullable EventAlertsIntegration plugin) {
141145
142146 public void setEnabled (boolean newStatus ) {
143147 if (enabled == newStatus ) return ;
144-
145148 enabled = newStatus ;
146149 save ();
147150
@@ -156,19 +159,16 @@ public void setFormat(@NotNull String newFormat) {
156159 }
157160 }
158161
159- public static class MinecraftToDiscord extends OkaeriConfig {
160- @ Nullable private transient final EventAlertsIntegration plugin ;
161-
162+ public static class MinecraftToDiscord extends SubConfig {
162163 public MinecraftToDiscord (@ Nullable EventAlertsIntegration plugin ) {
163- this . plugin = plugin ;
164+ super ( plugin ) ;
164165 }
165166
166167 @ Comment ("Whether to send join/quit messages in the event's Event Alerts thread in Discord" )
167168 public boolean connections = true ;
168169
169170 public void setConnections (boolean newStatus ) {
170171 if (connections == newStatus ) return ;
171-
172172 connections = newStatus ;
173173 save ();
174174
@@ -177,11 +177,9 @@ public void setConnections(boolean newStatus) {
177177 }
178178 }
179179
180- public static class Linking extends OkaeriConfig {
181- @ Nullable private transient final EventAlertsIntegration plugin ;
182-
180+ public static class Linking extends SubConfig {
183181 public Linking (@ Nullable EventAlertsIntegration plugin ) {
184- this . plugin = plugin ;
182+ super ( plugin ) ;
185183 }
186184
187185 @ Comment ("Whether to force players to be linked with Event Alerts to join/stay on the server" )
@@ -198,7 +196,6 @@ public Linking(@Nullable EventAlertsIntegration plugin) {
198196
199197 public void setRequireLink (boolean newStatus ) {
200198 if (require_link == newStatus ) return ;
201-
202199 require_link = newStatus ;
203200 save ();
204201
@@ -207,24 +204,20 @@ public void setRequireLink(boolean newStatus) {
207204
208205 public void setCheckOnJoin (boolean newStatus ) {
209206 if (check_on_join == newStatus ) return ;
210-
211207 check_on_join = newStatus ;
212208 save ();
213209 }
214210
215211 public void setAllowJoinOnFailure (boolean newStatus ) {
216212 if (allow_join_on_failure == newStatus ) return ;
217-
218213 allow_join_on_failure = newStatus ;
219214 save ();
220215 }
221216 }
222217
223- public static class CrossBan extends OkaeriConfig {
224- @ Nullable private transient final EventAlertsIntegration plugin ;
225-
218+ public static class CrossBan extends SubConfig {
226219 public CrossBan (@ Nullable EventAlertsIntegration plugin ) {
227- this . plugin = plugin ;
220+ super ( plugin ) ;
228221 }
229222
230223 @ Comment ("Whether to enable cross-ban checking" )
@@ -241,7 +234,6 @@ public CrossBan(@Nullable EventAlertsIntegration plugin) {
241234
242235 public void setEnabled (boolean newStatus ) {
243236 if (enabled == newStatus ) return ;
244-
245237 enabled = newStatus ;
246238 save ();
247239
@@ -250,24 +242,21 @@ public void setEnabled(boolean newStatus) {
250242
251243 public void setCheckOnJoin (boolean newStatus ) {
252244 if (check_on_join == newStatus ) return ;
253-
254245 check_on_join = newStatus ;
255246 save ();
256247 }
257248
258249 public void setAllowJoinOnFailure (boolean newStatus ) {
259250 if (allow_join_on_failure == newStatus ) return ;
260-
261251 allow_join_on_failure = newStatus ;
262252 save ();
263253 }
264254 }
265255
266- public static class EventMessages extends OkaeriConfig {
267- @ Nullable private transient final EventAlertsIntegration plugin ;
268-
256+ public static class EventMessages extends SubConfig {
269257 public EventMessages (@ Nullable EventAlertsIntegration plugin ) {
270- this .plugin = plugin ;
258+ super (plugin );
259+ sound = new SoundYml (plugin );
271260 }
272261
273262 @ Comment ("Whether to enable event messages being broadcast in the server chat" )
@@ -280,7 +269,7 @@ public EventMessages(@Nullable EventAlertsIntegration plugin) {
280269
281270 @ Comment
282271 @ Comment ("The sound to play when an event message is broadcasted" )
283- @ NotNull public SoundYml sound = new SoundYml () ;
272+ @ NotNull public SoundYml sound ;
284273
285274 @ Comment
286275 @ Comment ("Types of events that shouldn't be broadcasted in the server chat" )
@@ -313,7 +302,6 @@ public boolean isInHostFilter(long hostId) {
313302
314303 public void setEnabled (boolean newStatus ) {
315304 if (enabled == newStatus ) return ;
316-
317305 enabled = newStatus ;
318306 save ();
319307
@@ -322,7 +310,6 @@ public void setEnabled(boolean newStatus) {
322310
323311 public void setDetectIps (boolean newStatus ) {
324312 if (detect_ips == newStatus ) return ;
325-
326313 detect_ips = newStatus ;
327314 save ();
328315 }
@@ -335,6 +322,7 @@ public boolean toggleIgnoredPartnerRole(@NotNull PingRole role) {
335322 return toggleSetItem (ignored_partner_roles , role );
336323 }
337324
325+ //TODO
338326 public boolean toggleIgnoredFormat (@ NotNull EventFormat format ) {
339327 return toggleSetItem (ignored_formats , format );
340328 }
@@ -345,21 +333,21 @@ public boolean addHostFilter(@NotNull String id) {
345333 return true ;
346334 }
347335
348- public boolean removeHostFilter (@ NotNull String id ) {
349- if (!host_filter .remove (id )) return false ;
350- save ();
351- return true ;
336+ public void removeHostFilter (@ NotNull String id ) {
337+ if (host_filter .remove (id )) save ();
352338 }
353339
354340 private <T > boolean toggleSetItem (@ NotNull Set <T > set , @ NotNull T item ) {
355341 final boolean newStatus = !set .remove (item );
356342 if (newStatus ) set .add (item );
357-
358343 save ();
359344 return newStatus ;
360345 }
361346
362- public static class SoundYml extends OkaeriConfig {
347+ public static class SoundYml extends SubConfig {
348+ public SoundYml (@ Nullable EventAlertsIntegration plugin ) {
349+ super (plugin );
350+ }
363351
364352 @ Comment ("Whether to play a sound" )
365353 public boolean enabled = true ;
@@ -400,11 +388,10 @@ public void setCategory(@NotNull SoundCategory newCategory) {
400388 }
401389 }
402390
403- public static class Advanced extends OkaeriConfig {
404- @ Nullable private transient final EventAlertsIntegration plugin ;
405-
391+ public static class Advanced extends SubConfig {
406392 public Advanced (@ Nullable EventAlertsIntegration plugin ) {
407- this .plugin = plugin ;
393+ super (plugin );
394+ websocket = new Websocket (plugin );
408395 }
409396
410397 @ Comment ("Whether to enable debug logging" )
@@ -417,18 +404,28 @@ public Advanced(@Nullable EventAlertsIntegration plugin) {
417404
418405 @ Comment
419406 @ Comment ("Settings for websocket connections" )
420- @ NotNull public ConfigYml .Advanced .Websocket websocket = new Websocket ();
407+ @ NotNull public ConfigYml .Advanced .Websocket websocket ;
408+
409+ public void setDebug (boolean newStatus ) {
410+ if (debug == newStatus ) return ;
411+ debug = newStatus ;
412+ save ();
413+
414+ if (plugin != null ) plugin .setDebug (newStatus );
415+ }
421416
422417 public void setUseTestingApi (boolean newStatus ) {
423418 if (use_testing_api == newStatus ) return ;
424-
425419 use_testing_api = newStatus ;
426420 save ();
427421
428422 if (plugin != null ) plugin .webSockets .reconnectAll ("Testing API toggled" );
429423 }
430424
431- public static class Websocket extends OkaeriConfig {
425+ public static class Websocket extends SubConfig {
426+ public Websocket (@ Nullable EventAlertsIntegration plugin ) {
427+ super (plugin );
428+ }
432429
433430 @ Comment ("Whether to automatically reconnect to the websocket if it is disconnected" )
434431 public boolean retry = true ;
0 commit comments