1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

[CI skip] Small changes

This commit is contained in:
TheBusyBiscuit 2021-01-15 11:46:40 +01:00
parent dfcca27dd4
commit a810458345
4 changed files with 53 additions and 34 deletions

View File

@ -36,6 +36,7 @@
* Fixed #2511
* Fixed #2636
* Fixed a threading issue related to BlockStates and persistent data
* Fixed an error when the server was shutting down
* Fixed #2721
## Release Candidate 19 (11 Jan 2021)

View File

@ -1,6 +1,6 @@
package io.github.thebusybiscuit.slimefun4.core.services.github;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -16,42 +16,16 @@ import kong.unirest.json.JSONObject;
class ContributionsConnector extends GitHubConnector {
/*
* @formatter:off
/**
* GitHub Bots that do not count as Contributors
* (includes "invalid-email-address" because it is an invalid contributor)
*/
private static final List<String> blacklist = Arrays.asList(
"invalid-email-address",
"renovate-bot",
"TheBusyBot",
"ImgBotApp",
"imgbot",
"imgbot[bot]",
"github-actions[bot]",
"gitlocalize-app",
"gitlocalize-app[bot]",
"mt-gitlocalize"
);
private final List<String> ignoredAccounts = new ArrayList<>();
/*
* @formatter:on
/**
* Matches a GitHub name with a Minecraft name.
*/
private static final Map<String, String> aliases = new HashMap<>();
// Should probably be switched to UUIDs at some point...
static {
aliases.put("WalshyDev", "HumanRightsAct");
aliases.put("J3fftw1", "_lagpc_");
aliases.put("ajan-12", "ajan_12");
aliases.put("mrcoffee1026", "mr_coffee1026");
aliases.put("Cyber-MC", "CyberPatriot");
aliases.put("BurningBrimstone", "Bluedevil74");
aliases.put("bverhoeven", "soczol");
aliases.put("ramdon-person", "ramdon_person");
aliases.put("NCBPFluffyBear", "FluffyBear_");
}
private final Map<String, String> aliases = new HashMap<>();
private final String prefix;
private final String role;
@ -66,6 +40,36 @@ class ContributionsConnector extends GitHubConnector {
this.prefix = prefix;
this.page = page;
this.role = role;
loadConfiguration();
}
/**
* This method loads all aliases.
* This mapping matches a GitHub username with a Minecraft username.
* These people are... "special cases".
*/
private void loadConfiguration() {
ignoredAccounts.add("invalid-email-address");
ignoredAccounts.add("renovate-bot");
ignoredAccounts.add("TheBusyBot");
ignoredAccounts.add("ImgBotApp");
ignoredAccounts.add("imgbot");
ignoredAccounts.add("imgbot[bot]");
ignoredAccounts.add("github-actions[bot]");
ignoredAccounts.add("gitlocalize-app");
ignoredAccounts.add("gitlocalize-app[bot]");
ignoredAccounts.add("mt-gitlocalize");
aliases.put("WalshyDev", "HumanRightsAct");
aliases.put("J3fftw1", "_lagpc_");
aliases.put("ajan-12", "ajan_12");
aliases.put("mrcoffee1026", "mr_coffee1026");
aliases.put("Cyber-MC", "CyberPatriot");
aliases.put("BurningBrimstone", "Bluedevil74");
aliases.put("bverhoeven", "soczol");
aliases.put("ramdon-person", "ramdon_person");
aliases.put("NCBPFluffyBear", "FluffyBear_");
}
/**
@ -119,7 +123,7 @@ class ContributionsConnector extends GitHubConnector {
int commits = object.getInt("contributions");
String profile = object.getString("html_url");
if (!blacklist.contains(name)) {
if (!ignoredAccounts.contains(name)) {
String username = aliases.getOrDefault(name, name);
github.addContributor(username, profile, role, commits);
}

View File

@ -179,8 +179,22 @@ public class Contributor {
*/
@Nonnull
public String getTexture() {
return getTexture(SlimefunPlugin.getGitHubService());
}
/**
* Returns this contributor's head texture.
* If no texture could be found, or it hasn't been pulled yet,
* then it will return a placeholder texture.
*
* @param github
* Our {@link GitHubService} instance
*
* @return A Base64-Head Texture
*/
@Nonnull
protected String getTexture(@Nonnull GitHubService github) {
if (!headTexture.isComputed() || !headTexture.isPresent()) {
GitHubService github = SlimefunPlugin.getGitHubService();
String cached = github.getCachedTexture(githubUsername);
if (cached != null) {

View File

@ -214,7 +214,7 @@ public class GitHubService {
uuid.ifPresent(value -> uuidCache.setValue(contributor.getName(), value));
if (contributor.hasTexture()) {
String texture = contributor.getTexture();
String texture = contributor.getTexture(this);
if (!texture.equals(HeadTexture.UNKNOWN.getTexture())) {
texturesCache.setValue(contributor.getName(), texture);