3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-12-24 15:20:35 +01:00

check if a plugin has a executor service (#1038)

* check if a plugin has an executor service

* checkstyle
Dieser Commit ist enthalten in:
Aaron 2023-08-05 02:48:01 +02:00 committet von GitHub
Ursprung 37fedf508e
Commit be9ecf75b2
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
2 geänderte Dateien mit 20 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -71,4 +71,8 @@ public class VelocityPluginContainer implements PluginContainer {
return this.service;
}
public boolean hasExecutorService() {
return this.service != null;
}
}

Datei anzeigen

@ -30,9 +30,12 @@ import com.velocitypowered.api.scheduler.ScheduledTask;
import com.velocitypowered.api.scheduler.Scheduler;
import com.velocitypowered.api.scheduler.TaskStatus;
import com.velocitypowered.proxy.plugin.loader.VelocityPluginContainer;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
@ -116,17 +119,24 @@ public class VelocityScheduler implements Scheduler {
task.cancel();
}
timerExecutionService.shutdown();
for (final PluginContainer container : this.pluginManager.getPlugins()) {
final List<PluginContainer> plugins = new ArrayList<>(this.pluginManager.getPlugins());
final Iterator<PluginContainer> pluginIterator = plugins.iterator();
while (pluginIterator.hasNext()) {
final PluginContainer container = pluginIterator.next();
if (container instanceof VelocityPluginContainer) {
(container).getExecutorService().shutdown();
final VelocityPluginContainer pluginContainer = (VelocityPluginContainer) container;
if (pluginContainer.hasExecutorService()) {
container.getExecutorService().shutdown();
} else {
pluginIterator.remove();
}
} else {
pluginIterator.remove();
}
}
boolean allShutdown = true;
for (final PluginContainer container : this.pluginManager.getPlugins()) {
if (!(container instanceof VelocityPluginContainer)) {
continue;
}
for (final PluginContainer container : plugins) {
final String id = container.getDescription().getId();
final ExecutorService service = (container).getExecutorService();