mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-19 19:25:48 +00:00
Fixed #3241
This commit is contained in:
parent
68e32cb358
commit
79c6c139c6
@ -37,6 +37,7 @@
|
||||
|
||||
#### Fixes
|
||||
* Fixed #3218
|
||||
* Fixed #3241
|
||||
|
||||
## Release Candidate 28 (06 Sep 2021)
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class GitHubService {
|
||||
long period = TimeUnit.HOURS.toMillis(1);
|
||||
GitHubTask task = new GitHubTask(this);
|
||||
|
||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, task, 80L, period);
|
||||
plugin.getServer().getScheduler().runTaskTimerAsynchronously(plugin, task, 30 * 20L, period);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -103,8 +103,7 @@ public class GitHubService {
|
||||
contributors.put(name, contributor);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Contributor addContributor(@Nonnull String minecraftName, @Nonnull String profileURL, @Nonnull String role, int commits) {
|
||||
public @Nonnull Contributor addContributor(@Nonnull String minecraftName, @Nonnull String profileURL, @Nonnull String role, int commits) {
|
||||
Validate.notNull(minecraftName, "Minecraft username must not be null.");
|
||||
Validate.notNull(profileURL, "GitHub profile url must not be null.");
|
||||
Validate.notNull(role, "Role should not be null.");
|
||||
@ -118,8 +117,7 @@ public class GitHubService {
|
||||
return contributor;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public Contributor addContributor(@Nonnull String username, @Nonnull String role, int commits) {
|
||||
public @Nonnull Contributor addContributor(@Nonnull String username, @Nonnull String role, int commits) {
|
||||
Validate.notNull(username, "Username must not be null.");
|
||||
Validate.notNull(role, "Role should not be null.");
|
||||
Validate.isTrue(commits >= 0, "Commit count cannot be negative.");
|
||||
@ -158,8 +156,7 @@ public class GitHubService {
|
||||
}));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
protected Set<GitHubConnector> getConnectors() {
|
||||
protected @Nonnull Set<GitHubConnector> getConnectors() {
|
||||
return connectors;
|
||||
}
|
||||
|
||||
@ -172,8 +169,7 @@ public class GitHubService {
|
||||
*
|
||||
* @return A {@link ConcurrentMap} containing all {@link Contributor Contributors}
|
||||
*/
|
||||
@Nonnull
|
||||
public ConcurrentMap<String, Contributor> getContributors() {
|
||||
public @Nonnull ConcurrentMap<String, Contributor> getContributors() {
|
||||
return contributors;
|
||||
}
|
||||
|
||||
@ -205,12 +201,11 @@ public class GitHubService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the id of Slimefun's GitHub Repository. (e.g. "TheBusyBiscuit/Slimefun4").
|
||||
* Returns the id of Slimefun's GitHub Repository. (e.g. "Slimefun/Slimefun4").
|
||||
*
|
||||
* @return The id of our GitHub Repository
|
||||
*/
|
||||
@Nonnull
|
||||
public String getRepository() {
|
||||
public @Nonnull String getRepository() {
|
||||
return repository;
|
||||
}
|
||||
|
||||
@ -228,8 +223,7 @@ public class GitHubService {
|
||||
*
|
||||
* @return A {@link LocalDateTime} object representing the date and time of the latest commit
|
||||
*/
|
||||
@Nonnull
|
||||
public LocalDateTime getLastUpdate() {
|
||||
public @Nonnull LocalDateTime getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
@ -263,8 +257,7 @@ public class GitHubService {
|
||||
*
|
||||
* @return The cached skin texture for that user (or null)
|
||||
*/
|
||||
@Nullable
|
||||
protected String getCachedTexture(@Nonnull String username) {
|
||||
protected @Nullable String getCachedTexture(@Nonnull String username) {
|
||||
return texturesCache.getString(username);
|
||||
}
|
||||
}
|
||||
|
@ -7,6 +7,8 @@ import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
@ -105,13 +107,18 @@ class GitHubTask implements Runnable {
|
||||
} catch (IllegalArgumentException x) {
|
||||
// There cannot be a texture found because it is not a valid MC username
|
||||
contributor.setTexture(null);
|
||||
} catch (InterruptedException x) {
|
||||
Slimefun.logger().log(Level.WARNING, "The contributors thread was interrupted!");
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (Exception x) {
|
||||
// Too many requests
|
||||
Slimefun.logger().log(Level.WARNING, "Attempted to connect to mojang.com, got this response: {0}: {1}", new Object[] { x.getClass().getSimpleName(), x.getMessage() });
|
||||
Slimefun.logger().log(Level.WARNING, "This usually means mojang.com is temporarily down or started to rate-limit this connection, this is not an error message!");
|
||||
Slimefun.logger().log(Level.WARNING, "Attempted to refresh skin cache, got this response: {0}: {1}", new Object[] { x.getClass().getSimpleName(), x.getMessage() });
|
||||
Slimefun.logger().log(Level.WARNING, "This usually means mojang.com is temporarily down or started to rate-limit this connection, nothing to worry about!");
|
||||
|
||||
// Retry after 5 minutes if it was rate-limiting
|
||||
if (x.getMessage().contains("429")) {
|
||||
String msg = x.getMessage();
|
||||
|
||||
// Retry after 5 minutes if it was just rate-limiting
|
||||
if (msg != null && msg.contains("429")) {
|
||||
Bukkit.getScheduler().runTaskLaterAsynchronously(Slimefun.instance(), this::grabTextures, 5 * 60 * 20L);
|
||||
}
|
||||
|
||||
@ -122,12 +129,14 @@ class GitHubTask implements Runnable {
|
||||
return 0;
|
||||
}
|
||||
|
||||
private @Nullable String pullTexture(@Nonnull Contributor contributor, @Nonnull Map<String, String> skins) throws InterruptedException, ExecutionException {
|
||||
private @Nullable String pullTexture(@Nonnull Contributor contributor, @Nonnull Map<String, String> skins) throws InterruptedException, ExecutionException, TimeoutException {
|
||||
Optional<UUID> uuid = contributor.getUniqueId();
|
||||
|
||||
if (!uuid.isPresent()) {
|
||||
CompletableFuture<UUID> future = UUIDLookup.forUsername(Slimefun.instance(), contributor.getMinecraftName());
|
||||
uuid = Optional.ofNullable(future.get());
|
||||
|
||||
// Fixes #3241 - Do not wait for more than 30 seconds
|
||||
uuid = Optional.ofNullable(future.get(30, TimeUnit.SECONDS));
|
||||
uuid.ifPresent(contributor::setUniqueId);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user