2626import io .wdsj .asw .bukkit .permission .cache .CachingPermTool ;
2727import io .wdsj .asw .bukkit .proxy .velocity .VelocityChannel ;
2828import io .wdsj .asw .bukkit .proxy .velocity .VelocityReceiver ;
29+ import io .wdsj .asw .bukkit .proxy .velocity .sync .VelocitySyncClient ;
2930import io .wdsj .asw .bukkit .service .ListenerService ;
3031import io .wdsj .asw .bukkit .setting .PaperConfigurationService ;
3132import io .wdsj .asw .bukkit .setting .PluginMessages ;
@@ -69,6 +70,7 @@ public final class AdvancedSensitiveWords extends JavaPlugin {
6970 private PaperConfigurationService configurationService ;
7071 private volatile Updater .UpdateResult updateResult = Updater .UpdateResult .noUpdate ();
7172 private AswCommandRegistrar commandRegistrar ;
73+ private VelocitySyncClient velocitySyncClient ;
7274 public static TaskScheduler getScheduler () {
7375 return scheduler ;
7476 }
@@ -92,6 +94,10 @@ public LlmChatDetectionService getLlmChatDetectionService() {
9294 return listenerService .getLlmChatDetectionService ();
9395 }
9496
97+ public VelocitySyncClient getVelocitySyncClient () {
98+ return velocitySyncClient ;
99+ }
100+
95101 public static <T > T setting (SettingKey <T > key ) {
96102 return instance .configurationService .get (key );
97103 }
@@ -125,6 +131,7 @@ public void onEnable() {
125131 commandRegistrar .register ();
126132 setupMetrics ();
127133 registerVelocityChannel ();
134+ startVelocitySyncClient ();
128135 registerPlaceholderExpansion ();
129136 scheduleViolationResetTask ();
130137 long endTime = System .currentTimeMillis ();
@@ -173,6 +180,7 @@ public void doInitTasks() {
173180
174181 @ Override
175182 public void onDisable () {
183+ stopVelocitySyncClient ();
176184 listenerService .unregisterListeners ();
177185 getServer ().getMessenger ().unregisterOutgoingPluginChannel (this );
178186 getServer ().getMessenger ().unregisterIncomingPluginChannel (this );
@@ -201,6 +209,7 @@ public void reloadPluginConfiguration() {
201209 if (listenerService != null ) {
202210 listenerService .reloadConfiguration ();
203211 }
212+ restartVelocitySyncClient ();
204213 }
205214
206215 private void setupMetrics () {
@@ -220,6 +229,26 @@ private void registerVelocityChannel() {
220229 getServer ().getMessenger ().registerIncomingPluginChannel (this , VelocityChannel .CHANNEL , new VelocityReceiver ());
221230 }
222231
232+ private void startVelocitySyncClient () {
233+ stopVelocitySyncClient ();
234+ if (!configurationService .get (PluginSettings .VELOCITY_SYNC_ENABLED )) {
235+ return ;
236+ }
237+ velocitySyncClient = new VelocitySyncClient (this );
238+ velocitySyncClient .start ();
239+ }
240+
241+ private void stopVelocitySyncClient () {
242+ if (velocitySyncClient != null ) {
243+ velocitySyncClient .close ();
244+ velocitySyncClient = null ;
245+ }
246+ }
247+
248+ private void restartVelocitySyncClient () {
249+ startVelocitySyncClient ();
250+ }
251+
223252 private void registerPlaceholderExpansion () {
224253 if (Bukkit .getPluginManager ().isPluginEnabled ("PlaceholderAPI" ) &&
225254 configurationService .get (PluginSettings .ENABLE_PLACEHOLDER )) {
@@ -230,7 +259,7 @@ private void registerPlaceholderExpansion() {
230259
231260 private void scheduleViolationResetTask () {
232261 long resetIntervalTicks = configurationService .get (PluginSettings .VIOLATION_RESET_TIME ) * 20L * 60L ;
233- violationResetTask = new ViolationResetTask ().runTaskTimerAsynchronously (this , resetIntervalTicks , resetIntervalTicks );
262+ violationResetTask = new ViolationResetTask (configurationService ).runTaskTimerAsynchronously (this , resetIntervalTicks , resetIntervalTicks );
234263 }
235264
236265 private void checkForUpdatesAsync () {
0 commit comments