Skip to content

Commit e8ae7d0

Browse files
authored
Merge branch 'rtm516:master' into master
2 parents 0d25164 + 28e7c2a commit e8ae7d0

File tree

8 files changed

+38
-24
lines changed

8 files changed

+38
-24
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ You use this project at your own risk, the contributors are not responsible for
1717
## Features
1818
- Syncing of MOTD and other server details
1919
- Automatic friend list management
20-
- ~~Easy Geyser integration (as an extension)~~ (Currently not working due to API limitations)
20+
- Easy Geyser integration (as an extension)
2121

2222
## Pterodactyl Panel
2323
There is an egg for easy instance creation supplied for [Pterodactyl Panel](https://pterodactyl.io/), this being `egg-m-c-xbox-broadcast.json`

bootstrap/geyser/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
6-
<artifactId>boostrap-parent</artifactId>
6+
<artifactId>bootstrap-parent</artifactId>
77
<groupId>com.rtm516.mcxboxbroadcast</groupId>
88
<version>1.0-SNAPSHOT</version>
99
</parent>
@@ -38,13 +38,13 @@
3838
<dependency>
3939
<groupId>com.fasterxml.jackson.core</groupId>
4040
<artifactId>jackson-core</artifactId>
41-
<version>2.13.2</version>
41+
<version>2.14.0</version>
4242
<scope>compile</scope>
4343
</dependency>
4444
<dependency>
4545
<groupId>com.fasterxml.jackson.dataformat</groupId>
4646
<artifactId>jackson-dataformat-yaml</artifactId>
47-
<version>2.13.2</version>
47+
<version>2.14.0</version>
4848
<scope>compile</scope>
4949
</dependency>
5050
</dependencies>

bootstrap/geyser/src/main/java/com/rtm516/mcxboxbroadcast/bootstrap/geyser/MCXboxBroadcastExtension.java

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
import com.rtm516.mcxboxbroadcast.core.exceptions.SessionCreationException;
99
import com.rtm516.mcxboxbroadcast.core.exceptions.SessionUpdateException;
1010
import com.rtm516.mcxboxbroadcast.core.exceptions.XboxFriendsException;
11+
import com.rtm516.mcxboxbroadcast.core.models.FollowerResponse;
12+
import org.geysermc.api.Geyser;
1113
import org.geysermc.common.PlatformType;
14+
import org.geysermc.event.subscribe.Subscribe;
1215
import org.geysermc.floodgate.util.Utils;
1316
import org.geysermc.floodgate.util.WhitelistUtils;
1417
import org.geysermc.geyser.GeyserImpl;
15-
import org.geysermc.geyser.api.event.Subscribe;
1618
import org.geysermc.geyser.api.event.lifecycle.GeyserPostInitializeEvent;
1719
import org.geysermc.geyser.api.extension.Extension;
1820
import org.geysermc.geyser.api.network.AuthType;
@@ -24,9 +26,12 @@
2426
import java.net.InetAddress;
2527
import java.net.InetSocketAddress;
2628
import java.net.Socket;
29+
import java.net.URISyntaxException;
2730
import java.net.UnknownHostException;
2831
import java.nio.file.FileSystem;
32+
import java.nio.file.FileSystems;
2933
import java.nio.file.Files;
34+
import java.util.Collections;
3035
import java.util.concurrent.TimeUnit;
3136

3237
public class MCXboxBroadcastExtension implements Extension {
@@ -45,7 +50,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
4550
// Create the config file if it doesn't exist
4651
if (!configFile.exists()) {
4752
try (FileWriter writer = new FileWriter(configFile)) {
48-
try (FileSystem fileSystem = this.fileSystem()) {
53+
try (FileSystem fileSystem = FileSystems.newFileSystem(new File(MCXboxBroadcastExtension.class.getProtectionDomain().getCodeSource().getLocation().toURI()).toPath(), Collections.emptyMap())) {
4954
try (InputStream input = Files.newInputStream(fileSystem.getPath("config.yml"))) {
5055
byte[] bytes = new byte[input.available()];
5156

@@ -56,7 +61,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
5661
writer.flush();
5762
}
5863
}
59-
} catch (IOException e) {
64+
} catch (IOException | URISyntaxException e) {
6065
logger.error("Failed to create config", e);
6166
return;
6267
}
@@ -105,7 +110,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
105110
sessionInfo.setVersion(this.geyserApi().defaultRemoteServer().minecraftVersion());
106111
sessionInfo.setProtocol(this.geyserApi().defaultRemoteServer().protocolVersion());
107112
sessionInfo.setPlayers(this.geyserApi().onlineConnections().size());
108-
sessionInfo.setMaxPlayers(this.geyserApi().maxPlayers());
113+
sessionInfo.setMaxPlayers(GeyserImpl.getInstance().getConfig().getMaxPlayers()); // TODO Find API equivalent
109114

110115
sessionInfo.setIp(ip);
111116
sessionInfo.setPort(port);
@@ -120,7 +125,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
120125
}
121126

122127
// Start the update timer
123-
GeyserImpl.getInstance().getScheduledThread().scheduleWithFixedDelay(this::tick, config.updateInterval, config.updateInterval, TimeUnit.SECONDS);
128+
GeyserImpl.getInstance().getScheduledThread().scheduleWithFixedDelay(this::tick, config.updateInterval, config.updateInterval, TimeUnit.SECONDS); // TODO Find API equivalent
124129
}).start();
125130
}
126131

@@ -138,13 +143,13 @@ private void tick() {
138143

139144
// If we are in spigot, using floodgate authentication and have the config option enabled
140145
// get the users friends and whitelist them
141-
if (this.geyserApi().defaultRemoteServer().authType() == AuthType.HYBRID
142-
&& GeyserImpl.getInstance().getPlatformType() == PlatformType.SPIGOT
146+
if (this.geyserApi().defaultRemoteServer().authType() == AuthType.FLOODGATE
147+
&& GeyserImpl.getInstance().getPlatformType() == PlatformType.SPIGOT // TODO Find API equivalent
143148
&& config.whitelistFriends) {
144149
try {
145-
for (String xuid : sessionManager.getXboxFriends()) {
146-
if (WhitelistUtils.addPlayer(Utils.getJavaUuid(xuid), "unknown")) {
147-
logger.info("Added xbox friend " + xuid + " to whitelist");
150+
for (FollowerResponse.Person person : sessionManager.getXboxFriends()) {
151+
if (WhitelistUtils.addPlayer(Utils.getJavaUuid(person.xuid), "unknown")) {
152+
logger.info("Added xbox friend " + person.displayName + " to whitelist");
148153
}
149154
}
150155
} catch (XboxFriendsException e) {
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
id: mcxboxbroadcast
12
name: MCXboxBroadcast
23
version: 1.0
34
main: com.rtm516.mcxboxbroadcast.bootstrap.geyser.MCXboxBroadcastExtension
4-
api: "2.0.2"
5+
api: "1.0.1"
56
authors: [ "rtm516" ]

bootstrap/pom.xml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>boostrap-parent</artifactId>
12+
<artifactId>bootstrap-parent</artifactId>
1313
<packaging>pom</packaging>
1414

1515
<properties>
@@ -38,6 +38,14 @@
3838
<enabled>true</enabled>
3939
</snapshots>
4040
</repository>
41+
<repository>
42+
<id>sonatype-oss-snapshots1</id>
43+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
44+
</repository>
45+
<repository>
46+
<id>jitpack.io</id>
47+
<url>https://jitpack.io</url>
48+
</repository>
4149
</repositories>
4250

4351
<dependencies>
@@ -50,7 +58,7 @@
5058
</dependencies>
5159

5260
<modules>
53-
<!-- <module>geyser</module>-->
61+
<module>geyser</module>
5462
<module>standalone</module>
5563
</modules>
5664
</project>

bootstrap/standalone/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<parent>
6-
<artifactId>boostrap-parent</artifactId>
6+
<artifactId>bootstrap-parent</artifactId>
77
<groupId>com.rtm516.mcxboxbroadcast</groupId>
88
<version>1.0-SNAPSHOT</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

12-
<artifactId>boostrap-standalone</artifactId>
12+
<artifactId>bootstrap-standalone</artifactId>
1313

1414
<properties>
1515
<maven.compiler.source>17</maven.compiler.source>
@@ -20,20 +20,20 @@
2020
<dependency>
2121
<groupId>com.fasterxml.jackson.core</groupId>
2222
<artifactId>jackson-core</artifactId>
23-
<version>2.13.2</version>
23+
<version>2.14.0</version>
2424
<scope>compile</scope>
2525
</dependency>
2626
<dependency>
2727
<groupId>com.fasterxml.jackson.dataformat</groupId>
2828
<artifactId>jackson-dataformat-yaml</artifactId>
29-
<version>2.13.2</version>
29+
<version>2.14.0</version>
3030
<scope>compile</scope>
3131
</dependency>
3232
<!-- For pinging servers -->
3333
<dependency>
3434
<groupId>com.nukkitx.protocol</groupId>
3535
<artifactId>bedrock-common</artifactId>
36-
<version>2.9.4</version>
36+
<version>2.9.17-20230217.002312-1</version>
3737
</dependency>
3838
<dependency>
3939
<groupId>org.slf4j</groupId>

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<dependency>
2121
<groupId>com.fasterxml.jackson.core</groupId>
2222
<artifactId>jackson-databind</artifactId>
23-
<version>2.13.2.1</version>
23+
<version>2.14.0</version>
2424
</dependency>
2525
<dependency>
2626
<groupId>com.nimbusds</groupId>

core/src/main/java/com/rtm516/mcxboxbroadcast/core/RtaWebsocketClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void onMessage(String message) {
7373
*/
7474
@Override
7575
public void onClose(int code, String reason, boolean remote) {
76-
logger.debug("Websocket disconnected: " + reason + " (" + code + ")");
76+
logger.debug("Websocket disconnected: " + reason + " (" + code + ")");
7777
}
7878

7979
/**

0 commit comments

Comments
 (0)