12
12
import net .minestom .server .network .packet .server .ServerPacket ;
13
13
import net .minestom .server .network .player .GameProfile ;
14
14
import net .minestom .server .network .player .PlayerConnection ;
15
- import org .jetbrains .annotations .NotNull ;
16
15
17
16
import java .net .InetSocketAddress ;
18
17
import java .net .SocketAddress ;
19
18
import java .util .List ;
20
19
import java .util .Objects ;
21
- import java .util .UUID ;
22
20
import java .util .concurrent .CompletableFuture ;
23
21
import java .util .concurrent .CopyOnWriteArrayList ;
24
22
import java .util .concurrent .atomic .AtomicBoolean ;
25
23
26
24
final class TestConnectionImpl implements TestConnection {
27
- private final Env env ;
25
+
28
26
private final ServerProcess process ;
27
+ private final GameProfile gameProfile ;
29
28
private final PlayerConnectionImpl playerConnection = new PlayerConnectionImpl ();
30
29
31
30
private final AtomicBoolean connected = new AtomicBoolean (false );
32
31
33
32
private final List <IncomingCollector <ServerPacket >> incomingTrackers = new CopyOnWriteArrayList <>();
34
33
35
- TestConnectionImpl (Env env ) {
36
- this .env = env ;
34
+ TestConnectionImpl (Env env , GameProfile gameProfile ) {
37
35
this .process = env .process ();
36
+ this .gameProfile = gameProfile ;
38
37
}
39
38
40
39
@ Override
41
- public @ NotNull Player connect (@ NotNull Instance instance , @ NotNull Pos pos ) {
40
+ public Player connect (Instance instance , Pos pos ) {
42
41
if (!connected .compareAndSet (false , true )) {
43
42
throw new IllegalStateException ("Already connected" );
44
43
}
45
44
46
- final GameProfile gameProfile = new GameProfile (UUID .randomUUID (), "RandName" );
47
45
var player = process .connection ().createPlayer (playerConnection , gameProfile );
48
46
player .eventNode ().addListener (AsyncPlayerConfigurationEvent .class , event -> {
49
47
event .setSpawningInstance (instance );
@@ -67,7 +65,7 @@ final class TestConnectionImpl implements TestConnection {
67
65
}
68
66
69
67
@ Override
70
- public @ NotNull <T extends ServerPacket > Collector <T > trackIncoming (@ NotNull Class <T > type ) {
68
+ public <T extends ServerPacket > Collector <T > trackIncoming (Class <T > type ) {
71
69
var tracker = new IncomingCollector <>(type );
72
70
this .incomingTrackers .add (IncomingCollector .class .cast (tracker ));
73
71
return tracker ;
@@ -77,7 +75,7 @@ final class PlayerConnectionImpl extends PlayerConnection {
77
75
private boolean online = true ;
78
76
79
77
@ Override
80
- public void sendPacket (@ NotNull SendablePacket packet ) {
78
+ public void sendPacket (SendablePacket packet ) {
81
79
final var serverPacket = this .extractPacket (packet );
82
80
for (var tracker : incomingTrackers ) {
83
81
if (tracker .type .isAssignableFrom (serverPacket .getClass ())) tracker .packets .add (serverPacket );
@@ -100,7 +98,7 @@ private ServerPacket extractPacket(final SendablePacket packet) {
100
98
}
101
99
102
100
@ Override
103
- public @ NotNull SocketAddress getRemoteAddress () {
101
+ public SocketAddress getRemoteAddress () {
104
102
return new InetSocketAddress ("localhost" , 25565 );
105
103
}
106
104
@@ -124,7 +122,7 @@ public IncomingCollector(Class<T> type) {
124
122
}
125
123
126
124
@ Override
127
- public @ NotNull List <T > collect () {
125
+ public List <T > collect () {
128
126
incomingTrackers .remove (this );
129
127
return List .copyOf (packets );
130
128
}
0 commit comments