1
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:
TheBusyBiscuit 2019-12-12 00:22:00 +01:00
parent a91d926698
commit aa9652cf88
2 changed files with 5 additions and 4 deletions

View File

@ -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)

View File

@ -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;
} }