2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +00:00

Allow unsuccessful replacement of BungeeCord thread pool (#15)

* Allow unsuccessful replacement of BungeeCord thread pool

Port https://github.com/minecrafter/RedisBungee/pull/76

Some BungeeCord forks have different implementation of thread pool and RedisBungee won't load in such case

* Update RedisBungee.java
This commit is contained in:
foss-mc 2021-07-21 12:13:25 +00:00 committed by GitHub
parent 701c87db02
commit ede9a7cba9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -223,14 +223,15 @@ public final class RedisBungee extends Plugin {
@Override
public void onEnable() {
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
getExecutorService().shutdownNow();
ScheduledExecutorService service;
ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory);
try {
Field field = Plugin.class.getDeclaredField("service");
field.setAccessible(true);
field.set(this, service = Executors.newScheduledThreadPool(24, factory));
ExecutorService builtinService = (ExecutorService) field.get(this);
field.set(this, service);
builtinService.shutdownNow();
} catch (Exception e) {
throw new RuntimeException("Can't replace BungeeCord thread pool with our own", e);
getLogger().log(Level.WARNING, "Can't replace BungeeCord thread pool with our own", e);
}
try {
loadConfig();