From 95c2bd500e81770c2d539437affe72616c6745a0 Mon Sep 17 00:00:00 2001 From: pop4959 Date: Wed, 30 Sep 2020 21:46:00 -0700 Subject: [PATCH] Fix error on enable when LuckPerms isn't installed Fixes #2 --- gradle.properties | 2 +- src/main/java/org/popcraft/stress/Stress.java | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index f2bce18..c9ceff1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ pluginGroup=org.popcraft -pluginVersion=1.0.2 +pluginVersion=1.0.3 diff --git a/src/main/java/org/popcraft/stress/Stress.java b/src/main/java/org/popcraft/stress/Stress.java index f1c08ee..18cd6d4 100644 --- a/src/main/java/org/popcraft/stress/Stress.java +++ b/src/main/java/org/popcraft/stress/Stress.java @@ -76,14 +76,18 @@ public void onEnable() { int pluginId = 7063; Metrics metrics = new Metrics(this, pluginId); // Register LuckPerms contexts - LuckPermsContexts.register(); + if (serverSupportsContexts()) { + LuckPermsContexts.register(); + } } @Override public void onDisable() { tickProfiler.stop(); // Unregister LuckPerms contexts - LuckPermsContexts.unregister(); + if (serverSupportsContexts()) { + LuckPermsContexts.unregister(); + } } @Override @@ -188,4 +192,12 @@ private void addTests(Test... tests) { } } + private boolean serverSupportsContexts() { + try { + Class.forName("net.luckperms.api.context.ContextCalculator"); + return true; + } catch (ClassNotFoundException e) { + return false; + } + } }