Skip to content

Commit 5a6ba5c

Browse files
committed
Refactor package structure to com.gportal.a2s and add IP binding for QueryServer
1 parent 61db770 commit 5a6ba5c

18 files changed

Lines changed: 72 additions & 70 deletions

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ The library is published on GitHub Packages. To use it, you need to configure yo
3838
<dependency>
3939
<groupId>com.gportal</groupId>
4040
<artifactId>a2s</artifactId>
41-
<version>1.0.0</version> <!-- Use the desired release tag version -->
41+
<version>1.0.1</version> <!-- Use the desired release tag version -->
4242
</dependency>
4343
```
4444

@@ -67,9 +67,9 @@ dependencies {
6767
### Querying a Server (Client)
6868

6969
```java
70-
import com.gportal.source.query.QueryClient;
71-
import com.gportal.source.query.ServerInfo;
72-
import com.gportal.source.query.PlayerInfo;
70+
import com.gportal.a2s.QueryClient;
71+
import com.gportal.a2s.ServerInfo;
72+
import com.gportal.a2s.PlayerInfo;
7373
import java.net.InetSocketAddress;
7474
import java.util.List;
7575
import java.util.Map;
@@ -101,9 +101,9 @@ public class Example {
101101
### Starting an A2S Server
102102

103103
```java
104-
import com.gportal.source.query.QueryServer;
105-
import com.gportal.source.query.ServerInfo;
106-
import com.gportal.source.query.PlayerInfo;
104+
import com.gportal.a2s.QueryServer;
105+
import com.gportal.a2s.ServerInfo;
106+
import com.gportal.a2s.PlayerInfo;
107107

108108
public class ServerExample {
109109
public static void main(String[] args) {

src/main/java/com/gportal/source/query/Message.java renamed to src/main/java/com/gportal/a2s/Message.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.gportal.source.query;
1+
package com.gportal.a2s;
22

33
import java.net.InetSocketAddress;
44

src/main/java/com/gportal/source/query/MessageCodec.java renamed to src/main/java/com/gportal/a2s/MessageCodec.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
package com.gportal.source.query;
1+
package com.gportal.a2s;
22

33
import java.util.List;
44

5-
import com.gportal.source.query.messages.ChallengeReply;
6-
import com.gportal.source.query.messages.InfoQuery;
7-
import com.gportal.source.query.messages.InfoReply;
8-
import com.gportal.source.query.messages.PlayerQuery;
9-
import com.gportal.source.query.messages.PlayerReply;
10-
import com.gportal.source.query.messages.RulesQuery;
11-
import com.gportal.source.query.messages.RulesReply;
5+
import com.gportal.a2s.messages.ChallengeReply;
6+
import com.gportal.a2s.messages.InfoQuery;
7+
import com.gportal.a2s.messages.InfoReply;
8+
import com.gportal.a2s.messages.PlayerQuery;
9+
import com.gportal.a2s.messages.PlayerReply;
10+
import com.gportal.a2s.messages.RulesQuery;
11+
import com.gportal.a2s.messages.RulesReply;
1212

1313
import io.netty.buffer.ByteBuf;
1414
import io.netty.channel.ChannelHandlerContext;

src/main/java/com/gportal/source/query/PlayerInfo.java renamed to src/main/java/com/gportal/a2s/PlayerInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.gportal.source.query;
1+
package com.gportal.a2s;
22

3-
import static com.gportal.source.query.Message.readString;
4-
import static com.gportal.source.query.Message.writeString;
3+
import static com.gportal.a2s.Message.readString;
4+
import static com.gportal.a2s.Message.writeString;
55

66
import io.netty.buffer.ByteBuf;
77

src/main/java/com/gportal/source/query/Query.java renamed to src/main/java/com/gportal/a2s/Query.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.gportal.source.query;
1+
package com.gportal.a2s;
22

33
public interface Query extends Message {
44
public Integer challenge();

src/main/java/com/gportal/source/query/QueryClient.java renamed to src/main/java/com/gportal/a2s/QueryClient.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
package com.gportal.source.query;
1+
package com.gportal.a2s;
22

33
import java.net.InetSocketAddress;
44
import java.util.HashMap;
55
import java.util.List;
66
import java.util.Map;
77
import java.util.concurrent.CompletableFuture;
88

9-
import com.gportal.source.query.messages.ChallengeReply;
10-
import com.gportal.source.query.messages.InfoQuery;
11-
import com.gportal.source.query.messages.PlayerQuery;
12-
import com.gportal.source.query.messages.RulesQuery;
9+
import com.gportal.a2s.messages.ChallengeReply;
10+
import com.gportal.a2s.messages.InfoQuery;
11+
import com.gportal.a2s.messages.PlayerQuery;
12+
import com.gportal.a2s.messages.RulesQuery;
1313

1414
import io.netty.bootstrap.Bootstrap;
1515
import io.netty.channel.ChannelHandlerContext;

src/main/java/com/gportal/source/query/QueryServer.java renamed to src/main/java/com/gportal/a2s/QueryServer.java

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
package com.gportal.source.query;
1+
package com.gportal.a2s;
22

33
import java.util.ArrayList;
44
import java.util.HashMap;
55
import java.util.List;
66
import java.util.Map;
77

8-
import com.gportal.source.query.messages.InfoQuery;
9-
import com.gportal.source.query.messages.InfoReply;
10-
import com.gportal.source.query.messages.PlayerQuery;
11-
import com.gportal.source.query.messages.PlayerReply;
12-
import com.gportal.source.query.messages.RulesQuery;
13-
import com.gportal.source.query.messages.RulesReply;
8+
import java.net.InetSocketAddress;
9+
10+
import com.gportal.a2s.messages.InfoQuery;
11+
import com.gportal.a2s.messages.InfoReply;
12+
import com.gportal.a2s.messages.PlayerQuery;
13+
import com.gportal.a2s.messages.PlayerReply;
14+
import com.gportal.a2s.messages.RulesQuery;
15+
import com.gportal.a2s.messages.RulesReply;
1416

1517
import io.netty.bootstrap.Bootstrap;
1618
import io.netty.channel.ChannelHandlerContext;
@@ -28,7 +30,7 @@ public class QueryServer {
2830
public final Map<String, String> rules = new HashMap<String, String>();
2931
public final List<PlayerInfo> players = new ArrayList<PlayerInfo>();
3032

31-
public QueryServer(int port, ServerInfo info) {
33+
public QueryServer(InetSocketAddress address, ServerInfo info) {
3234
this.info = info;
3335
worker = new NioEventLoopGroup();
3436
Bootstrap bootstrap = new Bootstrap()
@@ -56,7 +58,7 @@ protected void channelRead0(ChannelHandlerContext ctx, RulesQuery msg) throws Ex
5658
);
5759
}
5860
});
59-
channel = (DatagramChannel) bootstrap.bind(port).syncUninterruptibly().channel();
61+
channel = (DatagramChannel) bootstrap.bind(address).syncUninterruptibly().channel();
6062
}
6163

6264
public void shutdown() {

src/main/java/com/gportal/source/query/Reply.java renamed to src/main/java/com/gportal/a2s/Reply.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.gportal.source.query;
1+
package com.gportal.a2s;
22

33
public interface Reply extends Message {
44
public Object payload();

src/main/java/com/gportal/source/query/ServerInfo.java renamed to src/main/java/com/gportal/a2s/ServerInfo.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
package com.gportal.source.query;
1+
package com.gportal.a2s;
22

3-
import static com.gportal.source.query.Message.readString;
4-
import static com.gportal.source.query.Message.writeString;
3+
import static com.gportal.a2s.Message.readString;
4+
import static com.gportal.a2s.Message.writeString;
55

66
import java.net.InetSocketAddress;
77

src/main/java/com/gportal/source/query/messages/ChallengeReply.java renamed to src/main/java/com/gportal/a2s/messages/ChallengeReply.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
package com.gportal.source.query.messages;
1+
package com.gportal.a2s.messages;
22

33
import java.net.InetSocketAddress;
44

5-
import com.gportal.source.query.Message;
5+
import com.gportal.a2s.Message;
66

77
import io.netty.buffer.ByteBuf;
88

0 commit comments

Comments
 (0)