Skip to content

Commit

Permalink
Potential fix for skinsrestorer skins not working (#812)
Browse files Browse the repository at this point in the history
  • Loading branch information
OmerBenGera committed Dec 30, 2021
1 parent 55a7e29 commit 44f18fc
Showing 1 changed file with 17 additions and 0 deletions.
Expand Up @@ -7,7 +7,11 @@
import com.bgsoftware.superiorskyblock.utils.debug.PluginDebugger;
import com.mojang.authlib.properties.Property;
import net.skinsrestorer.api.SkinsRestorerAPI;
import net.skinsrestorer.api.bukkit.events.SkinApplyBukkitEvent;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import skinsrestorer.bukkit.SkinsRestorer;
import skinsrestorer.shared.exception.SkinRequestException;
import skinsrestorer.shared.storage.SkinStorage;
Expand All @@ -27,6 +31,7 @@ public static void register(SuperiorSkyblockPlugin plugin) {
skinsRestorer = new SkinsRestorerOld();
}
plugin.getProviders().registerSkinsListener(SkinsRestorerHook::setSkinTexture);
plugin.getServer().getPluginManager().registerEvents(new SkinsListener(), plugin);
}

private static void setSkinTexture(SuperiorPlayer superiorPlayer) {
Expand Down Expand Up @@ -76,4 +81,16 @@ public Property getSkin(SuperiorPlayer superiorPlayer) {

}

private static final class SkinsListener implements Listener {

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSkinApply(SkinApplyBukkitEvent event) {
if(event.getProperty() instanceof Property) {
SuperiorPlayer superiorPlayer = plugin.getPlayers().getSuperiorPlayer(event.getWho());
plugin.getNMSPlayers().setSkinTexture(superiorPlayer, (Property) event.getProperty());
}
}

}

}

0 comments on commit 44f18fc

Please sign in to comment.