Skip to content

Commit

Permalink
feat: Made connection timeout between server and proxy configurable
Browse files Browse the repository at this point in the history
-Dio.github._4drian3d.signedvelocity.timeout=100
  • Loading branch information
4drian3d committed Sep 12, 2023
1 parent 5a42fa8 commit 12f5446
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.concurrent.TimeUnit;

public final class QueuedData {
private static final int timeout = Integer.getInteger("io.github._4drian3d.signedvelocity.timeout", 125);
private volatile CompletableFuture<SignedResult> futureResult;

// first
Expand All @@ -25,23 +26,23 @@ public CompletableFuture<SignedResult> nextResult() {
if (this.futureResult == null) {
// UnSynchronized
return (futureResult = new CompletableFuture<>())
.completeOnTimeout(SignedResult.allowed(), 100, TimeUnit.MILLISECONDS);
.completeOnTimeout(SignedResult.allowed(), timeout, TimeUnit.MILLISECONDS);
} else {
// Synchronized
final CompletableFuture<SignedResult> actual = this.futureResult;
this.futureResult = null;
return actual.completeOnTimeout(SignedResult.allowed(), 100, TimeUnit.MILLISECONDS);
return actual.completeOnTimeout(SignedResult.allowed(), timeout, TimeUnit.MILLISECONDS);
}
}

public CompletableFuture<SignedResult> nextResultWithoutAdvance() {
if (this.futureResult == null) {
// UnSynchronized
return (futureResult = new CompletableFuture<>())
.completeOnTimeout(SignedResult.allowed(), 100, TimeUnit.MILLISECONDS);
.completeOnTimeout(SignedResult.allowed(), timeout, TimeUnit.MILLISECONDS);
} else {
// Synchronized
return this.futureResult.completeOnTimeout(SignedResult.allowed(), 100, TimeUnit.MILLISECONDS);
return this.futureResult.completeOnTimeout(SignedResult.allowed(), timeout, TimeUnit.MILLISECONDS);
}
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group = io.github._4drian3d
version = 1.0.1
version = 1.0.2-SNAPSHOT
description = Allows you to cancel or modify messages or commands from Velocity without synchronization problems

0 comments on commit 12f5446

Please sign in to comment.