Skip to content

Commit

Permalink
Fixed errors thrown with SkinsRestorer in recent versions (#1208)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Jun 30, 2022
1 parent b081589 commit c2cbfc6
Showing 1 changed file with 13 additions and 4 deletions.
Expand Up @@ -21,6 +21,7 @@

import javax.annotation.Nullable;
import java.io.File;
import java.nio.file.Path;

@SuppressWarnings("unused")
public class SkinsRestorerHook {
Expand Down Expand Up @@ -94,14 +95,22 @@ private boolean checkForLocalMode() {
if (Config.MYSQL_ENABLED)
return true;

ReflectField<File> skinsFolder = new ReflectField<>(net.skinsrestorer.shared.storage.SkinStorage.class,
File.class, "skinsFolder");
ReflectField<Object> skinsFolderMethod = new ReflectField<>(net.skinsrestorer.shared.storage.SkinStorage.class,
Object.class, "skinsFolder");

if (!skinsFolder.isValid())
if (!skinsFolderMethod.isValid())
return false;

net.skinsrestorer.bukkit.SkinsRestorer skinsRestorer = JavaPlugin.getPlugin(net.skinsrestorer.bukkit.SkinsRestorer.class);
return skinsFolder.get(skinsRestorer).exists();
Object skinsFolder = skinsFolderMethod.get(skinsRestorer.getSkinStorage());

if (skinsFolder instanceof File) {
return ((File) skinsFolder).exists();
} else if (skinsFolder instanceof Path) {
return ((Path) skinsFolder).toFile().exists();
}

return false;
}

@Override
Expand Down

0 comments on commit c2cbfc6

Please sign in to comment.