This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Integrations: add SkinsRestorer support
- Loading branch information
Showing
6 changed files
with
62 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
src/main/java/net/flectone/chat/module/integrations/FSkinsRestorer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package net.flectone.chat.module.integrations; | ||
|
||
import net.skinsrestorer.api.PropertyUtils; | ||
import net.skinsrestorer.api.SkinsRestorer; | ||
import net.skinsrestorer.api.SkinsRestorerProvider; | ||
import net.skinsrestorer.api.exception.DataRequestException; | ||
import net.skinsrestorer.api.property.SkinProperty; | ||
import net.skinsrestorer.api.storage.PlayerStorage; | ||
import org.bukkit.entity.Player; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.Optional; | ||
|
||
public class FSkinsRestorer implements FIntegration{ | ||
|
||
private SkinsRestorer skinsRestorer; | ||
|
||
public FSkinsRestorer() { | ||
init(); | ||
} | ||
|
||
@Override | ||
public void init() { | ||
skinsRestorer = SkinsRestorerProvider.get(); | ||
} | ||
|
||
@Nullable | ||
public String getTextureId(@NotNull Player player) { | ||
PlayerStorage storage = skinsRestorer.getPlayerStorage(); | ||
try { | ||
Optional<SkinProperty> skin = storage.getSkinForPlayer(player.getUniqueId(), player.getName()); | ||
return skin.map(PropertyUtils::getSkinTextureUrlStripped).orElse(null); | ||
} catch (DataRequestException e) { | ||
return null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters