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:
parent
701c87db02
commit
ede9a7cba9
@ -223,14 +223,15 @@ public final class RedisBungee extends Plugin {
|
|||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
|
ThreadFactory factory = ((ThreadPoolExecutor) getExecutorService()).getThreadFactory();
|
||||||
getExecutorService().shutdownNow();
|
ScheduledExecutorService service = Executors.newScheduledThreadPool(24, factory);
|
||||||
ScheduledExecutorService service;
|
|
||||||
try {
|
try {
|
||||||
Field field = Plugin.class.getDeclaredField("service");
|
Field field = Plugin.class.getDeclaredField("service");
|
||||||
field.setAccessible(true);
|
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) {
|
} 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 {
|
try {
|
||||||
loadConfig();
|
loadConfig();
|
||||||
|
Loading…
Reference in New Issue
Block a user