Skip to content

Commit

Permalink
Fixed issue with detection of the correct version of SkinsRestorer wi…
Browse files Browse the repository at this point in the history
…th newer versions of the plugin (#1488)
  • Loading branch information
OmerBenGera committed Dec 1, 2022
1 parent 6443994 commit ce62682
Showing 1 changed file with 19 additions and 6 deletions.
Expand Up @@ -31,18 +31,31 @@ public class SkinsRestorerHook {

public static void register(SuperiorSkyblockPlugin plugin) {
SkinsRestorerHook.plugin = plugin;
try {
Class.forName("net.skinsrestorer.bukkit.SkinsRestorer");
skinsRestorer = new SkinsRestorerNew();
} catch (Exception ex) {
skinsRestorer = new SkinsRestorerOld();
}

skinsRestorer = isNewVersionDetected() ? new SkinsRestorerNew() : new SkinsRestorerOld();

if (skinsRestorer.isLocalMode()) {
plugin.getProviders().registerSkinsListener(SkinsRestorerHook::setSkinTexture);
plugin.getServer().getPluginManager().registerEvents(new SkinsListener(), plugin);
}
}

private static boolean isNewVersionDetected() {
try {
Class.forName("net.skinsrestorer.bukkit.SkinsRestorer");
return true;
} catch (Exception ignored) {
}

try {
Class.forName("net.skinsrestorer.bukkit.SkinsRestorerBukkit");
return true;
} catch (Exception ignored) {
}

return false;
}

private static void setSkinTexture(SuperiorPlayer superiorPlayer) {
if (Bukkit.isPrimaryThread()) {
BukkitExecutor.async(() -> setSkinTexture(superiorPlayer));
Expand Down

0 comments on commit ce62682

Please sign in to comment.