Skip to content

Commit af0ef2a

Browse files
committed
Stop ProtocolSupport from crying
If I ever tried to either cast or use FloodgatePlayer as a return type when Floodgate was not installed in the server, I got this error: [19:37:46 ERROR]: [FastLogin] Plugin FastLogin v1.11-SNAPSHOT-744264d has failed to register events for class com.github.games647.fastlogin.bukkit.listener.protocolsupport.ProtocolSupportListener because org/geysermc/floodgate/api/player/FloodgatePlayer does not exist. ProtocolLib doen't have this problem.
1 parent ee2b3a3 commit af0ef2a

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
import org.bukkit.entity.Player;
4343
import org.bukkit.event.EventHandler;
4444
import org.bukkit.event.Listener;
45-
import org.geysermc.floodgate.api.player.FloodgatePlayer;
4645

4746
import protocolsupport.api.events.ConnectionCloseEvent;
4847
import protocolsupport.api.events.PlayerLoginStartEvent;
@@ -132,7 +131,7 @@ public void startCrackedSession(ProtocolLoginSource source, StoredProfile profil
132131
}
133132

134133
@Override
135-
protected FloodgatePlayer getFloodgatePlayer(Object id) {
134+
protected Object getFloodgatePlayer(Object id) {
136135
if ((id instanceof String)) {
137136
return floodgateHook.getFloodgatePlayer((String) id);
138137
}

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public void onLogin(String username, S source) {
5656
}
5757

5858
//check if the player is connecting through Floodgate
59-
FloodgatePlayer floodgatePlayer = getFloodgatePlayer(username);
59+
Object floodgatePlayer = getFloodgatePlayer(username);
6060

6161
if (floodgatePlayer != null) {
6262
checkFloodgateNameConflict(username, source, floodgatePlayer);
@@ -149,11 +149,11 @@ private boolean checkNameChange(S source, String username, Profile profile) {
149149
* @param username the name of the player
150150
* @param source an instance of LoginSource
151151
*/
152-
public void checkFloodgateNameConflict(String username, LoginSource source, FloodgatePlayer floodgatePlayer) {
152+
public void checkFloodgateNameConflict(String username, LoginSource source, Object floodgatePlayer) {
153153
String allowConflict = core.getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
154154

155155
// check if the Bedrock player is linked to a Java account
156-
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
156+
boolean isLinked = ((FloodgatePlayer) floodgatePlayer).getLinkedPlayer() != null;
157157

158158
if (allowConflict.equals("false")
159159
|| allowConflict.equals("linked") && !isLinked) {
@@ -188,12 +188,16 @@ public void checkFloodgateNameConflict(String username, LoginSource source, Floo
188188
}
189189

190190
/**
191-
* Check if a player is connecting through Floodgate
191+
* Gets a FloodgatePlayer based on name or UUID Note: Don't change the return
192+
* type from Object to FloodgatePlayer, unless you want ProtocolSupport to throw
193+
* an error if Floodgate is not installed
194+
*
192195
* @param id UUID for BungeeCord, username for Bukkit
193-
* @return true if the player is connecting through Floodgate
194-
* <br> null if Floodgate is unavailable
196+
* @return an instance of FloodgatePlayer, if Floodgate is installed and a
197+
* player is found <br>
198+
* null if Floodgate is unavailable
195199
*/
196-
protected abstract FloodgatePlayer getFloodgatePlayer(Object id);
200+
protected abstract Object getFloodgatePlayer(Object id);
197201

198202
public abstract FastLoginPreLoginEvent callFastLoginPreLoginEvent(String username, S source, StoredProfile profile);
199203

0 commit comments

Comments
 (0)