88import com .rtm516 .mcxboxbroadcast .core .exceptions .SessionCreationException ;
99import com .rtm516 .mcxboxbroadcast .core .exceptions .SessionUpdateException ;
1010import com .rtm516 .mcxboxbroadcast .core .exceptions .XboxFriendsException ;
11+ import com .rtm516 .mcxboxbroadcast .core .models .FollowerResponse ;
12+ import org .geysermc .api .Geyser ;
1113import org .geysermc .common .PlatformType ;
14+ import org .geysermc .event .subscribe .Subscribe ;
1215import org .geysermc .floodgate .util .Utils ;
1316import org .geysermc .floodgate .util .WhitelistUtils ;
1417import org .geysermc .geyser .GeyserImpl ;
15- import org .geysermc .geyser .api .event .Subscribe ;
1618import org .geysermc .geyser .api .event .lifecycle .GeyserPostInitializeEvent ;
1719import org .geysermc .geyser .api .extension .Extension ;
1820import org .geysermc .geyser .api .network .AuthType ;
2426import java .net .InetAddress ;
2527import java .net .InetSocketAddress ;
2628import java .net .Socket ;
29+ import java .net .URISyntaxException ;
2730import java .net .UnknownHostException ;
2831import java .nio .file .FileSystem ;
32+ import java .nio .file .FileSystems ;
2933import java .nio .file .Files ;
34+ import java .util .Collections ;
3035import java .util .concurrent .TimeUnit ;
3136
3237public 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 ) {
0 commit comments