mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Fixed Credits erroring for invalid usernames
This commit is contained in:
parent
a91d926698
commit
aa9652cf88
@ -4,7 +4,6 @@ import java.util.Arrays;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import com.google.gson.JsonArray;
|
import com.google.gson.JsonArray;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
@ -12,8 +11,6 @@ import com.google.gson.JsonObject;
|
|||||||
|
|
||||||
public class ContributionsConnector extends GitHubConnector {
|
public class ContributionsConnector extends GitHubConnector {
|
||||||
|
|
||||||
private static final Pattern nameFormat = Pattern.compile("[\\w_]+");
|
|
||||||
|
|
||||||
// GitHub Bots that do not count as Contributors
|
// GitHub Bots that do not count as Contributors
|
||||||
// (includes "invalid-email-address" because it is an invalid contributor)
|
// (includes "invalid-email-address" because it is an invalid contributor)
|
||||||
private static final List<String> blacklist = Arrays.asList(
|
private static final List<String> blacklist = Arrays.asList(
|
||||||
@ -79,7 +76,7 @@ public class ContributionsConnector extends GitHubConnector {
|
|||||||
int commits = object.get("contributions").getAsInt();
|
int commits = object.get("contributions").getAsInt();
|
||||||
String profile = object.get("html_url").getAsString();
|
String profile = object.get("html_url").getAsString();
|
||||||
|
|
||||||
if (nameFormat.matcher(name).matches() && !blacklist.contains(name)) {
|
if (!blacklist.contains(name)) {
|
||||||
Contributor contributor = github.getContributors().computeIfAbsent(
|
Contributor contributor = github.getContributors().computeIfAbsent(
|
||||||
name,
|
name,
|
||||||
key -> new Contributor(aliases.getOrDefault(name, name), profile)
|
key -> new Contributor(aliases.getOrDefault(name, name), profile)
|
||||||
|
@ -324,6 +324,10 @@ public final class SlimefunPlugin extends JavaPlugin {
|
|||||||
contributor.setTexture(Optional.empty());
|
contributor.setTexture(Optional.empty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch(IllegalArgumentException x) {
|
||||||
|
// There cannot be a texture found because it is not a valid MC username
|
||||||
|
contributor.setTexture(Optional.empty());
|
||||||
|
}
|
||||||
catch(TooManyRequestsException x) {
|
catch(TooManyRequestsException x) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user