From 387e3d0ea946391967a5c5488efcac457636d53f Mon Sep 17 00:00:00 2001 From: MATRIX-feather Date: Fri, 15 Dec 2023 15:29:55 +0800 Subject: [PATCH] Try server renderer first, then LibsDisguises --- src/main/java/xiamomc/morph/MorphManager.java | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/src/main/java/xiamomc/morph/MorphManager.java b/src/main/java/xiamomc/morph/MorphManager.java index 0d6e0bb5..959ef6f0 100644 --- a/src/main/java/xiamomc/morph/MorphManager.java +++ b/src/main/java/xiamomc/morph/MorphManager.java @@ -111,28 +111,53 @@ public Material getActionItem() @Resolved private MorphClientHandler clientHandler; - @Initializer - private void load() + private void tryBackends() { - this.addSchedule(this::update); - try { this.currentBackend = new ServerBackend(); + return; } catch (NoClassDefFoundError e) { - logger.error("Unable to initialize renderer as our disguise backend, maybe ProtocolLib it's not installed on the server>"); - logger.error("Using NilBackend, displaying disguises at the server side will not be supported this run."); + logger.error("Unable to initialize renderer as our disguise backend, maybe ProtocolLib it's not installed on the server."); + logger.error("Trying LibsBackend..."); } catch (Throwable t) { logger.error("Unable to initialize renderer as our disguise backend: " + t.getMessage()); + logger.error("Please consider reporting this issue to our GitHub: https://github.com/XiaMoZhiShi/MorphPlugin/issues"); + logger.error("Trying LibsBackend..."); + + t.printStackTrace(); + } + + try + { + this.currentBackend = new LibsBackend(); + return; + } + catch (NoClassDefFoundError e) + { + logger.error("Unable to initialize LibsDisguises as our disguise backend, maybe it's not installed on the server."); + logger.error("Using NilBackend, displaying disguises at the server side will not be supported this run."); + } + catch (Throwable t) + { + logger.error("Unable to initialize LibsDisguises as our disguise backend: " + t.getMessage()); logger.error("Using NilBackend, displaying disguises at the server side will not be supported this run."); logger.error("Please consider reporting this issue to our GitHub: https://github.com/XiaMoZhiShi/MorphPlugin/issues"); t.printStackTrace(); } + } + + @Initializer + private void load() + { + this.addSchedule(this::update); + + tryBackends(); logger.info("Using backend: %s".formatted(currentBackend));