Skip to content

Commit b2b6153

Browse files
committed
Revert "Move Floodgate conflict chechking to core"
This reverts commit b0ef1a5.
1 parent b9dd921 commit b2b6153

File tree

6 files changed

+24
-63
lines changed

6 files changed

+24
-63
lines changed

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocollib/NameCheckTask.java

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
import org.bukkit.Bukkit;
4141
import org.bukkit.command.CommandSender;
4242
import org.bukkit.entity.Player;
43+
import org.geysermc.floodgate.api.FloodgateApi;
44+
import org.geysermc.floodgate.api.player.FloodgatePlayer;
4345

4446
public class NameCheckTask extends JoinManagement<Player, CommandSender, ProtocolLibLoginSource>
4547
implements Runnable {
@@ -68,8 +70,13 @@ public NameCheckTask(FastLoginBukkit plugin, PacketEvent packetEvent, Random ran
6870
@Override
6971
public void run() {
7072
try {
71-
boolean floodgateAvailable = Bukkit.getServer().getPluginManager().isPluginEnabled("floodgate");
72-
super.onLogin(username, new ProtocolLibLoginSource(packetEvent, player, random, publicKey), floodgateAvailable);
73+
// check if the player is connecting through Geyser
74+
if (!plugin.getCore().getConfig().get("allowFloodgateNameConflict").toString().equalsIgnoreCase("false")
75+
&& getFloodgatePlayer(username) != null) {
76+
plugin.getLog().info("Skipping name conflict checking for player {}", username);
77+
return;
78+
}
79+
super.onLogin(username, new ProtocolLibLoginSource(packetEvent, player, random, publicKey));
7380
} finally {
7481
ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
7582
}
@@ -114,4 +121,15 @@ public void startCrackedSession(ProtocolLibLoginSource source, StoredProfile pro
114121
plugin.putSession(player.getAddress(), loginSession);
115122
}
116123

124+
private static FloodgatePlayer getFloodgatePlayer(String username) {
125+
if (Bukkit.getServer().getPluginManager().isPluginEnabled("floodgate")) {
126+
// the Floodgate API requires UUID, which is inaccessible at NameCheckTask.java
127+
for (FloodgatePlayer floodgatePlayer : FloodgateApi.getInstance().getPlayers()) {
128+
if (floodgatePlayer.getUsername().equals(username)) {
129+
return floodgatePlayer;
130+
}
131+
}
132+
}
133+
return null;
134+
}
117135
}

bukkit/src/main/java/com/github/games647/fastlogin/bukkit/listener/protocolsupport/ProtocolSupportListener.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ public void onLoginStart(PlayerLoginStartEvent loginStartEvent) {
7676
//remove old data every time on a new login in order to keep the session only for one person
7777
plugin.removeSession(address);
7878

79-
boolean floodgateAvailable = Bukkit.getServer().getPluginManager().isPluginEnabled("floodgate");
80-
81-
super.onLogin(username, new ProtocolLoginSource(loginStartEvent), floodgateAvailable);
79+
super.onLogin(username, new ProtocolLoginSource(loginStartEvent));
8280
}
8381

8482
@EventHandler

bungee/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
<!-- Version 2.0 -->
137137
<dependency>
138138
<groupId>org.geysermc.floodgate</groupId>
139-
<artifactId>api</artifactId>
139+
<artifactId>bungee</artifactId>
140140
<version>2.0-SNAPSHOT</version>
141141
<scope>provided</scope>
142142
</dependency>

bungee/src/main/java/com/github/games647/fastlogin/bungee/task/AsyncPremiumCheck.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public void run() {
6262
plugin.getSession().remove(connection);
6363

6464
try {
65-
super.onLogin(username, new BungeeLoginSource(connection, preLoginEvent), false);
65+
super.onLogin(username, new BungeeLoginSource(connection, preLoginEvent));
6666
} finally {
6767
preLoginEvent.completeIntent(plugin);
6868
}

core/pom.xml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@
5353
<id>codemc-repo</id>
5454
<url>https://repo.codemc.io/repository/maven-public/</url>
5555
</repository>
56-
57-
<!-- Floodgate -->
58-
<repository>
59-
<id>nukkitx-snapshot</id>
60-
<url>https://repo.nukkitx.com/maven-snapshots/</url>
61-
</repository>
6256
</repositories>
6357

6458
<dependencies>
@@ -98,14 +92,6 @@
9892
<version>0.4</version>
9993
</dependency>
10094

101-
<!--Floodgate for Xbox Live Authentication-->
102-
<dependency>
103-
<groupId>org.geysermc.floodgate</groupId>
104-
<artifactId>api</artifactId>
105-
<version>2.0-SNAPSHOT</version>
106-
<scope>provided</scope>
107-
</dependency>
108-
10995
<!-- APIs we can use because they are available in all platforms (Spigot, Bungee) -->
11096
<dependency>
11197
<groupId>com.google.guava</groupId>

core/src/main/java/com/github/games647/fastlogin/core/shared/JoinManagement.java

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@
3333

3434
import java.util.Optional;
3535

36-
import org.geysermc.floodgate.api.FloodgateApi;
37-
import org.geysermc.floodgate.api.player.FloodgatePlayer;
38-
3936
import net.md_5.bungee.config.Configuration;
4037

4138
public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
@@ -48,28 +45,8 @@ public JoinManagement(FastLoginCore<P, C, ?> core, AuthPlugin<P> authHook) {
4845
this.authHook = authHook;
4946
}
5047

51-
public void onLogin(String username, S source, boolean floodgateAvailable) {
48+
public void onLogin(String username, S source) {
5249
core.getPlugin().getLog().info("Handling player {}", username);
53-
54-
// check if the player is connecting through Geyser
55-
if (floodgateAvailable && getFloodgatePlayer(username) != null) {
56-
if (core.getConfig().get("allowFloodgateNameConflict").toString().equalsIgnoreCase("false")) {
57-
core.getPlugin().getLog().info(
58-
"Bedrock Player {}'s name conflits an existing Java Premium Player's name",
59-
username);
60-
try {
61-
source.kick("Your name conflits an existing Java Premium Player's name");
62-
} catch (Exception e) {
63-
e.printStackTrace();
64-
core.getPlugin().getLog().error("Could not kick Player {}", username);
65-
}
66-
} else {
67-
core.getPlugin().getLog().info("Skipping name conflict checking for player {}", username);
68-
return;
69-
}
70-
71-
}
72-
7350
StoredProfile profile = core.getStorage().loadProfile(username);
7451
if (profile == null) {
7552
return;
@@ -153,24 +130,6 @@ private boolean checkNameChange(S source, String username, Profile profile) {
153130

154131
return false;
155132
}
156-
157-
/**
158-
* Get a FloodgatePlayyer by their name.
159-
* This is not supported by FloodgateApi.
160-
* <br>
161-
* <b>WARNING: This method does not check if the floodgate plugin is actually installed on the server!</b>
162-
* @param username the name of the player
163-
* @return FloodgatePlayer if found, null if the player is not online
164-
*/
165-
protected static FloodgatePlayer getFloodgatePlayer(String username) {
166-
// the Floodgate API requires UUID, which is inaccessible at NameCheckTask.java
167-
for (FloodgatePlayer floodgatePlayer : FloodgateApi.getInstance().getPlayers()) {
168-
if (floodgatePlayer.getUsername().equals(username)) {
169-
return floodgatePlayer;
170-
}
171-
}
172-
return null;
173-
}
174133

175134
public abstract FastLoginPreLoginEvent callFastLoginPreLoginEvent(String username, S source, StoredProfile profile);
176135

0 commit comments

Comments
 (0)