Skip to content

Commit

Permalink
Add tips for setting up bukkit
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexProgrammerDE committed Apr 23, 2024
1 parent 7a4558e commit 7a4f97a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ private void injectMixinsAndRun(String[] args) {
log.info("Used Runtime Agent to inject mixins");

this.postMixinMain(args);
} catch (ReflectiveOperationException | IOException t) {
} catch (IOException t) {
log.error("Failed to inject mixins", t);
System.exit(1);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import io.grpc.StatusRuntimeException;
import io.grpc.stub.StreamObserver;
import io.netty.handler.codec.http.HttpStatusClass;
import java.net.URL;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import javax.inject.Inject;
Expand All @@ -39,6 +40,9 @@
@Slf4j
@RequiredArgsConstructor(onConstructor_ = @Inject)
public class ProxyCheckServiceImpl extends ProxyCheckServiceGrpc.ProxyCheckServiceImplBase {
private static final URL IPIFY_URL = ReactorHttpHelper.createURL("https://api.ipify.org");
private static final URL AWS_URL = ReactorHttpHelper.createURL("https://checkip.amazonaws.com");

@Override
public void check(
ProxyCheckRequest request, StreamObserver<ProxyCheckResponse> responseObserver) {
Expand All @@ -47,8 +51,8 @@ public void check(
try {
var url =
switch (request.getTarget()) {
case IPIFY -> ReactorHttpHelper.createURL("https://api.ipify.org");
case AWS -> ReactorHttpHelper.createURL("https://checkip.amazonaws.com");
case IPIFY -> IPIFY_URL;
case AWS -> AWS_URL;
case UNRECOGNIZED -> throw new IllegalArgumentException("Unrecognized target");
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -1032,12 +1033,18 @@ private boolean isValidResourcePackUrl(String url) {

@EventHandler
public void onLoginDisconnectPacket(ClientboundLoginDisconnectPacket packet) {
log.error("Login failed with reason \"{}\"", toPlainText(packet.getReason()));
var plainMessage = toPlainText(packet.getReason());
log.error("Login failed with reason \"{}\"", plainMessage);

handleTips(plainMessage);
}

@EventHandler
public void onDisconnectPacket(ClientboundDisconnectPacket packet) {
log.info("Disconnected with reason \"{}\"", toPlainText(packet.getReason()));
var plainMessage = toPlainText(packet.getReason());
log.info("Disconnected with reason \"{}\"", plainMessage);

handleTips(plainMessage);
}

public void onDisconnectEvent(DisconnectedEvent event) {
Expand All @@ -1058,6 +1065,14 @@ public void onDisconnectEvent(DisconnectedEvent event) {
log.error("Cause: {}", cause.getMessage());
}

private void handleTips(String message) {
var lowerCaseMessage = message.toLowerCase(Locale.ROOT);
if (lowerCaseMessage.contains("connection throttled")) {
log.info("Tip: The server limits the amount of connections per second. To disable this, set 'settings.connection-throttle' to 0 in bukkit.yml of the server.");
log.info("Tip: If you don't have access to the server, you can try increasing your join delay in the bot settings.");
}
}

public @NotNull Level currentLevel() {
return Objects.requireNonNull(levels.get(currentDimension.dimensionType()));
}
Expand Down

0 comments on commit 7a4f97a

Please sign in to comment.