Skip to content

Commit

Permalink
Allow unsuccessful replacement of BungeeCord thread pool (#15)
Browse files Browse the repository at this point in the history
* Allow unsuccessful replacement of BungeeCord thread pool

Port minecrafter/RedisBungee#76

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

* Update RedisBungee.java
  • Loading branch information
foss-mc authored Jul 21, 2021
1 parent 701c87d commit ede9a7c
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ private long getRedisTime(List<String> timeRes) {
@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();
Expand Down

0 comments on commit ede9a7c

Please sign in to comment.