You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
package org.example;
import com.github.steveice10.mc.auth.exception.request.RequestException;
import com.github.steveice10.mc.auth.service.AuthenticationService;
import com.github.steveice10.mc.auth.service.MojangAuthenticationService;
import com.github.steveice10.mc.auth.service.MsaAuthenticationService;
import com.github.steveice10.mc.auth.service.SessionService;
import com.github.steveice10.mc.protocol.MinecraftConstants;
import com.github.steveice10.mc.protocol.MinecraftProtocol;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundSystemChatPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatPacket;
import com.github.steveice10.packetlib.ProxyInfo;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
import com.github.steveice10.packetlib.event.session.SessionAdapter;
import com.github.steveice10.packetlib.packet.Packet;
import com.github.steveice10.packetlib.tcp.TcpClientSession;
import net.kyori.adventure.text.Component;
import java.net.Proxy;
import java.time.Instant;
public class App {
public static void main(String[] args) {
login(.....);
}
private static void login(Boolean verify, String username, String password, Proxy proxy, ProxyInfo proxyInfo, String host, int port) {
MinecraftProtocol protocol = new MinecraftProtocol("Never gonna give you up");
if (verify) {
try {
AuthenticationService authService = new MsaAuthenticationService("");
authService.setUsername(username);
authService.setPassword(password);
authService.setProxy(proxy);
authService.login();
protocol = new MinecraftProtocol(authService.getSelectedProfile(), authService.getAccessToken());
System.out.println("Successfully authenticated user.");
} catch (RequestException e) {
e.printStackTrace();
return;
}
}
SessionService sessionService = new SessionService();
sessionService.setProxy(proxy);
Session client = new TcpClientSession(host, port, protocol, proxyInfo);
client.setFlag(MinecraftConstants.SESSION_SERVICE_KEY, sessionService);
client.addListener(new SessionAdapter() {
@Override
public void packetReceived(Session session, Packet packet) {
if (packet instanceof ClientboundLoginPacket) {
session.send(new ServerboundChatPacket("Never gonna give you up", Instant.now().toEpochMilli(), 0, new byte[0], false));
} else if (packet instanceof ClientboundSystemChatPacket) {
Component message = ((ClientboundSystemChatPacket) packet).getContent();
System.out.println("I- just " + message);
session.disconnect("Finished");
}
}
@Override
public void disconnected(DisconnectedEvent event) {
System.out.println("Disconnected: " + event.getReason());
if (event.getCause() != null) {
event.getCause().printStackTrace();
}
}
});
client.connect();
}
}
I running on openjdk 7.
But error printed:
Successfully authenticated user.
Disconnected: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: ~~~
io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: ~~~
Caused by: java.net.ConnectException: Connection refused: no further information
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:716)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:330)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:334)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:707)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)
at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:827)
How can I fix this?
Thank you
The text was updated successfully, but these errors were encountered:
I witer this code:
I running on openjdk 7.
But error printed:
How can I fix this?
Thank you
The text was updated successfully, but these errors were encountered: