forked from TuxCoding/FastLogin
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.
This commit is contained in:
@ -42,7 +42,6 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.geysermc.floodgate.api.player.FloodgatePlayer;
|
|
||||||
|
|
||||||
import protocolsupport.api.events.ConnectionCloseEvent;
|
import protocolsupport.api.events.ConnectionCloseEvent;
|
||||||
import protocolsupport.api.events.PlayerLoginStartEvent;
|
import protocolsupport.api.events.PlayerLoginStartEvent;
|
||||||
@ -132,7 +131,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected FloodgatePlayer getFloodgatePlayer(Object id) {
|
protected Object getFloodgatePlayer(Object id) {
|
||||||
if ((id instanceof String)) {
|
if ((id instanceof String)) {
|
||||||
return floodgateHook.getFloodgatePlayer((String) id);
|
return floodgateHook.getFloodgatePlayer((String) id);
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//check if the player is connecting through Floodgate
|
//check if the player is connecting through Floodgate
|
||||||
FloodgatePlayer floodgatePlayer = getFloodgatePlayer(username);
|
Object floodgatePlayer = getFloodgatePlayer(username);
|
||||||
|
|
||||||
if (floodgatePlayer != null) {
|
if (floodgatePlayer != null) {
|
||||||
checkFloodgateNameConflict(username, source, floodgatePlayer);
|
checkFloodgateNameConflict(username, source, floodgatePlayer);
|
||||||
@ -149,11 +149,11 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
|||||||
* @param username the name of the player
|
* @param username the name of the player
|
||||||
* @param source an instance of LoginSource
|
* @param source an instance of LoginSource
|
||||||
*/
|
*/
|
||||||
public void checkFloodgateNameConflict(String username, LoginSource source, FloodgatePlayer floodgatePlayer) {
|
public void checkFloodgateNameConflict(String username, LoginSource source, Object floodgatePlayer) {
|
||||||
String allowConflict = core.getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
|
String allowConflict = core.getConfig().get("allowFloodgateNameConflict").toString().toLowerCase();
|
||||||
|
|
||||||
// check if the Bedrock player is linked to a Java account
|
// check if the Bedrock player is linked to a Java account
|
||||||
boolean isLinked = floodgatePlayer.getLinkedPlayer() != null;
|
boolean isLinked = ((FloodgatePlayer) floodgatePlayer).getLinkedPlayer() != null;
|
||||||
|
|
||||||
if (allowConflict.equals("false")
|
if (allowConflict.equals("false")
|
||||||
|| allowConflict.equals("linked") && !isLinked) {
|
|| allowConflict.equals("linked") && !isLinked) {
|
||||||
@ -188,12 +188,16 @@ public abstract class JoinManagement<P extends C, C, S extends LoginSource> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a player is connecting through Floodgate
|
* Gets a FloodgatePlayer based on name or UUID Note: Don't change the return
|
||||||
|
* type from Object to FloodgatePlayer, unless you want ProtocolSupport to throw
|
||||||
|
* an error if Floodgate is not installed
|
||||||
|
*
|
||||||
* @param id UUID for BungeeCord, username for Bukkit
|
* @param id UUID for BungeeCord, username for Bukkit
|
||||||
* @return true if the player is connecting through Floodgate
|
* @return an instance of FloodgatePlayer, if Floodgate is installed and a
|
||||||
* <br> null if Floodgate is unavailable
|
* player is found <br>
|
||||||
|
* null if Floodgate is unavailable
|
||||||
*/
|
*/
|
||||||
protected abstract FloodgatePlayer getFloodgatePlayer(Object id);
|
protected abstract Object getFloodgatePlayer(Object id);
|
||||||
|
|
||||||
public abstract FastLoginPreLoginEvent callFastLoginPreLoginEvent(String username, S source, StoredProfile profile);
|
public abstract FastLoginPreLoginEvent callFastLoginPreLoginEvent(String username, S source, StoredProfile profile);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user