Skip to content

Commit

Permalink
Allow unsuccessful replacement of BungeeCord thread pool
Browse files Browse the repository at this point in the history
Port minecrafter/RedisBungee#76

Some BungeeCord forks have different implementation of thread pool and RedisBungee won't load in such case
  • Loading branch information
foss-mc authored Jul 21, 2021
1 parent 701c87d commit 6a1a6ac
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -224,13 +224,15 @@ private long getRedisTime(List<String> timeRes) {
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();
Expand Down

0 comments on commit 6a1a6ac

Please sign in to comment.