Skip to content

Commit

Permalink
Add mineskin api key config option
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverSchlueter committed Nov 23, 2024
1 parent a1a7474 commit c786178
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public interface FancyNpcsConfig {

int getRemoveNpcsFromPlayerlistDelay();

String getMineSkinApiKey();

List<String> getBlockedCommands();

Map<String, Integer> getMaxNpcsPerPermission();
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/de/oliver/fancynpcs/FancyNpcsConfigImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public class FancyNpcsConfigImpl implements FancyNpcsConfig {
*/
private int removeNpcsFromPlayerlistDelay;

/**
* The API key for the MineSkin API.
*/
private String mineskinApiKey;

/**
* The commands that are blocked for NPCs in the message.
*/
Expand Down Expand Up @@ -112,6 +117,9 @@ public void reload() {
visibilityDistance = (int) ConfigHelper.getOrDefault(config, "visibility_distance", 20);
config.setInlineComments("visibility_distance", List.of("The distance at which NPCs are visible."));

mineskinApiKey = (String) ConfigHelper.getOrDefault(config, "mineskin_api_key", "");
config.setInlineComments("mineskin_api_key", List.of("The API key for the MineSkin API. This will be used to load skins faster. You can get an API key at https://mineskin.org/account."));

removeNpcsFromPlayerlistDelay = (int) ConfigHelper.getOrDefault(config, "remove_npcs_from_playerlist_delay", 2000);
config.setInlineComments("remove_npcs_from_playerlist_delay", List.of("The delay in ticks to remove NPCs from the player list. Increase this value if you have problems with skins not loading correctly when joining or switching worlds. You can set it to -1, if you don't have any npcs using the show_in_tab feature."));

Expand Down Expand Up @@ -181,6 +189,14 @@ public int getRemoveNpcsFromPlayerlistDelay() {
return removeNpcsFromPlayerlistDelay;
}

public String getMineSkinApiKey() {
if (mineskinApiKey.isEmpty()) {
return null;
}

return mineskinApiKey;
}

public List<String> getBlockedCommands() {
return blockedCommands;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public SkinManagerImpl(SkinCache fileCache, SkinCache memCache) {

this.client = MineSkinClient.builder()
.requestHandler(JsoupRequestHandler::new)
.apiKey(FancyNpcs.getInstance().getFancyNpcConfig().getMineSkinApiKey())
.userAgent("FancyNpcs")
.getExecutor(executor)
.generateExecutor(executor)
Expand Down

0 comments on commit c786178

Please sign in to comment.