Revert "Move Floodgate conflict chechking to core"

This reverts commit b0ef1a59ac.
This commit is contained in:
Smart123s
2021-05-16 17:54:50 +02:00
parent b9dd921885
commit b2b61539e1
6 changed files with 24 additions and 63 deletions
@@ -40,6 +40,8 @@ import java.util.Random;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.geysermc.floodgate.api.FloodgateApi;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
public class NameCheckTask extends JoinManagement<Player, CommandSender, ProtocolLibLoginSource>
implements Runnable {
@@ -68,8 +70,13 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
@Override
public void run() {
try {
boolean floodgateAvailable = Bukkit.getServer().getPluginManager().isPluginEnabled("floodgate");
super.onLogin(username, new ProtocolLibLoginSource(packetEvent, player, random, publicKey), floodgateAvailable);
// check if the player is connecting through Geyser
if (!plugin.getCore().getConfig().get("allowFloodgateNameConflict").toString().equalsIgnoreCase("false")
&& getFloodgatePlayer(username) != null) {
plugin.getLog().info("Skipping name conflict checking for player {}", username);
return;
}
super.onLogin(username, new ProtocolLibLoginSource(packetEvent, player, random, publicKey));
} finally {
ProtocolLibrary.getProtocolManager().getAsynchronousManager().signalPacketTransmission(packetEvent);
}
@@ -114,4 +121,15 @@ public class NameCheckTask extends JoinManagement<Player, CommandSender, Protoco
plugin.putSession(player.getAddress(), loginSession);
}
private static FloodgatePlayer getFloodgatePlayer(String username) {
if (Bukkit.getServer().getPluginManager().isPluginEnabled("floodgate")) {
// the Floodgate API requires UUID, which is inaccessible at NameCheckTask.java
for (FloodgatePlayer floodgatePlayer : FloodgateApi.getInstance().getPlayers()) {
if (floodgatePlayer.getUsername().equals(username)) {
return floodgatePlayer;
}
}
}
return null;
}
}
@@ -76,9 +76,7 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
//remove old data every time on a new login in order to keep the session only for one person
plugin.removeSession(address);
boolean floodgateAvailable = Bukkit.getServer().getPluginManager().isPluginEnabled("floodgate");
super.onLogin(username, new ProtocolLoginSource(loginStartEvent), floodgateAvailable);
super.onLogin(username, new ProtocolLoginSource(loginStartEvent));
}
@EventHandler