Skip to content

Commit 9a6112e

Browse files
committed
Made ProtocolSupport check for Floodgate name conflicts
Rebased on Sat May 22 11:42:34 2021 +0200 Initialize FloodgateHook in constructor This way, it won't have to be initialized whenever a player joins
1 parent 1f3cd5f commit 9a6112e

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

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

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.github.games647.fastlogin.bukkit.BukkitLoginSession;
3030
import com.github.games647.fastlogin.bukkit.FastLoginBukkit;
3131
import com.github.games647.fastlogin.bukkit.event.BukkitFastLoginPreLoginEvent;
32+
import com.github.games647.fastlogin.bukkit.hook.floodgate.FloodgateHook;
3233
import com.github.games647.fastlogin.core.RateLimiter;
3334
import com.github.games647.fastlogin.core.StoredProfile;
3435
import com.github.games647.fastlogin.core.shared.JoinManagement;
@@ -37,11 +38,12 @@
3738
import java.net.InetSocketAddress;
3839
import java.util.Optional;
3940

40-
import org.bukkit.Bukkit;
4141
import org.bukkit.command.CommandSender;
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;
46+
4547
import protocolsupport.api.events.ConnectionCloseEvent;
4648
import protocolsupport.api.events.PlayerLoginStartEvent;
4749
import protocolsupport.api.events.PlayerProfileCompleteEvent;
@@ -51,12 +53,14 @@ public class ProtocolSupportListener extends JoinManagement<Player, CommandSende
5153

5254
private final FastLoginBukkit plugin;
5355
private final RateLimiter rateLimiter;
56+
private final FloodgateHook floodgateHook;
5457

5558
public ProtocolSupportListener(FastLoginBukkit plugin, RateLimiter rateLimiter) {
5659
super(plugin.getCore(), plugin.getCore().getAuthPluginHook());
5760

5861
this.plugin = plugin;
5962
this.rateLimiter = rateLimiter;
63+
this.floodgateHook = new FloodgateHook(plugin);
6064
}
6165

6266
@EventHandler
@@ -76,7 +80,17 @@ public void onLoginStart(PlayerLoginStartEvent loginStartEvent) {
7680
//remove old data every time on a new login in order to keep the session only for one person
7781
plugin.removeSession(address);
7882

79-
super.onLogin(username, new ProtocolLoginSource(loginStartEvent));
83+
ProtocolLoginSource source = new ProtocolLoginSource(loginStartEvent);
84+
85+
//check if the player is connecting through Floodgate
86+
FloodgatePlayer floodgatePlayer = floodgateHook.getFloodgatePlayer(username);
87+
88+
if (floodgatePlayer != null) {
89+
floodgateHook.checkNameConflict(username, source, floodgatePlayer);
90+
} else {
91+
//do Java login tasks
92+
super.onLogin(username, source);
93+
}
8094
}
8195

8296
@EventHandler

0 commit comments

Comments
 (0)